ajax.js 81 KB

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