ajax.js 83 KB

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