ajax.js 74 KB

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