ajax.js 97 KB

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