ajax.js 83 KB

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