ajax.js 79 KB

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