ajax.js 81 KB

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