ajax.js 66 KB

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