ajax.js 77 KB

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