ajax.js 71 KB

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