ajax.js 71 KB

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