ajax.js 66 KB

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