ajax.js 77 KB

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