ajax.js 85 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. /**
  20. * Config for each ajax-request
  21. *
  22. * Fields example:
  23. * mock - testMode url
  24. * real - real url (without API prefix)
  25. * type - request type (also may be defined in the format method)
  26. * format - function for processing ajax params after default formatRequest. May be called with one or two parameters (data, opt). Return ajax-params object
  27. * testInProduction - can this request be executed on production tests (used only in tests)
  28. *
  29. * @type {Object}
  30. */
  31. var urls = {
  32. 'common.services.update' : {
  33. 'real': '/clusters/{clusterName}/services?{urlParams}',
  34. 'mock': '/data/wizard/deploy/poll_1.json',
  35. 'format': function (data) {
  36. return {
  37. type: 'PUT',
  38. data: JSON.stringify({
  39. RequestInfo: {
  40. "context": data.context,
  41. "operation_level": {
  42. "level": "CLUSTER",
  43. "cluster_name" : data.clusterName
  44. }
  45. },
  46. Body: {
  47. ServiceInfo: data.ServiceInfo
  48. }
  49. })
  50. };
  51. }
  52. },
  53. 'common.service.update' : {
  54. 'real': '/clusters/{clusterName}/services/{serviceName}',
  55. 'mock': '/data/wizard/deploy/poll_1.json',
  56. 'format': function (data) {
  57. return {
  58. type: 'PUT',
  59. data: JSON.stringify({
  60. RequestInfo: {
  61. "context": data.context,
  62. "operation_level": {
  63. "level": "SERVICE",
  64. "cluster_name" : data.clusterName,
  65. "service_name" : data.serviceName
  66. }
  67. },
  68. Body: {
  69. ServiceInfo: data.ServiceInfo
  70. }
  71. })
  72. };
  73. }
  74. },
  75. 'common.service_component.info' : {
  76. 'real': '/clusters/{clusterName}/services/{serviceName}/components/{componentName}?{urlParams}',
  77. 'mock': '/data/wizard/deploy/poll_1.json'
  78. },
  79. 'common.host_component.update': {
  80. 'real': '/clusters/{clusterName}/host_components',
  81. 'mock': '',
  82. 'type': 'PUT',
  83. 'format': function (data) {
  84. return {
  85. data: JSON.stringify({
  86. RequestInfo: {
  87. context: data.context,
  88. query: data.query
  89. },
  90. Body: {
  91. "HostRoles": data.HostRoles
  92. }
  93. })
  94. }
  95. }
  96. },
  97. 'common.host.host_components.update': {
  98. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components?{urlParams}',
  99. 'mock': '',
  100. 'type': 'PUT',
  101. 'format': function (data) {
  102. return {
  103. data: JSON.stringify({
  104. RequestInfo: {
  105. "context": data.context,
  106. "operation_level": {
  107. level: "HOST",
  108. cluster_name: data.clusterName,
  109. host_names: data.hostName
  110. },
  111. query: data.query
  112. },
  113. Body: {
  114. "HostRoles": data.HostRoles
  115. }
  116. })
  117. }
  118. }
  119. },
  120. 'common.host.host_component.update': {
  121. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}?{urlParams}',
  122. 'mock': '/data/wizard/deploy/2_hosts/poll_9.json',
  123. 'type': 'PUT',
  124. 'format': function (data) {
  125. return {
  126. data: JSON.stringify({
  127. RequestInfo: {
  128. "context": data.context,
  129. "operation_level": {
  130. level: "HOST_COMPONENT",
  131. cluster_name: data.clusterName,
  132. host_name: data.hostName,
  133. service_name: data.serviceName || null
  134. }
  135. },
  136. Body: {
  137. "HostRoles": data.HostRoles
  138. }
  139. })
  140. }
  141. }
  142. },
  143. 'common.service.configurations': {
  144. 'real':'/clusters/{clusterName}',
  145. 'mock':'',
  146. 'format': function (data) {
  147. return {
  148. type: 'PUT',
  149. data: JSON.stringify({
  150. Clusters: {
  151. desired_config: data.desired_config
  152. }
  153. })
  154. }
  155. }
  156. },
  157. 'common.across.services.configurations': {
  158. 'type': 'PUT',
  159. 'real':'/clusters/{clusterName}',
  160. 'mock':'/data/services/ambari.json',
  161. 'format': function(data) {
  162. return {
  163. dataType: 'text',
  164. data: data.data
  165. }
  166. }
  167. },
  168. 'service.ambari': {
  169. 'real': '/services/AMBARI?fields=components/RootServiceComponents',
  170. 'mock': '/data/services/ambari.json'
  171. },
  172. 'service.flume.agent.command': {
  173. 'real': '/clusters/{clusterName}/hosts/{host}/host_components/FLUME_HANDLER',
  174. 'mock': '',
  175. 'format': function (data) {
  176. return {
  177. type: 'PUT',
  178. data: JSON.stringify({
  179. "RequestInfo": {
  180. "context": data.context,
  181. "flume_handler": data.agentName,
  182. "operation_level": {
  183. level: "HOST_COMPONENT",
  184. cluster_name: data.clusterName,
  185. service_name: "FLUME",
  186. host_name: data.host
  187. }
  188. },
  189. "Body": {
  190. "HostRoles": {
  191. "state": data.state
  192. }
  193. }
  194. })
  195. }
  196. }
  197. },
  198. 'common.host_components.update': {
  199. 'real': '/clusters/{clusterName}/host_components?{urlParams}',
  200. 'mock': '/data/wizard/deploy/poll_1.json',
  201. 'type': 'PUT',
  202. 'format': function (data) {
  203. return {
  204. data: JSON.stringify({
  205. RequestInfo: {
  206. "context": data.context,
  207. "operation_level": {
  208. level: data.level || "CLUSTER",
  209. cluster_name: data.clusterName
  210. },
  211. query: data.query
  212. },
  213. Body: {
  214. "HostRoles": data.HostRoles
  215. }
  216. })
  217. }
  218. }
  219. },
  220. 'common.service.passive': {
  221. 'real': '/clusters/{clusterName}/services/{serviceName}',
  222. 'mock': '',
  223. 'format': function (data) {
  224. return {
  225. type: 'PUT',
  226. data: JSON.stringify({
  227. RequestInfo: {
  228. "context": data.requestInfo
  229. },
  230. Body: {
  231. ServiceInfo: {
  232. maintenance_state: data.passive_state
  233. }
  234. }
  235. })
  236. };
  237. }
  238. },
  239. 'common.host.host_component.passive': {
  240. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  241. 'mock': '',
  242. 'type': 'PUT',
  243. 'format': function (data) {
  244. return {
  245. data: JSON.stringify({
  246. RequestInfo: {
  247. "context": data.context
  248. },
  249. Body: {
  250. HostRoles: {
  251. maintenance_state: data.passive_state
  252. }
  253. }
  254. })
  255. };
  256. }
  257. },
  258. 'common.host.with_host_component': {
  259. 'real': '/clusters/{clusterName}/hosts?host_components/HostRoles/component_name={componentName}&minimal_response=true',
  260. 'mock': ''
  261. },
  262. 'common.delete.host': {
  263. 'real': '/clusters/{clusterName}/hosts/{hostName}',
  264. 'type': 'DELETE'
  265. },
  266. 'common.delete.host_component': {
  267. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  268. 'type': 'DELETE'
  269. },
  270. 'common.delete.user': {
  271. 'real': '/users/{user}',
  272. 'type': 'DELETE'
  273. },
  274. 'common.delete.config_group': {
  275. 'real': '/clusters/{clusterName}/config_groups/{id}',
  276. 'type': 'DELETE'
  277. },
  278. 'common.delete.cluster': {
  279. 'real': '/clusters/{name}',
  280. 'type': 'DELETE'
  281. },
  282. 'common.delete.service': {
  283. 'real': '/clusters/{clusterName}/services/{serviceName}',
  284. 'mock': '/data/services/ambari.json',
  285. 'type': 'DELETE'
  286. },
  287. 'common.delete.request_schedule': {
  288. 'real': '/clusters/{clusterName}/request_schedules/{request_schedule_id}',
  289. 'type': 'DELETE'
  290. },
  291. 'alerts.load_alert_notification': {
  292. 'real': '/alert_targets?fields=*',
  293. 'mock': 'data/alerts/alertNotifications.json'
  294. },
  295. 'alerts.load_alert_groups': {
  296. 'real': '/clusters/{clusterName}/alert_groups?fields=*',
  297. 'mock': 'data/alerts/alertGroups.json'
  298. },
  299. 'alerts.load_an_alert_group': {
  300. 'real': '/clusters/{clusterName}/alert_groups/{group_id}',
  301. 'mock': 'data/alerts/alertGroup.json'
  302. },
  303. 'alert_groups.create': {
  304. 'real': '/clusters/{clusterName}/alert_groups',
  305. 'mock': '',
  306. 'format': function (data) {
  307. return {
  308. type: 'POST',
  309. data: JSON.stringify({
  310. "AlertGroup": {
  311. "name": data.name,
  312. "definitions": data.definitions,
  313. "targets": data.targets
  314. }
  315. })
  316. };
  317. }
  318. },
  319. 'alert_groups.update': {
  320. 'real': '/clusters/{clusterName}/alert_groups/{group_id}',
  321. 'mock': '',
  322. 'format': function (data) {
  323. return {
  324. type: 'PUT',
  325. data: JSON.stringify({
  326. "AlertGroup": {
  327. "name": data.name,
  328. "definitions": data.definitions,
  329. "targets": data.targets
  330. }
  331. })
  332. };
  333. }
  334. },
  335. 'alert_groups.delete': {
  336. 'real': '/clusters/{clusterName}/alert_groups/{group_id}',
  337. 'mock': '',
  338. 'format': function (data) {
  339. return {
  340. type: 'DELETE'
  341. };
  342. }
  343. },
  344. 'alerts.load_all_alert_definitions': {
  345. 'real': '/clusters/{clusterName}/alert_definitions?fields=*',
  346. 'mock': 'data/alerts/alertDefinitions.json'
  347. },
  348. 'alerts.instances': {
  349. 'real': '/clusters/{clusterName}/alerts?fields=*',
  350. 'mock': '/data/alerts/alert_instances.json'
  351. },
  352. 'alerts.notifications': {
  353. 'real': '/alert_targets?fields=*',
  354. 'mock': '/data/alerts/alertNotifications.json'
  355. },
  356. 'alerts.instances.by_definition': {
  357. 'real': '/clusters/{clusterName}/alerts?fields=*&(Alert/definition_id={definitionId}|Alert/state.in(CRITICAL,WARNING))',
  358. 'mock': '/data/alerts/alert_instances.json'
  359. },
  360. 'alerts.instances.by_host': {
  361. 'real': '/clusters/{clusterName}/alerts?fields=*&(Alert/host_name={hostName}|Alert/state.in(CRITICAL,WARNING))',
  362. 'mock': '/data/alerts/alert_instances.json'
  363. },
  364. 'alerts.update_alert_definition': {
  365. 'real': '/clusters/{clusterName}/alert_definitions/{id}',
  366. 'mock': '',
  367. 'format': function (data) {
  368. return {
  369. type: 'PUT',
  370. data: JSON.stringify(data.data)
  371. }
  372. }
  373. },
  374. 'alerts.create_alert_definition': {
  375. 'real': '/clusters/{clusterName}/alert_definitions/',
  376. 'mock': '',
  377. 'format': function (data) {
  378. return {
  379. type: 'POST',
  380. data: JSON.stringify(data.data)
  381. }
  382. }
  383. },
  384. 'alerts.delete_alert_definition': {
  385. 'real': '/clusters/{clusterName}/alert_definitions/{id}',
  386. 'mock': '',
  387. 'type': 'DELETE'
  388. },
  389. 'alerts.create_alert_notification': {
  390. 'real': '/alert_targets',
  391. 'mock': '',
  392. 'format': function (data) {
  393. return {
  394. type: 'POST',
  395. data: JSON.stringify(data.data)
  396. }
  397. }
  398. },
  399. 'alerts.update_alert_notification': {
  400. 'real': '/alert_targets/{id}',
  401. 'mock': '',
  402. 'format': function (data) {
  403. return {
  404. type: 'PUT',
  405. data: JSON.stringify(data.data)
  406. }
  407. }
  408. },
  409. 'alerts.delete_alert_notification': {
  410. 'real': '/alert_targets/{id}',
  411. 'mock': '',
  412. 'type': 'DELETE'
  413. },
  414. 'alerts.get_instances_history': {
  415. 'real': '/clusters/{clusterName}/alert_history?(AlertHistory/definition_name={definitionName})&(AlertHistory/timestamp>={timestamp})',
  416. 'mock': '/data/alerts/alert_instances_history.json'
  417. },
  418. 'background_operations.get_most_recent': {
  419. 'real': '/clusters/{clusterName}/requests?to=end&page_size={operationsCount}&fields=Requests',
  420. 'mock': '/data/background_operations/list_on_start.json',
  421. 'testInProduction': true
  422. },
  423. 'background_operations.get_by_request': {
  424. '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',
  425. 'mock': '/data/background_operations/task_by_request{requestId}.json',
  426. 'testInProduction': true
  427. },
  428. 'background_operations.get_by_task': {
  429. 'real': '/clusters/{clusterName}/requests/{requestId}/tasks/{taskId}',
  430. 'mock': '/data/background_operations/list_on_start.json',
  431. 'testInProduction': true
  432. },
  433. 'background_operations.abort_request': {
  434. 'real': '/clusters/{clusterName}/requests/{requestId}',
  435. 'mock': '',
  436. 'format': function () {
  437. return {
  438. type: 'PUT',
  439. data: JSON.stringify({
  440. "Requests": {
  441. "request_status": "ABORTED",
  442. "abort_reason": Em.I18n.t('hostPopup.bgop.abortRequest.reason')
  443. }
  444. })
  445. };
  446. }
  447. },
  448. 'service.item.smoke': {
  449. 'real': '/clusters/{clusterName}/requests',
  450. 'mock': '/data/wizard/deploy/poll_1.json',
  451. 'format': function (data) {
  452. return {
  453. 'type': 'POST',
  454. data: JSON.stringify({
  455. "RequestInfo": {
  456. "context": data.displayName + " Service Check",
  457. "command": data.actionName
  458. },
  459. "Requests/resource_filters": [{"service_name": data.serviceName}]
  460. })
  461. };
  462. }
  463. },
  464. 'service.item.rebalanceHdfsNodes': {
  465. 'real': '/clusters/{clusterName}/requests',
  466. 'mock': '',
  467. 'format': function (data) {
  468. return {
  469. type: 'POST',
  470. data: JSON.stringify({
  471. RequestInfo: {
  472. 'context': Em.I18n.t('services.service.actions.run.rebalanceHdfsNodes.context'),
  473. 'command': 'REBALANCEHDFS',
  474. 'namenode': JSON.stringify({threshold: data.threshold})
  475. },
  476. "Requests/resource_filters": [{
  477. 'service_name': 'HDFS',
  478. 'component_name': 'NAMENODE',
  479. 'hosts': data.hosts
  480. }]
  481. })
  482. }
  483. }
  484. },
  485. 'cancel.background.operation': {
  486. 'real': '/clusters/{clusterName}/requests/{requestId}',
  487. 'mock': '',
  488. 'format': function (data) {
  489. return {
  490. type: 'PUT',
  491. data: JSON.stringify({
  492. RequestInfo: {
  493. 'context': 'Cancel operation',
  494. "parameters": {
  495. "cancel_policy": "SIGKILL"
  496. }
  497. },
  498. "Requests/request_status": 'ABORTED',
  499. "Requests/abort_reason": "Cancel background operation"
  500. })
  501. }
  502. }
  503. },
  504. 'service.item.refreshQueueYarnRequest': {
  505. 'real': '/clusters/{clusterName}/requests',
  506. 'mock': '',
  507. 'format': function (data) {
  508. return {
  509. type: 'POST',
  510. data: JSON.stringify({
  511. RequestInfo: {
  512. 'context': data.context,
  513. 'command': data.command,
  514. 'parameters/forceRefreshConfigTags': data.forceRefreshConfigTags
  515. },
  516. "Requests/resource_filters": [{
  517. "service_name": data.serviceName,
  518. "component_name": data.componentName,
  519. 'hosts': data.hosts
  520. }]
  521. })
  522. }
  523. }
  524. },
  525. 'service.item.startStopLdapKnox': {
  526. 'real': '/clusters/{clusterName}/requests',
  527. 'mock': '',
  528. 'format': function (data) {
  529. return {
  530. type: 'POST',
  531. data: JSON.stringify({
  532. RequestInfo: {
  533. 'context': data.context,
  534. 'command': data.command
  535. },
  536. "Requests/resource_filters": [{
  537. "service_name": data.serviceName,
  538. "component_name": data.componentName,
  539. 'hosts': data.host
  540. }]
  541. })
  542. }
  543. }
  544. },
  545. 'service.item.executeCustomCommand': {
  546. 'real': '/clusters/{clusterName}/requests',
  547. 'mock': '',
  548. 'format': function (data) {
  549. return {
  550. type: 'POST',
  551. data: JSON.stringify({
  552. RequestInfo: {
  553. 'context': data.context,
  554. 'command': data.command
  555. },
  556. "Requests/resource_filters": [{
  557. "service_name": data.serviceName,
  558. "component_name": data.componentName,
  559. 'hosts': data.hosts
  560. }]
  561. })
  562. }
  563. }
  564. },
  565. 'service.load_config_groups': {
  566. 'real': '/clusters/{clusterName}/config_groups?ConfigGroup/tag={serviceName}&fields=*',
  567. 'mock': '/data/configurations/config_group.json'
  568. },
  569. 'reassign.load_configs': {
  570. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  571. 'mock': ''
  572. },
  573. 'reassign.save_configs': {
  574. 'real': '/clusters/{clusterName}',
  575. 'mock': '',
  576. 'type': 'PUT',
  577. 'format': function (data) {
  578. return {
  579. data: JSON.stringify({
  580. Clusters: {
  581. desired_config: {
  582. "type": data.siteName,
  583. "tag": 'version' + (new Date).getTime(),
  584. "properties": data.properties,
  585. "service_config_version_note": data.service_config_version_note
  586. }
  587. }
  588. })
  589. }
  590. }
  591. },
  592. 'config.cluster': {
  593. 'real': '{stackVersionUrl}/configurations?fields=*',
  594. 'mock': ''
  595. },
  596. 'config.advanced': {
  597. 'real': '{stackVersionUrl}/services/{serviceName}/configurations?fields=*',
  598. 'mock': '/data/wizard/stack/hdp/version{stackVersion}/{serviceName}.json'
  599. },
  600. 'config.advanced.partial': {
  601. 'real': '{stackVersionUrl}/services/?StackServices/service_name.in({serviceList})&fields=configurations/*{queryFilter}',
  602. 'mock': ''
  603. },
  604. 'config.config_types': {
  605. 'real': '{stackVersionUrl}/services/{serviceName}?fields=StackServices/config_types',
  606. 'mock': ''
  607. },
  608. 'config.tags': {
  609. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  610. 'mock': '/data/clusters/cluster.json'
  611. },
  612. 'config.tags_and_groups': {
  613. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs,config_groups/*{urlParams}',
  614. 'mock': '/data/clusters/tags_and_groups.json'
  615. },
  616. 'config.ambari.database.info': {
  617. 'real': '/services/AMBARI/components/AMBARI_SERVER?fields=hostComponents/RootServiceHostComponents/properties/server.jdbc.database_name,hostComponents/RootServiceHostComponents/properties/server.jdbc.url',
  618. 'mock': ''
  619. },
  620. 'config_groups.all_fields': {
  621. 'real': '/clusters/{clusterName}/config_groups?fields=*',
  622. 'mock': ''
  623. },
  624. 'config_groups.get_config_group_by_id': {
  625. 'real': '/clusters/{clusterName}/config_groups/{id}',
  626. 'mock': ''
  627. },
  628. 'config_groups.update_config_group': {
  629. 'real': '/clusters/{clusterName}/config_groups/{id}',
  630. 'mock': '',
  631. 'type': 'PUT',
  632. 'format': function (data) {
  633. return {
  634. data: JSON.stringify(
  635. [
  636. data.configGroup
  637. ]
  638. )
  639. }
  640. }
  641. },
  642. 'config.on_site': {
  643. 'real': '/clusters/{clusterName}/configurations?{params}',
  644. 'mock': '/data/configurations/cluster_level_configs.json?{params}'
  645. },
  646. 'config.host_overrides': {
  647. 'real': '/clusters/{clusterName}/configurations?{params}',
  648. 'mock': '/data/configurations/host_level_overrides_configs.json?{params}'
  649. },
  650. 'config.cluster_env_site': {
  651. 'real': '/clusters/{clusterName}/configurations?type=cluster-env',
  652. 'mock': '/data/configuration/cluster_env_site.json'
  653. },
  654. 'host.host_component.add_new_component': {
  655. 'real': '/clusters/{clusterName}/hosts?Hosts/host_name={hostName}',
  656. 'mock': '/data/wizard/deploy/poll_1.json',
  657. 'format': function (data) {
  658. return {
  659. type: 'POST',
  660. data: data.data
  661. }
  662. }
  663. },
  664. 'host.host_component.slave_desired_admin_state': {
  665. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}/?fields=HostRoles/desired_admin_state',
  666. 'mock': '/data/hosts/HDP2/decommission_state.json'
  667. },
  668. 'host.host_component.decommission_status': {
  669. 'real': '/clusters/{clusterName}/services/{serviceName}/components/{componentName}/?fields=ServiceComponentInfo,host_components/HostRoles/state',
  670. 'mock': ''
  671. },
  672. 'host_components.hbase_regionserver.active': {
  673. 'real': '/clusters/{clusterName}/host_components?HostRoles/component_name=HBASE_REGIONSERVER&HostRoles/maintenance_state=OFF&HostRoles/desired_admin_state=INSERVICE&HostRoles/host_name.in({hostNames})',
  674. 'mock': ''
  675. },
  676. 'host.host_component.decommission_status_datanode': {
  677. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}?fields=metrics/dfs/namenode',
  678. 'mock': '/data/hosts/HDP2/decommission_state.json'
  679. },
  680. 'host.region_servers.in_inservice': {
  681. 'real': '/clusters/{clusterName}/host_components?HostRoles/component_name=HBASE_REGIONSERVER&HostRoles/desired_admin_state=INSERVICE&fields=HostRoles/host_name&minimal_response=true',
  682. 'mock': ''
  683. },
  684. 'host.host_component.decommission_slave': {
  685. 'real': '/clusters/{clusterName}/requests',
  686. 'mock': '',
  687. 'format': function (data) {
  688. return {
  689. type: 'POST',
  690. data: JSON.stringify({
  691. RequestInfo: {
  692. 'context': data.context,
  693. 'command': data.command,
  694. 'parameters': {
  695. 'slave_type': data.slaveType,
  696. 'excluded_hosts': data.hostName
  697. },
  698. 'operation_level': {
  699. level: "HOST_COMPONENT",
  700. cluster_name: data.clusterName,
  701. host_name: data.hostName,
  702. service_name: data.serviceName
  703. }
  704. },
  705. "Requests/resource_filters": [{"service_name": data.serviceName, "component_name": data.componentName}]
  706. })
  707. }
  708. }
  709. },
  710. 'host.host_component.recommission_and_restart': {
  711. 'real': '/clusters/{clusterName}/request_schedules',
  712. 'mock': '',
  713. 'format': function (data) {
  714. return {
  715. type: 'POST',
  716. data: JSON.stringify([{
  717. "RequestSchedule": {
  718. "batch": [{
  719. "requests": data.batches
  720. }, {
  721. "batch_settings": {
  722. "batch_separation_in_seconds": data.intervalTimeSeconds,
  723. "task_failure_tolerance": data.tolerateSize
  724. }
  725. }]
  726. }
  727. }])
  728. }
  729. }
  730. },
  731. 'host.host_component.refresh_configs': {
  732. 'real': '/clusters/{clusterName}/requests',
  733. 'mock': '',
  734. 'format': function (data) {
  735. return {
  736. type: 'POST',
  737. data: JSON.stringify({
  738. "RequestInfo": {
  739. "command": "CONFIGURE",
  740. "context": data.context
  741. },
  742. "Requests/resource_filters": data.resource_filters
  743. })
  744. }
  745. }
  746. },
  747. 'hosts.metrics': {
  748. 'real': '/clusters/{clusterName}/hosts?fields={metricName}',
  749. 'mock': '/data/cluster_metrics/cpu_1hr.json'
  750. },
  751. 'hosts.metrics.host_component': {
  752. 'real': '/clusters/{clusterName}/services/{serviceName}/components/{componentName}?fields=host_components/{metricName}',
  753. 'mock': '/data/cluster_metrics/cpu_1hr.json'
  754. },
  755. 'service.metrics.flume.channel_fill_percent': {
  756. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/flume/flume/CHANNEL/*/ChannelFillPercentage[{fromSeconds},{toSeconds},{stepSeconds}]',
  757. 'mock': '/data/services/metrics/flume/channelFillPct.json',
  758. 'testInProduction': true
  759. },
  760. 'service.metrics.flume.channel_size': {
  761. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/flume/flume/CHANNEL/*/ChannelSize[{fromSeconds},{toSeconds},{stepSeconds}]',
  762. 'mock': '/data/services/metrics/flume/channelSize.json',
  763. 'testInProduction': true
  764. },
  765. 'service.metrics.flume.sink_drain_success': {
  766. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/flume/flume/SINK/*/EventDrainSuccessCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  767. 'mock': '/data/services/metrics/flume/sinkDrainSuccessCount.json',
  768. 'testInProduction': true
  769. },
  770. 'service.metrics.flume.sink_connection_failed': {
  771. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/flume/flume/SINK/*/ConnectionFailedCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  772. 'mock': '/data/services/metrics/flume/sinkConnectionFailedCount.json',
  773. 'testInProduction': true
  774. },
  775. 'service.metrics.flume.source_accepted': {
  776. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/flume/flume/SOURCE/*/EventAcceptedCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  777. 'mock': '/data/services/metrics/flume/sourceEventAccepted.json',
  778. 'testInProduction': true
  779. },
  780. 'service.metrics.flume.channel_size_for_all': {
  781. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=metrics/flume/flume/CHANNEL/ChannelSize/_sum[{fromSeconds},{toSeconds},{stepSeconds}]'
  782. },
  783. 'service.metrics.flume.gc': {
  784. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  785. 'mock': '/data/services/metrics/flume/jvmGcTime.json',
  786. 'testInProduction': true
  787. },
  788. 'service.metrics.flume.jvm_heap_used': {
  789. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/jvm/memHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}]',
  790. 'mock': '/data/services/metrics/flume/jvmMemHeapUsedM.json',
  791. 'testInProduction': true
  792. },
  793. 'service.metrics.flume.jvm_threads_runnable': {
  794. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/jvm/threadsRunnable[{fromSeconds},{toSeconds},{stepSeconds}]',
  795. 'mock': '/data/services/metrics/flume/jvmThreadsRunnable.json',
  796. 'testInProduction': true
  797. },
  798. 'service.metrics.flume.cpu_user': {
  799. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/cpu/cpu_user[{fromSeconds},{toSeconds},{stepSeconds}]',
  800. 'mock': '',
  801. 'testInProduction': true
  802. },
  803. 'service.metrics.flume.incoming_event_put_successCount': {
  804. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=metrics/flume/flume/CHANNEL/EventPutSuccessCount/rate[{fromSeconds},{toSeconds},{stepSeconds}]'
  805. },
  806. 'service.metrics.flume.outgoing_event_take_success_count': {
  807. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=metrics/flume/flume/CHANNEL/EventTakeSuccessCount/rate[{fromSeconds},{toSeconds},{stepSeconds}]'
  808. },
  809. 'service.metrics.hbase.cluster_requests': {
  810. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/cluster_requests[{fromSeconds},{toSeconds},{stepSeconds}]',
  811. 'mock': '/data/services/metrics/hbase/cluster_requests.json',
  812. 'testInProduction': true
  813. },
  814. 'service.metrics.hbase.hlog_split_size': {
  815. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitSize_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  816. 'mock': '/data/services/metrics/hbase/hlog_split_size.json',
  817. 'testInProduction': true
  818. },
  819. 'service.metrics.hbase.hlog_split_time': {
  820. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  821. 'mock': '/data/services/metrics/hbase/hlog_split_time.json',
  822. 'testInProduction': true
  823. },
  824. 'service.metrics.hbase.regionserver_queuesize': {
  825. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/flushQueueSize[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/compactionQueueSize[{fromSeconds},{toSeconds},{stepSeconds}]',
  826. 'mock': '/data/services/metrics/hbase/regionserver_queuesize.json',
  827. 'testInProduction': true
  828. },
  829. 'service.metrics.hbase.regionserver_regions': {
  830. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/regions[{fromSeconds},{toSeconds},{stepSeconds}]',
  831. 'mock': '/data/services/metrics/hbase/regionserver_regions.json',
  832. 'testInProduction': true
  833. },
  834. 'service.metrics.hbase.regionserver_rw_requests': {
  835. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/readRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/writeRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  836. 'mock': '/data/services/metrics/hbase/regionserver_rw_requests.json',
  837. 'testInProduction': true
  838. },
  839. 'service.metrics.mapreduce.gc': {
  840. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  841. 'mock': '/data/services/metrics/mapreduce/gc.json',
  842. 'testInProduction': true
  843. },
  844. 'service.metrics.mapreduce.jobs_status': {
  845. 'real': '/clusters/{clusterName}/services/MAPREDUCE/components/JOBTRACKER?fields=metrics/mapred/jobtracker/jobs_completed[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/jobs_preparing[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/jobs_failed[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/jobs_submitted[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/jobs_failed[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/jobs_running[{fromSeconds},{toSeconds},{stepSeconds}]',
  846. 'mock': '/data/services/metrics/mapreduce/jobs_status.json',
  847. 'testInProduction': true
  848. },
  849. 'service.metrics.mapreduce.jobs_heap': {
  850. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/jvm/memNonHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memNonHeapCommittedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/memHeapCommittedM[{fromSeconds},{toSeconds},{stepSeconds}]',
  851. 'mock': '/data/services/metrics/mapreduce/jvm_heap.json',
  852. 'testInProduction': true
  853. },
  854. 'service.metrics.mapreduce.jobs_threads': {
  855. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/jvm/threadsRunnable[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsBlocked[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsWaiting[{fromSeconds},{toSeconds},{stepSeconds}],metrics/jvm/threadsTimedWaiting[{fromSeconds},{toSeconds},{stepSeconds}]',
  856. 'mock': '/data/services/metrics/mapreduce/jvm_threads.json',
  857. 'testInProduction': true
  858. },
  859. 'service.metrics.mapreduce.map_slots': {
  860. 'real': '/clusters/{clusterName}/services/MAPREDUCE/components/JOBTRACKER?fields=metrics/mapred/jobtracker/occupied_map_slots[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/reserved_map_slots[{fromSeconds},{toSeconds},{stepSeconds}]',
  861. 'mock': '/data/services/metrics/mapreduce/map_slots.json',
  862. 'testInProduction': true
  863. },
  864. 'service.metrics.mapreduce.reduce_slots': {
  865. 'real': '/clusters/{clusterName}/services/MAPREDUCE/components/JOBTRACKER?fields=metrics/mapred/jobtracker/occupied_reduce_slots[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/reserved_reduce_slots[{fromSeconds},{toSeconds},{stepSeconds}]',
  866. 'mock': '/data/services/metrics/mapreduce/reduce_slots.json',
  867. 'testInProduction': true
  868. },
  869. 'service.metrics.mapreduce.rpc': {
  870. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  871. 'mock': '/data/services/metrics/mapreduce/rpc.json',
  872. 'testInProduction': true
  873. },
  874. 'service.metrics.mapreduce.tasks_running_waiting': {
  875. 'real': '/clusters/{clusterName}/services/MAPREDUCE/components/JOBTRACKER?fields=metrics/mapred/jobtracker/running_maps[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/running_reduces[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/waiting_maps[{fromSeconds},{toSeconds},{stepSeconds}],metrics/mapred/jobtracker/waiting_reduces[{fromSeconds},{toSeconds},{stepSeconds}]',
  876. 'mock': '/data/services/metrics/mapreduce/tasks_running_waiting.json',
  877. 'testInProduction': true
  878. },
  879. 'service.metrics.hdfs.block_status': {
  880. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/FSNamesystem/PendingReplicationBlocks[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/FSNamesystem/UnderReplicatedBlocks[{fromSeconds},{toSeconds},{stepSeconds}]',
  881. 'mock': '/data/services/metrics/hdfs/block_status.json',
  882. 'testInProduction': true
  883. },
  884. 'service.metrics.hdfs.file_operations': {
  885. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/namenode/FileInfoOps[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/namenode/CreateFileOps[{fromSeconds},{toSeconds},{stepSeconds}]',
  886. 'mock': '/data/services/metrics/hdfs/file_operations.json',
  887. 'testInProduction': true
  888. },
  889. 'service.metrics.hdfs.gc': {
  890. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  891. 'mock': '/data/services/metrics/hdfs/gc.json',
  892. 'testInProduction': true
  893. },
  894. 'service.metrics.hdfs.io': {
  895. 'real': '/clusters/{clusterName}/services/HDFS/components/DATANODE?fields=metrics/dfs/datanode/bytes_written[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/datanode/bytes_read[{fromSeconds},{toSeconds},{stepSeconds}]',
  896. 'mock': '/data/services/metrics/hdfs/io.json',
  897. 'testInProduction': true
  898. },
  899. 'service.metrics.hdfs.jvm_heap': {
  900. '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}]',
  901. 'mock': '/data/services/metrics/hdfs/jvm_heap.json',
  902. 'testInProduction': true
  903. },
  904. 'service.metrics.hdfs.jvm_threads': {
  905. '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}]',
  906. 'mock': '/data/services/metrics/hdfs/jvm_threads.json',
  907. 'testInProduction': true
  908. },
  909. 'service.metrics.hdfs.rpc': {
  910. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  911. 'mock': '/data/services/metrics/hdfs/rpc.json',
  912. 'testInProduction': true
  913. },
  914. 'service.metrics.hdfs.space_utilization': {
  915. '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}]',
  916. 'mock': '/data/services/metrics/hdfs/space_utilization.json',
  917. 'testInProduction': true
  918. },
  919. 'service.metrics.yarn.gc': {
  920. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  921. 'mock': '/data/services/metrics/yarn/gc.json',
  922. 'testInProduction': true
  923. },
  924. 'service.metrics.yarn.jobs_threads': {
  925. '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}]',
  926. 'mock': '/data/services/metrics/yarn/jvm_threads.json',
  927. 'testInProduction': true
  928. },
  929. 'service.metrics.yarn.rpc': {
  930. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  931. 'mock': '/data/services/metrics/yarn/rpc.json',
  932. 'testInProduction': true
  933. },
  934. 'service.metrics.yarn.jobs_heap': {
  935. '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}]',
  936. 'mock': '/data/services/metrics/yarn/jvm_heap.json',
  937. 'testInProduction': true
  938. },
  939. 'service.metrics.yarn.queue.allocated': {
  940. '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}]',
  941. 'mock': '',
  942. 'testInProduction': true
  943. },
  944. 'service.metrics.yarn.queue.allocated.container': {
  945. '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}]',
  946. 'mock': '',
  947. 'testInProduction': true
  948. },
  949. 'service.metrics.yarn.node.manager.statuses': {
  950. '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}]',
  951. 'mock': '',
  952. 'testInProduction': true
  953. },
  954. 'service.metrics.yarn.queue.memory.resource': {
  955. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=',
  956. 'mock': '',
  957. 'format': function (data, opt) {
  958. var field1 = 'metrics/yarn/Queue/{queueName}/AllocatedMB[{fromSeconds},{toSeconds},{stepSeconds}]';
  959. var field2 = 'metrics/yarn/Queue/{queueName}/AvailableMB[{fromSeconds},{toSeconds},{stepSeconds}]';
  960. if (opt.url != null && data.queueNames != null && data.queueNames.length > 0) {
  961. data.queueNames.forEach(function (q) {
  962. data.queueName = q;
  963. opt.url += (formatUrl(field1, data) + ",");
  964. opt.url += (formatUrl(field2, data) + ",");
  965. });
  966. } else {
  967. opt.url += (formatUrl(field1, data) + ",");
  968. opt.url += (formatUrl(field2, data) + ",");
  969. }
  970. },
  971. 'testInProduction': true
  972. },
  973. 'service.metrics.yarn.queue.apps.states.current': {
  974. '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}]',
  975. 'mock': '',
  976. 'testInProduction': true
  977. },
  978. 'service.metrics.yarn.queue.apps.states.finished': {
  979. '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}]',
  980. 'mock': '',
  981. 'testInProduction': true
  982. },
  983. 'service.metrics.kafka.broker.topic': {
  984. '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}]',
  985. 'mock': ''
  986. },
  987. 'service.metrics.kafka.controller.KafkaController': {
  988. 'real': '/clusters/{clusterName}/services/KAFKA/components/KAFKA_BROKER?fields=metrics/kafka/controller/KafkaController/ActiveControllerCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  989. 'mock': ''
  990. },
  991. 'service.metrics.kafka.controller.ControllerStats': {
  992. '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}]',
  993. 'mock': ''
  994. },
  995. 'service.metrics.kafka.log.LogFlushStats': {
  996. 'real': '/clusters/{clusterName}/services/KAFKA/components/KAFKA_BROKER?fields=metrics/kafka/log/LogFlushStats/LogFlushRateAndTimeMs/1MinuteRate[{fromSeconds},{toSeconds},{stepSeconds}]',
  997. 'mock': ''
  998. },
  999. 'service.metrics.kafka.server.ReplicaManager': {
  1000. '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}]',
  1001. 'mock': ''
  1002. },
  1003. 'service.metrics.kafka.server.ReplicaFetcherManager': {
  1004. 'real': '/clusters/{clusterName}/services/KAFKA/components/KAFKA_BROKER?fields=metrics/kafka/server/ReplicaFetcherManager/Replica-MaxLag[{fromSeconds},{toSeconds},{stepSeconds}]',
  1005. 'mock': ''
  1006. },
  1007. 'service.metrics.storm.nimbus': {
  1008. 'real': '/clusters/{clusterName}/services/STORM/components/NIMBUS?fields={metricsTemplate}',
  1009. 'mock': ''
  1010. },
  1011. 'dashboard.cluster_metrics.cpu': {
  1012. 'real': '/clusters/{clusterName}/?fields=metrics/cpu[{fromSeconds},{toSeconds},{stepSeconds}]',
  1013. 'mock': '/data/cluster_metrics/cpu_1hr.json',
  1014. 'testInProduction': true
  1015. },
  1016. 'dashboard.cluster_metrics.load': {
  1017. 'real': '/clusters/{clusterName}/?fields=metrics/load[{fromSeconds},{toSeconds},{stepSeconds}]',
  1018. 'mock': '/data/cluster_metrics/load_1hr.json',
  1019. 'testInProduction': true
  1020. },
  1021. 'dashboard.cluster_metrics.memory': {
  1022. 'real': '/clusters/{clusterName}/?fields=metrics/memory[{fromSeconds},{toSeconds},{stepSeconds}]',
  1023. 'mock': '/data/cluster_metrics/memory_1hr.json',
  1024. 'testInProduction': true
  1025. },
  1026. 'dashboard.cluster_metrics.network': {
  1027. 'real': '/clusters/{clusterName}/?fields=metrics/network[{fromSeconds},{toSeconds},{stepSeconds}]',
  1028. 'mock': '/data/cluster_metrics/network_1hr.json',
  1029. 'testInProduction': true
  1030. },
  1031. 'host.metrics.cpu': {
  1032. '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}]',
  1033. 'mock': '/data/hosts/metrics/cpu.json',
  1034. 'testInProduction': true
  1035. },
  1036. 'host.metrics.disk': {
  1037. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/disk/disk_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/disk/disk_free[{fromSeconds},{toSeconds},{stepSeconds}]',
  1038. 'mock': '/data/hosts/metrics/disk.json',
  1039. 'testInProduction': true
  1040. },
  1041. 'host.metrics.load': {
  1042. '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}]',
  1043. 'mock': '/data/hosts/metrics/load.json',
  1044. 'testInProduction': true
  1045. },
  1046. 'host.metrics.memory': {
  1047. '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}]',
  1048. 'mock': '/data/hosts/metrics/memory.json',
  1049. 'testInProduction': true
  1050. },
  1051. 'host.metrics.network': {
  1052. '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}]',
  1053. 'mock': '/data/hosts/metrics/network.json',
  1054. 'testInProduction': true
  1055. },
  1056. 'host.metrics.processes': {
  1057. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/process/proc_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/process/proc_run[{fromSeconds},{toSeconds},{stepSeconds}]',
  1058. 'mock': '/data/hosts/metrics/processes.json',
  1059. 'testInProduction': true
  1060. },
  1061. 'admin.security_status': {
  1062. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  1063. 'mock': '',
  1064. 'format': function () {
  1065. return {
  1066. timeout: 10000
  1067. };
  1068. }
  1069. },
  1070. 'settings.get.user_pref': {
  1071. 'real': '/persist/{key}',
  1072. 'mock': '/data/user_settings/{key}.json'
  1073. },
  1074. 'settings.post.user_pref': {
  1075. 'real': '/persist',
  1076. 'mock': '',
  1077. 'type': 'POST',
  1078. 'format': function (data) {
  1079. return {
  1080. data: JSON.stringify(data.keyValuePair)
  1081. }
  1082. }
  1083. },
  1084. 'cluster.load_cluster_name': {
  1085. 'real': '/clusters',
  1086. 'mock': '/data/clusters/info.json'
  1087. },
  1088. 'cluster.update_upgrade_version': {
  1089. 'real': '/stacks/{stackName}/versions?fields=stackServices/StackServices,Versions',
  1090. 'mock': '/data/wizard/stack/stacks.json',
  1091. 'format': function (data) {
  1092. return {
  1093. data: data.data
  1094. };
  1095. }
  1096. },
  1097. 'cluster.load_repositories': {
  1098. 'real': '/stacks/{stackName}/versions/{stackVersion}/operating_systems?fields=repositories/*',
  1099. 'mock': '/data/stacks/HDP-2.1/operating_systems.json',
  1100. 'format': function (data) {
  1101. return {
  1102. data: data.data
  1103. };
  1104. }
  1105. },
  1106. 'cluster.save_provisioning_state': {
  1107. 'real': '/clusters/{clusterName}',
  1108. 'type': 'PUT',
  1109. 'format': function (data) {
  1110. return {
  1111. data: JSON.stringify({
  1112. "Clusters": {
  1113. "provisioning_state": data.state
  1114. }
  1115. })
  1116. };
  1117. }
  1118. },
  1119. 'admin.high_availability.polling': {
  1120. 'real': '/clusters/{clusterName}/requests/{requestId}?fields=tasks/*,Requests/*',
  1121. 'mock': '/data/background_operations/host_upgrade_tasks.json'
  1122. },
  1123. 'admin.high_availability.getNnCheckPointStatus': {
  1124. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/NAMENODE',
  1125. 'mock': ''
  1126. },
  1127. 'admin.high_availability.getJnCheckPointStatus': {
  1128. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/JOURNALNODE?fields=metrics',
  1129. 'mock': ''
  1130. },
  1131. 'admin.high_availability.getHostComponent': {
  1132. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  1133. 'mock': ''
  1134. },
  1135. 'admin.high_availability.create_component': {
  1136. 'real': '/clusters/{clusterName}/hosts?Hosts/host_name={hostName}',
  1137. 'mock': '',
  1138. 'type': 'POST',
  1139. 'format': function (data) {
  1140. return {
  1141. data: JSON.stringify({
  1142. "host_components": [
  1143. {
  1144. "HostRoles": {
  1145. "component_name": data.componentName
  1146. }
  1147. }
  1148. ]
  1149. })
  1150. }
  1151. }
  1152. },
  1153. 'admin.high_availability.create_journalnode': {
  1154. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  1155. 'mock': '',
  1156. 'type': 'POST',
  1157. 'format': function () {
  1158. return {
  1159. data: JSON.stringify({
  1160. "components": [
  1161. {
  1162. "ServiceComponentInfo": {
  1163. "component_name": "JOURNALNODE"
  1164. }
  1165. }
  1166. ]
  1167. })
  1168. }
  1169. }
  1170. },
  1171. 'common.create_component': {
  1172. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name={serviceName}',
  1173. 'mock': '',
  1174. 'type': 'POST',
  1175. 'format': function (data) {
  1176. return {
  1177. data: JSON.stringify({
  1178. "components": [
  1179. {
  1180. "ServiceComponentInfo": {
  1181. "component_name": data.componentName
  1182. }
  1183. }
  1184. ]
  1185. })
  1186. }
  1187. }
  1188. },
  1189. 'admin.high_availability.create_zkfc': {
  1190. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  1191. 'mock': '',
  1192. 'type': 'POST',
  1193. 'format': function () {
  1194. return {
  1195. data: JSON.stringify({
  1196. "components": [
  1197. {
  1198. "ServiceComponentInfo": {
  1199. "component_name": "ZKFC"
  1200. }
  1201. }
  1202. ]
  1203. })
  1204. }
  1205. }
  1206. },
  1207. 'admin.high_availability.load_configs': {
  1208. 'real': '/clusters/{clusterName}/configurations?(type=core-site&tag={coreSiteTag})|(type=hdfs-site&tag={hdfsSiteTag})',
  1209. 'mock': ''
  1210. },
  1211. 'admin.high_availability.save_configs': {
  1212. 'real': '/clusters/{clusterName}',
  1213. 'mock': '',
  1214. 'type': 'PUT',
  1215. 'format': function (data) {
  1216. return {
  1217. data: JSON.stringify({
  1218. Clusters: {
  1219. desired_config: {
  1220. "type": data.siteName,
  1221. "tag": 'version' + (new Date).getTime(),
  1222. "properties": data.properties
  1223. }
  1224. }
  1225. })
  1226. }
  1227. }
  1228. },
  1229. 'admin.high_availability.load_hbase_configs': {
  1230. 'real': '/clusters/{clusterName}/configurations?type=hbase-site&tag={hbaseSiteTag}',
  1231. 'mock': ''
  1232. },
  1233. 'admin.security.cluster_configs': {
  1234. 'real': '/clusters/{clusterName}',
  1235. 'mock': '',
  1236. 'format': function () {
  1237. return {
  1238. timeout: 10000
  1239. };
  1240. }
  1241. },
  1242. 'admin.get.all_configurations': {
  1243. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  1244. 'mock': '',
  1245. 'format': function () {
  1246. return {
  1247. timeout: 10000
  1248. };
  1249. }
  1250. },
  1251. 'admin.security.add.cluster_configs': {
  1252. 'real': '/clusters/{clusterName}' + '?fields=Clusters/desired_configs',
  1253. 'mock': '',
  1254. 'format': function () {
  1255. return {
  1256. timeout: 10000
  1257. };
  1258. }
  1259. },
  1260. 'admin.kerberize.cluster': {
  1261. 'type': 'POST',
  1262. 'real': '/clusters/{clusterName}',
  1263. 'mock': '/data/wizard/kerberos/kerberize_cluster.json',
  1264. 'format' : function () {
  1265. return {
  1266. data: '{"RequestInfo": {"context" :"' + Em.I18n.t('requestInfo.kerberizeCluster') + '"}'
  1267. }
  1268. }
  1269. },
  1270. 'admin.kerberize.stack_descriptor': {
  1271. 'real': '',
  1272. 'mock': '/data/wizard/kerberos/stack_descriptors.json'
  1273. },
  1274. 'admin.poll.kerberize.cluster.request': {
  1275. 'real': '/clusters/{clusterName}/requests/{requestId}?fields=stages/Stage/context,stages/Stage/status,stages/Stage/progress_percent,stages/tasks/*,Requests/*',
  1276. 'mock': '/data/wizard/kerberos/kerberize_cluster.json'
  1277. },
  1278. 'admin.stack_upgrade.run_upgrade': {
  1279. 'real': '/clusters/{clusterName}',
  1280. 'mock': '',
  1281. 'format': function (data) {
  1282. return {
  1283. type: 'PUT',
  1284. data: data.data
  1285. };
  1286. }
  1287. },
  1288. 'admin.user.create': {
  1289. 'real': '/users/{user}',
  1290. 'mock': '/data/users/users.json',
  1291. 'format': function (data) {
  1292. return {
  1293. type: 'POST',
  1294. data: JSON.stringify(data.data)
  1295. }
  1296. }
  1297. },
  1298. 'admin.user.edit': {
  1299. 'real': '/users/{user}',
  1300. 'mock': '/data/users/users.json',
  1301. 'format': function (data) {
  1302. return {
  1303. type: 'PUT',
  1304. data: data.data
  1305. }
  1306. }
  1307. },
  1308. 'admin.stack_upgrade.do_poll': {
  1309. 'real': '/clusters/{cluster}/requests/{requestId}?fields=tasks/*',
  1310. 'mock': '/data/wizard/{mock}'
  1311. },
  1312. 'admin.upgrade.data': {
  1313. 'real': '/clusters/{clusterName}/upgrades/{id}?fields=Upgrade,upgrade_groups/UpgradeGroup,upgrade_groups/upgrade_items/*,upgrade_groups/upgrade_items/tasks/*',
  1314. 'mock': '/data/stack_versions/upgrade.json'
  1315. },
  1316. 'admin.upgrade.state': {
  1317. 'real': '/clusters/{clusterName}/upgrades/{id}?fields=Upgrade',
  1318. 'mock': '/data/stack_versions/upgrade_state.json'
  1319. },
  1320. 'admin.upgrade.start': {
  1321. 'real': '/clusters/{clusterName}/upgrades/{id}',
  1322. 'mock': '/data/stack_versions/start_upgrade.json',
  1323. 'type': 'POST',
  1324. 'format': function (data) {
  1325. return {
  1326. data: JSON.stringify({
  1327. "Upgrade": {
  1328. "repository_version": data.version
  1329. }
  1330. })
  1331. }
  1332. }
  1333. },
  1334. 'admin.stack_versions.all': {
  1335. 'real': '/clusters/{clusterName}/stack_versions?fields=ClusterStackVersions/*,repository_versions/RepositoryVersions/*&minimal_response=true',
  1336. 'mock': '/data/stack_versions/stack_version_all.json'
  1337. },
  1338. 'admin.stack_version.install.repo_version': {
  1339. 'real': '/clusters/{clusterName}/stack_versions',
  1340. 'format': function (data) {
  1341. return {
  1342. type: 'POST',
  1343. data: JSON.stringify({
  1344. ClusterStackVersions: data.ClusterStackVersions
  1345. })
  1346. }
  1347. },
  1348. 'mock': ''
  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',
  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&minimal_response=true',
  1961. 'mock': '/data/hosts/HDP2/host_status_counters.json'
  1962. },
  1963. 'components.filter_by_status': {
  1964. 'real': '/clusters/{clusterName}/components?fields=host_components/HostRoles/host_name,ServiceComponentInfo/component_name,ServiceComponentInfo/started_count{urlParams}&minimal_response=true',
  1965. 'mock': ''
  1966. },
  1967. 'hosts.all.install': {
  1968. 'real': '/hosts?minimal_response=true',
  1969. 'mock': ''
  1970. },
  1971. 'hosts.all': {
  1972. 'real': '/clusters/{clusterName}/hosts?minimal_response=true',
  1973. 'mock': '/data/hosts/HDP2/hosts.json'
  1974. },
  1975. 'hosts.with_public_host_names': {
  1976. 'real': '/clusters/{clusterName}/hosts?fields=Hosts/public_host_name&minimal_response=true',
  1977. 'mock': ''
  1978. },
  1979. 'hosts.for_quick_links': {
  1980. 'real': '/clusters/{clusterName}/hosts?Hosts/host_name.in({masterHosts})&fields=Hosts/public_host_name,host_components/HostRoles/component_name{urlParams}&minimal_response=true',
  1981. 'mock': '/data/hosts/quick_links.json'
  1982. },
  1983. 'hosts.confirmed.install': {
  1984. 'real': '/hosts?fields=Hosts/cpu_count,Hosts/disk_info,Hosts/total_mem&minimal_response=true',
  1985. 'mock': ''
  1986. },
  1987. 'hosts.confirmed': {
  1988. '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',
  1989. 'mock': '/data/hosts/HDP2/hosts.json'
  1990. },
  1991. 'host_components.all': {
  1992. 'real': '/clusters/{clusterName}/host_components?fields=HostRoles/host_name&minimal_response=true',
  1993. 'mock': ''
  1994. },
  1995. 'host_components.with_services_names': {
  1996. 'real': '/clusters/{clusterName}/host_components?fields=component/ServiceComponentInfo/service_name,HostRoles/host_name&minimal_response=true',
  1997. 'mock': ''
  1998. },
  1999. 'components.get_installed': {
  2000. 'real': '/clusters/{clusterName}/components',
  2001. 'mock': ''
  2002. },
  2003. 'hosts.heatmaps': {
  2004. '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',
  2005. 'mock': '/data/hosts/HDP2/hosts.json'
  2006. },
  2007. 'namenode.cpu_wio': {
  2008. 'real': '/clusters/{clusterName}/hosts/{nnHost}?fields=metrics/cpu',
  2009. 'mock': '/data/cluster_metrics/cpu.json'
  2010. },
  2011. 'custom_action.create': {
  2012. 'real': '/requests',
  2013. 'mock': '',
  2014. 'format': function (data) {
  2015. var requestInfo = {
  2016. context: 'Check host',
  2017. action: 'check_host',
  2018. parameters: {}
  2019. };
  2020. $.extend(true, requestInfo, data.requestInfo);
  2021. return {
  2022. type: 'POST',
  2023. data: JSON.stringify({
  2024. 'RequestInfo': requestInfo,
  2025. 'Requests/resource_filters': [{
  2026. hosts: data.filteredHosts.join(',')
  2027. }]
  2028. })
  2029. }
  2030. }
  2031. },
  2032. 'custom_action.request': {
  2033. 'real': '/requests/{requestId}/tasks/{taskId}',
  2034. 'mock': '',
  2035. 'format': function (data) {
  2036. return {
  2037. requestId: data.requestId,
  2038. taskId: data.taskId || ''
  2039. }
  2040. }
  2041. },
  2042. 'hosts.high_availability.wizard': {
  2043. 'real': '/clusters/{clusterName}/hosts?fields=Hosts/cpu_count,Hosts/disk_info,Hosts/total_mem&minimal_response=true',
  2044. 'mock': ''
  2045. },
  2046. 'hosts.security.wizard': {
  2047. 'real': '/clusters/{clusterName}/hosts?fields=host_components/HostRoles/service_name&minimal_response=true',
  2048. 'mock': ''
  2049. },
  2050. 'host_component.installed.on_hosts': {
  2051. 'real': '/clusters/{clusterName}/host_components?HostRoles/component_name={componentName}&HostRoles/host_name.in({hostNames})&fields=HostRoles/host_name&minimal_response=true',
  2052. 'mock': ''
  2053. },
  2054. 'hosts.by_component.one': {
  2055. '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',
  2056. 'mock': ''
  2057. },
  2058. 'hosts.by_component.all': {
  2059. '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',
  2060. 'mock': ''
  2061. },
  2062. 'hosts.config_groups': {
  2063. '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',
  2064. 'mock': ''
  2065. },
  2066. 'hosts.host_components.pre_load': {
  2067. real: '',
  2068. mock: '/data/hosts/HDP2/hosts.json',
  2069. format: function (data) {
  2070. return {
  2071. url: data.url
  2072. }
  2073. }
  2074. },
  2075. 'hosts.bulk.operations': {
  2076. real: '/clusters/{clusterName}/hosts?fields=Hosts/host_name,Hosts/maintenance_state,' +
  2077. 'host_components/HostRoles/state,host_components/HostRoles/maintenance_state,' +
  2078. 'host_components/HostRoles/stale_configs&minimal_response=true',
  2079. mock: '',
  2080. format: function (data) {
  2081. return {
  2082. headers: {
  2083. 'X-Http-Method-Override': 'GET'
  2084. },
  2085. type: 'POST',
  2086. data: JSON.stringify({
  2087. "RequestInfo": {"query": data.parameters}
  2088. })
  2089. }
  2090. }
  2091. },
  2092. 'service.serviceConfigVersions.get': {
  2093. 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',
  2094. mock: '/data/configurations/service_versions.json'
  2095. },
  2096. 'service.serviceConfigVersions.get.current': {
  2097. real: '/clusters/{clusterName}?fields=Clusters/desired_service_config_versions&minimal_response=true',
  2098. mock: ''
  2099. },
  2100. 'service.serviceConfigVersions.get.total': {
  2101. real: '/clusters/{clusterName}/configurations/service_config_versions?page_size=1&minimal_response=true',
  2102. mock: '/data/configurations/service_versions_total.json'
  2103. },
  2104. 'service.serviceConfigVersion.get': {
  2105. real: '/clusters/{clusterName}/configurations/service_config_versions?service_name={serviceName}&service_config_version={serviceConfigVersion}',
  2106. mock: '/data/configurations/service_version.json'
  2107. },
  2108. 'service.serviceConfigVersions.get.multiple': {
  2109. real: '/clusters/{clusterName}/configurations/service_config_versions?service_name={serviceName}&service_config_version.in({serviceConfigVersions})',
  2110. mock: '/data/configurations/service_version.json',
  2111. format: function (data) {
  2112. return {
  2113. serviceConfigVersions: data.serviceConfigVersions.join(',')
  2114. }
  2115. }
  2116. },
  2117. 'service.serviceConfigVersion.revert': {
  2118. 'real': '/clusters/{clusterName}',
  2119. 'mock': '',
  2120. 'type': 'PUT',
  2121. 'format': function (data) {
  2122. return {
  2123. data: JSON.stringify(data.data)
  2124. }
  2125. }
  2126. },
  2127. 'service.mysql.clean': {
  2128. 'real': '/clusters/{clusterName}/requests',
  2129. 'mock': '',
  2130. 'format': function (data) {
  2131. return {
  2132. type: 'POST',
  2133. data: JSON.stringify({
  2134. "RequestInfo": {
  2135. "command" : "CLEAN", "context" : "Clean MYSQL Server"
  2136. },
  2137. "Requests/resource_filters": [{
  2138. "service_name" : "HIVE",
  2139. "component_name" : "MYSQL_SERVER",
  2140. "hosts": data.host
  2141. }]
  2142. })
  2143. }
  2144. }
  2145. },
  2146. 'service.mysql.configure': {
  2147. 'real': '/clusters/{clusterName}/requests',
  2148. 'mock': '',
  2149. 'format': function (data) {
  2150. return {
  2151. type: 'POST',
  2152. data: JSON.stringify({
  2153. "RequestInfo": {
  2154. "command" : "CONFIGURE", "context" : "Configure MYSQL Server"
  2155. },
  2156. "Requests/resource_filters": [{
  2157. "service_name" : "HIVE",
  2158. "component_name" : "MYSQL_SERVER",
  2159. "hosts": data.host
  2160. }]
  2161. })
  2162. }
  2163. }
  2164. },
  2165. 'service.mysql.testHiveConnection': {
  2166. 'real': '/requests',
  2167. 'mock': '',
  2168. 'format': function (data) {
  2169. return {
  2170. type: 'POST',
  2171. data: JSON.stringify({
  2172. "RequestInfo": {
  2173. "context": "Check host",
  2174. "action": "check_host",
  2175. "parameters":{
  2176. "db_name": data.db_name,
  2177. "user_name": data.db_user,
  2178. "user_passwd": data.db_pass,
  2179. "db_connection_url": data.db_connection_url,
  2180. "jdk_location": data.jdk_location,
  2181. "threshold":"60",
  2182. "ambari_server_host": "c6403.ambari.apache.org",
  2183. "check_execute_list":"db_connection_check",
  2184. "java_home": data.java_home,
  2185. "jdk_name": data.jdk_name
  2186. }
  2187. },
  2188. "Requests/resource_filters": [{"hosts": data.hosts}]})
  2189. }
  2190. }
  2191. }
  2192. };
  2193. /**
  2194. * Replace data-placeholders to its values
  2195. *
  2196. * @param {String} url
  2197. * @param {Object} data
  2198. * @return {String}
  2199. */
  2200. var formatUrl = function (url, data) {
  2201. if (!url) return null;
  2202. var keys = url.match(/\{\w+\}/g);
  2203. keys = (keys === null) ? [] : keys;
  2204. if (keys) {
  2205. keys.forEach(function (key) {
  2206. var raw_key = key.substr(1, key.length - 2);
  2207. var replace;
  2208. if (!data || !data[raw_key]) {
  2209. replace = '';
  2210. }
  2211. else {
  2212. replace = data[raw_key];
  2213. }
  2214. url = url.replace(new RegExp(key, 'g'), replace);
  2215. });
  2216. }
  2217. return url;
  2218. };
  2219. /**
  2220. * this = object from config
  2221. * @return {Object}
  2222. */
  2223. var formatRequest = function (data) {
  2224. var opt = {
  2225. type: this.type || 'GET',
  2226. timeout: App.timeout,
  2227. dataType: 'json',
  2228. statusCode: require('data/statusCodes')
  2229. };
  2230. if (App.get('testMode')) {
  2231. opt.url = formatUrl(this.mock ? this.mock : '', data);
  2232. opt.type = 'GET';
  2233. }
  2234. else {
  2235. var prefix = this.apiPrefix != null ? this.apiPrefix : App.apiPrefix;
  2236. opt.url = prefix + formatUrl(this.real, data);
  2237. }
  2238. if (this.format) {
  2239. jQuery.extend(opt, this.format(data, opt));
  2240. }
  2241. return opt;
  2242. };
  2243. /**
  2244. * Wrapper for all ajax requests
  2245. *
  2246. * @type {Object}
  2247. */
  2248. var ajax = Em.Object.extend({
  2249. /**
  2250. * Send ajax request
  2251. *
  2252. * @param {Object} config
  2253. * @return {$.ajax} jquery ajax object
  2254. *
  2255. * config fields:
  2256. * name - url-key in the urls-object *required*
  2257. * sender - object that send request (need for proper callback initialization) *required*
  2258. * data - object with data for url-format
  2259. * beforeSend - method-name for ajax beforeSend response callback
  2260. * success - method-name for ajax success response callback
  2261. * error - method-name for ajax error response callback
  2262. * callback - callback from <code>App.updater.run</code> library
  2263. */
  2264. send: function (config) {
  2265. if (!config.sender) {
  2266. console.warn('Ajax sender should be defined!');
  2267. return null;
  2268. }
  2269. // default parameters
  2270. var params = {
  2271. clusterName: (App.get('clusterName') || App.clusterStatus.get('clusterName'))
  2272. };
  2273. // extend default parameters with provided
  2274. if (config.data) {
  2275. jQuery.extend(params, config.data);
  2276. }
  2277. var opt = {};
  2278. if (!urls[config.name]) {
  2279. console.warn('Invalid name provided!');
  2280. return null;
  2281. }
  2282. opt = formatRequest.call(urls[config.name], params);
  2283. opt.context = this;
  2284. // object sender should be provided for processing beforeSend, success and error responses
  2285. opt.beforeSend = function (xhr) {
  2286. if (config.beforeSend) {
  2287. config.sender[config.beforeSend](opt, xhr, params);
  2288. }
  2289. };
  2290. opt.success = function (data, textStatus, request) {
  2291. console.log("TRACE: The url is: " + opt.url);
  2292. if (config.success) {
  2293. config.sender[config.success](data, opt, params, request);
  2294. }
  2295. };
  2296. opt.error = function (request, ajaxOptions, error) {
  2297. if (config.error) {
  2298. config.sender[config.error](request, ajaxOptions, error, opt, params);
  2299. } else {
  2300. this.defaultErrorHandler(request, opt.url, opt.type);
  2301. }
  2302. };
  2303. opt.complete = function () {
  2304. if (config.callback) {
  2305. config.callback();
  2306. }
  2307. };
  2308. if ($.mocho) {
  2309. opt.url = 'http://' + $.hostName + opt.url;
  2310. }
  2311. return $.ajax(opt);
  2312. },
  2313. // A single instance of App.ModalPopup view
  2314. modalPopup: null,
  2315. /**
  2316. * defaultErrorHandler function is referred from App.ajax.send function and App.HttpClient.defaultErrorHandler function
  2317. * @jqXHR {jqXHR Object}
  2318. * @url {string}
  2319. * @method {String} Http method
  2320. * @showStatus {number} HTTP response code which should be shown. Default is 500.
  2321. */
  2322. defaultErrorHandler: function (jqXHR, url, method, showStatus) {
  2323. method = method || 'GET';
  2324. var self = this;
  2325. var api = " received on " + method + " method for API: " + url;
  2326. try {
  2327. var json = $.parseJSON(jqXHR.responseText);
  2328. var message = json.message;
  2329. } catch (err) {
  2330. }
  2331. if (!showStatus) {
  2332. showStatus = 500;
  2333. }
  2334. var statusCode = jqXHR.status + " status code";
  2335. if (jqXHR.status === showStatus && !this.get('modalPopup')) {
  2336. this.set('modalPopup', App.ModalPopup.show({
  2337. header: Em.I18n.t('common.error'),
  2338. secondary: false,
  2339. onPrimary: function () {
  2340. this.hide();
  2341. self.set('modalPopup', null);
  2342. },
  2343. bodyClass: Ember.View.extend({
  2344. classNames: ['api-error'],
  2345. templateName: require('templates/utils/ajax'),
  2346. api: api,
  2347. statusCode: statusCode,
  2348. message: message,
  2349. showMessage: !!message
  2350. })
  2351. }));
  2352. }
  2353. }
  2354. });
  2355. /**
  2356. * Add few access-methods for test purposes
  2357. */
  2358. if ($.mocho) {
  2359. ajax.reopen({
  2360. /**
  2361. * Don't use it anywhere except tests!
  2362. * @returns {Array}
  2363. */
  2364. fakeGetUrlNames: function () {
  2365. return Em.keys(urls);
  2366. },
  2367. /**
  2368. * Don't use it anywhere except tests!
  2369. * @param name
  2370. * @returns {*}
  2371. */
  2372. fakeGetUrl: function (name) {
  2373. return urls[name];
  2374. },
  2375. /**
  2376. * Don't use it anywhere except tests!
  2377. * @param url
  2378. * @param data
  2379. * @returns {String}
  2380. */
  2381. fakeFormatUrl: function (url, data) {
  2382. return formatUrl(url, data);
  2383. },
  2384. /**
  2385. * Don't use it anywhere except tests!
  2386. * @param urlObj
  2387. * @param data
  2388. * @returns {Object}
  2389. */
  2390. fakeFormatRequest: function (urlObj, data) {
  2391. return formatRequest.call(urlObj, data);
  2392. }
  2393. });
  2394. }
  2395. App.ajax = ajax.create({});