ajax.js 73 KB

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