ajax.js 86 KB

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