ajax.js 86 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536
  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.upgrade.upgradeItem.setState': {
  1349. 'real': '/clusters/{clusterName}/upgrades/{upgradeId}/upgrade_groups/{groupId}/upgrade_items/{itemId}',
  1350. 'mock': '',
  1351. type: 'PUT',
  1352. 'format': function (data) {
  1353. return {
  1354. data: JSON.stringify({
  1355. "UpgradeItem" : {
  1356. "status" : data.status
  1357. }
  1358. })
  1359. };
  1360. }
  1361. },
  1362. 'admin.stack_versions.all': {
  1363. 'real': '/clusters/{clusterName}/stack_versions?fields=ClusterStackVersions/*,repository_versions/RepositoryVersions/*&minimal_response=true',
  1364. 'mock': '/data/stack_versions/stack_version_all.json'
  1365. },
  1366. 'admin.stack_version.install.repo_version': {
  1367. 'real': '/clusters/{clusterName}/stack_versions',
  1368. 'format': function (data) {
  1369. return {
  1370. type: 'POST',
  1371. data: JSON.stringify({
  1372. ClusterStackVersions: data.ClusterStackVersions
  1373. })
  1374. }
  1375. },
  1376. 'mock': ''
  1377. },
  1378. 'admin.stack_versions.progress.request': {
  1379. 'real': '/clusters/{clusterName}/requests/{requestId}?fields=Requests/progress_percent',
  1380. 'mock': '/data/background_operations/host_upgrade_tasks.json'
  1381. },
  1382. 'admin.rolling_upgrade.pre_upgrade_check': {
  1383. 'real': '/clusters/{clusterName}/rolling_upgrades_check?fields=*',
  1384. 'mock': '/data/stack_versions/pre_upgrade_check.json'
  1385. },
  1386. 'wizard.advanced_repositories.valid_url': {
  1387. 'real': '/stacks/{stackName}/versions/{stackVersion}/operating_systems/{osType}/repositories/{repoId}',
  1388. 'mock': '',
  1389. 'type': 'PUT',
  1390. 'format': function (data) {
  1391. return {
  1392. data: JSON.stringify(data.data)
  1393. }
  1394. }
  1395. },
  1396. 'wizard.service_components': {
  1397. 'real': '{stackUrl}/services?fields=StackServices/*,serviceComponents/*,serviceComponents/dependencies/Dependencies/scope',
  1398. 'mock': '/data/stacks/HDP-2.1/service_components.json',
  1399. 'format': function (data) {
  1400. return {
  1401. timeout: 10000
  1402. };
  1403. }
  1404. },
  1405. 'wizard.step9.installer.get_host_status': {
  1406. 'real': '/clusters/{cluster}/hosts?fields=Hosts/host_state,host_components/HostRoles/state',
  1407. 'mock': '/data/wizard/deploy/5_hosts/get_host_state.json'
  1408. },
  1409. 'wizard.step9.load_log': {
  1410. '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',
  1411. 'mock': '/data/wizard/deploy/5_hosts/poll_{numPolls}.json',
  1412. 'format': function () {
  1413. return {
  1414. dataType: 'text'
  1415. };
  1416. }
  1417. },
  1418. 'wizard.step8.existing_cluster_names': {
  1419. 'real': '/clusters',
  1420. 'mock': ''
  1421. },
  1422. 'wizard.step8.create_cluster': {
  1423. 'real': '/clusters/{cluster}',
  1424. 'mock': '',
  1425. 'format': function (data) {
  1426. return {
  1427. type: 'POST',
  1428. dataType: 'text',
  1429. data: data.data
  1430. }
  1431. }
  1432. },
  1433. 'wizard.step8.create_selected_services': {
  1434. 'type': 'POST',
  1435. 'real': '/clusters/{cluster}/services',
  1436. 'mock': '/data/stacks/HDP-2.1/recommendations.json',
  1437. 'format': function (data) {
  1438. return {
  1439. dataType: 'text',
  1440. data: data.data
  1441. }
  1442. }
  1443. },
  1444. 'wizard.step8.create_components': {
  1445. 'real': '/clusters/{cluster}/services?ServiceInfo/service_name={serviceName}',
  1446. 'mock': '',
  1447. 'format': function (data) {
  1448. return {
  1449. type: 'POST',
  1450. dataType: 'text',
  1451. data: data.data
  1452. }
  1453. }
  1454. },
  1455. 'wizard.step8.register_host_to_cluster': {
  1456. 'real': '/clusters/{cluster}/hosts',
  1457. 'mock': '',
  1458. 'format': function (data) {
  1459. return {
  1460. type: 'POST',
  1461. dataType: 'text',
  1462. data: data.data
  1463. }
  1464. }
  1465. },
  1466. 'wizard.step8.register_host_to_component': {
  1467. 'real': '/clusters/{cluster}/hosts',
  1468. 'mock': '',
  1469. 'format': function (data) {
  1470. return {
  1471. type: 'POST',
  1472. dataType: 'text',
  1473. data: data.data
  1474. }
  1475. }
  1476. },
  1477. 'wizard.step8.apply_configuration_groups': {
  1478. 'real': '/clusters/{cluster}/config_groups',
  1479. 'mock': '',
  1480. 'format': function (data) {
  1481. return {
  1482. type: 'POST',
  1483. dataType: 'text',
  1484. data: data.data
  1485. }
  1486. }
  1487. },
  1488. 'wizard.step8.set_local_repos': {
  1489. 'real': '{stackVersionURL}/operating_systems/{osType}/repositories/{repoId}',
  1490. 'mock': '',
  1491. 'format': function (data) {
  1492. return {
  1493. type: 'PUT',
  1494. dataType: 'text',
  1495. data: data.data
  1496. }
  1497. }
  1498. },
  1499. 'wizard.step3.jdk_check': {
  1500. 'real': '/requests',
  1501. 'mock': '',
  1502. 'format': function (data) {
  1503. return {
  1504. type: 'POST',
  1505. data: JSON.stringify({
  1506. "RequestInfo": {
  1507. "context": "Check hosts",
  1508. "action": "check_host",
  1509. "parameters": {
  1510. "threshold": "60",
  1511. "java_home": data.java_home,
  1512. "jdk_location": data.jdk_location,
  1513. "check_execute_list": "java_home_check"
  1514. }
  1515. },
  1516. "Requests/resource_filters": [{
  1517. "hosts": data.host_names
  1518. }]
  1519. })
  1520. }
  1521. }
  1522. },
  1523. 'wizard.step3.jdk_check.get_results': {
  1524. 'real': '/requests/{requestIndex}?fields=*,tasks/Tasks/host_name,tasks/Tasks/status,tasks/Tasks/structured_out',
  1525. 'mock': '/data/requests/host_check/jdk_check_results.json'
  1526. },
  1527. 'wizard.step3.host_info': {
  1528. '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',
  1529. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  1530. 'format': function () {
  1531. return {
  1532. contentType: 'application/json'
  1533. };
  1534. }
  1535. },
  1536. 'wizard.loadrecommendations': {
  1537. 'real': '{stackVersionUrl}/recommendations',
  1538. 'mock': '/data/stacks/HDP-2.1/recommendations.json',
  1539. 'type': 'POST',
  1540. 'format': function (data) {
  1541. var q = {
  1542. hosts: data.hosts,
  1543. services: data.services,
  1544. recommend: data.recommend
  1545. };
  1546. if (data.recommendations) {
  1547. q.recommendations = data.recommendations;
  1548. }
  1549. return {
  1550. data: JSON.stringify(q)
  1551. }
  1552. }
  1553. },
  1554. // TODO: merge with wizard.loadrecommendations query
  1555. 'wizard.step7.loadrecommendations.configs': {
  1556. 'real': '{stackVersionUrl}/recommendations',
  1557. 'mock': '/data/stacks/HDP-2.1/recommendations_configs.json',
  1558. 'type': 'POST',
  1559. 'format': function (data) {
  1560. return {
  1561. data: JSON.stringify({
  1562. hosts: data.hosts,
  1563. services: data.services,
  1564. recommendations: data.recommendations,
  1565. recommend: "configurations"
  1566. })
  1567. }
  1568. }
  1569. },
  1570. 'config.validations': {
  1571. 'real': '{stackVersionUrl}/validations',
  1572. 'mock': '/data/stacks/HDP-2.1/validations.json',
  1573. 'type': 'POST',
  1574. 'format': function (data) {
  1575. return {
  1576. data: JSON.stringify({
  1577. hosts: data.hosts,
  1578. services: data.services,
  1579. validate: data.validate,
  1580. recommendations: data.recommendations
  1581. })
  1582. }
  1583. }
  1584. },
  1585. 'preinstalled.checks': {
  1586. 'real': '/requests',
  1587. 'mock': '',
  1588. 'format': function (data) {
  1589. return {
  1590. type: 'POST',
  1591. data: JSON.stringify({
  1592. "RequestInfo": data.RequestInfo,
  1593. "Requests/resource_filters": [data.resource_filters]
  1594. })
  1595. }
  1596. }
  1597. },
  1598. 'preinstalled.checks.tasks': {
  1599. 'real': '/requests/{requestId}?fields=tasks/Tasks',
  1600. 'mock': '/data/requests/host_check/1.json'
  1601. },
  1602. 'wizard.step3.rerun_checks': {
  1603. 'real': '/hosts?fields=Hosts/last_agent_env',
  1604. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  1605. 'format': function () {
  1606. return {
  1607. contentType: 'application/json'
  1608. };
  1609. }
  1610. },
  1611. 'wizard.step3.bootstrap': {
  1612. 'real': '/bootstrap/{bootRequestId}',
  1613. 'mock': '/data/wizard/bootstrap/poll_{numPolls}.json'
  1614. },
  1615. 'wizard.step3.is_hosts_registered': {
  1616. 'real': '/hosts?fields=Hosts/host_status',
  1617. 'mock': '/data/wizard/bootstrap/single_host_registration.json'
  1618. },
  1619. 'wizard.stacks': {
  1620. 'real': '/stacks',
  1621. 'mock': '/data/wizard/stack/stacks2.json'
  1622. },
  1623. 'wizard.stacks_versions': {
  1624. 'real': '/stacks/{stackName}/versions?fields=Versions,operatingSystems/repositories/Repositories',
  1625. 'mock': '/data/wizard/stack/{stackName}_versions.json'
  1626. },
  1627. 'wizard.launch_bootstrap': {
  1628. 'real': '/bootstrap',
  1629. 'mock': '/data/wizard/bootstrap/bootstrap.json',
  1630. 'type': 'POST',
  1631. 'format': function (data) {
  1632. return {
  1633. contentType: 'application/json',
  1634. data: data.bootStrapData,
  1635. popup: data.popup
  1636. }
  1637. }
  1638. },
  1639. 'router.login': {
  1640. 'real': '/users/{loginName}?fields=*,privileges/PrivilegeInfo/cluster_name,privileges/PrivilegeInfo/permission_name',
  1641. 'mock': '/data/users/user_{usr}.json',
  1642. 'format': function (data) {
  1643. var statusCode = jQuery.extend({}, require('data/statusCodes'));
  1644. statusCode['403'] = function () {
  1645. console.log("Error code 403: Forbidden.");
  1646. };
  1647. return {
  1648. statusCode: statusCode
  1649. };
  1650. }
  1651. },
  1652. 'users.all': {
  1653. real: '/users/?fields=*',
  1654. mock: '/data/users/users.json'
  1655. },
  1656. 'users.privileges': {
  1657. real: '/privileges?fields=*',
  1658. mock: '/data/users/privileges.json'
  1659. },
  1660. 'router.user.privileges': {
  1661. real: '/privileges?PrivilegeInfo/principal_name={userName}&fields=*',
  1662. mock: '/data/users/privileges_{userName}.json'
  1663. },
  1664. 'router.login.clusters': {
  1665. 'real': '/clusters?fields=Clusters/provisioning_state',
  1666. 'mock': '/data/clusters/info.json'
  1667. },
  1668. 'router.logoff': {
  1669. 'real': '/logout',
  1670. 'mock': ''
  1671. },
  1672. 'ambari.service.load_jdk_name': {
  1673. 'real': '/services/AMBARI/components/AMBARI_SERVER?fields=RootServiceComponents/properties/jdk.name,RootServiceComponents/properties/java.home,RootServiceComponents/properties/jdk_location',
  1674. 'mock': '/data/requests/host_check/jdk_name.json'
  1675. },
  1676. 'ambari.service.load_server_version': {
  1677. 'real': '/services/AMBARI/components/AMBARI_SERVER?fields=RootServiceComponents/component_version,RootServiceComponents/properties/server.os_type&minimal_response=true',
  1678. 'mock': '/data/ambari_components/component_version.json'
  1679. },
  1680. 'ambari.service': {
  1681. 'real': '/services/AMBARI/components/AMBARI_SERVER',
  1682. 'mock': '/data/services/ambari_server.json'
  1683. },
  1684. 'ambari.service.load_server_clock': {
  1685. 'real': '/services/AMBARI/components/AMBARI_SERVER?fields=RootServiceComponents/server_clock',
  1686. 'mock': ''
  1687. },
  1688. 'config_groups.create': {
  1689. 'real': '/clusters/{clusterName}/config_groups',
  1690. 'mock': '',
  1691. 'format': function (data) {
  1692. return {
  1693. type: 'POST',
  1694. data: JSON.stringify([{
  1695. "ConfigGroup": {
  1696. "group_name": data.group_name,
  1697. "tag": data.service_id,
  1698. "description": data.description,
  1699. "desired_configs": data.desired_configs,
  1700. "hosts": data.hosts
  1701. }
  1702. }])
  1703. }
  1704. }
  1705. },
  1706. 'config_groups.update': {
  1707. 'real': '/clusters/{clusterName}/config_groups/{id}',
  1708. 'mock': '',
  1709. 'format': function (data) {
  1710. return {
  1711. type: 'PUT',
  1712. data: JSON.stringify(data.data)
  1713. }
  1714. }
  1715. },
  1716. 'rolling_restart.post': {
  1717. 'real': '/clusters/{clusterName}/request_schedules',
  1718. 'mock': '',
  1719. 'format': function (data) {
  1720. return {
  1721. type: 'POST',
  1722. data: JSON.stringify([{
  1723. "RequestSchedule": {
  1724. "batch": [{
  1725. "requests": data.batches
  1726. }, {
  1727. "batch_settings": {
  1728. "batch_separation_in_seconds": data.intervalTimeSeconds,
  1729. "task_failure_tolerance": data.tolerateSize
  1730. }
  1731. }]
  1732. }
  1733. }])
  1734. }
  1735. }
  1736. },
  1737. 'request_schedule.get': {
  1738. 'real': '/clusters/{clusterName}/request_schedules/{request_schedule_id}',
  1739. 'mock': ''
  1740. },
  1741. 'restart.hostComponents': {
  1742. 'real': '/clusters/{clusterName}/requests',
  1743. 'mock': '',
  1744. 'format': function (data) {
  1745. return {
  1746. type: 'POST',
  1747. data: JSON.stringify({
  1748. "RequestInfo": {
  1749. "command": "RESTART",
  1750. "context": data.context,
  1751. "operation_level": data.operation_level
  1752. },
  1753. "Requests/resource_filters": data.resource_filters
  1754. })
  1755. }
  1756. }
  1757. },
  1758. 'mirroring.get_all_entities': {
  1759. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/list/{type}?fields=status&user.name=ambari-qa',
  1760. 'mock': '/data/mirroring/{type}s.xml',
  1761. 'apiPrefix': '',
  1762. 'format': function () {
  1763. return {
  1764. dataType: 'xml'
  1765. }
  1766. }
  1767. },
  1768. 'mirroring.get_definition': {
  1769. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/definition/{type}/{name}?user.name=ambari-qa',
  1770. 'mock': '/data/mirroring/{name}_definition.xml',
  1771. 'apiPrefix': '',
  1772. 'format': function () {
  1773. return {
  1774. cache: true,
  1775. dataType: 'xml'
  1776. }
  1777. }
  1778. },
  1779. 'mirroring.dataset.get_all_instances': {
  1780. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/status/feed/{dataset}?start={start}&end={end}&user.name=ambari-qa',
  1781. 'mock': '/data/mirroring/{dataset}_instances.json',
  1782. 'apiPrefix': ''
  1783. },
  1784. 'mirroring.create_new_dataset': {
  1785. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/submitAndSchedule/feed?user.name=ambari-qa',
  1786. 'mock': '/data/mirroring/succeeded.json',
  1787. 'apiPrefix': '',
  1788. 'type': 'POST',
  1789. 'format': function (data) {
  1790. return {
  1791. contentType: 'text/xml',
  1792. dataType: 'xml',
  1793. data: data.entity,
  1794. headers: {
  1795. 'AmbariProxy-Content-Type': 'text/xml'
  1796. }
  1797. }
  1798. }
  1799. },
  1800. 'mirroring.submit_entity': {
  1801. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/submit/{type}?user.name=ambari-qa',
  1802. 'mock': '/data/mirroring/succeeded.json',
  1803. 'apiPrefix': '',
  1804. 'type': 'POST',
  1805. 'format': function (data) {
  1806. return {
  1807. contentType: 'text/xml',
  1808. dataType: 'xml',
  1809. data: data.entity,
  1810. headers: {
  1811. 'AmbariProxy-Content-Type': 'text/xml'
  1812. }
  1813. }
  1814. }
  1815. },
  1816. 'mirroring.update_entity': {
  1817. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/update/{type}/{name}?user.name=ambari-qa',
  1818. 'mock': '/data/mirroring/succeeded.json',
  1819. 'apiPrefix': '',
  1820. 'type': 'POST',
  1821. 'format': function (data) {
  1822. return {
  1823. contentType: 'text/xml',
  1824. dataType: 'xml',
  1825. data: data.entity,
  1826. headers: {
  1827. 'AmbariProxy-Content-Type': 'text/xml'
  1828. }
  1829. }
  1830. }
  1831. },
  1832. 'mirroring.delete_entity': {
  1833. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/delete/{type}/{name}?user.name=ambari-qa',
  1834. 'mock': '/data/mirroring/succeeded.json',
  1835. 'apiPrefix': '',
  1836. 'type': 'DELETE',
  1837. 'format': function () {
  1838. return {
  1839. dataType: 'xml'
  1840. }
  1841. }
  1842. },
  1843. 'mirroring.suspend_entity': {
  1844. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/suspend/{type}/{name}?user.name=ambari-qa',
  1845. 'mock': '/data/mirroring/succeeded.json',
  1846. 'apiPrefix': '',
  1847. 'type': 'POST',
  1848. 'format': function (data) {
  1849. return {
  1850. dataType: 'xml',
  1851. data: data.entity
  1852. }
  1853. }
  1854. },
  1855. 'mirroring.resume_entity': {
  1856. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/resume/{type}/{name}?user.name=ambari-qa',
  1857. 'mock': '/data/mirroring/succeeded.json',
  1858. 'apiPrefix': '',
  1859. 'type': 'POST',
  1860. 'format': function () {
  1861. return {
  1862. dataType: 'xml'
  1863. }
  1864. }
  1865. },
  1866. 'mirroring.schedule_entity': {
  1867. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/schedule/{type}/{name}?user.name=ambari-qa',
  1868. 'mock': '/data/mirroring/succeeded.json',
  1869. 'apiPrefix': '',
  1870. 'type': 'POST',
  1871. 'format': function () {
  1872. return {
  1873. dataType: 'xml'
  1874. }
  1875. }
  1876. },
  1877. 'mirroring.suspend_instance': {
  1878. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/suspend/feed/{feed}?start={name}&user.name=ambari-qa',
  1879. 'mock': '/data/mirroring/succeeded.json',
  1880. 'apiPrefix': '',
  1881. 'type': 'POST'
  1882. },
  1883. 'mirroring.resume_instance': {
  1884. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/resume/feed/{feed}?start={name}&user.name=ambari-qa',
  1885. 'mock': '/data/mirroring/succeeded.json',
  1886. 'apiPrefix': '',
  1887. 'type': 'POST'
  1888. },
  1889. 'mirroring.kill_instance': {
  1890. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/kill/feed/{feed}?start={name}&user.name=ambari-qa',
  1891. 'mock': '/data/mirroring/succeeded.json',
  1892. 'apiPrefix': '',
  1893. 'type': 'POST'
  1894. },
  1895. 'bulk_request.decommission': {
  1896. 'real': '/clusters/{clusterName}/requests',
  1897. 'mock': '',
  1898. 'format': function (data) {
  1899. return {
  1900. type: 'POST',
  1901. data: JSON.stringify({
  1902. 'RequestInfo': {
  1903. 'context': data.context,
  1904. 'command': 'DECOMMISSION',
  1905. 'parameters': data.parameters,
  1906. 'operation_level': {
  1907. 'level': "CLUSTER",
  1908. 'cluster_name': data.clusterName
  1909. }
  1910. },
  1911. "Requests/resource_filters": [{"service_name": data.serviceName, "component_name": data.componentName}]
  1912. })
  1913. }
  1914. }
  1915. },
  1916. 'bulk_request.hosts.passive_state': {
  1917. 'real': '/clusters/{clusterName}/hosts',
  1918. 'mock': '',
  1919. 'format': function (data) {
  1920. return {
  1921. type: 'PUT',
  1922. data: JSON.stringify({
  1923. RequestInfo: {
  1924. context: data.requestInfo,
  1925. query: 'Hosts/host_name.in(' + data.hostNames + ')'
  1926. },
  1927. Body: {
  1928. Hosts: {
  1929. maintenance_state: data.passive_state
  1930. }
  1931. }
  1932. })
  1933. }
  1934. }
  1935. },
  1936. 'bulk_request.hosts.all_components.passive_state': {
  1937. 'real': '/clusters/{clusterName}/host_components',
  1938. 'mock': '',
  1939. 'format': function (data) {
  1940. return {
  1941. type: 'PUT',
  1942. data: JSON.stringify({
  1943. RequestInfo: {
  1944. context: data.requestInfo,
  1945. query: data.query
  1946. },
  1947. Body: {
  1948. HostRoles: {
  1949. maintenance_state: data.passive_state
  1950. }
  1951. }
  1952. })
  1953. }
  1954. }
  1955. },
  1956. 'views.info': {
  1957. 'real': '/views',
  1958. 'mock': '/data/views/views.json'
  1959. },
  1960. /**
  1961. * Get all instances of all views across versions
  1962. */
  1963. 'views.instances': {
  1964. 'real': '/views?fields=versions/instances/ViewInstanceInfo,versions/ViewVersionInfo/label&versions/ViewVersionInfo/system=false',
  1965. 'mock': '/data/views/instances.json'
  1966. },
  1967. 'host.host_component.flume.metrics': {
  1968. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/FLUME_HANDLER?fields=metrics/flume/flume/{flumeComponent}/*',
  1969. 'mock': ''
  1970. },
  1971. 'host.host_component.flume.metrics.timeseries': {
  1972. 'real': '',
  1973. 'mock': '',
  1974. format: function (data) {
  1975. return {
  1976. url: data.url
  1977. }
  1978. }
  1979. },
  1980. 'host.host_components.filtered': {
  1981. 'real': '/clusters/{clusterName}/hosts?{fields}',
  1982. 'mock': '',
  1983. format: function (data) {
  1984. return {
  1985. headers: {
  1986. 'X-Http-Method-Override': 'GET'
  1987. },
  1988. type: 'POST',
  1989. data: JSON.stringify({
  1990. "RequestInfo": {"query": data.parameters}
  1991. })
  1992. };
  1993. }
  1994. },
  1995. 'host.status.counters': {
  1996. 'real': '/clusters/{clusterName}?fields=Clusters/health_report,Clusters/total_hosts,alerts_summary_hosts&minimal_response=true',
  1997. 'mock': '/data/hosts/HDP2/host_status_counters.json'
  1998. },
  1999. 'host.stack_versions.install': {
  2000. 'real': '/clusters/{clusterName}/hosts/{hostName}/stack_versions',
  2001. 'mock': '',
  2002. 'type': 'POST',
  2003. 'format': function (data) {
  2004. return {
  2005. data: JSON.stringify({
  2006. "HostStackVersions": {
  2007. "stack": data.version.get('stack'),
  2008. "version": data.version.get('version'),
  2009. "repository_version": data.version.get('repoVersion')
  2010. }
  2011. })
  2012. }
  2013. }
  2014. },
  2015. 'components.filter_by_status': {
  2016. 'real': '/clusters/{clusterName}/components?fields=host_components/HostRoles/host_name,ServiceComponentInfo/component_name,ServiceComponentInfo/started_count{urlParams}&minimal_response=true',
  2017. 'mock': ''
  2018. },
  2019. 'hosts.all.install': {
  2020. 'real': '/hosts?minimal_response=true',
  2021. 'mock': ''
  2022. },
  2023. 'hosts.all': {
  2024. 'real': '/clusters/{clusterName}/hosts?minimal_response=true',
  2025. 'mock': '/data/hosts/HDP2/hosts.json'
  2026. },
  2027. 'hosts.with_public_host_names': {
  2028. 'real': '/clusters/{clusterName}/hosts?fields=Hosts/public_host_name&minimal_response=true',
  2029. 'mock': ''
  2030. },
  2031. 'hosts.for_quick_links': {
  2032. 'real': '/clusters/{clusterName}/hosts?Hosts/host_name.in({masterHosts})&fields=Hosts/public_host_name,host_components/HostRoles/component_name{urlParams}&minimal_response=true',
  2033. 'mock': '/data/hosts/quick_links.json'
  2034. },
  2035. 'hosts.confirmed.install': {
  2036. 'real': '/hosts?fields=Hosts/cpu_count,Hosts/disk_info,Hosts/total_mem&minimal_response=true',
  2037. 'mock': ''
  2038. },
  2039. 'hosts.confirmed': {
  2040. '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',
  2041. 'mock': '/data/hosts/HDP2/hosts.json'
  2042. },
  2043. 'host_components.all': {
  2044. 'real': '/clusters/{clusterName}/host_components?fields=HostRoles/host_name&minimal_response=true',
  2045. 'mock': ''
  2046. },
  2047. 'host_components.with_services_names': {
  2048. 'real': '/clusters/{clusterName}/host_components?fields=component/ServiceComponentInfo/service_name,HostRoles/host_name&minimal_response=true',
  2049. 'mock': ''
  2050. },
  2051. 'components.get_installed': {
  2052. 'real': '/clusters/{clusterName}/components',
  2053. 'mock': ''
  2054. },
  2055. 'hosts.heatmaps': {
  2056. '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',
  2057. 'mock': '/data/hosts/HDP2/hosts.json'
  2058. },
  2059. 'namenode.cpu_wio': {
  2060. 'real': '/clusters/{clusterName}/hosts/{nnHost}?fields=metrics/cpu',
  2061. 'mock': '/data/cluster_metrics/cpu.json'
  2062. },
  2063. 'custom_action.create': {
  2064. 'real': '/requests',
  2065. 'mock': '',
  2066. 'format': function (data) {
  2067. var requestInfo = {
  2068. context: 'Check host',
  2069. action: 'check_host',
  2070. parameters: {}
  2071. };
  2072. $.extend(true, requestInfo, data.requestInfo);
  2073. return {
  2074. type: 'POST',
  2075. data: JSON.stringify({
  2076. 'RequestInfo': requestInfo,
  2077. 'Requests/resource_filters': [{
  2078. hosts: data.filteredHosts.join(',')
  2079. }]
  2080. })
  2081. }
  2082. }
  2083. },
  2084. 'custom_action.request': {
  2085. 'real': '/requests/{requestId}/tasks/{taskId}',
  2086. 'mock': '',
  2087. 'format': function (data) {
  2088. return {
  2089. requestId: data.requestId,
  2090. taskId: data.taskId || ''
  2091. }
  2092. }
  2093. },
  2094. 'hosts.high_availability.wizard': {
  2095. 'real': '/clusters/{clusterName}/hosts?fields=Hosts/cpu_count,Hosts/disk_info,Hosts/total_mem&minimal_response=true',
  2096. 'mock': ''
  2097. },
  2098. 'hosts.security.wizard': {
  2099. 'real': '/clusters/{clusterName}/hosts?fields=host_components/HostRoles/service_name&minimal_response=true',
  2100. 'mock': ''
  2101. },
  2102. 'host_component.installed.on_hosts': {
  2103. 'real': '/clusters/{clusterName}/host_components?HostRoles/component_name={componentName}&HostRoles/host_name.in({hostNames})&fields=HostRoles/host_name&minimal_response=true',
  2104. 'mock': ''
  2105. },
  2106. 'hosts.by_component.one': {
  2107. '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',
  2108. 'mock': ''
  2109. },
  2110. 'hosts.by_component.all': {
  2111. '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',
  2112. 'mock': ''
  2113. },
  2114. 'hosts.config_groups': {
  2115. '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',
  2116. 'mock': ''
  2117. },
  2118. 'hosts.host_components.pre_load': {
  2119. real: '',
  2120. mock: '/data/hosts/HDP2/hosts.json',
  2121. format: function (data) {
  2122. return {
  2123. url: data.url
  2124. }
  2125. }
  2126. },
  2127. 'hosts.bulk.operations': {
  2128. real: '/clusters/{clusterName}/hosts?fields=Hosts/host_name,Hosts/maintenance_state,' +
  2129. 'host_components/HostRoles/state,host_components/HostRoles/maintenance_state,' +
  2130. 'host_components/HostRoles/stale_configs&minimal_response=true',
  2131. mock: '',
  2132. format: function (data) {
  2133. return {
  2134. headers: {
  2135. 'X-Http-Method-Override': 'GET'
  2136. },
  2137. type: 'POST',
  2138. data: JSON.stringify({
  2139. "RequestInfo": {"query": data.parameters}
  2140. })
  2141. }
  2142. }
  2143. },
  2144. 'service.serviceConfigVersions.get': {
  2145. 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',
  2146. mock: '/data/configurations/service_versions.json'
  2147. },
  2148. 'service.serviceConfigVersions.get.current': {
  2149. real: '/clusters/{clusterName}?fields=Clusters/desired_service_config_versions&minimal_response=true',
  2150. mock: ''
  2151. },
  2152. 'service.serviceConfigVersions.get.total': {
  2153. real: '/clusters/{clusterName}/configurations/service_config_versions?page_size=1&minimal_response=true',
  2154. mock: '/data/configurations/service_versions_total.json'
  2155. },
  2156. 'service.serviceConfigVersion.get': {
  2157. real: '/clusters/{clusterName}/configurations/service_config_versions?service_name={serviceName}&service_config_version={serviceConfigVersion}',
  2158. mock: '/data/configurations/service_version.json'
  2159. },
  2160. 'service.serviceConfigVersions.get.multiple': {
  2161. real: '/clusters/{clusterName}/configurations/service_config_versions?service_name={serviceName}&service_config_version.in({serviceConfigVersions})',
  2162. mock: '/data/configurations/service_version.json',
  2163. format: function (data) {
  2164. return {
  2165. serviceConfigVersions: data.serviceConfigVersions.join(',')
  2166. }
  2167. }
  2168. },
  2169. 'service.serviceConfigVersion.revert': {
  2170. 'real': '/clusters/{clusterName}',
  2171. 'mock': '',
  2172. 'type': 'PUT',
  2173. 'format': function (data) {
  2174. return {
  2175. data: JSON.stringify(data.data)
  2176. }
  2177. }
  2178. },
  2179. 'service.mysql.clean': {
  2180. 'real': '/clusters/{clusterName}/requests',
  2181. 'mock': '',
  2182. 'format': function (data) {
  2183. return {
  2184. type: 'POST',
  2185. data: JSON.stringify({
  2186. "RequestInfo": {
  2187. "command" : "CLEAN", "context" : "Clean MYSQL Server"
  2188. },
  2189. "Requests/resource_filters": [{
  2190. "service_name" : "HIVE",
  2191. "component_name" : "MYSQL_SERVER",
  2192. "hosts": data.host
  2193. }]
  2194. })
  2195. }
  2196. }
  2197. },
  2198. 'service.mysql.configure': {
  2199. 'real': '/clusters/{clusterName}/requests',
  2200. 'mock': '',
  2201. 'format': function (data) {
  2202. return {
  2203. type: 'POST',
  2204. data: JSON.stringify({
  2205. "RequestInfo": {
  2206. "command" : "CONFIGURE", "context" : "Configure MYSQL Server"
  2207. },
  2208. "Requests/resource_filters": [{
  2209. "service_name" : "HIVE",
  2210. "component_name" : "MYSQL_SERVER",
  2211. "hosts": data.host
  2212. }]
  2213. })
  2214. }
  2215. }
  2216. },
  2217. 'service.mysql.testHiveConnection': {
  2218. 'real': '/requests',
  2219. 'mock': '',
  2220. 'format': function (data) {
  2221. return {
  2222. type: 'POST',
  2223. data: JSON.stringify({
  2224. "RequestInfo": {
  2225. "context": "Check host",
  2226. "action": "check_host",
  2227. "parameters":{
  2228. "db_name": data.db_name,
  2229. "user_name": data.db_user,
  2230. "user_passwd": data.db_pass,
  2231. "db_connection_url": data.db_connection_url,
  2232. "jdk_location": data.jdk_location,
  2233. "threshold":"60",
  2234. "ambari_server_host": "c6403.ambari.apache.org",
  2235. "check_execute_list":"db_connection_check",
  2236. "java_home": data.java_home,
  2237. "jdk_name": data.jdk_name
  2238. }
  2239. },
  2240. "Requests/resource_filters": [{"hosts": data.hosts}]})
  2241. }
  2242. }
  2243. }
  2244. };
  2245. /**
  2246. * Replace data-placeholders to its values
  2247. *
  2248. * @param {String} url
  2249. * @param {Object} data
  2250. * @return {String}
  2251. */
  2252. var formatUrl = function (url, data) {
  2253. if (!url) return null;
  2254. var keys = url.match(/\{\w+\}/g);
  2255. keys = (keys === null) ? [] : keys;
  2256. if (keys) {
  2257. keys.forEach(function (key) {
  2258. var raw_key = key.substr(1, key.length - 2);
  2259. var replace;
  2260. if (!data || !data[raw_key]) {
  2261. replace = '';
  2262. }
  2263. else {
  2264. replace = data[raw_key];
  2265. }
  2266. url = url.replace(new RegExp(key, 'g'), replace);
  2267. });
  2268. }
  2269. return url;
  2270. };
  2271. /**
  2272. * this = object from config
  2273. * @return {Object}
  2274. */
  2275. var formatRequest = function (data) {
  2276. var opt = {
  2277. type: this.type || 'GET',
  2278. timeout: App.timeout,
  2279. dataType: 'json',
  2280. statusCode: require('data/statusCodes')
  2281. };
  2282. if (App.get('testMode')) {
  2283. opt.url = formatUrl(this.mock ? this.mock : '', data);
  2284. opt.type = 'GET';
  2285. }
  2286. else {
  2287. var prefix = this.apiPrefix != null ? this.apiPrefix : App.apiPrefix;
  2288. opt.url = prefix + formatUrl(this.real, data);
  2289. }
  2290. if (this.format) {
  2291. jQuery.extend(opt, this.format(data, opt));
  2292. }
  2293. return opt;
  2294. };
  2295. /**
  2296. * Wrapper for all ajax requests
  2297. *
  2298. * @type {Object}
  2299. */
  2300. var ajax = Em.Object.extend({
  2301. /**
  2302. * Send ajax request
  2303. *
  2304. * @param {Object} config
  2305. * @return {$.ajax} jquery ajax object
  2306. *
  2307. * config fields:
  2308. * name - url-key in the urls-object *required*
  2309. * sender - object that send request (need for proper callback initialization) *required*
  2310. * data - object with data for url-format
  2311. * beforeSend - method-name for ajax beforeSend response callback
  2312. * success - method-name for ajax success response callback
  2313. * error - method-name for ajax error response callback
  2314. * callback - callback from <code>App.updater.run</code> library
  2315. */
  2316. send: function (config) {
  2317. if (!config.sender) {
  2318. console.warn('Ajax sender should be defined!');
  2319. return null;
  2320. }
  2321. // default parameters
  2322. var params = {
  2323. clusterName: (App.get('clusterName') || App.clusterStatus.get('clusterName'))
  2324. };
  2325. // extend default parameters with provided
  2326. if (config.data) {
  2327. jQuery.extend(params, config.data);
  2328. }
  2329. var opt = {};
  2330. if (!urls[config.name]) {
  2331. console.warn('Invalid name provided!');
  2332. return null;
  2333. }
  2334. opt = formatRequest.call(urls[config.name], params);
  2335. opt.context = this;
  2336. // object sender should be provided for processing beforeSend, success and error responses
  2337. opt.beforeSend = function (xhr) {
  2338. if (config.beforeSend) {
  2339. config.sender[config.beforeSend](opt, xhr, params);
  2340. }
  2341. };
  2342. opt.success = function (data, textStatus, request) {
  2343. console.log("TRACE: The url is: " + opt.url);
  2344. if (config.success) {
  2345. config.sender[config.success](data, opt, params, request);
  2346. }
  2347. };
  2348. opt.error = function (request, ajaxOptions, error) {
  2349. if (config.error) {
  2350. config.sender[config.error](request, ajaxOptions, error, opt, params);
  2351. } else {
  2352. this.defaultErrorHandler(request, opt.url, opt.type);
  2353. }
  2354. };
  2355. opt.complete = function () {
  2356. if (config.callback) {
  2357. config.callback();
  2358. }
  2359. };
  2360. if ($.mocho) {
  2361. opt.url = 'http://' + $.hostName + opt.url;
  2362. }
  2363. return $.ajax(opt);
  2364. },
  2365. // A single instance of App.ModalPopup view
  2366. modalPopup: null,
  2367. /**
  2368. * defaultErrorHandler function is referred from App.ajax.send function and App.HttpClient.defaultErrorHandler function
  2369. * @jqXHR {jqXHR Object}
  2370. * @url {string}
  2371. * @method {String} Http method
  2372. * @showStatus {number} HTTP response code which should be shown. Default is 500.
  2373. */
  2374. defaultErrorHandler: function (jqXHR, url, method, showStatus) {
  2375. method = method || 'GET';
  2376. var self = this;
  2377. var api = " received on " + method + " method for API: " + url;
  2378. try {
  2379. var json = $.parseJSON(jqXHR.responseText);
  2380. var message = json.message;
  2381. } catch (err) {
  2382. }
  2383. if (!showStatus) {
  2384. showStatus = 500;
  2385. }
  2386. var statusCode = jqXHR.status + " status code";
  2387. if (jqXHR.status === showStatus && !this.get('modalPopup')) {
  2388. this.set('modalPopup', App.ModalPopup.show({
  2389. header: Em.I18n.t('common.error'),
  2390. secondary: false,
  2391. onPrimary: function () {
  2392. this.hide();
  2393. self.set('modalPopup', null);
  2394. },
  2395. bodyClass: Ember.View.extend({
  2396. classNames: ['api-error'],
  2397. templateName: require('templates/utils/ajax'),
  2398. api: api,
  2399. statusCode: statusCode,
  2400. message: message,
  2401. showMessage: !!message
  2402. })
  2403. }));
  2404. }
  2405. }
  2406. });
  2407. /**
  2408. * Add few access-methods for test purposes
  2409. */
  2410. if ($.mocho) {
  2411. ajax.reopen({
  2412. /**
  2413. * Don't use it anywhere except tests!
  2414. * @returns {Array}
  2415. */
  2416. fakeGetUrlNames: function () {
  2417. return Em.keys(urls);
  2418. },
  2419. /**
  2420. * Don't use it anywhere except tests!
  2421. * @param name
  2422. * @returns {*}
  2423. */
  2424. fakeGetUrl: function (name) {
  2425. return urls[name];
  2426. },
  2427. /**
  2428. * Don't use it anywhere except tests!
  2429. * @param url
  2430. * @param data
  2431. * @returns {String}
  2432. */
  2433. fakeFormatUrl: function (url, data) {
  2434. return formatUrl(url, data);
  2435. },
  2436. /**
  2437. * Don't use it anywhere except tests!
  2438. * @param urlObj
  2439. * @param data
  2440. * @returns {Object}
  2441. */
  2442. fakeFormatRequest: function (urlObj, data) {
  2443. return formatRequest.call(urlObj, data);
  2444. }
  2445. });
  2446. }
  2447. App.ajax = ajax.create({});