ajax.js 70 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251
  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.delete': {
  590. 'real': '/clusters/{clusterName}/hosts/{hostName}',
  591. 'mock': '',
  592. 'type': 'DELETE',
  593. 'format': function() {
  594. return {
  595. async: false
  596. }
  597. }
  598. },
  599. 'hosts.metrics': {
  600. 'real': '/clusters/{clusterName}/hosts?fields={metricName}',
  601. 'mock': '/data/cluster_metrics/cpu_1hr.json'
  602. },
  603. 'hosts.metrics.host_component': {
  604. 'real': '/clusters/{clusterName}/services/{serviceName}/components/{componentName}?fields=host_components/{metricName}',
  605. 'mock': '/data/cluster_metrics/cpu_1hr.json'
  606. },
  607. 'service.service_component': {
  608. 'real': '/clusters/{clusterName}/services/{serviceName}/components/{componentName}',
  609. 'mock': '',
  610. 'format': function(data) {
  611. return {
  612. async: data.async
  613. };
  614. }
  615. },
  616. 'service.metrics.flume.channel_fill_percent': {
  617. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/CHANNEL/*/ChannelFillPercentage[{fromSeconds},{toSeconds},{stepSeconds}]',
  618. 'mock': '/data/services/metrics/flume/channelFillPct.json',
  619. 'testInProduction': true
  620. },
  621. 'service.metrics.flume.channel_size': {
  622. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/CHANNEL/*/ChannelSize[{fromSeconds},{toSeconds},{stepSeconds}]',
  623. 'mock': '/data/services/metrics/flume/channelSize.json',
  624. 'testInProduction': true
  625. },
  626. 'service.metrics.flume.sink_drain_success': {
  627. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/SINK/*/EventDrainSuccessCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  628. 'mock': '/data/services/metrics/flume/sinkDrainSuccessCount.json',
  629. 'testInProduction': true
  630. },
  631. 'service.metrics.flume.sink_connection_failed': {
  632. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/SINK/*/ConnectionFailedCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  633. 'mock': '/data/services/metrics/flume/sinkConnectionFailedCount.json',
  634. 'testInProduction': true
  635. },
  636. 'service.metrics.flume.gc': {
  637. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  638. 'mock': '/data/services/metrics/flume/jvmGcTime.json',
  639. 'testInProduction': true
  640. },
  641. 'service.metrics.flume.jvm_heap_used': {
  642. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/jvm/memHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}]',
  643. 'mock': '/data/services/metrics/flume/jvmMemHeapUsedM.json',
  644. 'testInProduction': true
  645. },
  646. 'service.metrics.flume.jvm_threads_runnable': {
  647. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/jvm/threadsRunnable[{fromSeconds},{toSeconds},{stepSeconds}]',
  648. 'mock': '/data/services/metrics/flume/jvmThreadsRunnable.json',
  649. 'testInProduction': true
  650. },
  651. 'service.metrics.flume.cpu_user': {
  652. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/cpu/cpu_user[{fromSeconds},{toSeconds},{stepSeconds}]',
  653. 'mock': '',
  654. 'testInProduction': true
  655. },
  656. 'service.metrics.flume.source_accepted': {
  657. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/SOURCE/*/EventAcceptedCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  658. 'mock': '/data/services/metrics/flume/sourceEventAccepted.json',
  659. 'testInProduction': true
  660. },
  661. 'service.metrics.hbase.cluster_requests': {
  662. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/cluster_requests[{fromSeconds},{toSeconds},{stepSeconds}]',
  663. 'mock': '/data/services/metrics/hbase/cluster_requests.json',
  664. 'testInProduction': true
  665. },
  666. 'service.metrics.hbase.hlog_split_size': {
  667. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitSize_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  668. 'mock': '/data/services/metrics/hbase/hlog_split_size.json',
  669. 'testInProduction': true
  670. },
  671. 'service.metrics.hbase.hlog_split_time': {
  672. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  673. 'mock': '/data/services/metrics/hbase/hlog_split_time.json',
  674. 'testInProduction': true
  675. },
  676. 'service.metrics.hbase.regionserver_queuesize': {
  677. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/flushQueueSize[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/compactionQueueSize[{fromSeconds},{toSeconds},{stepSeconds}]',
  678. 'mock': '/data/services/metrics/hbase/regionserver_queuesize.json',
  679. 'testInProduction': true
  680. },
  681. 'service.metrics.hbase.regionserver_regions': {
  682. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/regions[{fromSeconds},{toSeconds},{stepSeconds}]',
  683. 'mock': '/data/services/metrics/hbase/regionserver_regions.json',
  684. 'testInProduction': true
  685. },
  686. 'service.metrics.hbase.regionserver_rw_requests': {
  687. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/readRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/writeRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  688. 'mock': '/data/services/metrics/hbase/regionserver_rw_requests.json',
  689. 'testInProduction': true
  690. },
  691. 'service.metrics.mapreduce.gc': {
  692. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  693. 'mock': '/data/services/metrics/mapreduce/gc.json',
  694. 'testInProduction': true
  695. },
  696. 'service.metrics.mapreduce.jobs_status': {
  697. '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}]',
  698. 'mock': '/data/services/metrics/mapreduce/jobs_status.json',
  699. 'testInProduction': true
  700. },
  701. 'service.metrics.mapreduce.jobs_heap': {
  702. '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}]',
  703. 'mock': '/data/services/metrics/mapreduce/jvm_heap.json',
  704. 'testInProduction': true
  705. },
  706. 'service.metrics.mapreduce.jobs_threads': {
  707. '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}]',
  708. 'mock': '/data/services/metrics/mapreduce/jvm_threads.json',
  709. 'testInProduction': true
  710. },
  711. 'service.metrics.mapreduce.map_slots': {
  712. '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}]',
  713. 'mock': '/data/services/metrics/mapreduce/map_slots.json',
  714. 'testInProduction': true
  715. },
  716. 'service.metrics.mapreduce.reduce_slots': {
  717. '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}]',
  718. 'mock': '/data/services/metrics/mapreduce/reduce_slots.json',
  719. 'testInProduction': true
  720. },
  721. 'service.metrics.mapreduce.rpc': {
  722. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  723. 'mock': '/data/services/metrics/mapreduce/rpc.json',
  724. 'testInProduction': true
  725. },
  726. 'service.metrics.mapreduce.tasks_running_waiting': {
  727. '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}]',
  728. 'mock': '/data/services/metrics/mapreduce/tasks_running_waiting.json',
  729. 'testInProduction': true
  730. },
  731. 'service.metrics.hdfs.block_status': {
  732. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/FSNamesystem/PendingReplicationBlocks[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/FSNamesystem/UnderReplicatedBlocks[{fromSeconds},{toSeconds},{stepSeconds}]',
  733. 'mock': '/data/services/metrics/hdfs/block_status.json',
  734. 'testInProduction': true
  735. },
  736. 'service.metrics.hdfs.file_operations': {
  737. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/namenode/FileInfoOps[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/namenode/CreateFileOps[{fromSeconds},{toSeconds},{stepSeconds}]',
  738. 'mock': '/data/services/metrics/hdfs/file_operations.json',
  739. 'testInProduction': true
  740. },
  741. 'service.metrics.hdfs.gc': {
  742. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  743. 'mock': '/data/services/metrics/hdfs/gc.json',
  744. 'testInProduction': true
  745. },
  746. 'service.metrics.hdfs.io': {
  747. 'real': '/clusters/{clusterName}/services/HDFS/components/DATANODE?fields=metrics/dfs/datanode/bytes_written[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/datanode/bytes_read[{fromSeconds},{toSeconds},{stepSeconds}]',
  748. 'mock': '/data/services/metrics/hdfs/io.json',
  749. 'testInProduction': true
  750. },
  751. 'service.metrics.hdfs.jvm_heap': {
  752. '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}]',
  753. 'mock': '/data/services/metrics/hdfs/jvm_heap.json',
  754. 'testInProduction': true
  755. },
  756. 'service.metrics.hdfs.jvm_threads': {
  757. '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}]',
  758. 'mock': '/data/services/metrics/hdfs/jvm_threads.json',
  759. 'testInProduction': true
  760. },
  761. 'service.metrics.hdfs.rpc': {
  762. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  763. 'mock': '/data/services/metrics/hdfs/rpc.json',
  764. 'testInProduction': true
  765. },
  766. 'service.metrics.hdfs.space_utilization': {
  767. '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}]',
  768. 'mock': '/data/services/metrics/hdfs/space_utilization.json',
  769. 'testInProduction': true
  770. },
  771. 'service.start_stop': {
  772. 'real': '/clusters/{clusterName}/services?params/run_smoke_test=true',
  773. 'mock': '/data/mirroring/poll/poll_6.json',
  774. 'format': function (data) {
  775. return {
  776. type: 'PUT',
  777. async: false,
  778. data: data.data
  779. };
  780. }
  781. },
  782. 'service.metrics.yarn.gc': {
  783. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  784. 'mock': '/data/services/metrics/yarn/gc.json',
  785. 'testInProduction': true
  786. },
  787. 'service.metrics.yarn.jobs_threads': {
  788. '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}]',
  789. 'mock': '/data/services/metrics/yarn/jvm_threads.json',
  790. 'testInProduction': true
  791. },
  792. 'service.metrics.yarn.rpc': {
  793. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  794. 'mock': '/data/services/metrics/yarn/rpc.json',
  795. 'testInProduction': true
  796. },
  797. 'service.metrics.yarn.jobs_heap': {
  798. '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}]',
  799. 'mock': '/data/services/metrics/yarn/jvm_heap.json',
  800. 'testInProduction': true
  801. },
  802. 'service.metrics.yarn.queue.allocated': {
  803. '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}]',
  804. 'mock': '',
  805. 'testInProduction': true
  806. },
  807. 'service.metrics.yarn.queue.allocated.container': {
  808. '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}]',
  809. 'mock': '',
  810. 'testInProduction': true
  811. },
  812. 'service.metrics.yarn.node.manager.statuses': {
  813. '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}]',
  814. 'mock': '',
  815. 'testInProduction': true
  816. },
  817. 'service.metrics.yarn.queue.memory.resource': {
  818. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=',
  819. 'mock': '',
  820. 'format': function (data, opt) {
  821. var field1 = 'metrics/yarn/Queue/{queueName}/AllocatedMB[{fromSeconds},{toSeconds},{stepSeconds}]';
  822. var field2 = 'metrics/yarn/Queue/{queueName}/AvailableMB[{fromSeconds},{toSeconds},{stepSeconds}]';
  823. if (opt.url != null && data.queueNames != null && data.queueNames.length > 0) {
  824. data.queueNames.forEach(function (q) {
  825. data.queueName = q;
  826. opt.url += (formatUrl(field1, data) + ",");
  827. opt.url += (formatUrl(field2, data) + ",");
  828. });
  829. } else {
  830. opt.url += (formatUrl(field1, data) + ",");
  831. opt.url += (formatUrl(field2, data) + ",");
  832. }
  833. },
  834. 'testInProduction': true
  835. },
  836. 'service.metrics.yarn.queue.apps.states.current': {
  837. '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}]',
  838. 'mock': '',
  839. 'testInProduction': true
  840. },
  841. 'service.metrics.yarn.queue.apps.states.finished': {
  842. '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}]',
  843. 'mock': '',
  844. 'testInProduction': true
  845. },
  846. 'service.metrics.storm.nimbus': {
  847. 'real': '/clusters/{clusterName}/services/STORM/components/NIMBUS?fields={metricsTemplate}',
  848. 'mock': ''
  849. },
  850. 'dashboard.cluster_metrics.cpu': {
  851. 'real': '/clusters/{clusterName}/?fields=metrics/cpu[{fromSeconds},{toSeconds},{stepSeconds}]',
  852. 'mock': '/data/cluster_metrics/cpu_1hr.json',
  853. 'testInProduction': true
  854. },
  855. 'dashboard.cluster_metrics.load': {
  856. 'real': '/clusters/{clusterName}/?fields=metrics/load[{fromSeconds},{toSeconds},{stepSeconds}]',
  857. 'mock': '/data/cluster_metrics/load_1hr.json',
  858. 'testInProduction': true
  859. },
  860. 'dashboard.cluster_metrics.memory': {
  861. 'real': '/clusters/{clusterName}/?fields=metrics/memory[{fromSeconds},{toSeconds},{stepSeconds}]',
  862. 'mock': '/data/cluster_metrics/memory_1hr.json',
  863. 'testInProduction': true
  864. },
  865. 'dashboard.cluster_metrics.network': {
  866. 'real': '/clusters/{clusterName}/?fields=metrics/network[{fromSeconds},{toSeconds},{stepSeconds}]',
  867. 'mock': '/data/cluster_metrics/network_1hr.json',
  868. 'testInProduction': true
  869. },
  870. 'host.metrics.cpu': {
  871. '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}]',
  872. 'mock': '/data/hosts/metrics/cpu.json',
  873. 'testInProduction': true
  874. },
  875. 'host.metrics.disk': {
  876. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/disk/disk_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/disk/disk_free[{fromSeconds},{toSeconds},{stepSeconds}]',
  877. 'mock': '/data/hosts/metrics/disk.json',
  878. 'testInProduction': true
  879. },
  880. 'host.metrics.load': {
  881. '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}]',
  882. 'mock': '/data/hosts/metrics/load.json',
  883. 'testInProduction': true
  884. },
  885. 'host.metrics.memory': {
  886. '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}]',
  887. 'mock': '/data/hosts/metrics/memory.json',
  888. 'testInProduction': true
  889. },
  890. 'host.metrics.network': {
  891. '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}]',
  892. 'mock': '/data/hosts/metrics/network.json',
  893. 'testInProduction': true
  894. },
  895. 'host.metrics.processes': {
  896. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/process/proc_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/process/proc_run[{fromSeconds},{toSeconds},{stepSeconds}]',
  897. 'mock': '/data/hosts/metrics/processes.json',
  898. 'testInProduction': true
  899. },
  900. 'host.service_config_hosts_overrides': {
  901. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  902. 'mock': '',
  903. 'format': function() {
  904. return {
  905. async: false,
  906. timeout: 10000
  907. };
  908. }
  909. },
  910. 'admin.security_status': {
  911. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  912. 'mock': '',
  913. 'format': function() {
  914. return {
  915. timeout: 10000
  916. };
  917. }
  918. },
  919. 'settings.get.user_pref': {
  920. 'real': '/persist/{key}',
  921. 'mock': '/data/user_settings/{key}.json',
  922. 'format': function(data) {
  923. return {
  924. async: data.async
  925. };
  926. }
  927. },
  928. 'settings.post.user_pref': {
  929. 'real': '/persist',
  930. 'mock': '',
  931. 'type': 'POST',
  932. 'format': function (data) {
  933. return {
  934. async: data.async,
  935. data: JSON.stringify(data.keyValuePair)
  936. }
  937. }
  938. },
  939. 'cluster.load_cluster_name': {
  940. 'real': '/clusters',
  941. 'mock': '/data/clusters/info.json',
  942. 'format': function() {
  943. return {
  944. async: false
  945. };
  946. }
  947. },
  948. 'cluster.update_upgrade_version': {
  949. 'real': '/stacks2/HDP/versions?fields=stackServices/StackServices,Versions',
  950. 'mock': '/data/wizard/stack/stacks.json',
  951. 'format': function() {
  952. return {
  953. async: false
  954. };
  955. }
  956. },
  957. 'cluster.load_repositories': {
  958. 'real': '/stacks2/{stackName}/versions/{stackVersion}/operatingSystems?fields=repositories/*',
  959. 'mock': '',
  960. 'type': 'GET',
  961. 'format': function (data) {
  962. return {
  963. data: data.data
  964. };
  965. }
  966. },
  967. 'admin.high_availability.stop_all_services': {
  968. 'real': '/clusters/{clusterName}/services',
  969. 'mock': '',
  970. 'format': function() {
  971. return {
  972. type: 'PUT',
  973. data: JSON.stringify({
  974. "RequestInfo": {
  975. "context": "Stop all services"
  976. },
  977. "Body": {
  978. "ServiceInfo": {
  979. "state": "INSTALLED"
  980. }
  981. }
  982. })
  983. }
  984. }
  985. },
  986. 'admin.high_availability.start_all_services': {
  987. 'real': '/clusters/{clusterName}/services',
  988. 'mock': '',
  989. 'format': function() {
  990. return {
  991. type: 'PUT',
  992. data: JSON.stringify({
  993. "RequestInfo": {
  994. "context": "Start all services"
  995. },
  996. "Body": {
  997. "ServiceInfo": {
  998. "state": "STARTED"
  999. }
  1000. }
  1001. })
  1002. }
  1003. }
  1004. },
  1005. 'admin.high_availability.polling': {
  1006. 'real': '/clusters/{clusterName}/requests/{requestId}?fields=tasks/*',
  1007. 'mock': '',
  1008. 'type': 'GET'
  1009. },
  1010. 'admin.high_availability.getNnCheckPointStatus': {
  1011. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/NAMENODE',
  1012. 'mock': '',
  1013. 'type': 'GET'
  1014. },
  1015. 'admin.high_availability.getJnCheckPointStatus': {
  1016. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/JOURNALNODE?fields=metrics',
  1017. 'mock': ''
  1018. },
  1019. 'admin.high_availability.getHostComponent': {
  1020. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  1021. 'mock': ''
  1022. },
  1023. 'admin.high_availability.create_component': {
  1024. 'real': '/clusters/{clusterName}/hosts?Hosts/host_name={hostName}',
  1025. 'mock': '',
  1026. 'type': 'POST',
  1027. 'format': function (data) {
  1028. return {
  1029. data: JSON.stringify({
  1030. "host_components": [
  1031. {
  1032. "HostRoles": {
  1033. "component_name": data.componentName
  1034. }
  1035. }
  1036. ]
  1037. })
  1038. }
  1039. }
  1040. },
  1041. 'admin.high_availability.create_journalnode': {
  1042. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  1043. 'mock': '',
  1044. 'type': 'POST',
  1045. 'format': function() {
  1046. return {
  1047. data: JSON.stringify({
  1048. "components": [
  1049. {
  1050. "ServiceComponentInfo": {
  1051. "component_name": "JOURNALNODE"
  1052. }
  1053. }
  1054. ]
  1055. })
  1056. }
  1057. }
  1058. },
  1059. 'admin.high_availability.create_zkfc': {
  1060. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  1061. 'mock': '',
  1062. 'type': 'POST',
  1063. 'format': function() {
  1064. return {
  1065. data: JSON.stringify({
  1066. "components": [
  1067. {
  1068. "ServiceComponentInfo": {
  1069. "component_name": "ZKFC"
  1070. }
  1071. }
  1072. ]
  1073. })
  1074. }
  1075. }
  1076. },
  1077. 'admin.high_availability.install_component': {
  1078. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  1079. 'mock': '',
  1080. 'type': 'PUT',
  1081. 'format': function (data) {
  1082. return {
  1083. data: JSON.stringify({
  1084. RequestInfo: {
  1085. "context": "Install " + data.displayName
  1086. },
  1087. Body: {
  1088. "HostRoles": {
  1089. "state": "INSTALLED"
  1090. }
  1091. }
  1092. })
  1093. }
  1094. }
  1095. },
  1096. 'admin.high_availability.start_component': {
  1097. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  1098. 'mock': '',
  1099. 'type': 'PUT',
  1100. 'format': function (data) {
  1101. return {
  1102. data: JSON.stringify({
  1103. RequestInfo: {
  1104. "context": "Start " + data.displayName
  1105. },
  1106. Body: {
  1107. "HostRoles": {
  1108. "state": "STARTED"
  1109. }
  1110. }
  1111. })
  1112. }
  1113. }
  1114. },
  1115. 'admin.high_availability.maintenance_mode': {
  1116. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  1117. 'mock': '',
  1118. 'type': 'PUT',
  1119. 'format': function () {
  1120. return {
  1121. data: JSON.stringify({
  1122. "HostRoles": {
  1123. "state": "DISABLED"
  1124. }
  1125. })
  1126. }
  1127. }
  1128. },
  1129. 'admin.high_availability.stop_component': {
  1130. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  1131. 'mock': '',
  1132. 'type': 'PUT',
  1133. 'format': function (data) {
  1134. return {
  1135. data: JSON.stringify({
  1136. RequestInfo: {
  1137. "context": "Stop " + data.displayName
  1138. },
  1139. Body: {
  1140. "HostRoles": {
  1141. "state": "INSTALLED"
  1142. }
  1143. }
  1144. })
  1145. }
  1146. }
  1147. },
  1148. 'admin.high_availability.load_configs': {
  1149. 'real': '/clusters/{clusterName}/configurations?(type=core-site&tag={coreSiteTag})|(type=hdfs-site&tag={hdfsSiteTag})',
  1150. 'mock': '',
  1151. 'type': 'GET'
  1152. },
  1153. 'admin.high_availability.save_configs': {
  1154. 'real': '/clusters/{clusterName}',
  1155. 'mock': '',
  1156. 'type': 'PUT',
  1157. 'format': function (data) {
  1158. return {
  1159. async: false,
  1160. data: JSON.stringify({
  1161. Clusters: {
  1162. desired_config: {
  1163. "type": data.siteName,
  1164. "tag": 'version' + (new Date).getTime(),
  1165. "properties": data.properties
  1166. }
  1167. }
  1168. })
  1169. }
  1170. }
  1171. },
  1172. 'admin.high_availability.load_hbase_configs': {
  1173. 'real': '/clusters/{clusterName}/configurations?type=hbase-site&tag={hbaseSiteTag}',
  1174. 'mock': '',
  1175. 'type': 'GET'
  1176. },
  1177. 'admin.delete_component': {
  1178. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  1179. 'mock': '',
  1180. 'type': 'DELETE'
  1181. },
  1182. 'admin.security.cluster_configs': {
  1183. 'real': '/clusters/{clusterName}',
  1184. 'mock': '',
  1185. 'format': function() {
  1186. return {
  1187. timeout: 10000
  1188. };
  1189. }
  1190. },
  1191. 'admin.delete_host': {
  1192. 'real': '/clusters/{clusterName}/hosts/{hostName}',
  1193. 'mock': '',
  1194. 'type': 'DELETE'
  1195. },
  1196. 'admin.get.all_configurations': {
  1197. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  1198. 'mock': '',
  1199. 'format': function() {
  1200. return {
  1201. timeout: 10000
  1202. };
  1203. }
  1204. },
  1205. 'admin.security.apply_configurations': {
  1206. 'real': '/clusters/{clusterName}',
  1207. 'mock': '',
  1208. 'format': function (data) {
  1209. return {
  1210. type: 'PUT',
  1211. timeout: 10000,
  1212. data: data.configData
  1213. };
  1214. }
  1215. },
  1216. 'admin.security.apply_configuration': {
  1217. 'real': '/clusters/{clusterName}',
  1218. 'mock': '',
  1219. 'format': function(data) {
  1220. return {
  1221. type: 'PUT',
  1222. async: false,
  1223. timeout: 5000,
  1224. data: JSON.stringify(data.clusterData)
  1225. };
  1226. }
  1227. },
  1228. 'admin.security.add.cluster_configs': {
  1229. 'real': '/clusters/{clusterName}' + '?fields=Clusters/desired_configs',
  1230. 'mock': '',
  1231. 'format': function() {
  1232. return {
  1233. timeout: 10000
  1234. };
  1235. }
  1236. },
  1237. 'admin.stack_upgrade.run_upgrade': {
  1238. 'real': '/clusters/{clusterName}',
  1239. 'mock': '',
  1240. 'format': function (data) {
  1241. return {
  1242. type: 'PUT',
  1243. async: false,
  1244. data: data.data
  1245. };
  1246. }
  1247. },
  1248. 'admin.stack_upgrade.stop_services': {
  1249. 'real': '/clusters/{clusterName}/services?ServiceInfo/state=STARTED',
  1250. 'mock': '',
  1251. 'format': function (data) {
  1252. return {
  1253. type: 'PUT',
  1254. async: false,
  1255. data: data.data
  1256. };
  1257. }
  1258. },
  1259. 'admin.user.create': {
  1260. 'real': '/users/{user}',
  1261. 'mock': '/data/users/users.json',
  1262. 'format': function(data) {
  1263. return {
  1264. type: 'POST',
  1265. data: JSON.stringify(data.data)
  1266. }
  1267. }
  1268. },
  1269. 'admin.user.delete': {
  1270. 'real': '/users/{user}',
  1271. 'mock': '/data/users/users.json',
  1272. 'format': function() {
  1273. return {
  1274. type: 'DELETE'
  1275. }
  1276. }
  1277. },
  1278. 'admin.user.edit': {
  1279. 'real': '/users/{user}',
  1280. 'mock':'/data/users/users.json',
  1281. 'format': function(data) {
  1282. return {
  1283. type: 'PUT',
  1284. data: data.data
  1285. }
  1286. }
  1287. },
  1288. 'admin.stack_upgrade.do_poll': {
  1289. 'real': '/clusters/{cluster}/requests/{requestId}?fields=tasks/*',
  1290. 'mock': '/data/wizard/{mock}'
  1291. },
  1292. 'wizard.advanced_repositories.valid_url': {
  1293. 'real': '/stacks2/{stackName}/versions/{stackVersion}/operatingSystems/{osType}/repositories/{nameVersionCombo}',
  1294. 'mock': '',
  1295. 'type': 'PUT',
  1296. 'format': function (data) {
  1297. return {
  1298. async: true,
  1299. data: JSON.stringify(data.data)
  1300. }
  1301. }
  1302. },
  1303. 'wizard.install_services.add_host_controller.is_retry': {
  1304. 'real': '/clusters/{cluster}/host_components',
  1305. 'mock': '',
  1306. 'format': function (data) {
  1307. return {
  1308. type: 'PUT',
  1309. async: false,
  1310. data: data.data
  1311. };
  1312. }
  1313. },
  1314. 'wizard.install_services.add_host_controller.not_is_retry': {
  1315. 'real': '/clusters/{cluster}/host_components',
  1316. 'mock': '',
  1317. 'format': function(data) {
  1318. return {
  1319. type: 'PUT',
  1320. async: false,
  1321. data: data.data
  1322. };
  1323. }
  1324. },
  1325. 'wizard.install_services.installer_controller.is_retry': {
  1326. 'real': '/clusters/{cluster}/host_components?HostRoles/state=INSTALLED',
  1327. 'mock': '/data/wizard/deploy/2_hosts/poll_1.json',
  1328. 'type': 'PUT',
  1329. 'format': function (data) {
  1330. return {
  1331. async: false,
  1332. data: data.data
  1333. };
  1334. }
  1335. },
  1336. 'wizard.install_services.installer_controller.not_is_retry': {
  1337. 'real': '/clusters/{cluster}/services?ServiceInfo/state=INIT',
  1338. 'mock': '/data/wizard/deploy/2_hosts/poll_1.json',
  1339. 'type': 'PUT',
  1340. 'format': function (data) {
  1341. return {
  1342. async: false,
  1343. data: data.data
  1344. };
  1345. }
  1346. },
  1347. 'wizard.install_services.add_service_controller.get_failed_host_components': {
  1348. 'real': '/clusters/{clusterName}/host_components?fields=HostRoles/state,component/ServiceComponentInfo/service_name',
  1349. 'mock': '',
  1350. 'format': function() {
  1351. return {
  1352. async: false
  1353. };
  1354. }
  1355. },
  1356. 'wizard.service_components': {
  1357. 'real': '{stackUrl}/stackServices?fields=StackServices/comments,StackServices/service_version,serviceComponents/*',
  1358. 'mock': '/data/stacks/HDP-2.1/service_components.json',
  1359. 'format': function(data) {
  1360. return {
  1361. timeout: 10000,
  1362. async: !!data.async
  1363. };
  1364. }
  1365. },
  1366. 'wizard.step9.installer.get_host_status': {
  1367. 'real': '/clusters/{cluster}/hosts?fields=Hosts/host_state,host_components/HostRoles/state',
  1368. 'mock': '/data/wizard/deploy/5_hosts/get_host_state.json',
  1369. 'format': function () {
  1370. return {
  1371. async: false
  1372. };
  1373. }
  1374. },
  1375. 'wizard.step9.installer.launch_start_services': {
  1376. 'real': '/clusters/{cluster}/services?ServiceInfo/state=INSTALLED&params/run_smoke_test=true&params/reconfigure_client=false',
  1377. 'mock': '/data/wizard/deploy/5_hosts/poll_6.json',
  1378. 'format': function (data) {
  1379. var d = {
  1380. type: 'PUT',
  1381. async: false,
  1382. data: data.data
  1383. };
  1384. if (App.testMode) {
  1385. d.type = 'GET';
  1386. }
  1387. return d;
  1388. }
  1389. },
  1390. 'wizard.step9.add_host.launch_start_services': {
  1391. 'real': '/clusters/{cluster}/host_components',
  1392. 'mock': '/data/wizard/deploy/5_hosts/poll_6.json',
  1393. 'format': function (data) {
  1394. return {
  1395. type: 'PUT',
  1396. async: false,
  1397. data: data.data
  1398. };
  1399. }
  1400. },
  1401. 'wizard.step9.load_log': {
  1402. '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',
  1403. 'mock': '/data/wizard/deploy/5_hosts/poll_{numPolls}.json',
  1404. 'format': function () {
  1405. return {
  1406. type: 'GET',
  1407. async: true,
  1408. dataType: 'text'
  1409. };
  1410. }
  1411. },
  1412. 'wizard.step8.delete_cluster': {
  1413. 'real': '/clusters/{name}',
  1414. 'mock': '',
  1415. 'format': function() {
  1416. return {
  1417. type: 'DELETE',
  1418. async: false
  1419. };
  1420. }
  1421. },
  1422. 'wizard.step8.existing_cluster_names': {
  1423. 'real': '/clusters',
  1424. 'mock': '',
  1425. 'format': function() {
  1426. return {
  1427. async: false
  1428. };
  1429. }
  1430. },
  1431. 'wizard.step8.create_cluster': {
  1432. 'real':'/clusters/{cluster}',
  1433. 'mock':'',
  1434. 'format': function(data) {
  1435. return {
  1436. type: 'POST',
  1437. async: true,
  1438. dataType: 'text',
  1439. data: data.data
  1440. }
  1441. }
  1442. },
  1443. 'wizard.step8.create_selected_services': {
  1444. 'real':'/clusters/{cluster}/services',
  1445. 'mock':'',
  1446. 'format': function(data) {
  1447. return {
  1448. type: 'POST',
  1449. async: true,
  1450. dataType: 'text',
  1451. data: data.data
  1452. }
  1453. }
  1454. },
  1455. 'wizard.step8.create_components': {
  1456. 'real':'/clusters/{cluster}/services?ServiceInfo/service_name={serviceName}',
  1457. 'mock':'',
  1458. 'format': function(data) {
  1459. return {
  1460. type: 'POST',
  1461. async: true,
  1462. dataType: 'text',
  1463. data: data.data
  1464. }
  1465. }
  1466. },
  1467. 'wizard.step8.register_host_to_cluster': {
  1468. 'real':'/clusters/{cluster}/hosts',
  1469. 'mock':'',
  1470. 'format': function(data) {
  1471. return {
  1472. type: 'POST',
  1473. async: true,
  1474. dataType: 'text',
  1475. data: data.data
  1476. }
  1477. }
  1478. },
  1479. 'wizard.step8.register_host_to_component': {
  1480. 'real':'/clusters/{cluster}/hosts',
  1481. 'mock':'',
  1482. 'format': function(data) {
  1483. return {
  1484. type: 'POST',
  1485. async: true,
  1486. dataType: 'text',
  1487. data: data.data
  1488. }
  1489. }
  1490. },
  1491. 'wizard.step8.apply_configuration_to_cluster': {
  1492. 'real':'/clusters/{cluster}',
  1493. 'mock':'',
  1494. 'format': function(data) {
  1495. return {
  1496. type: 'PUT',
  1497. async: true,
  1498. dataType: 'text',
  1499. data: data.data
  1500. }
  1501. }
  1502. },
  1503. 'wizard.step8.apply_configuration_groups': {
  1504. 'real':'/clusters/{cluster}/config_groups',
  1505. 'mock':'',
  1506. 'format': function(data) {
  1507. return {
  1508. type: 'POST',
  1509. async: true,
  1510. dataType: 'text',
  1511. data: data.data
  1512. }
  1513. }
  1514. },
  1515. 'wizard.step8.set_local_repos': {
  1516. 'real':'{stack2VersionURL}/operatingSystems/{osType}/repositories/{name}',
  1517. 'mock':'',
  1518. 'format': function(data) {
  1519. return {
  1520. type: 'PUT',
  1521. async: true,
  1522. dataType: 'text',
  1523. data: data.data
  1524. }
  1525. }
  1526. },
  1527. 'wizard.step3.host_info': {
  1528. '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',
  1529. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  1530. 'format': function() {
  1531. return {
  1532. contentType: 'application/json'
  1533. };
  1534. }
  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': '/stacks2',
  1555. 'mock': '/data/wizard/stack/stacks2.json',
  1556. 'format': function() {
  1557. return {
  1558. async: false
  1559. };
  1560. }
  1561. },
  1562. 'wizard.stacks_versions': {
  1563. 'real': '/stacks2/{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. async: false,
  1578. contentType: 'application/json',
  1579. data: data.bootStrapData
  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_server_version': {
  1623. 'real': '/services/AMBARI/components/AMBARI_SERVER?fields=RootServiceComponents/component_version',
  1624. 'mock': ''
  1625. },
  1626. 'ambari.service': {
  1627. 'real': '/services/AMBARI/components/AMBARI_SERVER',
  1628. 'mock': '/data/services/ambari_server.json'
  1629. },
  1630. 'ambari.service.load_server_clock': {
  1631. 'real': '/services/AMBARI/components/AMBARI_SERVER?fields=RootServiceComponents/server_clock',
  1632. 'mock': ''
  1633. },
  1634. 'config_groups.create': {
  1635. 'real': '/clusters/{clusterName}/config_groups',
  1636. 'mock': '',
  1637. 'format': function (data) {
  1638. return {
  1639. async: false,
  1640. type: 'POST',
  1641. data: JSON.stringify([{
  1642. "ConfigGroup": {
  1643. "group_name": data.group_name,
  1644. "tag": data.service_id,
  1645. "description": data.description,
  1646. "desired_configs": data.desired_configs,
  1647. "hosts": data.hosts
  1648. }
  1649. }])
  1650. }
  1651. }
  1652. },
  1653. 'config_groups.update': {
  1654. 'real': '/clusters/{clusterName}/config_groups/{id}',
  1655. 'mock': '',
  1656. 'format': function (data) {
  1657. return {
  1658. async: true,
  1659. type: 'PUT',
  1660. data: JSON.stringify(data.data)
  1661. }
  1662. }
  1663. },
  1664. 'rolling_restart.post': {
  1665. 'real': '/clusters/{clusterName}/request_schedules',
  1666. 'mock': '',
  1667. 'format' : function(data) {
  1668. return {
  1669. type : 'POST',
  1670. data : JSON.stringify([ {
  1671. "RequestSchedule" : {
  1672. "batch" : [ {
  1673. "requests" : data.batches
  1674. }, {
  1675. "batch_settings" : {
  1676. "batch_separation_in_seconds" : data.intervalTimeSeconds,
  1677. "task_failure_tolerance" : data.tolerateSize
  1678. }
  1679. } ]
  1680. }
  1681. } ])
  1682. }
  1683. }
  1684. },
  1685. 'request_schedule.delete': {
  1686. 'real': '/clusters/{clusterName}/request_schedules/{request_schedule_id}',
  1687. 'mock': '',
  1688. 'format' : function() {
  1689. return {
  1690. type : 'DELETE'
  1691. }
  1692. }
  1693. },
  1694. 'request_schedule.get': {
  1695. 'real': '/clusters/{clusterName}/request_schedules/{request_schedule_id}',
  1696. 'mock': ''
  1697. },
  1698. 'restart.hostComponents': {
  1699. 'real':'/clusters/{clusterName}/requests',
  1700. 'mock':'',
  1701. 'format': function(data) {
  1702. return {
  1703. type : 'POST',
  1704. data : JSON.stringify({
  1705. "RequestInfo": {
  1706. "command": "RESTART",
  1707. "context": data.context
  1708. },
  1709. "Requests/resource_filters": data.resource_filters
  1710. })
  1711. }
  1712. }
  1713. },
  1714. 'mirroring.get_all_entities': {
  1715. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/list/{type}?fields=status&user.name=ambari-qa',
  1716. 'mock': '/data/mirroring/{type}s.xml',
  1717. 'apiPrefix': '',
  1718. 'format': function () {
  1719. return {
  1720. dataType: 'xml'
  1721. }
  1722. }
  1723. },
  1724. 'mirroring.get_definition': {
  1725. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/definition/{type}/{name}?user.name=ambari-qa',
  1726. 'mock': '/data/mirroring/{name}_definition.xml',
  1727. 'apiPrefix': '',
  1728. 'format': function () {
  1729. return {
  1730. cache: true,
  1731. dataType: 'xml'
  1732. }
  1733. }
  1734. },
  1735. 'mirroring.dataset.get_all_instances': {
  1736. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/status/feed/{dataset}?start={start}&end={end}&user.name=ambari-qa',
  1737. 'mock': '/data/mirroring/{dataset}_instances.json',
  1738. 'apiPrefix': ''
  1739. },
  1740. 'mirroring.create_new_dataset': {
  1741. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/submitAndSchedule/feed?user.name=ambari-qa',
  1742. 'mock': '/data/mirroring/succeeded.json',
  1743. 'apiPrefix': '',
  1744. 'type': 'POST',
  1745. 'format': function (data) {
  1746. return {
  1747. contentType: 'text/xml',
  1748. dataType: 'xml',
  1749. data: data.dataset,
  1750. headers: {
  1751. 'AmbariProxy-Content-Type': 'text/xml'
  1752. }
  1753. }
  1754. }
  1755. },
  1756. 'mirroring.submit_entity': {
  1757. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/submit/{type}?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.entity,
  1766. headers: {
  1767. 'AmbariProxy-Content-Type': 'text/xml'
  1768. }
  1769. }
  1770. }
  1771. },
  1772. 'mirroring.update_entity': {
  1773. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/update/{type}/{name}?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.delete_entity': {
  1789. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/delete/{type}/{name}?user.name=ambari-qa',
  1790. 'mock': '/data/mirroring/succeeded.json',
  1791. 'apiPrefix': '',
  1792. 'type': 'DELETE',
  1793. 'format': function () {
  1794. return {
  1795. dataType: 'xml'
  1796. }
  1797. }
  1798. },
  1799. 'mirroring.suspend_entity': {
  1800. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/suspend/{type}/{name}?user.name=ambari-qa',
  1801. 'mock': '/data/mirroring/succeeded.json',
  1802. 'apiPrefix': '',
  1803. 'type': 'POST',
  1804. 'format': function (data) {
  1805. return {
  1806. dataType: 'xml',
  1807. data: data.entity
  1808. }
  1809. }
  1810. },
  1811. 'mirroring.resume_entity': {
  1812. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/resume/{type}/{name}?user.name=ambari-qa',
  1813. 'mock': '/data/mirroring/succeeded.json',
  1814. 'apiPrefix': '',
  1815. 'type': 'POST',
  1816. 'format': function () {
  1817. return {
  1818. dataType: 'xml'
  1819. }
  1820. }
  1821. },
  1822. 'mirroring.schedule_entity': {
  1823. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/schedule/{type}/{name}?user.name=ambari-qa',
  1824. 'mock': '/data/mirroring/succeeded.json',
  1825. 'apiPrefix': '',
  1826. 'type': 'POST',
  1827. 'format': function () {
  1828. return {
  1829. dataType: 'xml'
  1830. }
  1831. }
  1832. },
  1833. 'mirroring.suspend_instance': {
  1834. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/suspend/feed/{feed}?start={name}&user.name=ambari-qa',
  1835. 'mock': '/data/mirroring/succeeded.json',
  1836. 'apiPrefix': '',
  1837. 'type': 'POST'
  1838. },
  1839. 'mirroring.resume_instance': {
  1840. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/resume/feed/{feed}?start={name}&user.name=ambari-qa',
  1841. 'mock': '/data/mirroring/succeeded.json',
  1842. 'apiPrefix': '',
  1843. 'type': 'POST'
  1844. },
  1845. 'mirroring.kill_instance': {
  1846. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/kill/feed/{feed}?start={name}&user.name=ambari-qa',
  1847. 'mock': '/data/mirroring/succeeded.json',
  1848. 'apiPrefix': '',
  1849. 'type': 'POST'
  1850. },
  1851. 'bulk_request.host_components': {
  1852. 'real': '/clusters/{clusterName}/host_components',
  1853. 'mock': '',
  1854. 'format': function(data) {
  1855. return {
  1856. type: 'PUT',
  1857. data: JSON.stringify({
  1858. RequestInfo: {
  1859. context: data.requestInfo,
  1860. query: 'HostRoles/component_name=' + data.componentName + '&HostRoles/host_name.in(' + data.hostNames + ')&HostRoles/maintenance_state=OFF'
  1861. },
  1862. Body: {
  1863. HostRoles: {
  1864. state: data.state
  1865. }
  1866. }
  1867. })
  1868. }
  1869. }
  1870. },
  1871. 'bulk_request.hosts.all_components': {
  1872. 'real': '/clusters/{clusterName}/host_components',
  1873. 'mock': '',
  1874. 'format': function(data) {
  1875. return {
  1876. type: 'PUT',
  1877. data: JSON.stringify({
  1878. RequestInfo: {
  1879. context: data.requestInfo,
  1880. query: data.query
  1881. },
  1882. Body: {
  1883. HostRoles: {
  1884. state: data.state
  1885. }
  1886. }
  1887. })
  1888. }
  1889. }
  1890. },
  1891. 'bulk_request.decommission': {
  1892. 'real' : '/clusters/{clusterName}/requests',
  1893. 'mock' : '',
  1894. 'format': function(data) {
  1895. return {
  1896. type: 'POST',
  1897. data: JSON.stringify({
  1898. 'RequestInfo': {
  1899. 'context': data.context,
  1900. 'command': 'DECOMMISSION',
  1901. 'parameters': data.parameters
  1902. },
  1903. "Requests/resource_filters": [{"service_name" : data.serviceName, "component_name" : data.componentName}]
  1904. })
  1905. }
  1906. }
  1907. },
  1908. 'bulk_request.hosts.passive_state': {
  1909. 'real': '/clusters/{clusterName}/hosts',
  1910. 'mock': '',
  1911. 'format': function(data) {
  1912. return {
  1913. type: 'PUT',
  1914. data: JSON.stringify({
  1915. RequestInfo: {
  1916. context: data.requestInfo,
  1917. query: 'Hosts/host_name.in(' + data.hostNames + ')'
  1918. },
  1919. Body: {
  1920. Hosts: {
  1921. maintenance_state: data.passive_state
  1922. }
  1923. }
  1924. })
  1925. }
  1926. }
  1927. },
  1928. 'bulk_request.hosts.all_components.passive_state': {
  1929. 'real': '/clusters/{clusterName}/host_components',
  1930. 'mock': '',
  1931. 'format': function(data) {
  1932. return {
  1933. type: 'PUT',
  1934. data: JSON.stringify({
  1935. RequestInfo: {
  1936. context: data.requestInfo,
  1937. query: data.query
  1938. },
  1939. Body: {
  1940. HostRoles: {
  1941. maintenance_state: data.passive_state
  1942. }
  1943. }
  1944. })
  1945. }
  1946. }
  1947. },
  1948. 'jobs.lastID': {
  1949. 'real': '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/HIVE_QUERY_ID?limit=1&secondaryFilter=tez:true',
  1950. 'mock': 'data/jobs/hive-queries.json',
  1951. 'apiPrefix': ''
  1952. },
  1953. 'jobs.tezDag.NametoID': {
  1954. 'real': '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/TEZ_DAG_ID?primaryFilter=dagName:{tezDagName}',
  1955. 'mock': '/data/jobs/tezDag-name-to-id.json',
  1956. 'apiPrefix': ''
  1957. },
  1958. 'jobs.tezDag.tezDagId': {
  1959. 'real': '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/TEZ_DAG_ID/{tezDagId}?fields=relatedentities,otherinfo',
  1960. 'mock': '/data/jobs/tezDag.json',
  1961. 'apiPrefix': ''
  1962. },
  1963. 'jobs.tezDag.tezDagVertexId': {
  1964. 'real': '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/TEZ_VERTEX_ID/{tezDagVertexId}?fields=otherinfo',
  1965. 'mock': '/data/jobs/tezDagVertex.json',
  1966. 'apiPrefix': ''
  1967. },
  1968. 'views.info': {
  1969. 'real': '/views',
  1970. 'mock':''
  1971. },
  1972. 'views.instances': {
  1973. 'real': '/views/{viewName}',
  1974. 'mock':''
  1975. }
  1976. };
  1977. /**
  1978. * Replace data-placeholders to its values
  1979. *
  1980. * @param {String} url
  1981. * @param {Object} data
  1982. * @return {String}
  1983. */
  1984. var formatUrl = function (url, data) {
  1985. if (!url) return null;
  1986. var keys = url.match(/\{\w+\}/g);
  1987. keys = (keys === null) ? [] : keys;
  1988. if (keys) {
  1989. keys.forEach(function (key) {
  1990. var raw_key = key.substr(1, key.length - 2);
  1991. var replace;
  1992. if (!data || !data[raw_key]) {
  1993. replace = '';
  1994. }
  1995. else {
  1996. replace = data[raw_key];
  1997. }
  1998. url = url.replace(new RegExp(key, 'g'), replace);
  1999. });
  2000. }
  2001. return url;
  2002. };
  2003. /**
  2004. * this = object from config
  2005. * @return {Object}
  2006. */
  2007. var formatRequest = function (data) {
  2008. var opt = {
  2009. type: this.type || 'GET',
  2010. timeout: App.timeout,
  2011. dataType: 'json',
  2012. statusCode: require('data/statusCodes')
  2013. };
  2014. if (App.testMode) {
  2015. opt.url = formatUrl(this.mock ? this.mock : '', data);
  2016. opt.type = 'GET';
  2017. }
  2018. else {
  2019. var prefix = this.apiPrefix != null ? this.apiPrefix : App.apiPrefix;
  2020. opt.url = prefix + formatUrl(this.real, data);
  2021. }
  2022. if (this.format) {
  2023. jQuery.extend(opt, this.format(data, opt));
  2024. }
  2025. return opt;
  2026. };
  2027. /**
  2028. * Wrapper for all ajax requests
  2029. *
  2030. * @type {Object}
  2031. */
  2032. var ajax = Em.Object.extend({
  2033. /**
  2034. * Send ajax request
  2035. *
  2036. * @param {Object} config
  2037. * @return {$.ajax} jquery ajax object
  2038. *
  2039. * config fields:
  2040. * name - url-key in the urls-object *required*
  2041. * sender - object that send request (need for proper callback initialization) *required*
  2042. * data - object with data for url-format
  2043. * beforeSend - method-name for ajax beforeSend response callback
  2044. * success - method-name for ajax success response callback
  2045. * error - method-name for ajax error response callback
  2046. * callback - callback from <code>App.updater.run</code> library
  2047. */
  2048. send: function (config) {
  2049. console.warn('============== ajax ==============', config.name, config.data);
  2050. if (!config.sender) {
  2051. console.warn('Ajax sender should be defined!');
  2052. return null;
  2053. }
  2054. // default parameters
  2055. var params = {
  2056. clusterName: App.get('clusterName')
  2057. };
  2058. // extend default parameters with provided
  2059. if (config.data) {
  2060. jQuery.extend(params, config.data);
  2061. }
  2062. var opt = {};
  2063. if (!urls[config.name]) {
  2064. console.warn('Invalid name provided!');
  2065. return null;
  2066. }
  2067. opt = formatRequest.call(urls[config.name], params);
  2068. opt.context = this;
  2069. // object sender should be provided for processing beforeSend, success and error responses
  2070. opt.beforeSend = function (xhr) {
  2071. if (config.beforeSend) {
  2072. config.sender[config.beforeSend](opt, xhr, params);
  2073. }
  2074. };
  2075. opt.success = function (data) {
  2076. console.log("TRACE: The url is: " + opt.url);
  2077. if (config.success) {
  2078. config.sender[config.success](data, opt, params);
  2079. }
  2080. };
  2081. opt.error = function (request, ajaxOptions, error) {
  2082. if (config.error) {
  2083. config.sender[config.error](request, ajaxOptions, error, opt, params);
  2084. } else {
  2085. this.defaultErrorHandler(request, opt.url, opt.type);
  2086. }
  2087. };
  2088. opt.complete = function () {
  2089. if (config.callback) {
  2090. config.callback();
  2091. }
  2092. };
  2093. if ($.mocho) {
  2094. opt.url = 'http://' + $.hostName + opt.url;
  2095. }
  2096. return $.ajax(opt);
  2097. },
  2098. // A single instance of App.ModalPopup view
  2099. modalPopup: null,
  2100. /**
  2101. * defaultErrorHandler function is referred from App.ajax.send function and App.HttpClient.defaultErrorHandler function
  2102. * @jqXHR {jqXHR Object}
  2103. * @url {string}
  2104. * @method {String} Http method
  2105. * @showStatus {number} HTTP response code which should be shown. Default is 500.
  2106. */
  2107. defaultErrorHandler: function (jqXHR, url, method, showStatus) {
  2108. method = method || 'GET';
  2109. var self = this;
  2110. var api = " received on " + method + " method for API: " + url;
  2111. try {
  2112. var json = $.parseJSON(jqXHR.responseText);
  2113. var message = json.message;
  2114. } catch (err) {
  2115. }
  2116. if (!showStatus) {
  2117. showStatus = 500;
  2118. }
  2119. var statusCode = jqXHR.status + " status code";
  2120. if (jqXHR.status === showStatus && !this.modalPopup) {
  2121. this.modalPopup = App.ModalPopup.show({
  2122. header: jqXHR.statusText,
  2123. secondary: false,
  2124. onPrimary: function () {
  2125. this.hide();
  2126. self.modalPopup = null;
  2127. },
  2128. bodyClass: Ember.View.extend({
  2129. classNames: ['api-error'],
  2130. templateName: require('templates/utils/ajax'),
  2131. api: api,
  2132. statusCode: statusCode,
  2133. message: message,
  2134. showMessage: !!message
  2135. })
  2136. });
  2137. }
  2138. }
  2139. });
  2140. /**
  2141. * Add few access-methods for test purposes
  2142. */
  2143. if ($.mocho) {
  2144. ajax.reopen({
  2145. /**
  2146. * Don't use it anywhere except tests!
  2147. * @returns {Array}
  2148. */
  2149. fakeGetUrlNames: function() {
  2150. return Em.keys(urls);
  2151. },
  2152. /**
  2153. * Don't use it anywhere except tests!
  2154. * @param name
  2155. * @returns {*}
  2156. */
  2157. fakeGetUrl: function(name) {
  2158. return urls[name];
  2159. },
  2160. /**
  2161. * Don't use it anywhere except tests!
  2162. * @param url
  2163. * @param data
  2164. * @returns {String}
  2165. */
  2166. fakeFormatUrl: function(url, data) {
  2167. return formatUrl(url, data);
  2168. },
  2169. /**
  2170. * Don't use it anywhere except tests!
  2171. * @param urlObj
  2172. * @param data
  2173. * @returns {Object}
  2174. */
  2175. fakeFormatRequest: function(urlObj, data) {
  2176. return formatRequest.call(urlObj, data);
  2177. }
  2178. });
  2179. }
  2180. App.ajax = ajax.create({});