ajax.js 73 KB

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