ajax.js 72 KB

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