ajax.js 78 KB

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