ajax.js 77 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. /**
  20. * Config for each ajax-request
  21. *
  22. * Fields example:
  23. * mock - testMode url
  24. * real - real url (without API prefix)
  25. * type - request type (also may be defined in the format method)
  26. * format - function for processing ajax params after default formatRequest. May be called with one or two parameters (data, opt). Return ajax-params object
  27. * testInProduction - can this request be executed on production tests (used only in tests)
  28. *
  29. * @type {Object}
  30. */
  31. var urls = {
  32. 'alerts.get_by_service': {
  33. 'real': '/clusters/{clusterName}/services/{serviceName}?fields=alerts',
  34. 'mock': '/data/alerts/HDP2/service_alerts.json'
  35. },
  36. 'alerts.get_by_host': {
  37. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=alerts',
  38. 'mock': '/data/alerts/HDP2/host_alerts.json'
  39. },
  40. 'background_operations.get_most_recent': {
  41. 'real': '/clusters/{clusterName}/requests?to=end&page_size=10&fields=Requests',
  42. 'mock': '/data/background_operations/list_on_start.json',
  43. 'testInProduction': true
  44. },
  45. 'background_operations.get_by_request': {
  46. 'real': '/clusters/{clusterName}/requests/{requestId}?fields=*,tasks/Tasks/command,tasks/Tasks/command_detail,tasks/Tasks/start_time,tasks/Tasks/end_time,tasks/Tasks/exit_code,tasks/Tasks/host_name,tasks/Tasks/id,tasks/Tasks/role,tasks/Tasks/status&minimal_response=true',
  47. 'mock': '/data/background_operations/task_by_request{requestId}.json',
  48. 'testInProduction': true
  49. },
  50. 'background_operations.get_by_task': {
  51. 'real': '/clusters/{clusterName}/requests/{requestId}/tasks/{taskId}',
  52. 'mock': '/data/background_operations/list_on_start.json',
  53. 'testInProduction': true
  54. },
  55. 'service.item.start_stop': {
  56. 'real': '/clusters/{clusterName}/services/{serviceName}',
  57. 'mock': '/data/wizard/deploy/poll_1.json',
  58. 'format': function (data) {
  59. return {
  60. type: 'PUT',
  61. data: JSON.stringify({
  62. RequestInfo: {
  63. "context": data.requestInfo,
  64. "operation_level": {
  65. "level": "SERVICE",
  66. "cluster_name" : data.clusterName,
  67. "service_name" : data.serviceName
  68. }
  69. },
  70. Body: {
  71. ServiceInfo: {
  72. state: data.state
  73. }
  74. }
  75. })
  76. };
  77. }
  78. },
  79. 'service.item.smoke': {
  80. 'real': '/clusters/{clusterName}/requests',
  81. 'mock': '/data/wizard/deploy/poll_1.json',
  82. 'format': function (data) {
  83. return {
  84. 'type': 'POST',
  85. data: JSON.stringify({
  86. "RequestInfo": {
  87. "context": data.displayName + " Service Check",
  88. "command" : data.actionName
  89. },
  90. "Requests/resource_filters": [{"service_name" : data.serviceName}]
  91. })
  92. };
  93. }
  94. },
  95. 'service.item.passive': {
  96. 'real': '/clusters/{clusterName}/services/{serviceName}',
  97. 'mock': '',
  98. 'format': function (data) {
  99. return {
  100. type: 'PUT',
  101. data: JSON.stringify({
  102. RequestInfo: {
  103. "context": data.requestInfo
  104. },
  105. Body: {
  106. ServiceInfo: {
  107. maintenance_state: data.passive_state
  108. }
  109. }
  110. })
  111. };
  112. }
  113. },
  114. 'service.stale_host_components.start_stop': {
  115. 'real': '/clusters/{clusterName}/host_components?' +
  116. 'HostRoles/stale_configs=true&HostRoles/component_name.in({componentNames})',
  117. 'mock': '/data/wizard/deploy/poll_1.json',
  118. 'format': function (data) {
  119. return {
  120. type: 'PUT',
  121. data: JSON.stringify({
  122. RequestInfo: {
  123. "context": data.requestInfo
  124. },
  125. Body: {
  126. HostRoles: {
  127. state: data.state
  128. }
  129. }
  130. })
  131. };
  132. }
  133. },
  134. 'service.load_config_groups': {
  135. 'real': '/clusters/{clusterName}/config_groups?ConfigGroup/tag={serviceName}&fields=*',
  136. 'mock': '/data/configurations/config_group.json'
  137. },
  138. 'service.flume.agent.command': {
  139. 'real': '/clusters/{clusterName}/hosts/{host}/host_components/FLUME_HANDLER',
  140. 'mock': '',
  141. 'format': function (data) {
  142. return {
  143. type: 'PUT',
  144. data: JSON.stringify({
  145. "RequestInfo": {
  146. "context": data.context,
  147. "flume_handler": data.agentName
  148. },
  149. "Body": {
  150. "HostRoles": {
  151. "state": data.state
  152. }
  153. }
  154. })
  155. }
  156. }
  157. },
  158. 'reassign.stop_services': {
  159. 'real': '/clusters/{clusterName}/services',
  160. 'mock': '',
  161. 'format': function() {
  162. return {
  163. type: 'PUT',
  164. data: JSON.stringify({
  165. "RequestInfo": {
  166. "context": "Stop all services"
  167. },
  168. "Body": {
  169. "ServiceInfo": {
  170. "state": "INSTALLED"
  171. }
  172. }
  173. })
  174. }
  175. }
  176. },
  177. 'reassign.stop_YMR2_services': {
  178. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name.in({servicesList})',
  179. 'mock': '',
  180. 'format': function() {
  181. return {
  182. type: 'PUT',
  183. data: JSON.stringify({
  184. "RequestInfo": {
  185. "context": "Stop without HDFS"
  186. },
  187. "Body": {
  188. "ServiceInfo": {
  189. "state": "INSTALLED"
  190. }
  191. }
  192. })
  193. }
  194. }
  195. },
  196. 'reassign.start_services': {
  197. 'real': '/clusters/{clusterName}/services?params/run_smoke_test=true',
  198. 'mock': '',
  199. 'format': function() {
  200. return {
  201. type: 'PUT',
  202. data: JSON.stringify({
  203. "RequestInfo": {
  204. "context": "Start all services"
  205. },
  206. "Body": {
  207. "ServiceInfo": {
  208. "state": "STARTED"
  209. }
  210. }
  211. })
  212. }
  213. }
  214. },
  215. 'reassign.start_YMR2_services': {
  216. 'real': '/clusters/{clusterName}/services/?ServiceInfo/service_name.in({servicesList})',
  217. 'mock': '',
  218. 'format': function() {
  219. return {
  220. type: 'PUT',
  221. data: JSON.stringify({
  222. "RequestInfo": {
  223. "context": "Start without HDFS"
  224. },
  225. "Body": {
  226. "ServiceInfo": {
  227. "state": "STARTED"
  228. }
  229. }
  230. })
  231. }
  232. }
  233. },
  234. 'reassign.maintenance_mode': {
  235. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  236. 'mock': '',
  237. 'type': 'PUT',
  238. 'format': function () {
  239. return {
  240. data: JSON.stringify(
  241. {
  242. "HostRoles": {
  243. "state": "DISABLED"
  244. }
  245. }
  246. )
  247. }
  248. }
  249. },
  250. 'reassign.remove_component': {
  251. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  252. 'mock': '',
  253. 'type': 'DELETE'
  254. },
  255. 'reassign.load_configs': {
  256. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  257. 'mock': ''
  258. },
  259. 'reassign.save_configs': {
  260. 'real': '/clusters/{clusterName}',
  261. 'mock': '',
  262. 'type': 'PUT',
  263. 'format': function (data) {
  264. return {
  265. async: false,
  266. data: JSON.stringify({
  267. Clusters: {
  268. desired_config: {
  269. "type": data.siteName,
  270. "tag": 'version' + (new Date).getTime(),
  271. "properties": data.properties
  272. }
  273. }
  274. })
  275. }
  276. }
  277. },
  278. 'host_component.passive': {
  279. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  280. 'mock': '',
  281. 'type': 'PUT',
  282. 'format': function(data) {
  283. return {
  284. data: JSON.stringify({
  285. RequestInfo: {
  286. "context": data.requestInfo
  287. },
  288. Body: {
  289. HostRoles: {
  290. maintenance_state: data.passive_state
  291. }
  292. }
  293. })
  294. };
  295. }
  296. },
  297. 'config.cluster_configuration.put': {
  298. 'real': '/clusters/{cluster}',
  299. 'mock': '',
  300. 'format': function(data) {
  301. return {
  302. type: 'PUT',
  303. async: false,
  304. dataType: 'text',
  305. data: data.data
  306. }
  307. }
  308. },
  309. 'config.advanced': {
  310. 'real': '{stackVersionUrl}/services/{serviceName}/configurations?fields=*',
  311. 'mock': '/data/wizard/stack/hdp/version{stackVersion}/{serviceName}.json',
  312. 'format': function (data) {
  313. return {
  314. async: !data.sync
  315. };
  316. }
  317. },
  318. 'config.advanced.global': {
  319. 'real': '{stackVersionUrl}/services?fields=configurations/StackConfigurations/type',
  320. 'mock': '/data/wizard/stack/hdp/version1.3.0/global.json',
  321. 'format': function() {
  322. return {
  323. async: false
  324. };
  325. }
  326. },
  327. 'config.tags': {
  328. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  329. 'mock': '/data/clusters/cluster.json'
  330. },
  331. 'config.tags_and_groups': {
  332. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs,config_groups/*{urlParams}',
  333. 'mock': '/data/clusters/tags_and_groups.json'
  334. },
  335. 'config.tags.sync': {
  336. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  337. 'mock': '/data/clusters/cluster.json',
  338. 'format': function() {
  339. return {
  340. async: false
  341. };
  342. }
  343. },
  344. 'config.ambari.database.info': {
  345. 'real': '/services/AMBARI/components/AMBARI_SERVER?fields=hostComponents/RootServiceHostComponents/properties/server.jdbc.database,hostComponents/RootServiceHostComponents/properties/server.jdbc.url',
  346. 'mock': '',
  347. 'format': function() {
  348. return {
  349. async: false
  350. };
  351. }
  352. },
  353. 'config_groups.all_fields': {
  354. 'real': '/clusters/{clusterName}/config_groups?fields=*',
  355. 'mock': ''
  356. },
  357. 'config_groups.get_config_group_by_id': {
  358. 'real': '/clusters/{clusterName}/config_groups/{id}',
  359. 'mock': ''
  360. },
  361. 'config_groups.update_config_group': {
  362. 'real': '/clusters/{clusterName}/config_groups/{id}',
  363. 'mock': '',
  364. 'type': 'PUT',
  365. 'format': function (data) {
  366. return {
  367. async: false,
  368. data: JSON.stringify(
  369. [
  370. data.configGroup
  371. ]
  372. )
  373. }
  374. }
  375. },
  376. 'config_groups.delete_config_group': {
  377. 'real': '/clusters/{clusterName}/config_groups/{id}',
  378. 'mock': '',
  379. 'type': 'DELETE'
  380. },
  381. 'config.on_site': {
  382. 'real': '/clusters/{clusterName}/configurations?{params}',
  383. 'mock': '/data/configurations/cluster_level_configs.json?{params}',
  384. 'format': function() {
  385. return {
  386. async: false
  387. };
  388. }
  389. },
  390. 'config.host_overrides': {
  391. 'real': '/clusters/{clusterName}/configurations?{params}',
  392. 'mock': '/data/configurations/host_level_overrides_configs.json?{params}',
  393. 'format': function() {
  394. return {
  395. async: false
  396. };
  397. }
  398. },
  399. 'host.host_component.delete': {
  400. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  401. 'mock': '',
  402. 'format': function() {
  403. return {
  404. type: 'DELETE',
  405. async: false
  406. }
  407. }
  408. },
  409. 'host.host_components.delete': {
  410. 'real': '/clusters/{clusterName}/hosts/{hostName}',
  411. 'mock': '',
  412. 'format': function() {
  413. return {
  414. type: 'DELETE',
  415. async: false
  416. }
  417. }
  418. },
  419. 'host.host_component.stop': {
  420. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  421. 'mock': '/data/wizard/deploy/poll_1.json',
  422. 'format': function(data) {
  423. return {
  424. type: 'PUT',
  425. data: data.data
  426. }
  427. }
  428. },
  429. 'host.host_components.stop': {
  430. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components',
  431. 'mock': '/data/wizard/deploy/poll_1.json',
  432. 'format': function(data) {
  433. return {
  434. type: 'PUT',
  435. async: false,
  436. data: data.data
  437. }
  438. }
  439. },
  440. 'host.host_component.start': {
  441. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  442. 'mock': '/data/wizard/deploy/poll_1.json',
  443. 'format': function(data) {
  444. return {
  445. type: 'PUT',
  446. data: data.data
  447. }
  448. }
  449. },
  450. 'host.host_component.install': {
  451. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  452. 'mock': '/data/wizard/deploy/poll_1.json',
  453. 'format': function(data) {
  454. return {
  455. type: 'PUT',
  456. data: data.data
  457. }
  458. }
  459. },
  460. 'host.host_component.update': {
  461. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  462. 'mock': '/data/wizard/deploy/poll_1.json',
  463. 'format': function(data) {
  464. return {
  465. type: 'PUT',
  466. data: data.data
  467. }
  468. }
  469. },
  470. 'host.host_component.add_new_component': {
  471. 'real': '/clusters/{clusterName}/hosts?Hosts/host_name={hostName}',
  472. 'mock': '/data/wizard/deploy/poll_1.json',
  473. 'format': function(data) {
  474. return {
  475. type: 'POST',
  476. data: data.data
  477. }
  478. }
  479. },
  480. 'host.host_component.install_new_component': {
  481. 'real': '/clusters/{clusterName}/host_components?HostRoles/host_name={hostName}\&HostRoles/component_name={componentName}\&HostRoles/state=INIT',
  482. 'mock': '/data/wizard/deploy/poll_1.json',
  483. 'format': function(data) {
  484. return {
  485. type: 'PUT',
  486. data: data.data
  487. }
  488. }
  489. },
  490. 'host.host_component.slave_desired_admin_state': {
  491. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}/?fields=HostRoles/desired_admin_state',
  492. 'mock': ''
  493. },
  494. 'host.host_component.decommission_status': {
  495. 'real': '/clusters/{clusterName}/services/{serviceName}/components/{componentName}/?fields=ServiceComponentInfo',
  496. 'mock': ''
  497. },
  498. 'host.host_component.decommission_status_datanode': {
  499. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}?fields=metrics/dfs/namenode',
  500. 'mock': ''
  501. },
  502. 'host.host_component.decommission_slave': {
  503. 'real' : '/clusters/{clusterName}/requests',
  504. 'mock' : '',
  505. 'format' : function(data) {
  506. return {
  507. type : 'POST',
  508. data : JSON.stringify({
  509. RequestInfo: {
  510. 'context': data.context,
  511. 'command': data.command,
  512. 'parameters': {
  513. 'slave_type': data.slaveType,
  514. 'excluded_hosts': data.hostName
  515. }
  516. },
  517. "Requests/resource_filters": [{"service_name" : data.serviceName, "component_name" : data.componentName}]
  518. })
  519. }
  520. }
  521. },
  522. 'host.host_component.recommission_and_restart': {
  523. 'real': '/clusters/{clusterName}/request_schedules',
  524. 'mock': '',
  525. 'format' : function(data) {
  526. return {
  527. type : 'POST',
  528. data : JSON.stringify([ {
  529. "RequestSchedule" : {
  530. "batch" : [ {
  531. "requests" : data.batches
  532. }, {
  533. "batch_settings" : {
  534. "batch_separation_in_seconds" : data.intervalTimeSeconds,
  535. "task_failure_tolerance" : data.tolerateSize
  536. }
  537. } ]
  538. }
  539. } ])
  540. }
  541. }
  542. },
  543. 'host.host_component.recommission_slave' : {
  544. 'real' : '/clusters/{clusterName}/requests',
  545. 'mock' : '',
  546. 'format' : function(data) {
  547. return {
  548. type : 'POST',
  549. data : JSON.stringify({
  550. RequestInfo: {
  551. context: data.context,
  552. command: data.command,
  553. parameters: {
  554. slave_type: data.slaveType,
  555. included_hosts: data.hostName
  556. }
  557. },
  558. "Requests/resource_filters": [{"service_name" : data.serviceName, "component_name" : data.componentName}]
  559. })
  560. }
  561. }
  562. },
  563. 'host.stale_host_components.start_stop': {
  564. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components?HostRoles/stale_configs=true&' +
  565. 'HostRoles/component_name.in({componentNames})',
  566. 'mock': '',
  567. 'type': 'PUT',
  568. 'format': function (data) {
  569. return {
  570. data: JSON.stringify({
  571. RequestInfo: {
  572. "context": data.context
  573. },
  574. Body: {
  575. "HostRoles": {
  576. "state": data.state
  577. }
  578. }
  579. })
  580. }
  581. }
  582. },
  583. 'host.host_component.refresh_configs': {
  584. 'real':'/clusters/{clusterName}/requests',
  585. 'mock':'',
  586. 'format': function(data) {
  587. return {
  588. type : 'POST',
  589. data : JSON.stringify({
  590. "RequestInfo": {
  591. "command": "CONFIGURE",
  592. "context": data.context
  593. },
  594. "Requests/resource_filters": data.resource_filters
  595. })
  596. }
  597. }
  598. },
  599. 'host.delete': {
  600. 'real': '/clusters/{clusterName}/hosts/{hostName}',
  601. 'mock': '',
  602. 'type': 'DELETE',
  603. 'format': function() {
  604. return {
  605. async: false
  606. }
  607. }
  608. },
  609. 'hosts.metrics': {
  610. 'real': '/clusters/{clusterName}/hosts?fields={metricName}',
  611. 'mock': '/data/cluster_metrics/cpu_1hr.json'
  612. },
  613. 'hosts.metrics.host_component': {
  614. 'real': '/clusters/{clusterName}/services/{serviceName}/components/{componentName}?fields=host_components/{metricName}',
  615. 'mock': '/data/cluster_metrics/cpu_1hr.json'
  616. },
  617. 'service.service_component': {
  618. 'real': '/clusters/{clusterName}/services/{serviceName}/components/{componentName}',
  619. 'mock': '',
  620. 'format': function(data) {
  621. return {
  622. async: data.async
  623. };
  624. }
  625. },
  626. 'service.metrics.flume.channel_fill_percent': {
  627. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/flume/flume/CHANNEL/*/ChannelFillPercentage[{fromSeconds},{toSeconds},{stepSeconds}]',
  628. 'mock': '/data/services/metrics/flume/channelFillPct.json',
  629. 'testInProduction': true
  630. },
  631. 'service.metrics.flume.channel_size': {
  632. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/flume/flume/CHANNEL/*/ChannelSize[{fromSeconds},{toSeconds},{stepSeconds}]',
  633. 'mock': '/data/services/metrics/flume/channelSize.json',
  634. 'testInProduction': true
  635. },
  636. 'service.metrics.flume.sink_drain_success': {
  637. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/flume/flume/SINK/*/EventDrainSuccessCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  638. 'mock': '/data/services/metrics/flume/sinkDrainSuccessCount.json',
  639. 'testInProduction': true
  640. },
  641. 'service.metrics.flume.sink_connection_failed': {
  642. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/flume/flume/SINK/*/ConnectionFailedCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  643. 'mock': '/data/services/metrics/flume/sinkConnectionFailedCount.json',
  644. 'testInProduction': true
  645. },
  646. 'service.metrics.flume.gc': {
  647. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  648. 'mock': '/data/services/metrics/flume/jvmGcTime.json',
  649. 'testInProduction': true
  650. },
  651. 'service.metrics.flume.jvm_heap_used': {
  652. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/jvm/memHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}]',
  653. 'mock': '/data/services/metrics/flume/jvmMemHeapUsedM.json',
  654. 'testInProduction': true
  655. },
  656. 'service.metrics.flume.jvm_threads_runnable': {
  657. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/jvm/threadsRunnable[{fromSeconds},{toSeconds},{stepSeconds}]',
  658. 'mock': '/data/services/metrics/flume/jvmThreadsRunnable.json',
  659. 'testInProduction': true
  660. },
  661. 'service.metrics.flume.cpu_user': {
  662. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/cpu/cpu_user[{fromSeconds},{toSeconds},{stepSeconds}]',
  663. 'mock': '',
  664. 'testInProduction': true
  665. },
  666. 'service.metrics.flume.source_accepted': {
  667. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/flume/flume/SOURCE/*/EventAcceptedCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  668. 'mock': '/data/services/metrics/flume/sourceEventAccepted.json',
  669. 'testInProduction': true
  670. },
  671. 'service.metrics.hbase.cluster_requests': {
  672. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/cluster_requests[{fromSeconds},{toSeconds},{stepSeconds}]',
  673. 'mock': '/data/services/metrics/hbase/cluster_requests.json',
  674. 'testInProduction': true
  675. },
  676. 'service.metrics.hbase.hlog_split_size': {
  677. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitSize_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  678. 'mock': '/data/services/metrics/hbase/hlog_split_size.json',
  679. 'testInProduction': true
  680. },
  681. 'service.metrics.hbase.hlog_split_time': {
  682. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  683. 'mock': '/data/services/metrics/hbase/hlog_split_time.json',
  684. 'testInProduction': true
  685. },
  686. 'service.metrics.hbase.regionserver_queuesize': {
  687. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/flushQueueSize[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/compactionQueueSize[{fromSeconds},{toSeconds},{stepSeconds}]',
  688. 'mock': '/data/services/metrics/hbase/regionserver_queuesize.json',
  689. 'testInProduction': true
  690. },
  691. 'service.metrics.hbase.regionserver_regions': {
  692. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/regions[{fromSeconds},{toSeconds},{stepSeconds}]',
  693. 'mock': '/data/services/metrics/hbase/regionserver_regions.json',
  694. 'testInProduction': true
  695. },
  696. 'service.metrics.hbase.regionserver_rw_requests': {
  697. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/readRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/writeRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  698. 'mock': '/data/services/metrics/hbase/regionserver_rw_requests.json',
  699. 'testInProduction': true
  700. },
  701. 'service.metrics.mapreduce.gc': {
  702. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  703. 'mock': '/data/services/metrics/mapreduce/gc.json',
  704. 'testInProduction': true
  705. },
  706. 'service.metrics.mapreduce.jobs_status': {
  707. 'real': '/clusters/{clusterName}/services/MAPREDUCE/components/JOBTRACKER?fields=metrics/mapred/jobtracker/jobs_completed[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/jobs_preparing[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/jobs_failed[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/jobs_submitted[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/jobs_failed[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/jobs_running[{fromSeconds},{toSeconds},{stepSeconds}]',
  708. 'mock': '/data/services/metrics/mapreduce/jobs_status.json',
  709. 'testInProduction': true
  710. },
  711. 'service.metrics.mapreduce.jobs_heap': {
  712. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/jvm/memNonHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memNonHeapCommittedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memHeapCommittedM[{fromSeconds},{toSeconds},{stepSeconds}]',
  713. 'mock': '/data/services/metrics/mapreduce/jvm_heap.json',
  714. 'testInProduction': true
  715. },
  716. 'service.metrics.mapreduce.jobs_threads': {
  717. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/jvm/threadsRunnable[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsBlocked[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsWaiting[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsTimedWaiting[{fromSeconds},{toSeconds},{stepSeconds}]',
  718. 'mock': '/data/services/metrics/mapreduce/jvm_threads.json',
  719. 'testInProduction': true
  720. },
  721. 'service.metrics.mapreduce.map_slots': {
  722. 'real': '/clusters/{clusterName}/services/MAPREDUCE/components/JOBTRACKER?fields=metrics/mapred/jobtracker/occupied_map_slots[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/reserved_map_slots[{fromSeconds},{toSeconds},{stepSeconds}]',
  723. 'mock': '/data/services/metrics/mapreduce/map_slots.json',
  724. 'testInProduction': true
  725. },
  726. 'service.metrics.mapreduce.reduce_slots': {
  727. 'real': '/clusters/{clusterName}/services/MAPREDUCE/components/JOBTRACKER?fields=metrics/mapred/jobtracker/occupied_reduce_slots[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/reserved_reduce_slots[{fromSeconds},{toSeconds},{stepSeconds}]',
  728. 'mock': '/data/services/metrics/mapreduce/reduce_slots.json',
  729. 'testInProduction': true
  730. },
  731. 'service.metrics.mapreduce.rpc': {
  732. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  733. 'mock': '/data/services/metrics/mapreduce/rpc.json',
  734. 'testInProduction': true
  735. },
  736. 'service.metrics.mapreduce.tasks_running_waiting': {
  737. 'real': '/clusters/{clusterName}/services/MAPREDUCE/components/JOBTRACKER?fields=metrics/mapred/jobtracker/running_maps[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/running_reduces[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/waiting_maps[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/waiting_reduces[{fromSeconds},{toSeconds},{stepSeconds}]',
  738. 'mock': '/data/services/metrics/mapreduce/tasks_running_waiting.json',
  739. 'testInProduction': true
  740. },
  741. 'service.metrics.hdfs.block_status': {
  742. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/FSNamesystem/PendingReplicationBlocks[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/FSNamesystem/UnderReplicatedBlocks[{fromSeconds},{toSeconds},{stepSeconds}]',
  743. 'mock': '/data/services/metrics/hdfs/block_status.json',
  744. 'testInProduction': true
  745. },
  746. 'service.metrics.hdfs.file_operations': {
  747. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/namenode/FileInfoOps[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/namenode/CreateFileOps[{fromSeconds},{toSeconds},{stepSeconds}]',
  748. 'mock': '/data/services/metrics/hdfs/file_operations.json',
  749. 'testInProduction': true
  750. },
  751. 'service.metrics.hdfs.gc': {
  752. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  753. 'mock': '/data/services/metrics/hdfs/gc.json',
  754. 'testInProduction': true
  755. },
  756. 'service.metrics.hdfs.io': {
  757. 'real': '/clusters/{clusterName}/services/HDFS/components/DATANODE?fields=metrics/dfs/datanode/bytes_written[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/datanode/bytes_read[{fromSeconds},{toSeconds},{stepSeconds}]',
  758. 'mock': '/data/services/metrics/hdfs/io.json',
  759. 'testInProduction': true
  760. },
  761. 'service.metrics.hdfs.jvm_heap': {
  762. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/jvm/memNonHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memNonHeapCommittedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memHeapCommittedM[{fromSeconds},{toSeconds},{stepSeconds}]',
  763. 'mock': '/data/services/metrics/hdfs/jvm_heap.json',
  764. 'testInProduction': true
  765. },
  766. 'service.metrics.hdfs.jvm_threads': {
  767. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/jvm/threadsRunnable[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsBlocked[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsWaiting[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsTimedWaiting[{fromSeconds},{toSeconds},{stepSeconds}]',
  768. 'mock': '/data/services/metrics/hdfs/jvm_threads.json',
  769. 'testInProduction': true
  770. },
  771. 'service.metrics.hdfs.rpc': {
  772. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  773. 'mock': '/data/services/metrics/hdfs/rpc.json',
  774. 'testInProduction': true
  775. },
  776. 'service.metrics.hdfs.space_utilization': {
  777. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/FSNamesystem/CapacityRemainingGB[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/FSNamesystem/CapacityUsedGB[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/FSNamesystem/CapacityTotalGB[{fromSeconds},{toSeconds},{stepSeconds}]',
  778. 'mock': '/data/services/metrics/hdfs/space_utilization.json',
  779. 'testInProduction': true
  780. },
  781. 'service.start_stop': {
  782. 'real': '/clusters/{clusterName}/services?params/run_smoke_test=true',
  783. 'mock': '/data/mirroring/poll/poll_6.json',
  784. 'format': function (data) {
  785. return {
  786. type: 'PUT',
  787. async: false,
  788. data: data.data
  789. };
  790. }
  791. },
  792. 'service.metrics.yarn.gc': {
  793. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  794. 'mock': '/data/services/metrics/yarn/gc.json',
  795. 'testInProduction': true
  796. },
  797. 'service.metrics.yarn.jobs_threads': {
  798. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/jvm/threadsRunnable[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsBlocked[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsWaiting[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsTimedWaiting[{fromSeconds},{toSeconds},{stepSeconds}]',
  799. 'mock': '/data/services/metrics/yarn/jvm_threads.json',
  800. 'testInProduction': true
  801. },
  802. 'service.metrics.yarn.rpc': {
  803. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  804. 'mock': '/data/services/metrics/yarn/rpc.json',
  805. 'testInProduction': true
  806. },
  807. 'service.metrics.yarn.jobs_heap': {
  808. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/jvm/memNonHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memNonHeapCommittedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memHeapCommittedM[{fromSeconds},{toSeconds},{stepSeconds}]',
  809. 'mock': '/data/services/metrics/yarn/jvm_heap.json',
  810. 'testInProduction': true
  811. },
  812. 'service.metrics.yarn.queue.allocated': {
  813. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/yarn/Queue/root/AvailableMB[{fromSeconds},{toSeconds},{stepSeconds}],metrics/yarn/Queue/root/PendingMB[{fromSeconds},{toSeconds},{stepSeconds}],metrics/yarn/Queue/root/AllocatedMB[{fromSeconds},{toSeconds},{stepSeconds}]',
  814. 'mock': '',
  815. 'testInProduction': true
  816. },
  817. 'service.metrics.yarn.queue.allocated.container': {
  818. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/yarn/Queue/root/AllocatedContainers[{fromSeconds},{toSeconds},{stepSeconds}],metrics/yarn/Queue/root/ReservedContainers[{fromSeconds},{toSeconds},{stepSeconds}],metrics/yarn/Queue/root/PendingContainers[{fromSeconds},{toSeconds},{stepSeconds}]',
  819. 'mock': '',
  820. 'testInProduction': true
  821. },
  822. 'service.metrics.yarn.node.manager.statuses': {
  823. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/yarn/ClusterMetrics/NumActiveNMs[{fromSeconds},{toSeconds},{stepSeconds}],metrics/yarn/ClusterMetrics/NumDecommissionedNMs[{fromSeconds},{toSeconds},{stepSeconds}],metrics/yarn/ClusterMetrics/NumLostNMs[{fromSeconds},{toSeconds},{stepSeconds}],metrics/yarn/ClusterMetrics/NumRebootedNMs[{fromSeconds},{toSeconds},{stepSeconds}],metrics/yarn/ClusterMetrics/NumUnhealthyNMs[{fromSeconds},{toSeconds},{stepSeconds}]',
  824. 'mock': '',
  825. 'testInProduction': true
  826. },
  827. 'service.metrics.yarn.queue.memory.resource': {
  828. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=',
  829. 'mock': '',
  830. 'format': function (data, opt) {
  831. var field1 = 'metrics/yarn/Queue/{queueName}/AllocatedMB[{fromSeconds},{toSeconds},{stepSeconds}]';
  832. var field2 = 'metrics/yarn/Queue/{queueName}/AvailableMB[{fromSeconds},{toSeconds},{stepSeconds}]';
  833. if (opt.url != null && data.queueNames != null && data.queueNames.length > 0) {
  834. data.queueNames.forEach(function (q) {
  835. data.queueName = q;
  836. opt.url += (formatUrl(field1, data) + ",");
  837. opt.url += (formatUrl(field2, data) + ",");
  838. });
  839. } else {
  840. opt.url += (formatUrl(field1, data) + ",");
  841. opt.url += (formatUrl(field2, data) + ",");
  842. }
  843. },
  844. 'testInProduction': true
  845. },
  846. 'service.metrics.yarn.queue.apps.states.current': {
  847. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/yarn/Queue/root/AppsPending[{fromSeconds},{toSeconds},{stepSeconds}],metrics/yarn/Queue/root/AppsRunning[{fromSeconds},{toSeconds},{stepSeconds}]',
  848. 'mock': '',
  849. 'testInProduction': true
  850. },
  851. 'service.metrics.yarn.queue.apps.states.finished': {
  852. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/yarn/Queue/root/AppsKilled[{fromSeconds},{toSeconds},{stepSeconds}],metrics/yarn/Queue/root/AppsFailed[{fromSeconds},{toSeconds},{stepSeconds}],metrics/yarn/Queue/root/AppsSubmitted[{fromSeconds},{toSeconds},{stepSeconds}],metrics/yarn/Queue/root/AppsCompleted[{fromSeconds},{toSeconds},{stepSeconds}]',
  853. 'mock': '',
  854. 'testInProduction': true
  855. },
  856. 'service.metrics.storm.nimbus': {
  857. 'real': '/clusters/{clusterName}/services/STORM/components/NIMBUS?fields={metricsTemplate}',
  858. 'mock': ''
  859. },
  860. 'dashboard.cluster_metrics.cpu': {
  861. 'real': '/clusters/{clusterName}/?fields=metrics/cpu[{fromSeconds},{toSeconds},{stepSeconds}]',
  862. 'mock': '/data/cluster_metrics/cpu_1hr.json',
  863. 'testInProduction': true
  864. },
  865. 'dashboard.cluster_metrics.load': {
  866. 'real': '/clusters/{clusterName}/?fields=metrics/load[{fromSeconds},{toSeconds},{stepSeconds}]',
  867. 'mock': '/data/cluster_metrics/load_1hr.json',
  868. 'testInProduction': true
  869. },
  870. 'dashboard.cluster_metrics.memory': {
  871. 'real': '/clusters/{clusterName}/?fields=metrics/memory[{fromSeconds},{toSeconds},{stepSeconds}]',
  872. 'mock': '/data/cluster_metrics/memory_1hr.json',
  873. 'testInProduction': true
  874. },
  875. 'dashboard.cluster_metrics.network': {
  876. 'real': '/clusters/{clusterName}/?fields=metrics/network[{fromSeconds},{toSeconds},{stepSeconds}]',
  877. 'mock': '/data/cluster_metrics/network_1hr.json',
  878. 'testInProduction': true
  879. },
  880. 'host.metrics.cpu': {
  881. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/cpu/cpu_user[{fromSeconds},{toSeconds},{stepSeconds}],metrics/cpu/cpu_wio[{fromSeconds},{toSeconds},{stepSeconds}],metrics/cpu/cpu_nice[{fromSeconds},{toSeconds},{stepSeconds}],metrics/cpu/cpu_aidle[{fromSeconds},{toSeconds},{stepSeconds}],metrics/cpu/cpu_system[{fromSeconds},{toSeconds},{stepSeconds}],metrics/cpu/cpu_idle[{fromSeconds},{toSeconds},{stepSeconds}]',
  882. 'mock': '/data/hosts/metrics/cpu.json',
  883. 'testInProduction': true
  884. },
  885. 'host.metrics.disk': {
  886. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/disk/disk_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/disk/disk_free[{fromSeconds},{toSeconds},{stepSeconds}]',
  887. 'mock': '/data/hosts/metrics/disk.json',
  888. 'testInProduction': true
  889. },
  890. 'host.metrics.load': {
  891. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/load/load_fifteen[{fromSeconds},{toSeconds},{stepSeconds}],metrics/load/load_one[{fromSeconds},{toSeconds},{stepSeconds}],metrics/load/load_five[{fromSeconds},{toSeconds},{stepSeconds}]',
  892. 'mock': '/data/hosts/metrics/load.json',
  893. 'testInProduction': true
  894. },
  895. 'host.metrics.memory': {
  896. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/memory/swap_free[{fromSeconds},{toSeconds},{stepSeconds}],metrics/memory/mem_shared[{fromSeconds},{toSeconds},{stepSeconds}],metrics/memory/mem_free[{fromSeconds},{toSeconds},{stepSeconds}],metrics/memory/mem_cached[{fromSeconds},{toSeconds},{stepSeconds}],metrics/memory/mem_buffers[{fromSeconds},{toSeconds},{stepSeconds}]',
  897. 'mock': '/data/hosts/metrics/memory.json',
  898. 'testInProduction': true
  899. },
  900. 'host.metrics.network': {
  901. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/network/bytes_in[{fromSeconds},{toSeconds},{stepSeconds}],metrics/network/bytes_out[{fromSeconds},{toSeconds},{stepSeconds}],metrics/network/pkts_in[{fromSeconds},{toSeconds},{stepSeconds}],metrics/network/pkts_out[{fromSeconds},{toSeconds},{stepSeconds}]',
  902. 'mock': '/data/hosts/metrics/network.json',
  903. 'testInProduction': true
  904. },
  905. 'host.metrics.processes': {
  906. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/process/proc_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/process/proc_run[{fromSeconds},{toSeconds},{stepSeconds}]',
  907. 'mock': '/data/hosts/metrics/processes.json',
  908. 'testInProduction': true
  909. },
  910. 'host.service_config_hosts_overrides': {
  911. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  912. 'mock': '',
  913. 'format': function() {
  914. return {
  915. async: false,
  916. timeout: 10000
  917. };
  918. }
  919. },
  920. 'admin.security_status': {
  921. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  922. 'mock': '',
  923. 'format': function() {
  924. return {
  925. timeout: 10000
  926. };
  927. }
  928. },
  929. 'settings.get.user_pref': {
  930. 'real': '/persist/{key}',
  931. 'mock': '/data/user_settings/{key}.json',
  932. 'format': function(data) {
  933. return {
  934. async: data.async
  935. };
  936. }
  937. },
  938. 'settings.post.user_pref': {
  939. 'real': '/persist',
  940. 'mock': '',
  941. 'type': 'POST',
  942. 'format': function (data) {
  943. return {
  944. async: data.async,
  945. data: JSON.stringify(data.keyValuePair)
  946. }
  947. }
  948. },
  949. 'cluster.load_cluster_name': {
  950. 'real': '/clusters',
  951. 'mock': '/data/clusters/info.json',
  952. 'format': function() {
  953. return {
  954. async: false
  955. };
  956. }
  957. },
  958. 'cluster.update_upgrade_version': {
  959. 'real': '/stacks/HDP/versions?fields=stackServices/StackServices,Versions',
  960. 'mock': '/data/wizard/stack/stacks.json',
  961. 'format': function() {
  962. return {
  963. async: false
  964. };
  965. }
  966. },
  967. 'cluster.load_repositories': {
  968. 'real': '/stacks/{stackName}/versions/{stackVersion}/operating_systems?fields=repositories/*',
  969. 'mock': '',
  970. 'type': 'GET',
  971. 'format': function (data) {
  972. return {
  973. data: data.data
  974. };
  975. }
  976. },
  977. 'admin.high_availability.stop_all_services': {
  978. 'real': '/clusters/{clusterName}/services',
  979. 'mock': '',
  980. 'format': function() {
  981. return {
  982. type: 'PUT',
  983. data: JSON.stringify({
  984. "RequestInfo": {
  985. "context": "Stop all services"
  986. },
  987. "Body": {
  988. "ServiceInfo": {
  989. "state": "INSTALLED"
  990. }
  991. }
  992. })
  993. }
  994. }
  995. },
  996. 'admin.high_availability.start_all_services': {
  997. 'real': '/clusters/{clusterName}/services',
  998. 'mock': '',
  999. 'format': function() {
  1000. return {
  1001. type: 'PUT',
  1002. data: JSON.stringify({
  1003. "RequestInfo": {
  1004. "context": "Start all services"
  1005. },
  1006. "Body": {
  1007. "ServiceInfo": {
  1008. "state": "STARTED"
  1009. }
  1010. }
  1011. })
  1012. }
  1013. }
  1014. },
  1015. 'admin.high_availability.polling': {
  1016. 'real': '/clusters/{clusterName}/requests/{requestId}?fields=tasks/*',
  1017. 'mock': '',
  1018. 'type': 'GET'
  1019. },
  1020. 'admin.high_availability.getNnCheckPointStatus': {
  1021. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/NAMENODE',
  1022. 'mock': '',
  1023. 'type': 'GET'
  1024. },
  1025. 'admin.high_availability.getJnCheckPointStatus': {
  1026. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/JOURNALNODE?fields=metrics',
  1027. 'mock': ''
  1028. },
  1029. 'admin.high_availability.getHostComponent': {
  1030. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  1031. 'mock': ''
  1032. },
  1033. 'admin.high_availability.create_component': {
  1034. 'real': '/clusters/{clusterName}/hosts?Hosts/host_name={hostName}',
  1035. 'mock': '',
  1036. 'type': 'POST',
  1037. 'format': function (data) {
  1038. return {
  1039. data: JSON.stringify({
  1040. "host_components": [
  1041. {
  1042. "HostRoles": {
  1043. "component_name": data.componentName
  1044. }
  1045. }
  1046. ]
  1047. })
  1048. }
  1049. }
  1050. },
  1051. 'admin.high_availability.install_component': {
  1052. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  1053. 'mock': '',
  1054. 'type': 'PUT',
  1055. 'format': function (data) {
  1056. return {
  1057. data: JSON.stringify({
  1058. RequestInfo: {
  1059. "context": "Install " + data.displayName
  1060. },
  1061. Body: {
  1062. "HostRoles": {
  1063. "state": "INSTALLED"
  1064. }
  1065. }
  1066. })
  1067. }
  1068. }
  1069. },
  1070. 'admin.high_availability.start_component': {
  1071. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  1072. 'mock': '',
  1073. 'type': 'PUT',
  1074. 'format': function (data) {
  1075. return {
  1076. data: JSON.stringify({
  1077. RequestInfo: {
  1078. "context": "Start " + data.displayName
  1079. },
  1080. Body: {
  1081. "HostRoles": {
  1082. "state": "STARTED"
  1083. }
  1084. }
  1085. })
  1086. }
  1087. }
  1088. },
  1089. 'admin.high_availability.maintenance_mode': {
  1090. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  1091. 'mock': '',
  1092. 'type': 'PUT',
  1093. 'format': function () {
  1094. return {
  1095. data: JSON.stringify({
  1096. "HostRoles": {
  1097. "state": "DISABLED"
  1098. }
  1099. })
  1100. }
  1101. }
  1102. },
  1103. 'admin.high_availability.stop_component': {
  1104. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  1105. 'mock': '',
  1106. 'type': 'PUT',
  1107. 'format': function (data) {
  1108. return {
  1109. data: JSON.stringify({
  1110. RequestInfo: {
  1111. "context": "Stop " + data.displayName
  1112. },
  1113. Body: {
  1114. "HostRoles": {
  1115. "state": "INSTALLED"
  1116. }
  1117. }
  1118. })
  1119. }
  1120. }
  1121. },
  1122. 'admin.high_availability.load_configs': {
  1123. 'real': '/clusters/{clusterName}/configurations?(type=core-site&tag={coreSiteTag})|(type=hdfs-site&tag={hdfsSiteTag})',
  1124. 'mock': '',
  1125. 'type': 'GET'
  1126. },
  1127. 'admin.high_availability.save_configs': {
  1128. 'real': '/clusters/{clusterName}',
  1129. 'mock': '',
  1130. 'type': 'PUT',
  1131. 'format': function (data) {
  1132. return {
  1133. async: false,
  1134. data: JSON.stringify({
  1135. Clusters: {
  1136. desired_config: {
  1137. "type": data.siteName,
  1138. "tag": 'version' + (new Date).getTime(),
  1139. "properties": data.properties
  1140. }
  1141. }
  1142. })
  1143. }
  1144. }
  1145. },
  1146. 'admin.high_availability.load_hbase_configs': {
  1147. 'real': '/clusters/{clusterName}/configurations?type=hbase-site&tag={hbaseSiteTag}',
  1148. 'mock': '',
  1149. 'type': 'GET'
  1150. },
  1151. 'admin.delete_component': {
  1152. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  1153. 'mock': '',
  1154. 'type': 'DELETE'
  1155. },
  1156. 'admin.security.cluster_configs': {
  1157. 'real': '/clusters/{clusterName}',
  1158. 'mock': '',
  1159. 'format': function() {
  1160. return {
  1161. timeout: 10000
  1162. };
  1163. }
  1164. },
  1165. 'admin.delete_host': {
  1166. 'real': '/clusters/{clusterName}/hosts/{hostName}',
  1167. 'mock': '',
  1168. 'type': 'DELETE'
  1169. },
  1170. 'admin.get.all_configurations': {
  1171. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  1172. 'mock': '',
  1173. 'format': function() {
  1174. return {
  1175. timeout: 10000
  1176. };
  1177. }
  1178. },
  1179. 'admin.security.apply_configurations': {
  1180. 'real': '/clusters/{clusterName}',
  1181. 'mock': '',
  1182. 'format': function (data) {
  1183. return {
  1184. type: 'PUT',
  1185. timeout: 10000,
  1186. data: data.configData
  1187. };
  1188. }
  1189. },
  1190. 'admin.security.apply_configuration': {
  1191. 'real': '/clusters/{clusterName}',
  1192. 'mock': '',
  1193. 'format': function(data) {
  1194. return {
  1195. type: 'PUT',
  1196. async: false,
  1197. timeout: 5000,
  1198. data: JSON.stringify(data.clusterData)
  1199. };
  1200. }
  1201. },
  1202. 'admin.security.add.cluster_configs': {
  1203. 'real': '/clusters/{clusterName}' + '?fields=Clusters/desired_configs',
  1204. 'mock': '',
  1205. 'format': function() {
  1206. return {
  1207. timeout: 10000
  1208. };
  1209. }
  1210. },
  1211. 'admin.stack_upgrade.run_upgrade': {
  1212. 'real': '/clusters/{clusterName}',
  1213. 'mock': '',
  1214. 'format': function (data) {
  1215. return {
  1216. type: 'PUT',
  1217. async: false,
  1218. data: data.data
  1219. };
  1220. }
  1221. },
  1222. 'admin.stack_upgrade.stop_services': {
  1223. 'real': '/clusters/{clusterName}/services?ServiceInfo/state=STARTED',
  1224. 'mock': '',
  1225. 'format': function (data) {
  1226. return {
  1227. type: 'PUT',
  1228. async: false,
  1229. data: data.data
  1230. };
  1231. }
  1232. },
  1233. 'admin.user.create': {
  1234. 'real': '/users/{user}',
  1235. 'mock': '/data/users/users.json',
  1236. 'format': function(data) {
  1237. return {
  1238. type: 'POST',
  1239. data: JSON.stringify(data.data)
  1240. }
  1241. }
  1242. },
  1243. 'admin.user.delete': {
  1244. 'real': '/users/{user}',
  1245. 'mock': '/data/users/users.json',
  1246. 'format': function() {
  1247. return {
  1248. type: 'DELETE'
  1249. }
  1250. }
  1251. },
  1252. 'admin.user.edit': {
  1253. 'real': '/users/{user}',
  1254. 'mock':'/data/users/users.json',
  1255. 'format': function(data) {
  1256. return {
  1257. type: 'PUT',
  1258. data: data.data
  1259. }
  1260. }
  1261. },
  1262. 'admin.stack_upgrade.do_poll': {
  1263. 'real': '/clusters/{cluster}/requests/{requestId}?fields=tasks/*',
  1264. 'mock': '/data/wizard/{mock}'
  1265. },
  1266. 'wizard.advanced_repositories.valid_url': {
  1267. 'real': '/stacks/{stackName}/versions/{stackVersion}/operating_systems/{osType}/repositories/{repoId}',
  1268. 'mock': '',
  1269. 'type': 'PUT',
  1270. 'format': function (data) {
  1271. return {
  1272. async: true,
  1273. data: JSON.stringify(data.data)
  1274. }
  1275. }
  1276. },
  1277. 'wizard.install_services.add_host_controller.is_retry': {
  1278. 'real': '/clusters/{cluster}/host_components',
  1279. 'mock': '',
  1280. 'format': function (data) {
  1281. return {
  1282. type: 'PUT',
  1283. async: false,
  1284. data: data.data
  1285. };
  1286. }
  1287. },
  1288. 'wizard.install_services.add_host_controller.not_is_retry': {
  1289. 'real': '/clusters/{cluster}/host_components',
  1290. 'mock': '',
  1291. 'format': function(data) {
  1292. return {
  1293. type: 'PUT',
  1294. async: false,
  1295. data: data.data
  1296. };
  1297. }
  1298. },
  1299. 'wizard.install_services.installer_controller.is_retry': {
  1300. 'real': '/clusters/{cluster}/host_components?HostRoles/state=INSTALLED',
  1301. 'mock': '/data/wizard/deploy/2_hosts/poll_1.json',
  1302. 'type': 'PUT',
  1303. 'format': function (data) {
  1304. return {
  1305. async: false,
  1306. data: data.data
  1307. };
  1308. }
  1309. },
  1310. 'wizard.install_services.installer_controller.not_is_retry': {
  1311. 'real': '/clusters/{cluster}/services?ServiceInfo/state=INIT',
  1312. 'mock': '/data/wizard/deploy/2_hosts/poll_1.json',
  1313. 'type': 'PUT',
  1314. 'format': function (data) {
  1315. return {
  1316. async: false,
  1317. data: data.data
  1318. };
  1319. }
  1320. },
  1321. 'wizard.install_services.add_service_controller.get_failed_host_components': {
  1322. 'real': '/clusters/{clusterName}/host_components?fields=HostRoles/state,component/ServiceComponentInfo/service_name',
  1323. 'mock': '',
  1324. 'format': function() {
  1325. return {
  1326. async: false
  1327. };
  1328. }
  1329. },
  1330. 'wizard.service_components': {
  1331. 'real': '{stackUrl}/services?fields=StackServices/comments,StackServices/service_version,serviceComponents/*',
  1332. 'mock': '/data/stacks/HDP-2.1/service_components.json',
  1333. 'format': function(data) {
  1334. return {
  1335. timeout: 10000,
  1336. async: !!data.async
  1337. };
  1338. }
  1339. },
  1340. 'wizard.step9.installer.get_host_status': {
  1341. 'real': '/clusters/{cluster}/hosts?fields=Hosts/host_state,host_components/HostRoles/state',
  1342. 'mock': '/data/wizard/deploy/5_hosts/get_host_state.json',
  1343. 'format': function () {
  1344. return {
  1345. async: false
  1346. };
  1347. }
  1348. },
  1349. 'wizard.step9.installer.launch_start_services': {
  1350. 'real': '/clusters/{cluster}/services?ServiceInfo/state=INSTALLED&params/run_smoke_test=true&params/reconfigure_client=false',
  1351. 'mock': '/data/wizard/deploy/5_hosts/poll_6.json',
  1352. 'format': function (data) {
  1353. var d = {
  1354. type: 'PUT',
  1355. async: false,
  1356. data: data.data
  1357. };
  1358. if (App.testMode) {
  1359. d.type = 'GET';
  1360. }
  1361. return d;
  1362. }
  1363. },
  1364. 'wizard.step9.add_service.launch_start_services': {
  1365. 'real': '/clusters/{cluster}/services?ServiceInfo/state=INSTALLED&ServiceInfo/service_name.in({servicesList})&params/reconfigure_client=false',
  1366. 'mock': '/data/wizard/deploy/5_hosts/poll_6.json',
  1367. 'format': function (data) {
  1368. var d = {
  1369. type: 'PUT',
  1370. async: false,
  1371. data: data.data
  1372. };
  1373. if (App.testMode) {
  1374. d.type = 'GET';
  1375. }
  1376. return d;
  1377. }
  1378. },
  1379. 'wizard.step9.add_host.launch_start_services': {
  1380. 'real': '/clusters/{cluster}/host_components',
  1381. 'mock': '/data/wizard/deploy/5_hosts/poll_6.json',
  1382. 'format': function (data) {
  1383. return {
  1384. type: 'PUT',
  1385. async: false,
  1386. data: data.data
  1387. };
  1388. }
  1389. },
  1390. 'wizard.step9.load_log': {
  1391. 'real': '/clusters/{cluster}/requests/{requestId}?fields=tasks/Tasks/command,tasks/Tasks/exit_code,tasks/Tasks/start_time,tasks/Tasks/end_time,tasks/Tasks/host_name,tasks/Tasks/id,tasks/Tasks/role,tasks/Tasks/status&minimal_response=true',
  1392. 'mock': '/data/wizard/deploy/5_hosts/poll_{numPolls}.json',
  1393. 'format': function () {
  1394. return {
  1395. type: 'GET',
  1396. async: true,
  1397. dataType: 'text'
  1398. };
  1399. }
  1400. },
  1401. 'wizard.step8.delete_cluster': {
  1402. 'real': '/clusters/{name}',
  1403. 'mock': '',
  1404. 'format': function() {
  1405. return {
  1406. type: 'DELETE',
  1407. async: false
  1408. };
  1409. }
  1410. },
  1411. 'wizard.step8.existing_cluster_names': {
  1412. 'real': '/clusters',
  1413. 'mock': '',
  1414. 'format': function() {
  1415. return {
  1416. async: false
  1417. };
  1418. }
  1419. },
  1420. 'wizard.step8.create_cluster': {
  1421. 'real':'/clusters/{cluster}',
  1422. 'mock':'',
  1423. 'format': function(data) {
  1424. return {
  1425. type: 'POST',
  1426. async: true,
  1427. dataType: 'text',
  1428. data: data.data
  1429. }
  1430. }
  1431. },
  1432. 'wizard.step8.create_selected_services': {
  1433. 'real':'/clusters/{cluster}/services',
  1434. 'mock':'',
  1435. 'format': function(data) {
  1436. return {
  1437. type: 'POST',
  1438. async: true,
  1439. dataType: 'text',
  1440. data: data.data
  1441. }
  1442. }
  1443. },
  1444. 'wizard.step8.create_components': {
  1445. 'real':'/clusters/{cluster}/services?ServiceInfo/service_name={serviceName}',
  1446. 'mock':'',
  1447. 'format': function(data) {
  1448. return {
  1449. type: 'POST',
  1450. async: true,
  1451. dataType: 'text',
  1452. data: data.data
  1453. }
  1454. }
  1455. },
  1456. 'wizard.step8.register_host_to_cluster': {
  1457. 'real':'/clusters/{cluster}/hosts',
  1458. 'mock':'',
  1459. 'format': function(data) {
  1460. return {
  1461. type: 'POST',
  1462. async: true,
  1463. dataType: 'text',
  1464. data: data.data
  1465. }
  1466. }
  1467. },
  1468. 'wizard.step8.register_host_to_component': {
  1469. 'real':'/clusters/{cluster}/hosts',
  1470. 'mock':'',
  1471. 'format': function(data) {
  1472. return {
  1473. type: 'POST',
  1474. async: true,
  1475. dataType: 'text',
  1476. data: data.data
  1477. }
  1478. }
  1479. },
  1480. 'wizard.step8.apply_configuration_to_cluster': {
  1481. 'real':'/clusters/{cluster}',
  1482. 'mock':'',
  1483. 'format': function(data) {
  1484. return {
  1485. type: 'PUT',
  1486. async: true,
  1487. dataType: 'text',
  1488. data: data.data
  1489. }
  1490. }
  1491. },
  1492. 'wizard.step8.apply_configuration_groups': {
  1493. 'real':'/clusters/{cluster}/config_groups',
  1494. 'mock':'',
  1495. 'format': function(data) {
  1496. return {
  1497. type: 'POST',
  1498. async: true,
  1499. dataType: 'text',
  1500. data: data.data
  1501. }
  1502. }
  1503. },
  1504. 'wizard.step8.set_local_repos': {
  1505. 'real':'{stackVersionURL}/operating_systems/{osType}/repositories/{repoId}',
  1506. 'mock':'',
  1507. 'format': function(data) {
  1508. return {
  1509. type: 'PUT',
  1510. async: true,
  1511. dataType: 'text',
  1512. data: data.data
  1513. }
  1514. }
  1515. },
  1516. 'wizard.step3.jdk_check': {
  1517. 'real': '/requests',
  1518. 'mock': '',
  1519. 'format': function (data) {
  1520. return {
  1521. type: 'POST',
  1522. data: JSON.stringify({
  1523. "RequestInfo": {
  1524. "context": "Check hosts",
  1525. "action": "check_host",
  1526. "parameters" : {
  1527. "threshold" : "60",
  1528. "java_home" : data.java_home,
  1529. "jdk_location": data.jdk_location,
  1530. "check_execute_list" : "java_home_check"
  1531. }
  1532. },
  1533. "Requests/resource_filters": [{
  1534. "hosts": data.host_names
  1535. }]
  1536. })
  1537. }
  1538. }
  1539. },
  1540. 'wizard.step3.jdk_check.get_results': {
  1541. 'real': '/requests/{requestIndex}?fields=*,tasks/Tasks/host_name,tasks/Tasks/status,tasks/Tasks/structured_out',
  1542. 'mock': '/data/requests/host_check/jdk_check_results.json'
  1543. },
  1544. 'wizard.step3.host_info': {
  1545. 'real': '/hosts?fields=Hosts/total_mem,Hosts/cpu_count,Hosts/disk_info,Hosts/last_agent_env,Hosts/host_name,Hosts/os_type,Hosts/os_arch,Hosts/ip',
  1546. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  1547. 'format': function() {
  1548. return {
  1549. contentType: 'application/json'
  1550. };
  1551. }
  1552. },
  1553. 'preinstalled.checks': {
  1554. 'real':'/requests',
  1555. 'mock':'',
  1556. 'format': function(data) {
  1557. return {
  1558. type : 'POST',
  1559. data : JSON.stringify({
  1560. "RequestInfo": data.RequestInfo,
  1561. "Requests/resource_filters": [data.resource_filters]
  1562. })
  1563. }
  1564. }
  1565. },
  1566. 'preinstalled.checks.tasks': {
  1567. 'real':'/requests/{requestId}?fields=tasks/Tasks',
  1568. 'mock':'/data/requests/host_check/1.json'
  1569. },
  1570. 'wizard.step3.rerun_checks': {
  1571. 'real': '/hosts?fields=Hosts/last_agent_env',
  1572. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  1573. 'format': function() {
  1574. return {
  1575. contentType: 'application/json'
  1576. };
  1577. }
  1578. },
  1579. 'wizard.step3.bootstrap': {
  1580. 'real': '/bootstrap/{bootRequestId}',
  1581. 'mock': '/data/wizard/bootstrap/poll_{numPolls}.json'
  1582. },
  1583. 'wizard.step3.is_hosts_registered': {
  1584. 'real': '/hosts',
  1585. 'mock': '/data/wizard/bootstrap/single_host_registration.json'
  1586. },
  1587. 'wizard.stacks': {
  1588. 'real': '/stacks',
  1589. 'mock': '/data/wizard/stack/stacks2.json',
  1590. 'format': function() {
  1591. return {
  1592. async: false
  1593. };
  1594. }
  1595. },
  1596. 'wizard.stacks_versions': {
  1597. 'real': '/stacks/{stackName}/versions?fields=Versions,operatingSystems/repositories/Repositories',
  1598. 'mock': '/data/wizard/stack/{stackName}_versions.json',
  1599. 'format': function() {
  1600. return {
  1601. async: false
  1602. };
  1603. }
  1604. },
  1605. 'wizard.launch_bootstrap': {
  1606. 'real': '/bootstrap',
  1607. 'mock': '/data/wizard/bootstrap/bootstrap.json',
  1608. 'type': 'POST',
  1609. 'format': function (data) {
  1610. return {
  1611. contentType: 'application/json',
  1612. data: data.bootStrapData,
  1613. popup: data.popup
  1614. }
  1615. }
  1616. },
  1617. 'router.login': {
  1618. 'real': '/users/{loginName}',
  1619. 'mock': '/data/users/user_{usr}.json',
  1620. 'format': function (data) {
  1621. var statusCode = jQuery.extend({}, require('data/statusCodes'));
  1622. statusCode['403'] = function () {
  1623. console.log("Error code 403: Forbidden.");
  1624. };
  1625. return {
  1626. statusCode: statusCode
  1627. };
  1628. }
  1629. },
  1630. 'router.login2': {
  1631. 'real': '/clusters',
  1632. 'mock': '/data/clusters/info.json'
  1633. },
  1634. 'router.logoff': {
  1635. 'real': '/logout',
  1636. 'mock': ''
  1637. },
  1638. 'router.set_ambari_stacks': {
  1639. 'real': '/stacks',
  1640. 'mock': '/data/wizard/stack/stacks.json',
  1641. 'format': function() {
  1642. return {
  1643. async: false
  1644. };
  1645. }
  1646. },
  1647. 'router.authentication': {
  1648. 'real': '/clusters',
  1649. 'mock': '/data/clusters/info.json',
  1650. 'format': function() {
  1651. return {
  1652. async: false
  1653. };
  1654. }
  1655. },
  1656. 'ambari.service.load_jdk_name': {
  1657. 'real': '/services/AMBARI/components/AMBARI_SERVER?fields=RootServiceComponents/properties/jdk.name,RootServiceComponents/properties/java.home,RootServiceComponents/properties/jdk_location',
  1658. 'mock': '/data/requests/host_check/jdk_name.json'
  1659. },
  1660. 'ambari.service.load_server_version': {
  1661. 'real': '/services/AMBARI/components/AMBARI_SERVER?fields=RootServiceComponents/component_version',
  1662. 'mock': ''
  1663. },
  1664. 'ambari.service': {
  1665. 'real': '/services/AMBARI/components/AMBARI_SERVER',
  1666. 'mock': '/data/services/ambari_server.json'
  1667. },
  1668. 'ambari.service.load_server_clock': {
  1669. 'real': '/services/AMBARI/components/AMBARI_SERVER?fields=RootServiceComponents/server_clock',
  1670. 'mock': ''
  1671. },
  1672. 'config_groups.create': {
  1673. 'real': '/clusters/{clusterName}/config_groups',
  1674. 'mock': '',
  1675. 'format': function (data) {
  1676. return {
  1677. async: false,
  1678. type: 'POST',
  1679. data: JSON.stringify([{
  1680. "ConfigGroup": {
  1681. "group_name": data.group_name,
  1682. "tag": data.service_id,
  1683. "description": data.description,
  1684. "desired_configs": data.desired_configs,
  1685. "hosts": data.hosts
  1686. }
  1687. }])
  1688. }
  1689. }
  1690. },
  1691. 'config_groups.update': {
  1692. 'real': '/clusters/{clusterName}/config_groups/{id}',
  1693. 'mock': '',
  1694. 'format': function (data) {
  1695. return {
  1696. async: true,
  1697. type: 'PUT',
  1698. data: JSON.stringify(data.data)
  1699. }
  1700. }
  1701. },
  1702. 'rolling_restart.post': {
  1703. 'real': '/clusters/{clusterName}/request_schedules',
  1704. 'mock': '',
  1705. 'format' : function(data) {
  1706. return {
  1707. type : 'POST',
  1708. data : JSON.stringify([ {
  1709. "RequestSchedule" : {
  1710. "batch" : [ {
  1711. "requests" : data.batches
  1712. }, {
  1713. "batch_settings" : {
  1714. "batch_separation_in_seconds" : data.intervalTimeSeconds,
  1715. "task_failure_tolerance" : data.tolerateSize
  1716. }
  1717. } ]
  1718. }
  1719. } ])
  1720. }
  1721. }
  1722. },
  1723. 'request_schedule.delete': {
  1724. 'real': '/clusters/{clusterName}/request_schedules/{request_schedule_id}',
  1725. 'mock': '',
  1726. 'format' : function() {
  1727. return {
  1728. type : 'DELETE'
  1729. }
  1730. }
  1731. },
  1732. 'request_schedule.get': {
  1733. 'real': '/clusters/{clusterName}/request_schedules/{request_schedule_id}',
  1734. 'mock': ''
  1735. },
  1736. 'restart.hostComponents': {
  1737. 'real':'/clusters/{clusterName}/requests',
  1738. 'mock':'',
  1739. 'format': function(data) {
  1740. return {
  1741. type : 'POST',
  1742. data : JSON.stringify({
  1743. "RequestInfo": {
  1744. "command": "RESTART",
  1745. "context": data.context,
  1746. "operation_level": data.operation_level
  1747. },
  1748. "Requests/resource_filters": data.resource_filters
  1749. })
  1750. }
  1751. }
  1752. },
  1753. 'mirroring.get_all_entities': {
  1754. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/list/{type}?fields=status&user.name=ambari-qa',
  1755. 'mock': '/data/mirroring/{type}s.xml',
  1756. 'apiPrefix': '',
  1757. 'format': function () {
  1758. return {
  1759. dataType: 'xml'
  1760. }
  1761. }
  1762. },
  1763. 'mirroring.get_definition': {
  1764. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/definition/{type}/{name}?user.name=ambari-qa',
  1765. 'mock': '/data/mirroring/{name}_definition.xml',
  1766. 'apiPrefix': '',
  1767. 'format': function () {
  1768. return {
  1769. cache: true,
  1770. dataType: 'xml'
  1771. }
  1772. }
  1773. },
  1774. 'mirroring.dataset.get_all_instances': {
  1775. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/status/feed/{dataset}?start={start}&end={end}&user.name=ambari-qa',
  1776. 'mock': '/data/mirroring/{dataset}_instances.json',
  1777. 'apiPrefix': ''
  1778. },
  1779. 'mirroring.create_new_dataset': {
  1780. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/submitAndSchedule/feed?user.name=ambari-qa',
  1781. 'mock': '/data/mirroring/succeeded.json',
  1782. 'apiPrefix': '',
  1783. 'type': 'POST',
  1784. 'format': function (data) {
  1785. return {
  1786. contentType: 'text/xml',
  1787. dataType: 'xml',
  1788. data: data.entity,
  1789. headers: {
  1790. 'AmbariProxy-Content-Type': 'text/xml'
  1791. }
  1792. }
  1793. }
  1794. },
  1795. 'mirroring.submit_entity': {
  1796. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/submit/{type}?user.name=ambari-qa',
  1797. 'mock': '/data/mirroring/succeeded.json',
  1798. 'apiPrefix': '',
  1799. 'type': 'POST',
  1800. 'format': function (data) {
  1801. return {
  1802. contentType: 'text/xml',
  1803. dataType: 'xml',
  1804. data: data.entity,
  1805. headers: {
  1806. 'AmbariProxy-Content-Type': 'text/xml'
  1807. }
  1808. }
  1809. }
  1810. },
  1811. 'mirroring.update_entity': {
  1812. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/update/{type}/{name}?user.name=ambari-qa',
  1813. 'mock': '/data/mirroring/succeeded.json',
  1814. 'apiPrefix': '',
  1815. 'type': 'POST',
  1816. 'format': function (data) {
  1817. return {
  1818. contentType: 'text/xml',
  1819. dataType: 'xml',
  1820. data: data.entity,
  1821. headers: {
  1822. 'AmbariProxy-Content-Type': 'text/xml'
  1823. }
  1824. }
  1825. }
  1826. },
  1827. 'mirroring.delete_entity': {
  1828. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/delete/{type}/{name}?user.name=ambari-qa',
  1829. 'mock': '/data/mirroring/succeeded.json',
  1830. 'apiPrefix': '',
  1831. 'type': 'DELETE',
  1832. 'format': function () {
  1833. return {
  1834. dataType: 'xml'
  1835. }
  1836. }
  1837. },
  1838. 'mirroring.suspend_entity': {
  1839. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/suspend/{type}/{name}?user.name=ambari-qa',
  1840. 'mock': '/data/mirroring/succeeded.json',
  1841. 'apiPrefix': '',
  1842. 'type': 'POST',
  1843. 'format': function (data) {
  1844. return {
  1845. dataType: 'xml',
  1846. data: data.entity
  1847. }
  1848. }
  1849. },
  1850. 'mirroring.resume_entity': {
  1851. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/resume/{type}/{name}?user.name=ambari-qa',
  1852. 'mock': '/data/mirroring/succeeded.json',
  1853. 'apiPrefix': '',
  1854. 'type': 'POST',
  1855. 'format': function () {
  1856. return {
  1857. dataType: 'xml'
  1858. }
  1859. }
  1860. },
  1861. 'mirroring.schedule_entity': {
  1862. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/schedule/{type}/{name}?user.name=ambari-qa',
  1863. 'mock': '/data/mirroring/succeeded.json',
  1864. 'apiPrefix': '',
  1865. 'type': 'POST',
  1866. 'format': function () {
  1867. return {
  1868. dataType: 'xml'
  1869. }
  1870. }
  1871. },
  1872. 'mirroring.suspend_instance': {
  1873. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/suspend/feed/{feed}?start={name}&user.name=ambari-qa',
  1874. 'mock': '/data/mirroring/succeeded.json',
  1875. 'apiPrefix': '',
  1876. 'type': 'POST'
  1877. },
  1878. 'mirroring.resume_instance': {
  1879. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/resume/feed/{feed}?start={name}&user.name=ambari-qa',
  1880. 'mock': '/data/mirroring/succeeded.json',
  1881. 'apiPrefix': '',
  1882. 'type': 'POST'
  1883. },
  1884. 'mirroring.kill_instance': {
  1885. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/kill/feed/{feed}?start={name}&user.name=ambari-qa',
  1886. 'mock': '/data/mirroring/succeeded.json',
  1887. 'apiPrefix': '',
  1888. 'type': 'POST'
  1889. },
  1890. 'bulk_request.host_components': {
  1891. 'real': '/clusters/{clusterName}/host_components',
  1892. 'mock': '',
  1893. 'format': function(data) {
  1894. return {
  1895. type: 'PUT',
  1896. data: JSON.stringify({
  1897. RequestInfo: {
  1898. context: data.requestInfo,
  1899. query: 'HostRoles/component_name=' + data.componentName + '&HostRoles/host_name.in(' + data.hostNames + ')&HostRoles/maintenance_state=OFF'
  1900. },
  1901. Body: {
  1902. HostRoles: {
  1903. state: data.state
  1904. }
  1905. }
  1906. })
  1907. }
  1908. }
  1909. },
  1910. 'bulk_request.hosts.all_components': {
  1911. 'real': '/clusters/{clusterName}/host_components',
  1912. 'mock': '',
  1913. 'format': function(data) {
  1914. return {
  1915. type: 'PUT',
  1916. data: JSON.stringify({
  1917. RequestInfo: {
  1918. context: data.requestInfo,
  1919. query: data.query,
  1920. operation_level: {
  1921. level: "HOST",
  1922. cluster_name: data.clusterName,
  1923. host_name: data.hostName
  1924. }
  1925. },
  1926. Body: {
  1927. HostRoles: {
  1928. state: data.state
  1929. }
  1930. }
  1931. })
  1932. }
  1933. }
  1934. },
  1935. 'bulk_request.decommission': {
  1936. 'real' : '/clusters/{clusterName}/requests',
  1937. 'mock' : '',
  1938. 'format': function(data) {
  1939. return {
  1940. type: 'POST',
  1941. data: JSON.stringify({
  1942. 'RequestInfo': {
  1943. 'context': data.context,
  1944. 'command': 'DECOMMISSION',
  1945. 'parameters': data.parameters
  1946. },
  1947. "Requests/resource_filters": [{"service_name" : data.serviceName, "component_name" : data.componentName}]
  1948. })
  1949. }
  1950. }
  1951. },
  1952. 'bulk_request.hosts.passive_state': {
  1953. 'real': '/clusters/{clusterName}/hosts',
  1954. 'mock': '',
  1955. 'format': function(data) {
  1956. return {
  1957. type: 'PUT',
  1958. data: JSON.stringify({
  1959. RequestInfo: {
  1960. context: data.requestInfo,
  1961. query: 'Hosts/host_name.in(' + data.hostNames + ')'
  1962. },
  1963. Body: {
  1964. Hosts: {
  1965. maintenance_state: data.passive_state
  1966. }
  1967. }
  1968. })
  1969. }
  1970. }
  1971. },
  1972. 'bulk_request.hosts.all_components.passive_state': {
  1973. 'real': '/clusters/{clusterName}/host_components',
  1974. 'mock': '',
  1975. 'format': function(data) {
  1976. return {
  1977. type: 'PUT',
  1978. data: JSON.stringify({
  1979. RequestInfo: {
  1980. context: data.requestInfo,
  1981. query: data.query
  1982. },
  1983. Body: {
  1984. HostRoles: {
  1985. maintenance_state: data.passive_state
  1986. }
  1987. }
  1988. })
  1989. }
  1990. }
  1991. },
  1992. 'jobs.lastID': {
  1993. 'real': '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/HIVE_QUERY_ID?limit=1&secondaryFilter=tez:true',
  1994. 'mock': 'data/jobs/hive-queries.json',
  1995. 'apiPrefix': ''
  1996. },
  1997. 'jobs.tezDag.NametoID': {
  1998. 'real': '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/TEZ_DAG_ID?primaryFilter=dagName:{tezDagName}',
  1999. 'mock': '/data/jobs/tezDag-name-to-id.json',
  2000. 'apiPrefix': ''
  2001. },
  2002. 'jobs.tezDag.tezDagId': {
  2003. 'real': '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/TEZ_DAG_ID/{tezDagId}?fields=relatedentities,otherinfo',
  2004. 'mock': '/data/jobs/tezDag.json',
  2005. 'apiPrefix': ''
  2006. },
  2007. 'jobs.tezDag.tezDagVertexId': {
  2008. 'real': '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/TEZ_VERTEX_ID/{tezDagVertexId}?fields=otherinfo',
  2009. 'mock': '/data/jobs/tezDagVertex.json',
  2010. 'apiPrefix': ''
  2011. },
  2012. 'views.info': {
  2013. 'real': '/views',
  2014. 'mock':''
  2015. },
  2016. /**
  2017. * Get all instances of all views across versions
  2018. */
  2019. 'views.instances': {
  2020. 'real': '/views?fields=versions/instances/ViewInstanceInfo,versions/ViewVersionInfo/label',
  2021. 'mock':''
  2022. },
  2023. 'host.host_component.flume.metrics': {
  2024. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/FLUME_HANDLER?fields=metrics/flume/flume/{flumeComponent}/*',
  2025. 'mock': '',
  2026. 'format': function(data) {
  2027. return {
  2028. async: data.async
  2029. }
  2030. }
  2031. },
  2032. 'host.host_component.flume.metrics.timeseries': {
  2033. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/FLUME_HANDLER?fields=metrics/flume/flume/{flumeComponent}/*/{flumeComponentMetric}[{fromSeconds},{toSeconds},{stepSeconds}]',
  2034. 'mock': ''
  2035. },
  2036. 'host.host_components.filtered': {
  2037. 'real': '/clusters/{clusterName}/hosts',
  2038. 'mock': '',
  2039. format: function(data, opt) {
  2040. return {
  2041. url: opt.url + data.urlParams
  2042. }
  2043. }
  2044. },
  2045. 'host.status.counters': {
  2046. 'real': '/clusters/{clusterName}?fields=alerts,Clusters/health_report,Clusters/total_hosts&minimal_response=true',
  2047. 'mock': '/data/hosts/HDP2/host_status_counters.json'
  2048. },
  2049. 'components.filter_by_status': {
  2050. 'real': '/clusters/{clusterName}/components?fields=host_components/HostRoles/host_name,ServiceComponentInfo/component_name,ServiceComponentInfo/started_count{urlParams}&minimal_response=true',
  2051. 'mock': ''
  2052. },
  2053. 'hosts.all.install': {
  2054. 'real': '/hosts?minimal_response=true',
  2055. 'mock': ''
  2056. },
  2057. 'hosts.all': {
  2058. 'real': '/clusters/{clusterName}/hosts?minimal_response=true',
  2059. 'mock': ''
  2060. },
  2061. 'hosts.with_public_host_names': {
  2062. 'real': '/clusters/{clusterName}/hosts?fields=Hosts/public_host_name&minimal_response=true',
  2063. 'mock': ''
  2064. },
  2065. 'hosts.for_quick_links': {
  2066. 'real': '/clusters/{clusterName}/hosts?host_components/HostRoles/component_name.in({masterComponents})&fields=Hosts/public_host_name,host_components/HostRoles/component_name{urlParams}&minimal_response=true',
  2067. 'mock': ''
  2068. },
  2069. 'hosts.confirmed.install': {
  2070. 'real': '/hosts?fields=Hosts/cpu_count,Hosts/disk_info,Hosts/total_mem&minimal_response=true',
  2071. 'mock': ''
  2072. },
  2073. 'hosts.confirmed': {
  2074. 'real': '/clusters/{clusterName}/hosts?fields=Hosts/cpu_count,Hosts/disk_info,Hosts/total_mem,host_components&minimal_response=true',
  2075. 'mock': ''
  2076. },
  2077. 'host_components.all': {
  2078. 'real': '/clusters/{clusterName}/host_components?fields=HostRoles/host_name&minimal_response=true',
  2079. 'mock': ''
  2080. },
  2081. 'host_components.with_services_names': {
  2082. 'real': '/clusters/{clusterName}/host_components?fields=component/ServiceComponentInfo/service_name,HostRoles/host_name&minimal_response=true',
  2083. 'mock': ''
  2084. },
  2085. 'components.get_installed': {
  2086. 'real': '/clusters/{clusterName}/components',
  2087. 'mock': ''
  2088. },
  2089. 'hosts.heatmaps': {
  2090. 'real': '/clusters/{clusterName}/hosts?fields=Hosts/host_name,Hosts/maintenance_state,Hosts/public_host_name,Hosts/cpu_count,Hosts/ph_cpu_count,Hosts/total_mem,Hosts/host_status,Hosts/last_heartbeat_time,Hosts/os_arch,Hosts/os_type,Hosts/ip,host_components/HostRoles/service_name,host_components/HostRoles/state,host_components/HostRoles/maintenance_state,Hosts/disk_info,metrics/disk,metrics/load/load_one,metrics/cpu/cpu_system,metrics/cpu/cpu_user,metrics/memory/mem_total,metrics/memory/mem_free,alerts/summary&minimal_response=true',
  2091. 'mock': ''
  2092. },
  2093. 'custom_action.create': {
  2094. 'real': '/requests',
  2095. 'mock': '',
  2096. 'format': function(data) {
  2097. var requestInfo = {
  2098. context: 'Check host',
  2099. action: 'check_host',
  2100. parameters: { }
  2101. };
  2102. $.extend(true, requestInfo, data.requestInfo)
  2103. return {
  2104. type: 'POST',
  2105. async: true,
  2106. data: JSON.stringify({
  2107. 'RequestInfo': requestInfo,
  2108. 'Requests/resource_filters': [{
  2109. hosts: data.filteredHosts.join(',')
  2110. }]
  2111. })
  2112. }
  2113. }
  2114. },
  2115. 'custom_action.request': {
  2116. 'real': '/requests/{requestId}/tasks/{taskId}',
  2117. 'mock': '',
  2118. 'format': function(data) {
  2119. return {
  2120. async: true,
  2121. requestId: data.requestId,
  2122. taskId: data.taskId || ''
  2123. }
  2124. }
  2125. },
  2126. 'hosts.total_count': {
  2127. 'real': '/clusters/{clusterName}?fields=Clusters/total_hosts&minimal_response=true',
  2128. 'mock': '',
  2129. 'format': function() {
  2130. return {
  2131. async: false
  2132. }
  2133. }
  2134. },
  2135. 'hosts.high_availability.wizard': {
  2136. 'real': '/clusters/{clusterName}/hosts?fields=Hosts/cpu_count,Hosts/disk_info,Hosts/total_mem&minimal_response=true',
  2137. 'mock': ''
  2138. },
  2139. 'hosts.security.wizard': {
  2140. 'real': '/clusters/{clusterName}/hosts?fields=host_components/HostRoles/service_name&minimal_response=true',
  2141. 'mock': ''
  2142. },
  2143. 'host_component.installed.on_hosts': {
  2144. 'real': '/clusters/{clusterName}/host_components?HostRoles/component_name={componentName}&HostRoles/host_name.in({hostNames})&fields=HostRoles/host_name&minimal_response=true',
  2145. 'mock': '',
  2146. 'format': function() {
  2147. return {
  2148. async: false
  2149. }
  2150. }
  2151. },
  2152. 'hosts.config_groups': {
  2153. 'real': '/clusters/{clusterName}/hosts?fields=Hosts/cpu_count,Hosts/disk_info,Hosts/total_mem,Hosts/ip,Hosts/os_type,Hosts/os_arch,Hosts/public_host_name,metrics/disk,host_components&minimal_response=true',
  2154. 'mock': ''
  2155. }
  2156. };
  2157. /**
  2158. * Replace data-placeholders to its values
  2159. *
  2160. * @param {String} url
  2161. * @param {Object} data
  2162. * @return {String}
  2163. */
  2164. var formatUrl = function (url, data) {
  2165. if (!url) return null;
  2166. var keys = url.match(/\{\w+\}/g);
  2167. keys = (keys === null) ? [] : keys;
  2168. if (keys) {
  2169. keys.forEach(function (key) {
  2170. var raw_key = key.substr(1, key.length - 2);
  2171. var replace;
  2172. if (!data || !data[raw_key]) {
  2173. replace = '';
  2174. }
  2175. else {
  2176. replace = data[raw_key];
  2177. }
  2178. url = url.replace(new RegExp(key, 'g'), replace);
  2179. });
  2180. }
  2181. return url;
  2182. };
  2183. /**
  2184. * this = object from config
  2185. * @return {Object}
  2186. */
  2187. var formatRequest = function (data) {
  2188. var opt = {
  2189. type: this.type || 'GET',
  2190. timeout: App.timeout,
  2191. dataType: 'json',
  2192. statusCode: require('data/statusCodes')
  2193. };
  2194. if (App.testMode) {
  2195. opt.url = formatUrl(this.mock ? this.mock : '', data);
  2196. opt.type = 'GET';
  2197. }
  2198. else {
  2199. var prefix = this.apiPrefix != null ? this.apiPrefix : App.apiPrefix;
  2200. opt.url = prefix + formatUrl(this.real, data);
  2201. }
  2202. if (this.format) {
  2203. jQuery.extend(opt, this.format(data, opt));
  2204. }
  2205. return opt;
  2206. };
  2207. /**
  2208. * Wrapper for all ajax requests
  2209. *
  2210. * @type {Object}
  2211. */
  2212. var ajax = Em.Object.extend({
  2213. /**
  2214. * Send ajax request
  2215. *
  2216. * @param {Object} config
  2217. * @return {$.ajax} jquery ajax object
  2218. *
  2219. * config fields:
  2220. * name - url-key in the urls-object *required*
  2221. * sender - object that send request (need for proper callback initialization) *required*
  2222. * data - object with data for url-format
  2223. * beforeSend - method-name for ajax beforeSend response callback
  2224. * success - method-name for ajax success response callback
  2225. * error - method-name for ajax error response callback
  2226. * callback - callback from <code>App.updater.run</code> library
  2227. */
  2228. send: function (config) {
  2229. console.warn('============== ajax ==============', config.name, config.data);
  2230. if (!config.sender) {
  2231. console.warn('Ajax sender should be defined!');
  2232. return null;
  2233. }
  2234. // default parameters
  2235. var params = {
  2236. clusterName: App.get('clusterName')
  2237. };
  2238. // extend default parameters with provided
  2239. if (config.data) {
  2240. jQuery.extend(params, config.data);
  2241. }
  2242. var opt = {};
  2243. if (!urls[config.name]) {
  2244. console.warn('Invalid name provided!');
  2245. return null;
  2246. }
  2247. opt = formatRequest.call(urls[config.name], params);
  2248. opt.context = this;
  2249. // object sender should be provided for processing beforeSend, success and error responses
  2250. opt.beforeSend = function (xhr) {
  2251. if (config.beforeSend) {
  2252. config.sender[config.beforeSend](opt, xhr, params);
  2253. }
  2254. };
  2255. opt.success = function (data) {
  2256. console.log("TRACE: The url is: " + opt.url);
  2257. if (config.success) {
  2258. config.sender[config.success](data, opt, params);
  2259. }
  2260. };
  2261. opt.error = function (request, ajaxOptions, error) {
  2262. if (config.error) {
  2263. config.sender[config.error](request, ajaxOptions, error, opt, params);
  2264. } else {
  2265. this.defaultErrorHandler(request, opt.url, opt.type);
  2266. }
  2267. };
  2268. opt.complete = function () {
  2269. if (config.callback) {
  2270. config.callback();
  2271. }
  2272. };
  2273. if ($.mocho) {
  2274. opt.url = 'http://' + $.hostName + opt.url;
  2275. }
  2276. return $.ajax(opt);
  2277. },
  2278. // A single instance of App.ModalPopup view
  2279. modalPopup: null,
  2280. /**
  2281. * defaultErrorHandler function is referred from App.ajax.send function and App.HttpClient.defaultErrorHandler function
  2282. * @jqXHR {jqXHR Object}
  2283. * @url {string}
  2284. * @method {String} Http method
  2285. * @showStatus {number} HTTP response code which should be shown. Default is 500.
  2286. */
  2287. defaultErrorHandler: function (jqXHR, url, method, showStatus) {
  2288. method = method || 'GET';
  2289. var self = this;
  2290. var api = " received on " + method + " method for API: " + url;
  2291. try {
  2292. var json = $.parseJSON(jqXHR.responseText);
  2293. var message = json.message;
  2294. } catch (err) {
  2295. }
  2296. if (!showStatus) {
  2297. showStatus = 500;
  2298. }
  2299. var statusCode = jqXHR.status + " status code";
  2300. if (jqXHR.status === showStatus && !this.modalPopup) {
  2301. this.modalPopup = App.ModalPopup.show({
  2302. header: jqXHR.statusText,
  2303. secondary: false,
  2304. onPrimary: function () {
  2305. this.hide();
  2306. self.modalPopup = null;
  2307. },
  2308. bodyClass: Ember.View.extend({
  2309. classNames: ['api-error'],
  2310. templateName: require('templates/utils/ajax'),
  2311. api: api,
  2312. statusCode: statusCode,
  2313. message: message,
  2314. showMessage: !!message
  2315. })
  2316. });
  2317. }
  2318. }
  2319. });
  2320. /**
  2321. * Add few access-methods for test purposes
  2322. */
  2323. if ($.mocho) {
  2324. ajax.reopen({
  2325. /**
  2326. * Don't use it anywhere except tests!
  2327. * @returns {Array}
  2328. */
  2329. fakeGetUrlNames: function() {
  2330. return Em.keys(urls);
  2331. },
  2332. /**
  2333. * Don't use it anywhere except tests!
  2334. * @param name
  2335. * @returns {*}
  2336. */
  2337. fakeGetUrl: function(name) {
  2338. return urls[name];
  2339. },
  2340. /**
  2341. * Don't use it anywhere except tests!
  2342. * @param url
  2343. * @param data
  2344. * @returns {String}
  2345. */
  2346. fakeFormatUrl: function(url, data) {
  2347. return formatUrl(url, data);
  2348. },
  2349. /**
  2350. * Don't use it anywhere except tests!
  2351. * @param urlObj
  2352. * @param data
  2353. * @returns {Object}
  2354. */
  2355. fakeFormatRequest: function(urlObj, data) {
  2356. return formatRequest.call(urlObj, data);
  2357. }
  2358. });
  2359. }
  2360. App.ajax = ajax.create({});