ajax.js 72 KB

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