ajax.js 97 KB

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