ajax.js 77 KB

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