ajax.js 77 KB

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