ajax.js 66 KB

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