ajax.js 77 KB

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