ajax.js 73 KB

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