ajax.js 77 KB

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