ajax.js 77 KB

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