ajax.js 80 KB

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