ajax.js 77 KB

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