ajax.js 80 KB

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