ajax.js 80 KB

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