ajax.js 79 KB

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