ajax.js 66 KB

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