ajax.js 63 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909
  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. },
  75. Body: {
  76. ServiceInfo: {
  77. state: data.state
  78. }
  79. }
  80. })
  81. };
  82. }
  83. },
  84. 'service.item.smoke': {
  85. 'real': '/clusters/{clusterName}/requests',
  86. 'mock': '/data/wizard/deploy/poll_1.json',
  87. 'format': function (data) {
  88. return {
  89. 'type': 'POST',
  90. data: JSON.stringify({
  91. "RequestInfo": {
  92. "context": data.displayName + " Service Check",
  93. "command" : data.actionName
  94. },
  95. "Requests/resource_filters": [{"service_name" : data.serviceName}]
  96. })
  97. };
  98. }
  99. },
  100. 'service.item.passive': {
  101. 'real': '/clusters/{clusterName}/services/{serviceName}',
  102. 'mock': '',
  103. 'format': function (data) {
  104. return {
  105. type: 'PUT',
  106. data: JSON.stringify({
  107. RequestInfo: {
  108. "context": data.requestInfo
  109. },
  110. Body: {
  111. ServiceInfo: {
  112. maintenance_state: data.passive_state
  113. }
  114. }
  115. })
  116. };
  117. }
  118. },
  119. 'service.stale_host_components.start_stop': {
  120. 'real': '/clusters/{clusterName}/host_components?' +
  121. 'HostRoles/stale_configs=true&HostRoles/component_name.in({componentNames})',
  122. 'mock': '/data/wizard/deploy/poll_1.json',
  123. 'format': function (data) {
  124. return {
  125. type: 'PUT',
  126. data: JSON.stringify({
  127. RequestInfo: {
  128. "context": data.requestInfo
  129. },
  130. Body: {
  131. HostRoles: {
  132. state: data.state
  133. }
  134. }
  135. })
  136. };
  137. }
  138. },
  139. 'service.load_config_groups': {
  140. 'real': '/clusters/{clusterName}/config_groups?ConfigGroup/tag={serviceName}&fields=*',
  141. 'mock': '/data/configurations/config_group.json'
  142. },
  143. 'reassign.stop_services': {
  144. 'real': '/clusters/{clusterName}/services',
  145. 'mock': '',
  146. 'format': function() {
  147. return {
  148. type: 'PUT',
  149. data: JSON.stringify({
  150. "RequestInfo": {
  151. "context": "Stop all services"
  152. },
  153. "Body": {
  154. "ServiceInfo": {
  155. "state": "INSTALLED"
  156. }
  157. }
  158. })
  159. }
  160. }
  161. },
  162. 'reassign.start_services': {
  163. 'real': '/clusters/{clusterName}/services?params/run_smoke_test=true',
  164. 'mock': '',
  165. 'format': function() {
  166. return {
  167. type: 'PUT',
  168. data: JSON.stringify({
  169. "RequestInfo": {
  170. "context": "Start all services"
  171. },
  172. "Body": {
  173. "ServiceInfo": {
  174. "state": "STARTED"
  175. }
  176. }
  177. })
  178. }
  179. }
  180. },
  181. 'reassign.maintenance_mode': {
  182. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  183. 'mock': '',
  184. 'type': 'PUT',
  185. 'format': function () {
  186. return {
  187. data: JSON.stringify(
  188. {
  189. "HostRoles": {
  190. "state": "DISABLED"
  191. }
  192. }
  193. )
  194. }
  195. }
  196. },
  197. 'reassign.remove_component': {
  198. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  199. 'mock': '',
  200. 'type': 'DELETE'
  201. },
  202. 'reassign.load_configs': {
  203. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  204. 'mock': ''
  205. },
  206. 'reassign.save_configs': {
  207. 'real': '/clusters/{clusterName}',
  208. 'mock': '',
  209. 'type': 'PUT',
  210. 'format': function (data) {
  211. return {
  212. async: false,
  213. data: JSON.stringify({
  214. Clusters: {
  215. desired_config: {
  216. "type": data.siteName,
  217. "tag": 'version' + (new Date).getTime(),
  218. "properties": data.properties
  219. }
  220. }
  221. })
  222. }
  223. }
  224. },
  225. 'host_component.passive': {
  226. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  227. 'mock': '',
  228. 'type': 'PUT',
  229. 'format': function(data) {
  230. return {
  231. data: JSON.stringify({
  232. RequestInfo: {
  233. "context": data.requestInfo
  234. },
  235. Body: {
  236. HostRoles: {
  237. maintenance_state: data.passive_state
  238. }
  239. }
  240. })
  241. };
  242. }
  243. },
  244. 'config.advanced': {
  245. 'real': '{stack2VersionUrl}/stackServices/{serviceName}/configurations?fields=*',
  246. 'mock': '/data/wizard/stack/hdp/version{stackVersion}/{serviceName}.json',
  247. 'format': function() {
  248. return {
  249. async: false
  250. };
  251. }
  252. },
  253. 'config.advanced.global': {
  254. 'real': '{stack2VersionUrl}/stackServices?fields=configurations/StackConfigurations/type',
  255. 'mock': '/data/wizard/stack/hdp/version1.3.0/global.json',
  256. 'format': function() {
  257. return {
  258. async: false
  259. };
  260. }
  261. },
  262. 'config.tags': {
  263. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  264. 'mock': '/data/clusters/cluster.json'
  265. },
  266. 'config.tags_and_groups': {
  267. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs,config_groups/*',
  268. 'mock': '/data/clusters/tags_and_groups.json'
  269. },
  270. 'config.tags.sync': {
  271. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  272. 'mock': '/data/clusters/cluster.json',
  273. 'format': function() {
  274. return {
  275. async: false
  276. };
  277. }
  278. },
  279. 'config_groups.all_fields': {
  280. 'real': '/clusters/{clusterName}/config_groups?fields=*',
  281. 'mock': ''
  282. },
  283. 'config_groups.get_config_group_by_id': {
  284. 'real': '/clusters/{clusterName}/config_groups/{id}',
  285. 'mock': ''
  286. },
  287. 'config_groups.update_config_group': {
  288. 'real': '/clusters/{clusterName}/config_groups/{id}',
  289. 'mock': '',
  290. 'type': 'PUT',
  291. 'format': function (data) {
  292. return {
  293. async: false,
  294. data: JSON.stringify(
  295. [
  296. data.configGroup
  297. ]
  298. )
  299. }
  300. }
  301. },
  302. 'config_groups.delete_config_group': {
  303. 'real': '/clusters/{clusterName}/config_groups/{id}',
  304. 'mock': '',
  305. 'type': 'DELETE'
  306. },
  307. 'config.on_site': {
  308. 'real': '/clusters/{clusterName}/configurations?{params}',
  309. 'mock': '/data/configurations/cluster_level_configs.json?{params}',
  310. 'format': function() {
  311. return {
  312. async: false
  313. };
  314. }
  315. },
  316. 'config.host_overrides': {
  317. 'real': '/clusters/{clusterName}/configurations?{params}',
  318. 'mock': '/data/configurations/host_level_overrides_configs.json?{params}',
  319. 'format': function() {
  320. return {
  321. async: false
  322. };
  323. }
  324. },
  325. 'host.host_component.action': {
  326. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  327. 'mock': '',
  328. 'type': 'PUT',
  329. 'format': function (data) {
  330. return {
  331. data: JSON.stringify({
  332. RequestInfo: {
  333. "context": data.context
  334. },
  335. Body: {
  336. "HostRoles": {
  337. "state": data.state
  338. }
  339. }
  340. })
  341. }
  342. }
  343. },
  344. 'host.host_component.slave_desired_admin_state': {
  345. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}/?fields=HostRoles/desired_admin_state',
  346. 'mock': ''
  347. },
  348. 'host.host_component.decommission_status': {
  349. 'real': '/clusters/{clusterName}/services/{serviceName}/components/{componentName}/?fields=ServiceComponentInfo',
  350. 'mock': ''
  351. },
  352. 'host.host_component.decommission_status_datanode': {
  353. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}?fields=metrics/dfs/namenode',
  354. 'mock': ''
  355. },
  356. 'host.host_component.decommission_slave': {
  357. 'real' : '/clusters/{clusterName}/requests',
  358. 'mock' : '',
  359. 'format' : function(data) {
  360. return {
  361. type : 'POST',
  362. data : JSON.stringify({
  363. RequestInfo: {
  364. 'context': data.context,
  365. 'command': data.command,
  366. 'parameters': {
  367. 'slave_type': data.slaveType,
  368. 'excluded_hosts': data.hostName
  369. }
  370. },
  371. "Requests/resource_filters": [{"service_name" : data.serviceName, "component_name" : data.componentName}]
  372. })
  373. }
  374. }
  375. },
  376. 'host.host_component.recommission_and_restart': {
  377. 'real': '/clusters/{clusterName}/request_schedules',
  378. 'mock': '',
  379. 'format' : function(data) {
  380. return {
  381. type : 'POST',
  382. data : JSON.stringify([ {
  383. "RequestSchedule" : {
  384. "batch" : [ {
  385. "requests" : data.batches
  386. }, {
  387. "batch_settings" : {
  388. "batch_separation_in_seconds" : data.intervalTimeSeconds,
  389. "task_failure_tolerance" : data.tolerateSize
  390. }
  391. } ]
  392. }
  393. } ])
  394. }
  395. }
  396. },
  397. 'host.host_component.recommission_slave' : {
  398. 'real' : '/clusters/{clusterName}/requests',
  399. 'mock' : '',
  400. 'format' : function(data) {
  401. return {
  402. type : 'POST',
  403. data : JSON.stringify({
  404. RequestInfo: {
  405. context: data.context,
  406. command: data.command,
  407. parameters: {
  408. slave_type: data.slaveType,
  409. included_hosts: data.hostName
  410. }
  411. },
  412. "Requests/resource_filters": [{"service_name" : data.serviceName, "component_name" : data.componentName}]
  413. })
  414. }
  415. }
  416. },
  417. 'host.stale_host_components.start_stop': {
  418. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components?HostRoles/stale_configs=true&' +
  419. 'HostRoles/component_name.in({componentNames})',
  420. 'mock': '',
  421. 'type': 'PUT',
  422. 'format': function (data) {
  423. return {
  424. data: JSON.stringify({
  425. RequestInfo: {
  426. "context": data.context
  427. },
  428. Body: {
  429. "HostRoles": {
  430. "state": data.state
  431. }
  432. }
  433. })
  434. }
  435. }
  436. },
  437. 'host.delete': {
  438. 'real': '/clusters/{clusterName}/hosts/{hostName}',
  439. 'mock': '',
  440. 'type': 'DELETE',
  441. 'format': function() {
  442. return {
  443. async: false
  444. }
  445. }
  446. },
  447. 'hosts.metrics': {
  448. 'real': '/clusters/{clusterName}/hosts?fields={metricName}',
  449. 'mock': '/data/cluster_metrics/cpu_1hr.json'
  450. },
  451. 'hosts.metrics.host_component': {
  452. 'real': '/clusters/{clusterName}/services/{serviceName}/components/{componentName}?fields=host_components/{metricName}',
  453. 'mock': '/data/cluster_metrics/cpu_1hr.json'
  454. },
  455. 'service.metrics.flume.channel_fill_percent': {
  456. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/CHANNEL/*/ChannelFillPercentage[{fromSeconds},{toSeconds},{stepSeconds}]',
  457. 'mock': '/data/services/metrics/flume/channelFillPct.json',
  458. 'testInProduction': true
  459. },
  460. 'service.metrics.flume.channel_size': {
  461. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/CHANNEL/*/ChannelSize[{fromSeconds},{toSeconds},{stepSeconds}]',
  462. 'mock': '/data/services/metrics/flume/channelSize.json',
  463. 'testInProduction': true
  464. },
  465. 'service.metrics.flume.sink_drain_success': {
  466. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/SINK/*/EventDrainSuccessCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  467. 'mock': '/data/services/metrics/flume/sinkDrainSuccessCount.json',
  468. 'testInProduction': true
  469. },
  470. 'service.metrics.flume.sink_connection_failed': {
  471. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/SINK/*/ConnectionFailedCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  472. 'mock': '/data/services/metrics/flume/sinkConnectionFailedCount.json',
  473. 'testInProduction': true
  474. },
  475. 'service.metrics.flume.gc': {
  476. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  477. 'mock': '/data/services/metrics/flume/jvmGcTime.json',
  478. 'testInProduction': true
  479. },
  480. 'service.metrics.flume.jvm_heap_used': {
  481. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/jvm/memHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}]',
  482. 'mock': '/data/services/metrics/flume/jvmMemHeapUsedM.json',
  483. 'testInProduction': true
  484. },
  485. 'service.metrics.flume.jvm_threads_runnable': {
  486. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/jvm/threadsRunnable[{fromSeconds},{toSeconds},{stepSeconds}]',
  487. 'mock': '/data/services/metrics/flume/jvmThreadsRunnable.json',
  488. 'testInProduction': true
  489. },
  490. 'service.metrics.flume.cpu_user': {
  491. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/cpu/cpu_user[{fromSeconds},{toSeconds},{stepSeconds}]',
  492. 'mock': '',
  493. 'testInProduction': true
  494. },
  495. 'service.metrics.flume.source_accepted': {
  496. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/SOURCE/*/EventAcceptedCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  497. 'mock': '/data/services/metrics/flume/sourceEventAccepted.json',
  498. 'testInProduction': true
  499. },
  500. 'service.metrics.hbase.cluster_requests': {
  501. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/cluster_requests[{fromSeconds},{toSeconds},{stepSeconds}]',
  502. 'mock': '/data/services/metrics/hbase/cluster_requests.json',
  503. 'testInProduction': true
  504. },
  505. 'service.metrics.hbase.hlog_split_size': {
  506. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitSize_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  507. 'mock': '/data/services/metrics/hbase/hlog_split_size.json',
  508. 'testInProduction': true
  509. },
  510. 'service.metrics.hbase.hlog_split_time': {
  511. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  512. 'mock': '/data/services/metrics/hbase/hlog_split_time.json',
  513. 'testInProduction': true
  514. },
  515. 'service.metrics.hbase.regionserver_queuesize': {
  516. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/flushQueueSize[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/compactionQueueSize[{fromSeconds},{toSeconds},{stepSeconds}]',
  517. 'mock': '/data/services/metrics/hbase/regionserver_queuesize.json',
  518. 'testInProduction': true
  519. },
  520. 'service.metrics.hbase.regionserver_regions': {
  521. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/regions[{fromSeconds},{toSeconds},{stepSeconds}]',
  522. 'mock': '/data/services/metrics/hbase/regionserver_regions.json',
  523. 'testInProduction': true
  524. },
  525. 'service.metrics.hbase.regionserver_rw_requests': {
  526. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/readRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/writeRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  527. 'mock': '/data/services/metrics/hbase/regionserver_rw_requests.json',
  528. 'testInProduction': true
  529. },
  530. 'service.metrics.mapreduce.gc': {
  531. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  532. 'mock': '/data/services/metrics/mapreduce/gc.json',
  533. 'testInProduction': true
  534. },
  535. 'service.metrics.mapreduce.jobs_status': {
  536. '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}]',
  537. 'mock': '/data/services/metrics/mapreduce/jobs_status.json',
  538. 'testInProduction': true
  539. },
  540. 'service.metrics.mapreduce.jobs_heap': {
  541. '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}]',
  542. 'mock': '/data/services/metrics/mapreduce/jvm_heap.json',
  543. 'testInProduction': true
  544. },
  545. 'service.metrics.mapreduce.jobs_threads': {
  546. '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}]',
  547. 'mock': '/data/services/metrics/mapreduce/jvm_threads.json',
  548. 'testInProduction': true
  549. },
  550. 'service.metrics.mapreduce.map_slots': {
  551. '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}]',
  552. 'mock': '/data/services/metrics/mapreduce/map_slots.json',
  553. 'testInProduction': true
  554. },
  555. 'service.metrics.mapreduce.reduce_slots': {
  556. '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}]',
  557. 'mock': '/data/services/metrics/mapreduce/reduce_slots.json',
  558. 'testInProduction': true
  559. },
  560. 'service.metrics.mapreduce.rpc': {
  561. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  562. 'mock': '/data/services/metrics/mapreduce/rpc.json',
  563. 'testInProduction': true
  564. },
  565. 'service.metrics.mapreduce.tasks_running_waiting': {
  566. '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}]',
  567. 'mock': '/data/services/metrics/mapreduce/tasks_running_waiting.json',
  568. 'testInProduction': true
  569. },
  570. 'service.metrics.hdfs.block_status': {
  571. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/FSNamesystem/PendingReplicationBlocks[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/FSNamesystem/UnderReplicatedBlocks[{fromSeconds},{toSeconds},{stepSeconds}]',
  572. 'mock': '/data/services/metrics/hdfs/block_status.json',
  573. 'testInProduction': true
  574. },
  575. 'service.metrics.hdfs.file_operations': {
  576. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/namenode/FileInfoOps[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/namenode/CreateFileOps[{fromSeconds},{toSeconds},{stepSeconds}]',
  577. 'mock': '/data/services/metrics/hdfs/file_operations.json',
  578. 'testInProduction': true
  579. },
  580. 'service.metrics.hdfs.gc': {
  581. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  582. 'mock': '/data/services/metrics/hdfs/gc.json',
  583. 'testInProduction': true
  584. },
  585. 'service.metrics.hdfs.io': {
  586. 'real': '/clusters/{clusterName}/services/HDFS/components/DATANODE?fields=metrics/dfs/datanode/bytes_written[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/datanode/bytes_read[{fromSeconds},{toSeconds},{stepSeconds}]',
  587. 'mock': '/data/services/metrics/hdfs/io.json',
  588. 'testInProduction': true
  589. },
  590. 'service.metrics.hdfs.jvm_heap': {
  591. '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}]',
  592. 'mock': '/data/services/metrics/hdfs/jvm_heap.json',
  593. 'testInProduction': true
  594. },
  595. 'service.metrics.hdfs.jvm_threads': {
  596. '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}]',
  597. 'mock': '/data/services/metrics/hdfs/jvm_threads.json',
  598. 'testInProduction': true
  599. },
  600. 'service.metrics.hdfs.rpc': {
  601. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  602. 'mock': '/data/services/metrics/hdfs/rpc.json',
  603. 'testInProduction': true
  604. },
  605. 'service.metrics.hdfs.space_utilization': {
  606. '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}]',
  607. 'mock': '/data/services/metrics/hdfs/space_utilization.json',
  608. 'testInProduction': true
  609. },
  610. 'service.start_stop': {
  611. 'real': '/clusters/{clusterName}/services?params/run_smoke_test=true',
  612. 'mock': '/data/mirroring/poll/poll_6.json',
  613. 'format': function (data) {
  614. return {
  615. type: 'PUT',
  616. async: false,
  617. data: data.data
  618. };
  619. }
  620. },
  621. 'service.metrics.yarn.gc': {
  622. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  623. 'mock': '/data/services/metrics/yarn/gc.json',
  624. 'testInProduction': true
  625. },
  626. 'service.metrics.yarn.jobs_threads': {
  627. '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}]',
  628. 'mock': '/data/services/metrics/yarn/jvm_threads.json',
  629. 'testInProduction': true
  630. },
  631. 'service.metrics.yarn.rpc': {
  632. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  633. 'mock': '/data/services/metrics/yarn/rpc.json',
  634. 'testInProduction': true
  635. },
  636. 'service.metrics.yarn.jobs_heap': {
  637. '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}]',
  638. 'mock': '/data/services/metrics/yarn/jvm_heap.json',
  639. 'testInProduction': true
  640. },
  641. 'service.metrics.yarn.queue.allocated': {
  642. '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}]',
  643. 'mock': '',
  644. 'testInProduction': true
  645. },
  646. 'service.metrics.yarn.queue.allocated.container': {
  647. '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}]',
  648. 'mock': '',
  649. 'testInProduction': true
  650. },
  651. 'service.metrics.yarn.node.manager.statuses': {
  652. '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}]',
  653. 'mock': '',
  654. 'testInProduction': true
  655. },
  656. 'service.metrics.yarn.queue.memory.resource': {
  657. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=',
  658. 'mock': '',
  659. 'format': function (data, opt) {
  660. var field1 = 'metrics/yarn/Queue/{queueName}/AllocatedMB[{fromSeconds},{toSeconds},{stepSeconds}]';
  661. var field2 = 'metrics/yarn/Queue/{queueName}/AvailableMB[{fromSeconds},{toSeconds},{stepSeconds}]';
  662. if (opt.url != null && data.queueNames != null && data.queueNames.length > 0) {
  663. data.queueNames.forEach(function (q) {
  664. data.queueName = q;
  665. opt.url += (formatUrl(field1, data) + ",");
  666. opt.url += (formatUrl(field2, data) + ",");
  667. });
  668. } else {
  669. opt.url += (formatUrl(field1, data) + ",");
  670. opt.url += (formatUrl(field2, data) + ",");
  671. }
  672. },
  673. 'testInProduction': true
  674. },
  675. 'service.metrics.yarn.queue.apps.states.current': {
  676. '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}]',
  677. 'mock': '',
  678. 'testInProduction': true
  679. },
  680. 'service.metrics.yarn.queue.apps.states.finished': {
  681. '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}]',
  682. 'mock': '',
  683. 'testInProduction': true
  684. },
  685. 'service.metrics.storm.nimbus': {
  686. 'real': '/clusters/{clusterName}/services/STORM/components/NIMBUS?fields={metricsTemplate}',
  687. 'mock': ''
  688. },
  689. 'dashboard.cluster_metrics.cpu': {
  690. 'real': '/clusters/{clusterName}/?fields=metrics/cpu[{fromSeconds},{toSeconds},{stepSeconds}]',
  691. 'mock': '/data/cluster_metrics/cpu_1hr.json',
  692. 'testInProduction': true
  693. },
  694. 'dashboard.cluster_metrics.load': {
  695. 'real': '/clusters/{clusterName}/?fields=metrics/load[{fromSeconds},{toSeconds},{stepSeconds}]',
  696. 'mock': '/data/cluster_metrics/load_1hr.json',
  697. 'testInProduction': true
  698. },
  699. 'dashboard.cluster_metrics.memory': {
  700. 'real': '/clusters/{clusterName}/?fields=metrics/memory[{fromSeconds},{toSeconds},{stepSeconds}]',
  701. 'mock': '/data/cluster_metrics/memory_1hr.json',
  702. 'testInProduction': true
  703. },
  704. 'dashboard.cluster_metrics.network': {
  705. 'real': '/clusters/{clusterName}/?fields=metrics/network[{fromSeconds},{toSeconds},{stepSeconds}]',
  706. 'mock': '/data/cluster_metrics/network_1hr.json',
  707. 'testInProduction': true
  708. },
  709. 'host.metrics.cpu': {
  710. '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}]',
  711. 'mock': '/data/hosts/metrics/cpu.json',
  712. 'testInProduction': true
  713. },
  714. 'host.metrics.disk': {
  715. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/disk/disk_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/disk/disk_free[{fromSeconds},{toSeconds},{stepSeconds}]',
  716. 'mock': '/data/hosts/metrics/disk.json',
  717. 'testInProduction': true
  718. },
  719. 'host.metrics.load': {
  720. '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}]',
  721. 'mock': '/data/hosts/metrics/load.json',
  722. 'testInProduction': true
  723. },
  724. 'host.metrics.memory': {
  725. '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}]',
  726. 'mock': '/data/hosts/metrics/memory.json',
  727. 'testInProduction': true
  728. },
  729. 'host.metrics.network': {
  730. '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}]',
  731. 'mock': '/data/hosts/metrics/network.json',
  732. 'testInProduction': true
  733. },
  734. 'host.metrics.processes': {
  735. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/process/proc_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/process/proc_run[{fromSeconds},{toSeconds},{stepSeconds}]',
  736. 'mock': '/data/hosts/metrics/processes.json',
  737. 'testInProduction': true
  738. },
  739. 'host.service_config_hosts_overrides': {
  740. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  741. 'mock': '',
  742. 'format': function() {
  743. return {
  744. async: false,
  745. timeout: 10000
  746. };
  747. }
  748. },
  749. 'admin.security_status': {
  750. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  751. 'mock': '',
  752. 'format': function() {
  753. return {
  754. timeout: 10000
  755. };
  756. }
  757. },
  758. 'settings.get.user_pref': {
  759. 'real': '/persist/{key}',
  760. 'mock': '/data/user_settings/{key}.json',
  761. 'format': function(data) {
  762. return {
  763. async: data.async
  764. };
  765. }
  766. },
  767. 'settings.post.user_pref': {
  768. 'real': '/persist',
  769. 'mock': '',
  770. 'type': 'POST',
  771. 'format': function (data) {
  772. return {
  773. async: data.async,
  774. data: JSON.stringify(data.keyValuePair)
  775. }
  776. }
  777. },
  778. 'cluster.load_cluster_name': {
  779. 'real': '/clusters',
  780. 'mock': '/data/clusters/info.json',
  781. 'format': function() {
  782. return {
  783. async: false
  784. };
  785. }
  786. },
  787. 'cluster.state': {
  788. 'type': 'POST',
  789. 'real': '/persist/',
  790. 'mock': '',
  791. 'format': function(data) {
  792. return {
  793. async: false,
  794. data: JSON.stringify(data.keyValuePair)
  795. };
  796. }
  797. },
  798. 'cluster.update_upgrade_version': {
  799. 'real': '/stacks2/HDP/versions?fields=stackServices/StackServices,Versions',
  800. 'mock': '/data/wizard/stack/stacks.json',
  801. 'format': function() {
  802. return {
  803. async: false
  804. };
  805. }
  806. },
  807. 'cluster.load_repositories': {
  808. 'real': '/stacks2/{stackName}/versions/{stackVersion}/operatingSystems?fields=repositories/*',
  809. 'mock': '',
  810. 'type': 'GET',
  811. 'format': function (data) {
  812. return {
  813. data: data.data
  814. };
  815. }
  816. },
  817. 'admin.high_availability.stop_all_services': {
  818. 'real': '/clusters/{clusterName}/services',
  819. 'mock': '',
  820. 'format': function() {
  821. return {
  822. type: 'PUT',
  823. data: JSON.stringify({
  824. "RequestInfo": {
  825. "context": "Stop all services"
  826. },
  827. "Body": {
  828. "ServiceInfo": {
  829. "state": "INSTALLED"
  830. }
  831. }
  832. })
  833. }
  834. }
  835. },
  836. 'admin.high_availability.start_all_services': {
  837. 'real': '/clusters/{clusterName}/services',
  838. 'mock': '',
  839. 'format': function() {
  840. return {
  841. type: 'PUT',
  842. data: JSON.stringify({
  843. "RequestInfo": {
  844. "context": "Start all services"
  845. },
  846. "Body": {
  847. "ServiceInfo": {
  848. "state": "STARTED"
  849. }
  850. }
  851. })
  852. }
  853. }
  854. },
  855. 'admin.high_availability.polling': {
  856. 'real': '/clusters/{clusterName}/requests/{requestId}?fields=tasks/*',
  857. 'mock': '',
  858. 'type': 'GET'
  859. },
  860. 'admin.high_availability.getNnCheckPointStatus': {
  861. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/NAMENODE',
  862. 'mock': '',
  863. 'type': 'GET'
  864. },
  865. 'admin.high_availability.getJnCheckPointStatus': {
  866. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/JOURNALNODE?fields=metrics',
  867. 'mock': ''
  868. },
  869. 'admin.high_availability.getHostComponent': {
  870. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  871. 'mock': ''
  872. },
  873. 'admin.high_availability.create_component': {
  874. 'real': '/clusters/{clusterName}/hosts?Hosts/host_name={hostName}',
  875. 'mock': '',
  876. 'type': 'POST',
  877. 'format': function (data) {
  878. return {
  879. data: JSON.stringify({
  880. "host_components": [
  881. {
  882. "HostRoles": {
  883. "component_name": data.componentName
  884. }
  885. }
  886. ]
  887. })
  888. }
  889. }
  890. },
  891. 'admin.high_availability.create_journalnode': {
  892. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  893. 'mock': '',
  894. 'type': 'POST',
  895. 'format': function() {
  896. return {
  897. data: JSON.stringify({
  898. "components": [
  899. {
  900. "ServiceComponentInfo": {
  901. "component_name": "JOURNALNODE"
  902. }
  903. }
  904. ]
  905. })
  906. }
  907. }
  908. },
  909. 'admin.high_availability.create_zkfc': {
  910. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  911. 'mock': '',
  912. 'type': 'POST',
  913. 'format': function() {
  914. return {
  915. data: JSON.stringify({
  916. "components": [
  917. {
  918. "ServiceComponentInfo": {
  919. "component_name": "ZKFC"
  920. }
  921. }
  922. ]
  923. })
  924. }
  925. }
  926. },
  927. 'admin.high_availability.install_component': {
  928. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  929. 'mock': '',
  930. 'type': 'PUT',
  931. 'format': function (data) {
  932. return {
  933. data: JSON.stringify({
  934. RequestInfo: {
  935. "context": "Install " + data.displayName
  936. },
  937. Body: {
  938. "HostRoles": {
  939. "state": "INSTALLED"
  940. }
  941. }
  942. })
  943. }
  944. }
  945. },
  946. 'admin.high_availability.start_component': {
  947. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  948. 'mock': '',
  949. 'type': 'PUT',
  950. 'format': function (data) {
  951. return {
  952. data: JSON.stringify({
  953. RequestInfo: {
  954. "context": "Start " + data.displayName
  955. },
  956. Body: {
  957. "HostRoles": {
  958. "state": "STARTED"
  959. }
  960. }
  961. })
  962. }
  963. }
  964. },
  965. 'admin.high_availability.maintenance_mode': {
  966. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  967. 'mock': '',
  968. 'type': 'PUT',
  969. 'format': function () {
  970. return {
  971. data: JSON.stringify({
  972. "HostRoles": {
  973. "state": "DISABLED"
  974. }
  975. })
  976. }
  977. }
  978. },
  979. 'admin.high_availability.stop_component': {
  980. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  981. 'mock': '',
  982. 'type': 'PUT',
  983. 'format': function (data) {
  984. return {
  985. data: JSON.stringify({
  986. RequestInfo: {
  987. "context": "Stop " + data.displayName
  988. },
  989. Body: {
  990. "HostRoles": {
  991. "state": "INSTALLED"
  992. }
  993. }
  994. })
  995. }
  996. }
  997. },
  998. 'admin.high_availability.load_configs': {
  999. 'real': '/clusters/{clusterName}/configurations?(type=core-site&tag={coreSiteTag})|(type=hdfs-site&tag={hdfsSiteTag})',
  1000. 'mock': '',
  1001. 'type': 'GET'
  1002. },
  1003. 'admin.high_availability.save_configs': {
  1004. 'real': '/clusters/{clusterName}',
  1005. 'mock': '',
  1006. 'type': 'PUT',
  1007. 'format': function (data) {
  1008. return {
  1009. async: false,
  1010. data: JSON.stringify({
  1011. Clusters: {
  1012. desired_config: {
  1013. "type": data.siteName,
  1014. "tag": 'version' + (new Date).getTime(),
  1015. "properties": data.properties
  1016. }
  1017. }
  1018. })
  1019. }
  1020. }
  1021. },
  1022. 'admin.high_availability.load_hbase_configs': {
  1023. 'real': '/clusters/{clusterName}/configurations?type=hbase-site&tag={hbaseSiteTag}',
  1024. 'mock': '',
  1025. 'type': 'GET'
  1026. },
  1027. 'admin.delete_component': {
  1028. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  1029. 'mock': '',
  1030. 'type': 'DELETE'
  1031. },
  1032. 'admin.security.cluster_configs': {
  1033. 'real': '/clusters/{clusterName}',
  1034. 'mock': '',
  1035. 'format': function() {
  1036. return {
  1037. timeout: 10000
  1038. };
  1039. }
  1040. },
  1041. 'admin.delete_host': {
  1042. 'real': '/clusters/{clusterName}/hosts/{hostName}',
  1043. 'mock': '',
  1044. 'type': 'DELETE'
  1045. },
  1046. 'admin.get.all_configurations': {
  1047. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  1048. 'mock': '',
  1049. 'format': function() {
  1050. return {
  1051. timeout: 10000
  1052. };
  1053. }
  1054. },
  1055. 'admin.security.apply_configurations': {
  1056. 'real': '/clusters/{clusterName}',
  1057. 'mock': '',
  1058. 'format': function (data) {
  1059. return {
  1060. type: 'PUT',
  1061. timeout: 10000,
  1062. data: data.configData
  1063. };
  1064. }
  1065. },
  1066. 'admin.security.apply_configuration': {
  1067. 'real': '/clusters/{clusterName}',
  1068. 'mock': '',
  1069. 'format': function(data) {
  1070. return {
  1071. type: 'PUT',
  1072. async: false,
  1073. timeout: 5000,
  1074. data: JSON.stringify(data.clusterData)
  1075. };
  1076. }
  1077. },
  1078. 'admin.security.add.cluster_configs': {
  1079. 'real': '/clusters/{clusterName}' + '?fields=Clusters/desired_configs',
  1080. 'mock': '',
  1081. 'format': function() {
  1082. return {
  1083. timeout: 10000
  1084. };
  1085. }
  1086. },
  1087. 'admin.stack_upgrade.run_upgrade': {
  1088. 'real': '/clusters/{clusterName}',
  1089. 'mock': '',
  1090. 'format': function () {
  1091. return {
  1092. type: 'PUT',
  1093. async: false,
  1094. data: data.data
  1095. };
  1096. }
  1097. },
  1098. 'admin.stack_upgrade.stop_services': {
  1099. 'real': '/clusters/{clusterName}/services?ServiceInfo/state=STARTED',
  1100. 'mock': '',
  1101. 'format': function () {
  1102. return {
  1103. type: 'PUT',
  1104. async: false,
  1105. data: data.data
  1106. };
  1107. }
  1108. },
  1109. 'admin.stack_upgrade.do_poll': {
  1110. 'real': '/clusters/{cluster}/requests/{requestId}?fields=tasks/*',
  1111. 'mock': '/data/wizard/{mock}'
  1112. },
  1113. 'wizard.advanced_repositories.valid_url': {
  1114. 'real': '/stacks2/{stackName}/versions/{stackVersion}/operatingSystems/{osType}/repositories/{nameVersionCombo}',
  1115. 'mock': '',
  1116. 'type': 'PUT',
  1117. 'format': function (data) {
  1118. return {
  1119. async: true,
  1120. data: JSON.stringify(data.data)
  1121. }
  1122. }
  1123. },
  1124. 'wizard.install_services.add_host_controller.is_retry': {
  1125. 'real': '/clusters/{cluster}/host_components',
  1126. 'mock': '',
  1127. 'format': function (data) {
  1128. return {
  1129. type: 'PUT',
  1130. async: false,
  1131. data: data.data
  1132. };
  1133. }
  1134. },
  1135. 'wizard.install_services.add_host_controller.not_is_retry': {
  1136. 'real': '/clusters/{cluster}/host_components',
  1137. 'mock': '',
  1138. 'format': function(data) {
  1139. return {
  1140. type: 'PUT',
  1141. async: false,
  1142. data: data.data
  1143. };
  1144. }
  1145. },
  1146. 'wizard.install_services.installer_controller.is_retry': {
  1147. 'real': '/clusters/{cluster}/host_components?HostRoles/state=INSTALLED',
  1148. 'mock': '/data/wizard/deploy/2_hosts/poll_1.json',
  1149. 'type': 'PUT',
  1150. 'format': function (data) {
  1151. return {
  1152. async: false,
  1153. data: data.data
  1154. };
  1155. }
  1156. },
  1157. 'wizard.install_services.installer_controller.not_is_retry': {
  1158. 'real': '/clusters/{cluster}/services?ServiceInfo/state=INIT',
  1159. 'mock': '/data/wizard/deploy/2_hosts/poll_1.json',
  1160. 'type': 'PUT',
  1161. 'format': function (data) {
  1162. return {
  1163. async: false,
  1164. data: data.data
  1165. };
  1166. }
  1167. },
  1168. 'wizard.install_services.add_service_controller.get_failed_host_components': {
  1169. 'real': '/clusters/{clusterName}/host_components?fields=HostRoles/state,component/ServiceComponentInfo/service_name',
  1170. 'mock': '',
  1171. 'format': function() {
  1172. return {
  1173. async: false
  1174. };
  1175. }
  1176. },
  1177. 'wizard.service_components': {
  1178. 'real': '{stackUrl}/stackServices?fields=StackServices',
  1179. 'mock': '/data/wizard/stack/hdp/version/{stackVersion}.json',
  1180. 'format': function() {
  1181. return {
  1182. timeout: 10000,
  1183. async: false
  1184. };
  1185. }
  1186. },
  1187. 'wizard.step9.installer.get_host_status': {
  1188. 'real': '/clusters/{cluster}/hosts?fields=Hosts/host_state,host_components/HostRoles/state',
  1189. 'mock': '/data/wizard/deploy/5_hosts/get_host_status.json',
  1190. 'format': function () {
  1191. return {
  1192. async: false
  1193. };
  1194. }
  1195. },
  1196. 'wizard.step9.installer.launch_start_services': {
  1197. 'real': '/clusters/{cluster}/services?ServiceInfo/state=INSTALLED&params/run_smoke_test=true&params/reconfigure_client=false',
  1198. 'mock': '/data/wizard/deploy/5_hosts/poll_6.json',
  1199. 'format': function (data) {
  1200. var d = {
  1201. type: 'PUT',
  1202. async: false,
  1203. data: data.data
  1204. };
  1205. if (App.testMode) {
  1206. d.type = 'GET';
  1207. }
  1208. return d;
  1209. }
  1210. },
  1211. 'wizard.step9.add_host.launch_start_services': {
  1212. 'real': '/clusters/{cluster}/host_components',
  1213. 'mock': '/data/wizard/deploy/5_hosts/poll_6.json',
  1214. 'format': function (data) {
  1215. return {
  1216. type: 'PUT',
  1217. async: false,
  1218. data: data.data
  1219. };
  1220. }
  1221. },
  1222. 'wizard.step8.delete_cluster': {
  1223. 'real': '/clusters/{name}',
  1224. 'mock': '',
  1225. 'format': function() {
  1226. return {
  1227. type: 'DELETE',
  1228. async: false
  1229. };
  1230. }
  1231. },
  1232. 'wizard.step8.existing_cluster_names': {
  1233. 'real': '/clusters',
  1234. 'mock': '',
  1235. 'format': function() {
  1236. return {
  1237. async: false
  1238. };
  1239. }
  1240. },
  1241. 'wizard.step3.host_info': {
  1242. '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',
  1243. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  1244. 'format': function() {
  1245. return {
  1246. contentType: 'application/json'
  1247. };
  1248. }
  1249. },
  1250. 'wizard.step3.rerun_checks': {
  1251. 'real': '/hosts?fields=Hosts/last_agent_env',
  1252. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  1253. 'format': function() {
  1254. return {
  1255. contentType: 'application/json'
  1256. };
  1257. }
  1258. },
  1259. 'wizard.step3.bootstrap': {
  1260. 'real': '/bootstrap/{bootRequestId}',
  1261. 'mock': '/data/wizard/bootstrap/poll_{numPolls}.json'
  1262. },
  1263. 'wizard.step3.is_hosts_registered': {
  1264. 'real': '/hosts',
  1265. 'mock': '/data/wizard/bootstrap/single_host_registration.json'
  1266. },
  1267. 'wizard.stacks': {
  1268. 'real': '/stacks2',
  1269. 'mock': '/data/wizard/stack/stacks2.json',
  1270. 'format': function() {
  1271. return {
  1272. async: false
  1273. };
  1274. }
  1275. },
  1276. 'wizard.stacks_versions': {
  1277. 'real': '/stacks2/{stackName}/versions?fields=Versions,operatingSystems/repositories/Repositories',
  1278. 'mock': '/data/wizard/stack/{stackName}_versions.json',
  1279. 'format': function() {
  1280. return {
  1281. async: false
  1282. };
  1283. }
  1284. },
  1285. 'wizard.launch_bootstrap': {
  1286. 'real': '/bootstrap',
  1287. 'mock': '/data/wizard/bootstrap/bootstrap.json',
  1288. 'type': 'POST',
  1289. 'format': function (data) {
  1290. return {
  1291. async: false,
  1292. contentType: 'application/json',
  1293. data: data.bootStrapData
  1294. }
  1295. }
  1296. },
  1297. 'router.login': {
  1298. 'real': '/users/{loginName}',
  1299. 'mock': '/data/users/user_{usr}.json',
  1300. 'format': function (data) {
  1301. var statusCode = jQuery.extend({}, require('data/statusCodes'));
  1302. statusCode['403'] = function () {
  1303. console.log("Error code 403: Forbidden.");
  1304. };
  1305. return {
  1306. statusCode: statusCode
  1307. };
  1308. }
  1309. },
  1310. 'router.login2': {
  1311. 'real': '/clusters',
  1312. 'mock': '/data/clusters/info.json'
  1313. },
  1314. 'router.logoff': {
  1315. 'real': '/logout',
  1316. 'mock': ''
  1317. },
  1318. 'router.set_ambari_stacks': {
  1319. 'real': '/stacks',
  1320. 'mock': '/data/wizard/stack/stacks.json',
  1321. 'format': function() {
  1322. return {
  1323. async: false
  1324. };
  1325. }
  1326. },
  1327. 'router.authentication': {
  1328. 'real': '/clusters',
  1329. 'mock': '/data/clusters/info.json',
  1330. 'format': function() {
  1331. return {
  1332. async: false
  1333. };
  1334. }
  1335. },
  1336. 'ambari.service': {
  1337. 'real': '/services/AMBARI/components/AMBARI_SERVER',
  1338. 'mock': ''
  1339. },
  1340. 'ambari.service.load_server_clock': {
  1341. 'real': '/services/AMBARI/components/AMBARI_SERVER?fields=RootServiceComponents/server_clock',
  1342. 'mock': ''
  1343. },
  1344. 'config_groups.create': {
  1345. 'real': '/clusters/{clusterName}/config_groups',
  1346. 'mock': '',
  1347. 'format': function (data) {
  1348. return {
  1349. async: false,
  1350. type: 'POST',
  1351. data: JSON.stringify([{
  1352. "ConfigGroup": {
  1353. "group_name": data.group_name,
  1354. "tag": data.service_id,
  1355. "description": data.description,
  1356. "desired_configs": data.desired_configs,
  1357. "hosts": data.hosts
  1358. }
  1359. }])
  1360. }
  1361. }
  1362. },
  1363. 'config_groups.update': {
  1364. 'real': '/clusters/{clusterName}/config_groups/{id}',
  1365. 'mock': '',
  1366. 'format': function (data) {
  1367. return {
  1368. async: true,
  1369. type: 'PUT',
  1370. data: JSON.stringify(data.data)
  1371. }
  1372. }
  1373. },
  1374. 'rolling_restart.post': {
  1375. 'real': '/clusters/{clusterName}/request_schedules',
  1376. 'mock': '',
  1377. 'format' : function(data) {
  1378. return {
  1379. type : 'POST',
  1380. data : JSON.stringify([ {
  1381. "RequestSchedule" : {
  1382. "batch" : [ {
  1383. "requests" : data.batches
  1384. }, {
  1385. "batch_settings" : {
  1386. "batch_separation_in_seconds" : data.intervalTimeSeconds,
  1387. "task_failure_tolerance" : data.tolerateSize
  1388. }
  1389. } ]
  1390. }
  1391. } ])
  1392. }
  1393. }
  1394. },
  1395. 'request_schedule.delete': {
  1396. 'real': '/clusters/{clusterName}/request_schedules/{request_schedule_id}',
  1397. 'mock': '',
  1398. 'format' : function() {
  1399. return {
  1400. type : 'DELETE'
  1401. }
  1402. }
  1403. },
  1404. 'request_schedule.get': {
  1405. 'real': '/clusters/{clusterName}/request_schedules/{request_schedule_id}',
  1406. 'mock': ''
  1407. },
  1408. 'restart.hostComponents': {
  1409. 'real':'/clusters/{clusterName}/requests',
  1410. 'mock':'',
  1411. 'format': function(data) {
  1412. return {
  1413. type : 'POST',
  1414. data : JSON.stringify({
  1415. "RequestInfo": {
  1416. "command": "RESTART",
  1417. "context": data.context
  1418. },
  1419. "Requests/resource_filters": data.resource_filters
  1420. })
  1421. }
  1422. }
  1423. },
  1424. 'mirroring.get_all_entities': {
  1425. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/list/{type}?fields=status&user.name=ambari-qa',
  1426. 'mock': '/data/mirroring/{type}s.xml',
  1427. 'apiPrefix': '',
  1428. 'format': function () {
  1429. return {
  1430. dataType: 'xml'
  1431. }
  1432. }
  1433. },
  1434. 'mirroring.get_definition': {
  1435. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/definition/{type}/{name}?user.name=ambari-qa',
  1436. 'mock': '/data/mirroring/{name}_definition.xml',
  1437. 'apiPrefix': '',
  1438. 'format': function () {
  1439. return {
  1440. cache: true,
  1441. dataType: 'xml'
  1442. }
  1443. }
  1444. },
  1445. 'mirroring.dataset.get_all_instances': {
  1446. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/status/feed/{dataset}?start={start}&end={end}&user.name=ambari-qa',
  1447. 'mock': '/data/mirroring/{dataset}_instances.json',
  1448. 'apiPrefix': ''
  1449. },
  1450. 'mirroring.create_new_dataset': {
  1451. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/submitAndSchedule/feed?user.name=ambari-qa',
  1452. 'mock': '/data/mirroring/succeeded.json',
  1453. 'apiPrefix': '',
  1454. 'type': 'POST',
  1455. 'format': function (data) {
  1456. return {
  1457. contentType: 'text/xml',
  1458. dataType: 'xml',
  1459. data: data.dataset,
  1460. headers: {
  1461. 'AmbariProxy-Content-Type': 'text/xml'
  1462. }
  1463. }
  1464. }
  1465. },
  1466. 'mirroring.submit_entity': {
  1467. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/submit/{type}?user.name=ambari-qa',
  1468. 'mock': '/data/mirroring/succeeded.json',
  1469. 'apiPrefix': '',
  1470. 'type': 'POST',
  1471. 'format': function (data) {
  1472. return {
  1473. contentType: 'text/xml',
  1474. dataType: 'xml',
  1475. data: data.entity,
  1476. headers: {
  1477. 'AmbariProxy-Content-Type': 'text/xml'
  1478. }
  1479. }
  1480. }
  1481. },
  1482. 'mirroring.update_entity': {
  1483. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/update/{type}/{name}?user.name=ambari-qa',
  1484. 'mock': '/data/mirroring/succeeded.json',
  1485. 'apiPrefix': '',
  1486. 'type': 'POST',
  1487. 'format': function (data) {
  1488. return {
  1489. contentType: 'text/xml',
  1490. dataType: 'xml',
  1491. data: data.entity,
  1492. headers: {
  1493. 'AmbariProxy-Content-Type': 'text/xml'
  1494. }
  1495. }
  1496. }
  1497. },
  1498. 'mirroring.delete_entity': {
  1499. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/delete/{type}/{name}?user.name=ambari-qa',
  1500. 'mock': '/data/mirroring/succeeded.json',
  1501. 'apiPrefix': '',
  1502. 'type': 'DELETE',
  1503. 'format': function () {
  1504. return {
  1505. dataType: 'xml'
  1506. }
  1507. }
  1508. },
  1509. 'mirroring.suspend_entity': {
  1510. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/suspend/{type}/{name}?user.name=ambari-qa',
  1511. 'mock': '/data/mirroring/succeeded.json',
  1512. 'apiPrefix': '',
  1513. 'type': 'POST',
  1514. 'format': function (data) {
  1515. return {
  1516. dataType: 'xml',
  1517. data: data.entity
  1518. }
  1519. }
  1520. },
  1521. 'mirroring.schedule_entity': {
  1522. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/resume/{type}/{name}?user.name=ambari-qa',
  1523. 'mock': '/data/mirroring/succeeded.json',
  1524. 'apiPrefix': '',
  1525. 'type': 'POST',
  1526. 'format': function () {
  1527. return {
  1528. dataType: 'xml'
  1529. }
  1530. }
  1531. },
  1532. 'mirroring.suspend_instance': {
  1533. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/suspend/feed/{feed}?start={name}&user.name=ambari-qa',
  1534. 'mock': '/data/mirroring/succeeded.json',
  1535. 'apiPrefix': '',
  1536. 'type': 'POST'
  1537. },
  1538. 'mirroring.resume_instance': {
  1539. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/resume/feed/{feed}?start={name}&user.name=ambari-qa',
  1540. 'mock': '/data/mirroring/succeeded.json',
  1541. 'apiPrefix': '',
  1542. 'type': 'POST'
  1543. },
  1544. 'mirroring.kill_instance': {
  1545. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/kill/feed/{feed}?start={name}&user.name=ambari-qa',
  1546. 'mock': '/data/mirroring/succeeded.json',
  1547. 'apiPrefix': '',
  1548. 'type': 'POST'
  1549. },
  1550. 'bulk_request.host_components': {
  1551. 'real': '/clusters/{clusterName}/host_components',
  1552. 'mock': '',
  1553. 'format': function(data) {
  1554. return {
  1555. type: 'PUT',
  1556. data: JSON.stringify({
  1557. RequestInfo: {
  1558. context: data.requestInfo,
  1559. query: 'HostRoles/component_name=' + data.componentName + '&HostRoles/host_name.in(' + data.hostNames + ')&HostRoles/maintenance_state=OFF'
  1560. },
  1561. Body: {
  1562. HostRoles: {
  1563. state: data.state
  1564. }
  1565. }
  1566. })
  1567. }
  1568. }
  1569. },
  1570. 'bulk_request.hosts.all_components': {
  1571. 'real': '/clusters/{clusterName}/host_components',
  1572. 'mock': '',
  1573. 'format': function(data) {
  1574. return {
  1575. type: 'PUT',
  1576. data: JSON.stringify({
  1577. RequestInfo: {
  1578. context: data.requestInfo,
  1579. query: data.query
  1580. },
  1581. Body: {
  1582. HostRoles: {
  1583. state: data.state
  1584. }
  1585. }
  1586. })
  1587. }
  1588. }
  1589. },
  1590. 'bulk_request.decommission': {
  1591. 'real' : '/clusters/{clusterName}/requests',
  1592. 'mock' : '',
  1593. 'format': function(data) {
  1594. return {
  1595. type: 'POST',
  1596. data: JSON.stringify({
  1597. 'RequestInfo': {
  1598. 'context': data.context,
  1599. 'command': 'DECOMMISSION',
  1600. 'parameters': data.parameters
  1601. },
  1602. "Requests/resource_filters": [{"service_name" : data.serviceName, "component_name" : data.componentName}]
  1603. })
  1604. }
  1605. }
  1606. },
  1607. 'bulk_request.hosts.passive_state': {
  1608. 'real': '/clusters/{clusterName}/hosts',
  1609. 'mock': '',
  1610. 'format': function(data) {
  1611. return {
  1612. type: 'PUT',
  1613. data: JSON.stringify({
  1614. RequestInfo: {
  1615. context: data.requestInfo,
  1616. query: 'Hosts/host_name.in(' + data.hostNames + ')'
  1617. },
  1618. Body: {
  1619. Hosts: {
  1620. maintenance_state: data.passive_state
  1621. }
  1622. }
  1623. })
  1624. }
  1625. }
  1626. },
  1627. 'bulk_request.hosts.all_components.passive_state': {
  1628. 'real': '/clusters/{clusterName}/host_components',
  1629. 'mock': '',
  1630. 'format': function(data) {
  1631. return {
  1632. type: 'PUT',
  1633. data: JSON.stringify({
  1634. RequestInfo: {
  1635. context: data.requestInfo,
  1636. query: data.query
  1637. },
  1638. Body: {
  1639. HostRoles: {
  1640. maintenance_state: data.passive_state
  1641. }
  1642. }
  1643. })
  1644. }
  1645. }
  1646. },
  1647. 'jobs.tezDag.NametoID': {
  1648. 'real': '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/TEZ_DAG_ID?primaryFilter=dagName:{tezDagName}',
  1649. 'mock': '/data/jobs/tezDag-name-to-id.json',
  1650. 'apiPrefix': ''
  1651. },
  1652. 'jobs.tezDag.tezDagId': {
  1653. 'real': '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/TEZ_DAG_ID/{tezDagId}?fields=relatedentities',
  1654. 'mock': '/data/jobs/tezDag.json',
  1655. 'apiPrefix': ''
  1656. },
  1657. 'jobs.tezDag.tezDagVertexId': {
  1658. 'real': '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/TEZ_VERTEX_ID/{tezDagVertexId}?fields=otherinfo',
  1659. 'mock': '/data/jobs/tezDagVertex.json',
  1660. 'apiPrefix': ''
  1661. }
  1662. };
  1663. /**
  1664. * Replace data-placeholders to its values
  1665. *
  1666. * @param {String} url
  1667. * @param {Object} data
  1668. * @return {String}
  1669. */
  1670. var formatUrl = function (url, data) {
  1671. if (!url) return null;
  1672. var keys = url.match(/\{\w+\}/g);
  1673. keys = (keys === null) ? [] : keys;
  1674. if (keys) {
  1675. keys.forEach(function (key) {
  1676. var raw_key = key.substr(1, key.length - 2);
  1677. var replace;
  1678. if (!data || !data[raw_key]) {
  1679. replace = '';
  1680. }
  1681. else {
  1682. replace = data[raw_key];
  1683. }
  1684. url = url.replace(new RegExp(key, 'g'), replace);
  1685. });
  1686. }
  1687. return url;
  1688. };
  1689. /**
  1690. * this = object from config
  1691. * @return {Object}
  1692. */
  1693. var formatRequest = function (data) {
  1694. var opt = {
  1695. type: this.type || 'GET',
  1696. timeout: App.timeout,
  1697. dataType: 'json',
  1698. statusCode: require('data/statusCodes')
  1699. };
  1700. if (App.testMode) {
  1701. opt.url = formatUrl(this.mock ? this.mock : '', data);
  1702. opt.type = 'GET';
  1703. }
  1704. else {
  1705. var prefix = this.apiPrefix != null ? this.apiPrefix : App.apiPrefix;
  1706. opt.url = prefix + formatUrl(this.real, data);
  1707. }
  1708. if (this.format) {
  1709. jQuery.extend(opt, this.format(data, opt));
  1710. }
  1711. return opt;
  1712. };
  1713. /**
  1714. * Wrapper for all ajax requests
  1715. *
  1716. * @type {Object}
  1717. */
  1718. var ajax = Em.Object.extend({
  1719. /**
  1720. * Send ajax request
  1721. *
  1722. * @param {Object} config
  1723. * @return {$.ajax} jquery ajax object
  1724. *
  1725. * config fields:
  1726. * name - url-key in the urls-object *required*
  1727. * sender - object that send request (need for proper callback initialization) *required*
  1728. * data - object with data for url-format
  1729. * beforeSend - method-name for ajax beforeSend response callback
  1730. * success - method-name for ajax success response callback
  1731. * error - method-name for ajax error response callback
  1732. * callback - callback from <code>App.updater.run</code> library
  1733. */
  1734. send: function (config) {
  1735. console.warn('============== ajax ==============', config.name, config.data);
  1736. if (!config.sender) {
  1737. console.warn('Ajax sender should be defined!');
  1738. return null;
  1739. }
  1740. // default parameters
  1741. var params = {
  1742. clusterName: App.get('clusterName')
  1743. };
  1744. // extend default parameters with provided
  1745. if (config.data) {
  1746. jQuery.extend(params, config.data);
  1747. }
  1748. var opt = {};
  1749. if (!urls[config.name]) {
  1750. console.warn('Invalid name provided!');
  1751. return null;
  1752. }
  1753. opt = formatRequest.call(urls[config.name], params);
  1754. opt.context = this;
  1755. // object sender should be provided for processing beforeSend, success and error responses
  1756. opt.beforeSend = function (xhr) {
  1757. if (config.beforeSend) {
  1758. config.sender[config.beforeSend](opt, xhr, params);
  1759. }
  1760. };
  1761. opt.success = function (data) {
  1762. console.log("TRACE: The url is: " + opt.url);
  1763. if (config.success) {
  1764. config.sender[config.success](data, opt, params);
  1765. }
  1766. };
  1767. opt.error = function (request, ajaxOptions, error) {
  1768. if (config.error) {
  1769. config.sender[config.error](request, ajaxOptions, error, opt);
  1770. } else {
  1771. this.defaultErrorHandler(request, opt.url, opt.type);
  1772. }
  1773. };
  1774. opt.complete = function () {
  1775. if (config.callback) {
  1776. config.callback();
  1777. }
  1778. };
  1779. if ($.mocho) {
  1780. opt.url = 'http://' + $.hostName + opt.url;
  1781. }
  1782. return $.ajax(opt);
  1783. },
  1784. // A single instance of App.ModalPopup view
  1785. modalPopup: null,
  1786. /**
  1787. * defaultErrorHandler function is referred from App.ajax.send function and App.HttpClient.defaultErrorHandler function
  1788. * @jqXHR {jqXHR Object}
  1789. * @url {string}
  1790. * @method {String} Http method
  1791. * @showStatus {number} HTTP response code which should be shown. Default is 500.
  1792. */
  1793. defaultErrorHandler: function (jqXHR, url, method, showStatus) {
  1794. method = method || 'GET';
  1795. var self = this;
  1796. var api = " received on " + method + " method for API: " + url;
  1797. try {
  1798. var json = $.parseJSON(jqXHR.responseText);
  1799. var message = json.message;
  1800. } catch (err) {
  1801. }
  1802. if (!showStatus) {
  1803. showStatus = 500;
  1804. }
  1805. var statusCode = jqXHR.status + " status code";
  1806. if (jqXHR.status === showStatus && !this.modalPopup) {
  1807. this.modalPopup = App.ModalPopup.show({
  1808. header: jqXHR.statusText,
  1809. secondary: false,
  1810. onPrimary: function () {
  1811. this.hide();
  1812. self.modalPopup = null;
  1813. },
  1814. bodyClass: Ember.View.extend({
  1815. classNames: ['api-error'],
  1816. templateName: require('templates/utils/ajax'),
  1817. api: api,
  1818. statusCode: statusCode,
  1819. message: message,
  1820. showMessage: !!message
  1821. })
  1822. });
  1823. }
  1824. }
  1825. });
  1826. /**
  1827. * Add few access-methods for test purposes
  1828. */
  1829. if ($.mocho) {
  1830. ajax.reopen({
  1831. /**
  1832. * Don't use it anywhere except tests!
  1833. * @returns {Array}
  1834. */
  1835. fakeGetUrlNames: function() {
  1836. return Em.keys(urls);
  1837. },
  1838. /**
  1839. * Don't use it anywhere except tests!
  1840. * @param name
  1841. * @returns {*}
  1842. */
  1843. fakeGetUrl: function(name) {
  1844. return urls[name];
  1845. },
  1846. /**
  1847. * Don't use it anywhere except tests!
  1848. * @param url
  1849. * @param data
  1850. * @returns {String}
  1851. */
  1852. fakeFormatUrl: function(url, data) {
  1853. return formatUrl(url, data);
  1854. },
  1855. /**
  1856. * Don't use it anywhere except tests!
  1857. * @param urlObj
  1858. * @param data
  1859. * @returns {Object}
  1860. */
  1861. fakeFormatRequest: function(urlObj, data) {
  1862. return formatRequest.call(urlObj, data);
  1863. }
  1864. });
  1865. }
  1866. App.ajax = ajax.create({});
  1867. App.formatRequest = formatRequest;
  1868. App.urls = urls;