ajax.js 86 KB

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