ajax.js 72 KB

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