ajax.js 96 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841
  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.cluster.update' : {
  33. 'type': 'PUT',
  34. 'real': '/clusters/{clusterName}',
  35. 'mock': '/data/wizard/deploy/poll_1.json',
  36. 'format': function (data) {
  37. return {
  38. data: JSON.stringify(data.data)
  39. };
  40. }
  41. },
  42. 'common.services.update' : {
  43. 'real': '/clusters/{clusterName}/services?{urlParams}',
  44. 'mock': '/data/wizard/deploy/poll_1.json',
  45. 'format': function (data) {
  46. return {
  47. type: 'PUT',
  48. data: JSON.stringify({
  49. RequestInfo: {
  50. "context": data.context,
  51. "operation_level": {
  52. "level": "CLUSTER",
  53. "cluster_name" : data.clusterName
  54. }
  55. },
  56. Body: {
  57. ServiceInfo: data.ServiceInfo
  58. }
  59. })
  60. };
  61. }
  62. },
  63. 'common.service.update' : {
  64. 'real': '/clusters/{clusterName}/services/{serviceName}',
  65. 'mock': '/data/wizard/deploy/poll_1.json',
  66. 'format': function (data) {
  67. return {
  68. type: 'PUT',
  69. data: JSON.stringify({
  70. RequestInfo: {
  71. "context": data.context,
  72. "operation_level": {
  73. "level": "SERVICE",
  74. "cluster_name" : data.clusterName,
  75. "service_name" : data.serviceName
  76. }
  77. },
  78. Body: {
  79. ServiceInfo: data.ServiceInfo
  80. }
  81. })
  82. };
  83. }
  84. },
  85. 'common.service_component.info' : {
  86. 'real': '/clusters/{clusterName}/services/{serviceName}/components/{componentName}?{urlParams}',
  87. 'mock': '/data/wizard/deploy/poll_1.json'
  88. },
  89. 'common.host_component.update': {
  90. 'real': '/clusters/{clusterName}/host_components',
  91. 'mock': '',
  92. 'type': 'PUT',
  93. 'format': function (data) {
  94. return {
  95. data: JSON.stringify({
  96. RequestInfo: {
  97. context: data.context,
  98. query: data.query
  99. },
  100. Body: {
  101. "HostRoles": data.HostRoles
  102. }
  103. })
  104. }
  105. }
  106. },
  107. 'common.host.host_components.update': {
  108. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components?{urlParams}',
  109. 'mock': '',
  110. 'type': 'PUT',
  111. 'format': function (data) {
  112. return {
  113. data: JSON.stringify({
  114. RequestInfo: {
  115. "context": data.context,
  116. "operation_level": {
  117. level: "HOST",
  118. cluster_name: data.clusterName,
  119. host_names: data.hostName
  120. },
  121. query: data.query
  122. },
  123. Body: {
  124. "HostRoles": data.HostRoles
  125. }
  126. })
  127. }
  128. }
  129. },
  130. 'common.host.host_component.update': {
  131. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}?{urlParams}',
  132. 'mock': '/data/wizard/deploy/2_hosts/poll_9.json',
  133. 'type': 'PUT',
  134. 'format': function (data) {
  135. return {
  136. data: JSON.stringify({
  137. RequestInfo: {
  138. "context": data.context,
  139. "operation_level": {
  140. level: "HOST_COMPONENT",
  141. cluster_name: data.clusterName,
  142. host_name: data.hostName,
  143. service_name: data.serviceName || null
  144. }
  145. },
  146. Body: {
  147. "HostRoles": data.HostRoles
  148. }
  149. })
  150. }
  151. }
  152. },
  153. 'common.hosts.all': {
  154. 'real': '/clusters/{clusterName}/host_components?{urlParams}&minimal_response=true',
  155. 'mock': ''
  156. },
  157. 'common.service.configurations': {
  158. 'real':'/clusters/{clusterName}',
  159. 'mock':'',
  160. 'format': function (data) {
  161. return {
  162. type: 'PUT',
  163. data: JSON.stringify({
  164. Clusters: {
  165. desired_config: data.desired_config
  166. }
  167. })
  168. }
  169. }
  170. },
  171. 'common.across.services.configurations': {
  172. 'type': 'PUT',
  173. 'real':'/clusters/{clusterName}',
  174. 'mock':'/data/services/ambari.json',
  175. 'format': function(data) {
  176. return {
  177. dataType: 'text',
  178. data: data.data
  179. }
  180. }
  181. },
  182. 'common.request.polling': {
  183. 'real': '/clusters/{clusterName}/requests/{requestId}?fields=tasks/Tasks/request_id,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,tasks/Tasks/structured_out,Requests/*&tasks/Tasks/stage_id={stageId}',
  184. 'mock': '/data/background_operations/host_upgrade_tasks.json'
  185. },
  186. 'service.ambari': {
  187. 'real': '/services/AMBARI?fields=components/RootServiceComponents',
  188. 'mock': '/data/services/ambari.json'
  189. },
  190. 'ambari.service.load_server_version': {
  191. 'real': '/services/AMBARI?fields=components/RootServiceComponents/component_version&components/RootServiceComponents/component_name=AMBARI_SERVER&minimal_response=true',
  192. 'mock': '/data/services/ambari.json'
  193. },
  194. 'service.flume.agent.command': {
  195. 'real': '/clusters/{clusterName}/hosts/{host}/host_components/FLUME_HANDLER',
  196. 'mock': '',
  197. 'format': function (data) {
  198. return {
  199. type: 'PUT',
  200. data: JSON.stringify({
  201. "RequestInfo": {
  202. "context": data.context,
  203. "flume_handler": data.agentName,
  204. "operation_level": {
  205. level: "HOST_COMPONENT",
  206. cluster_name: data.clusterName,
  207. service_name: "FLUME",
  208. host_name: data.host
  209. }
  210. },
  211. "Body": {
  212. "HostRoles": {
  213. "state": data.state
  214. }
  215. }
  216. })
  217. }
  218. }
  219. },
  220. 'common.host_components.update': {
  221. 'real': '/clusters/{clusterName}/host_components?{urlParams}',
  222. 'mock': '/data/wizard/deploy/poll_1.json',
  223. 'type': 'PUT',
  224. 'format': function (data) {
  225. return {
  226. data: JSON.stringify({
  227. RequestInfo: {
  228. "context": data.context,
  229. "operation_level": {
  230. level: data.level || "CLUSTER",
  231. cluster_name: data.clusterName
  232. },
  233. query: data.query
  234. },
  235. Body: {
  236. "HostRoles": data.HostRoles
  237. }
  238. })
  239. }
  240. }
  241. },
  242. 'common.service.passive': {
  243. 'real': '/clusters/{clusterName}/services/{serviceName}',
  244. 'mock': '',
  245. 'format': function (data) {
  246. return {
  247. type: 'PUT',
  248. data: JSON.stringify({
  249. RequestInfo: {
  250. "context": data.requestInfo
  251. },
  252. Body: {
  253. ServiceInfo: {
  254. maintenance_state: data.passive_state
  255. }
  256. }
  257. })
  258. };
  259. }
  260. },
  261. 'common.host.host_component.passive': {
  262. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  263. 'mock': '',
  264. 'type': 'PUT',
  265. 'format': function (data) {
  266. return {
  267. data: JSON.stringify({
  268. RequestInfo: {
  269. "context": data.context
  270. },
  271. Body: {
  272. HostRoles: {
  273. maintenance_state: data.passive_state
  274. }
  275. }
  276. })
  277. };
  278. }
  279. },
  280. 'common.host.with_host_component': {
  281. 'real': '/clusters/{clusterName}/hosts?host_components/HostRoles/component_name={componentName}&minimal_response=true',
  282. 'mock': ''
  283. },
  284. 'common.delete.host': {
  285. 'real': '/clusters/{clusterName}/hosts/{hostName}',
  286. 'type': 'DELETE'
  287. },
  288. 'common.delete.host_component': {
  289. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  290. 'type': 'DELETE'
  291. },
  292. 'common.delete.user': {
  293. 'real': '/users/{user}',
  294. 'type': 'DELETE'
  295. },
  296. 'common.delete.config_group': {
  297. 'real': '/clusters/{clusterName}/config_groups/{id}',
  298. 'type': 'DELETE'
  299. },
  300. 'common.delete.cluster': {
  301. 'real': '/clusters/{name}',
  302. 'type': 'DELETE'
  303. },
  304. 'common.delete.service': {
  305. 'real': '/clusters/{clusterName}/services/{serviceName}',
  306. 'mock': '/data/services/ambari.json',
  307. 'type': 'DELETE'
  308. },
  309. 'common.delete.request_schedule': {
  310. 'real': '/clusters/{clusterName}/request_schedules/{request_schedule_id}',
  311. 'type': 'DELETE'
  312. },
  313. 'alerts.load_alert_groups': {
  314. 'real': '/clusters/{clusterName}/alert_groups?fields=*',
  315. 'mock': 'data/alerts/alertGroups.json'
  316. },
  317. 'alerts.load_an_alert_group': {
  318. 'real': '/clusters/{clusterName}/alert_groups/{group_id}',
  319. 'mock': 'data/alerts/alertGroup.json'
  320. },
  321. 'alert_groups.create': {
  322. 'real': '/clusters/{clusterName}/alert_groups',
  323. 'mock': '',
  324. 'format': function (data) {
  325. return {
  326. type: 'POST',
  327. data: JSON.stringify({
  328. "AlertGroup": {
  329. "name": data.name,
  330. "definitions": data.definitions,
  331. "targets": data.targets
  332. }
  333. })
  334. };
  335. }
  336. },
  337. 'alert_groups.update': {
  338. 'real': '/clusters/{clusterName}/alert_groups/{group_id}',
  339. 'mock': '',
  340. 'format': function (data) {
  341. return {
  342. type: 'PUT',
  343. data: JSON.stringify({
  344. "AlertGroup": {
  345. "name": data.name,
  346. "definitions": data.definitions,
  347. "targets": data.targets
  348. }
  349. })
  350. };
  351. }
  352. },
  353. 'alert_groups.delete': {
  354. 'real': '/clusters/{clusterName}/alert_groups/{group_id}',
  355. 'mock': '',
  356. 'format': function (data) {
  357. return {
  358. type: 'DELETE'
  359. };
  360. }
  361. },
  362. 'alerts.load_all_alert_definitions': {
  363. 'real': '/clusters/{clusterName}/alert_definitions?fields=*',
  364. 'mock': 'data/alerts/alertDefinitions.json'
  365. },
  366. 'alerts.notifications': {
  367. 'real': '/alert_targets?fields=*',
  368. 'mock': '/data/alerts/alertNotifications.json'
  369. },
  370. 'alerts.instances': {
  371. 'real': '/clusters/{clusterName}/alerts?fields=*',
  372. 'mock': '/data/alerts/alert_instances.json'
  373. },
  374. 'alerts.instances.unhealthy': {
  375. 'real': '/clusters/{clusterName}/alerts?fields=*&Alert/state.in(CRITICAL,WARNING)&{paginationInfo}',
  376. 'mock': '/data/alerts/alert_instances.json'
  377. },
  378. 'alerts.instances.by_definition': {
  379. 'real': '/clusters/{clusterName}/alerts?fields=*&Alert/definition_id={definitionId}',
  380. 'mock': '/data/alerts/alert_instances.json'
  381. },
  382. 'alerts.instances.by_host': {
  383. 'real': '/clusters/{clusterName}/alerts?fields=*&Alert/host_name={hostName}',
  384. 'mock': '/data/alerts/alert_instances.json'
  385. },
  386. 'alerts.update_alert_definition': {
  387. 'real': '/clusters/{clusterName}/alert_definitions/{id}',
  388. 'mock': '',
  389. 'format': function (data) {
  390. return {
  391. type: 'PUT',
  392. data: JSON.stringify(data.data)
  393. }
  394. }
  395. },
  396. 'alerts.create_alert_definition': {
  397. 'real': '/clusters/{clusterName}/alert_definitions/',
  398. 'mock': '',
  399. 'format': function (data) {
  400. return {
  401. type: 'POST',
  402. data: JSON.stringify(data.data)
  403. }
  404. }
  405. },
  406. 'alerts.delete_alert_definition': {
  407. 'real': '/clusters/{clusterName}/alert_definitions/{id}',
  408. 'mock': '',
  409. 'type': 'DELETE'
  410. },
  411. 'alerts.create_alert_notification': {
  412. 'real': '/alert_targets?{urlParams}',
  413. 'mock': '',
  414. 'format': function (data) {
  415. return {
  416. type: 'POST',
  417. data: JSON.stringify(data.data)
  418. }
  419. }
  420. },
  421. 'alerts.update_alert_notification': {
  422. 'real': '/alert_targets/{id}',
  423. 'mock': '',
  424. 'format': function (data) {
  425. return {
  426. type: 'PUT',
  427. data: JSON.stringify(data.data)
  428. }
  429. }
  430. },
  431. 'alerts.delete_alert_notification': {
  432. 'real': '/alert_targets/{id}',
  433. 'mock': '',
  434. 'type': 'DELETE'
  435. },
  436. 'alerts.get_instances_history': {
  437. 'real': '/clusters/{clusterName}/alert_history?(AlertHistory/definition_name={definitionName})&(AlertHistory/timestamp>={timestamp})',
  438. 'mock': '/data/alerts/alert_instances_history.json'
  439. },
  440. 'background_operations.get_most_recent': {
  441. 'real': '/clusters/{clusterName}/requests?to=end&page_size={operationsCount}&fields=Requests',
  442. 'mock': '/data/background_operations/list_on_start.json',
  443. 'testInProduction': true
  444. },
  445. 'background_operations.get_by_request': {
  446. 'real': '/clusters/{clusterName}/requests/{requestId}?fields=*,tasks/Tasks/request_id,tasks/Tasks/command,tasks/Tasks/command_detail,tasks/Tasks/host_name,tasks/Tasks/id,tasks/Tasks/role,tasks/Tasks/status&minimal_response=true',
  447. 'mock': '/data/background_operations/task_by_request{requestId}.json',
  448. 'testInProduction': true
  449. },
  450. 'background_operations.get_by_task': {
  451. 'real': '/clusters/{clusterName}/requests/{requestId}/tasks/{taskId}',
  452. 'mock': '/data/background_operations/list_on_start.json',
  453. 'testInProduction': true
  454. },
  455. 'background_operations.abort_request': {
  456. 'real': '/clusters/{clusterName}/requests/{requestId}',
  457. 'mock': '',
  458. 'format': function () {
  459. return {
  460. type: 'PUT',
  461. data: JSON.stringify({
  462. "Requests": {
  463. "request_status": "ABORTED",
  464. "abort_reason": Em.I18n.t('hostPopup.bgop.abortRequest.reason')
  465. }
  466. })
  467. };
  468. }
  469. },
  470. 'service.item.smoke': {
  471. 'real': '/clusters/{clusterName}/requests',
  472. 'mock': '/data/wizard/deploy/poll_1.json',
  473. 'format': function (data) {
  474. var requestData = {
  475. "RequestInfo": {
  476. "context": data.displayName + " Service Check",
  477. "command": data.actionName
  478. },
  479. "Requests/resource_filters": [{"service_name": data.serviceName}]
  480. };
  481. if (data.operationLevel) {
  482. requestData.RequestInfo.operation_level = data.operationLevel;
  483. }
  484. return {
  485. 'type': 'POST',
  486. data: JSON.stringify(requestData)
  487. };
  488. }
  489. },
  490. 'service.item.rebalanceHdfsNodes': {
  491. 'real': '/clusters/{clusterName}/requests',
  492. 'mock': '',
  493. 'format': function (data) {
  494. return {
  495. type: 'POST',
  496. data: JSON.stringify({
  497. RequestInfo: {
  498. 'context': Em.I18n.t('services.service.actions.run.rebalanceHdfsNodes.context'),
  499. 'command': 'REBALANCEHDFS',
  500. 'namenode': JSON.stringify({threshold: data.threshold})
  501. },
  502. "Requests/resource_filters": [{
  503. 'service_name': 'HDFS',
  504. 'component_name': 'NAMENODE',
  505. 'hosts': data.hosts
  506. }]
  507. })
  508. }
  509. }
  510. },
  511. 'cancel.background.operation': {
  512. 'real': '/clusters/{clusterName}/requests/{requestId}',
  513. 'mock': '',
  514. 'format': function (data) {
  515. return {
  516. type: 'PUT',
  517. data: JSON.stringify({
  518. RequestInfo: {
  519. 'context': 'Cancel operation',
  520. "parameters": {
  521. "cancel_policy": "SIGKILL"
  522. }
  523. },
  524. "Requests/request_status": 'ABORTED',
  525. "Requests/abort_reason": "Cancel background operation"
  526. })
  527. }
  528. }
  529. },
  530. 'service.item.refreshQueueYarnRequest': {
  531. 'real': '/clusters/{clusterName}/requests',
  532. 'mock': '',
  533. 'format': function (data) {
  534. return {
  535. type: 'POST',
  536. data: JSON.stringify({
  537. RequestInfo: {
  538. 'context': data.context,
  539. 'command': data.command,
  540. 'parameters/forceRefreshConfigTags': data.forceRefreshConfigTags
  541. },
  542. "Requests/resource_filters": [{
  543. "service_name": data.serviceName,
  544. "component_name": data.componentName,
  545. 'hosts': data.hosts
  546. }]
  547. })
  548. }
  549. }
  550. },
  551. 'service.item.startStopLdapKnox': {
  552. 'real': '/clusters/{clusterName}/requests',
  553. 'mock': '',
  554. 'format': function (data) {
  555. return {
  556. type: 'POST',
  557. data: JSON.stringify({
  558. RequestInfo: {
  559. 'context': data.context,
  560. 'command': data.command
  561. },
  562. "Requests/resource_filters": [{
  563. "service_name": data.serviceName,
  564. "component_name": data.componentName,
  565. 'hosts': data.host
  566. }]
  567. })
  568. }
  569. }
  570. },
  571. 'service.item.executeCustomCommand': {
  572. 'real': '/clusters/{clusterName}/requests',
  573. 'mock': '',
  574. 'format': function (data) {
  575. return {
  576. type: 'POST',
  577. data: JSON.stringify({
  578. RequestInfo: {
  579. 'context': data.context,
  580. 'command': data.command
  581. },
  582. "Requests/resource_filters": [{
  583. "service_name": data.serviceName,
  584. "component_name": data.componentName,
  585. 'hosts': data.hosts
  586. }]
  587. })
  588. }
  589. }
  590. },
  591. /*************************CONFIG THEME****************************************/
  592. 'configs.theme': {
  593. 'real': '{stackVersionUrl}/services/{serviceName}/themes?ThemeInfo/default=true&fields=*',
  594. 'mock': '/data/configurations/theme.json'
  595. },
  596. 'configs.theme.services': {
  597. 'real': '{stackVersionUrl}/services?StackServices/service_name.in({serviceNames})&themes/ThemeInfo/default=true&fields=themes/*',
  598. 'mock': '/data/configurations/theme_services.json'
  599. },
  600. /*************************CONFIG GROUPS***************************************/
  601. 'configs.config_groups.load.all': {
  602. 'real': '/clusters/{clusterName}/config_groups?fields=*',
  603. 'mock': '/data/configurations/config_groups.json'
  604. },
  605. 'configs.config_groups.load.services': {
  606. 'real': '/clusters/{clusterName}/config_groups?ConfigGroup/tag.in({serviceList})&fields=*',
  607. 'mock': '/data/configurations/config_groups.json'
  608. },
  609. /*************************STACK CONFIGS**************************************/
  610. 'configs.stack_configs.load.all': {
  611. 'real': '{stackVersionUrl}/services?fields=configurations/*,StackServices/config_types/*',
  612. 'mock': '/data/stacks/HDP-2.2/configurations.json'
  613. },
  614. 'configs.stack_configs.load.services': {
  615. 'real': '{stackVersionUrl}/services?StackServices/service_name.in({serviceList})&fields=configurations/*,configurations/dependencies/*,StackServices/config_types/*',
  616. 'mock': '/data/stacks/HDP-2.2/configurations.json'
  617. },
  618. 'configs.stack_configs.load.service': {
  619. 'real': '{stackVersionUrl}/services/{serviceName}?fields=configurations/*,StackServices/config_types/*',
  620. 'mock': '/data/stacks/HDP-2.2/configurations.json'
  621. },
  622. /*************************CONFIG VERSIONS*************************************/
  623. 'configs.config_versions.load.all.min': {
  624. 'real': '/clusters/{clusterName}/configurations/service_config_versions?fields=service_config_version,user,hosts,group_id,group_name,is_current,createtime,service_name,service_config_version_note&minimal_response=true',
  625. 'mock': '/data/configurations/config_versions.json'
  626. },
  627. 'configs.config_versions.load.service.min': {
  628. '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',
  629. 'mock': '/data/configurations/config_versions.json'
  630. },
  631. 'configs.config_versions.load': {
  632. 'real': '/clusters/{clusterName}/configurations/service_config_versions?service_name={serviceName}&service_config_version={configVersion}&fields=*',
  633. 'mock': '/data/configurations/config_versions.json'
  634. },
  635. 'configs.config_versions.load.group': {
  636. 'real': '/clusters/{clusterName}/configurations/service_config_versions?service_name={serviceName}&group_id={configGroupId}&fields=*',
  637. 'mock': '/data/configurations/config_versions.json'
  638. },
  639. 'configs.config_versions.load.current_versions': {
  640. 'real': '/clusters/{clusterName}/configurations/service_config_versions?service_name.in({serviceNames})&is_current=true&fields=*',
  641. 'mock': '/data/configurations/config_versions.json'
  642. },
  643. 'service.load_config_groups': {
  644. 'real': '/clusters/{clusterName}/config_groups?ConfigGroup/tag={serviceName}&fields=*',
  645. 'mock': '/data/configurations/config_group.json'
  646. },
  647. 'reassign.load_configs': {
  648. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  649. 'mock': ''
  650. },
  651. 'reassign.save_configs': {
  652. 'real': '/clusters/{clusterName}',
  653. 'mock': '',
  654. 'type': 'PUT',
  655. 'format': function (data) {
  656. return {
  657. data: JSON.stringify({
  658. Clusters: {
  659. desired_config: {
  660. "type": data.siteName,
  661. "tag": 'version' + (new Date).getTime(),
  662. "properties": data.properties,
  663. "service_config_version_note": data.service_config_version_note
  664. }
  665. }
  666. })
  667. }
  668. }
  669. },
  670. 'config.cluster': {
  671. 'real': '{stackVersionUrl}/configurations?fields=*',
  672. 'mock': ''
  673. },
  674. 'config.advanced': {
  675. 'real': '{stackVersionUrl}/services/{serviceName}/configurations?fields=*',
  676. 'mock': '/data/wizard/stack/hdp/version{stackVersion}/{serviceName}.json'
  677. },
  678. 'config.advanced.partial': {
  679. 'real': '{stackVersionUrl}/services/?StackServices/service_name.in({serviceList})&fields=configurations/*{queryFilter}',
  680. 'mock': ''
  681. },
  682. 'config.config_types': {
  683. 'real': '{stackVersionUrl}/services/{serviceName}?fields=StackServices/config_types',
  684. 'mock': ''
  685. },
  686. 'config.tags': {
  687. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  688. 'mock': '/data/clusters/cluster.json'
  689. },
  690. 'config.tags_and_groups': {
  691. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs,config_groups/*{urlParams}',
  692. 'mock': '/data/clusters/tags_and_groups.json'
  693. },
  694. 'config_groups.all_fields': {
  695. 'real': '/clusters/{clusterName}/config_groups?fields=*',
  696. 'mock': ''
  697. },
  698. 'config_groups.get_config_group_by_id': {
  699. 'real': '/clusters/{clusterName}/config_groups/{id}',
  700. 'mock': ''
  701. },
  702. 'config_groups.update_config_group': {
  703. 'real': '/clusters/{clusterName}/config_groups/{id}',
  704. 'mock': '',
  705. 'type': 'PUT',
  706. 'format': function (data) {
  707. return {
  708. data: JSON.stringify(
  709. [
  710. data.configGroup
  711. ]
  712. )
  713. }
  714. }
  715. },
  716. 'config.on_site': {
  717. 'real': '/clusters/{clusterName}/configurations?{params}',
  718. 'mock': '/data/configurations/cluster_level_configs.json?{params}'
  719. },
  720. 'config.host_overrides': {
  721. 'real': '/clusters/{clusterName}/configurations?{params}',
  722. 'mock': '/data/configurations/host_level_overrides_configs.json?{params}'
  723. },
  724. 'config.cluster_env_site': {
  725. 'real': '/clusters/{clusterName}/configurations?type=cluster-env',
  726. 'mock': '/data/configuration/cluster_env_site.json'
  727. },
  728. 'host.host_component.add_new_component': {
  729. 'real': '/clusters/{clusterName}/hosts?Hosts/host_name={hostName}',
  730. 'mock': '/data/wizard/deploy/poll_1.json',
  731. 'format': function (data) {
  732. return {
  733. type: 'POST',
  734. data: data.data
  735. }
  736. }
  737. },
  738. 'host.host_component.slave_desired_admin_state': {
  739. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}/?fields=HostRoles/desired_admin_state',
  740. 'mock': '/data/hosts/HDP2/decommission_state.json'
  741. },
  742. 'host.host_component.decommission_status': {
  743. 'real': '/clusters/{clusterName}/services/{serviceName}/components/{componentName}/?fields=ServiceComponentInfo,host_components/HostRoles/state',
  744. 'mock': ''
  745. },
  746. 'host_components.hbase_regionserver.active': {
  747. 'real': '/clusters/{clusterName}/host_components?HostRoles/component_name=HBASE_REGIONSERVER&HostRoles/maintenance_state=OFF&HostRoles/desired_admin_state=INSERVICE&HostRoles/host_name.in({hostNames})',
  748. 'mock': ''
  749. },
  750. 'host.host_component.decommission_status_datanode': {
  751. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}?fields=metrics/dfs/namenode',
  752. 'mock': '/data/hosts/HDP2/decommission_state.json'
  753. },
  754. 'host.region_servers.in_inservice': {
  755. 'real': '/clusters/{clusterName}/host_components?HostRoles/component_name=HBASE_REGIONSERVER&HostRoles/desired_admin_state=INSERVICE&fields=HostRoles/host_name&minimal_response=true',
  756. 'mock': ''
  757. },
  758. 'host.host_component.decommission_slave': {
  759. 'real': '/clusters/{clusterName}/requests',
  760. 'mock': '',
  761. 'format': function (data) {
  762. return {
  763. type: 'POST',
  764. data: JSON.stringify({
  765. RequestInfo: {
  766. 'context': data.context,
  767. 'command': data.command,
  768. 'parameters': {
  769. 'slave_type': data.slaveType,
  770. 'excluded_hosts': data.hostName
  771. },
  772. 'operation_level': {
  773. level: "HOST_COMPONENT",
  774. cluster_name: data.clusterName,
  775. host_name: data.hostName,
  776. service_name: data.serviceName
  777. }
  778. },
  779. "Requests/resource_filters": [{"service_name": data.serviceName, "component_name": data.componentName}]
  780. })
  781. }
  782. }
  783. },
  784. 'host.host_component.recommission_and_restart': {
  785. 'real': '/clusters/{clusterName}/request_schedules',
  786. 'mock': '',
  787. 'format': function (data) {
  788. return {
  789. type: 'POST',
  790. data: JSON.stringify([{
  791. "RequestSchedule": {
  792. "batch": [{
  793. "requests": data.batches
  794. }, {
  795. "batch_settings": {
  796. "batch_separation_in_seconds": data.intervalTimeSeconds,
  797. "task_failure_tolerance": data.tolerateSize
  798. }
  799. }]
  800. }
  801. }])
  802. }
  803. }
  804. },
  805. 'host.host_component.refresh_configs': {
  806. 'real': '/clusters/{clusterName}/requests',
  807. 'mock': '',
  808. 'format': function (data) {
  809. return {
  810. type: 'POST',
  811. data: JSON.stringify({
  812. "RequestInfo": {
  813. "command": "CONFIGURE",
  814. "context": data.context
  815. },
  816. "Requests/resource_filters": data.resource_filters
  817. })
  818. }
  819. }
  820. },
  821. 'hosts.metrics': {
  822. 'real': '/clusters/{clusterName}/hosts?fields={metricName}',
  823. 'mock': '/data/cluster_metrics/cpu_1hr.json'
  824. },
  825. 'hosts.metrics.host_component': {
  826. 'real': '/clusters/{clusterName}/services/{serviceName}/components/{componentName}?fields=host_components/{metricName}',
  827. 'mock': '/data/cluster_metrics/cpu_1hr.json'
  828. },
  829. 'service.metrics.flume.channel_fill_percent': {
  830. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/flume/flume/CHANNEL/ChannelFillPercentage[{fromSeconds},{toSeconds},{stepSeconds}]',
  831. 'mock': '/data/services/metrics/flume/channelFillPct.json',
  832. 'testInProduction': true
  833. },
  834. 'service.metrics.flume.channel_size': {
  835. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/flume/flume/CHANNEL/ChannelSize[{fromSeconds},{toSeconds},{stepSeconds}]',
  836. 'mock': '/data/services/metrics/flume/channelSize.json',
  837. 'testInProduction': true
  838. },
  839. 'service.metrics.flume.sink_drain_success': {
  840. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/flume/flume/SINK/EventDrainSuccessCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  841. 'mock': '/data/services/metrics/flume/sinkDrainSuccessCount.json',
  842. 'testInProduction': true
  843. },
  844. 'service.metrics.flume.sink_connection_failed': {
  845. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/flume/flume/SINK/ConnectionFailedCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  846. 'mock': '/data/services/metrics/flume/sinkConnectionFailedCount.json',
  847. 'testInProduction': true
  848. },
  849. 'service.metrics.flume.source_accepted': {
  850. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/flume/flume/SOURCE/EventAcceptedCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  851. 'mock': '/data/services/metrics/flume/sourceEventAccepted.json',
  852. 'testInProduction': true
  853. },
  854. 'service.metrics.flume.channel_size_for_all': {
  855. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=metrics/flume/flume/CHANNEL/ChannelSize/rate[{fromSeconds},{toSeconds},{stepSeconds}]'
  856. },
  857. 'service.metrics.flume.gc': {
  858. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  859. 'mock': '/data/services/metrics/flume/jvmGcTime.json',
  860. 'testInProduction': true
  861. },
  862. 'service.metrics.flume.jvm_heap_used': {
  863. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/jvm/memHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}]',
  864. 'mock': '/data/services/metrics/flume/jvmMemHeapUsedM.json',
  865. 'testInProduction': true
  866. },
  867. 'service.metrics.flume.jvm_threads_runnable': {
  868. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/jvm/threadsRunnable[{fromSeconds},{toSeconds},{stepSeconds}]',
  869. 'mock': '/data/services/metrics/flume/jvmThreadsRunnable.json',
  870. 'testInProduction': true
  871. },
  872. 'service.metrics.flume.cpu_user': {
  873. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/cpu/cpu_user[{fromSeconds},{toSeconds},{stepSeconds}]',
  874. 'mock': '',
  875. 'testInProduction': true
  876. },
  877. 'service.metrics.flume.incoming_event_put_successCount': {
  878. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=metrics/flume/flume/CHANNEL/EventPutSuccessCount/rate[{fromSeconds},{toSeconds},{stepSeconds}]'
  879. },
  880. 'service.metrics.flume.outgoing_event_take_success_count': {
  881. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=metrics/flume/flume/CHANNEL/EventTakeSuccessCount/rate[{fromSeconds},{toSeconds},{stepSeconds}]'
  882. },
  883. 'service.metrics.hbase.cluster_requests': {
  884. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/cluster_requests[{fromSeconds},{toSeconds},{stepSeconds}]',
  885. 'mock': '/data/services/metrics/hbase/cluster_requests.json',
  886. 'testInProduction': true
  887. },
  888. 'service.metrics.hbase.hlog_split_size': {
  889. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitSize_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  890. 'mock': '/data/services/metrics/hbase/hlog_split_size.json',
  891. 'testInProduction': true
  892. },
  893. 'service.metrics.hbase.hlog_split_time': {
  894. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  895. 'mock': '/data/services/metrics/hbase/hlog_split_time.json',
  896. 'testInProduction': true
  897. },
  898. 'service.metrics.hbase.regionserver_queuesize': {
  899. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/flushQueueSize[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/compactionQueueSize[{fromSeconds},{toSeconds},{stepSeconds}]',
  900. 'mock': '/data/services/metrics/hbase/regionserver_queuesize.json',
  901. 'testInProduction': true
  902. },
  903. 'service.metrics.hbase.regionserver_regions': {
  904. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/regions[{fromSeconds},{toSeconds},{stepSeconds}]',
  905. 'mock': '/data/services/metrics/hbase/regionserver_regions.json',
  906. 'testInProduction': true
  907. },
  908. 'service.metrics.hbase.regionserver_rw_requests': {
  909. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/readRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/writeRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  910. 'mock': '/data/services/metrics/hbase/regionserver_rw_requests.json',
  911. 'testInProduction': true
  912. },
  913. 'service.metrics.ambari_metrics.master.average_load': {
  914. 'real': '/clusters/{clusterName}/services/AMBARI_METRICS/components/METRICS_COLLECTOR?fields=metrics/hbase/master/AverageLoad[{fromSeconds},{toSeconds},{stepSeconds}]',
  915. 'mock': '/data/services/metrics/ambari_metrics/master_average_load.json',
  916. 'testInProduction': true
  917. },
  918. 'service.metrics.ambari_metrics.region_server.store_files': {
  919. 'real': '/clusters/{clusterName}/services/AMBARI_METRICS/components/METRICS_COLLECTOR?fields=metrics/hbase/regionserver/storefiles[{fromSeconds},{toSeconds},{stepSeconds}]',
  920. 'mock': '/data/services/metrics/ambari_metrics/regionserver_store_files.json',
  921. 'testInProduction': true
  922. },
  923. 'service.metrics.ambari_metrics.region_server.regions': {
  924. 'real': '/clusters/{clusterName}/services/AMBARI_METRICS/components/METRICS_COLLECTOR?fields=metrics/hbase/regionserver/regions[{fromSeconds},{toSeconds},{stepSeconds}]',
  925. 'mock': '/data/services/metrics/ambari_metrics/regionserver_regions.json',
  926. 'testInProduction': true
  927. },
  928. 'service.metrics.ambari_metrics.region_server.request': {
  929. 'real': '/clusters/{clusterName}/services/AMBARI_METRICS/components/METRICS_COLLECTOR?fields=metrics/hbase/regionserver/requests[{fromSeconds},{toSeconds},{stepSeconds}]',
  930. 'mock': '/data/services/metrics/ambari_metrics/regionserver_requests.json',
  931. 'testInProduction': true
  932. },
  933. 'service.metrics.ambari_metrics.region_server.block_cache_hit_percent': {
  934. 'real': '/clusters/{clusterName}/services/AMBARI_METRICS/components/METRICS_COLLECTOR?fields=metrics/hbase/regionserver/blockCacheHitPercent[{fromSeconds},{toSeconds},{stepSeconds}]',
  935. 'mock': '/data/services/metrics/ambari_metrics/regionserver_blockcache_hitpercent.json',
  936. 'testInProduction': true
  937. },
  938. 'service.metrics.ambari_metrics.region_server.compaction_queue_size': {
  939. 'real': '/clusters/{clusterName}/services/AMBARI_METRICS/components/METRICS_COLLECTOR?fields=metrics/hbase/regionserver/compactionQueueSize[{fromSeconds},{toSeconds},{stepSeconds}]',
  940. 'mock': '/data/services/metrics/ambari_metrics/regionserver_compaction_queue_size.json',
  941. 'testInProduction': true
  942. },
  943. 'service.metrics.hdfs.block_status': {
  944. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/FSNamesystem/PendingReplicationBlocks[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/FSNamesystem/UnderReplicatedBlocks[{fromSeconds},{toSeconds},{stepSeconds}]',
  945. 'mock': '/data/services/metrics/hdfs/block_status.json',
  946. 'testInProduction': true
  947. },
  948. 'service.metrics.hdfs.file_operations': {
  949. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/namenode/FileInfoOps[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/namenode/CreateFileOps[{fromSeconds},{toSeconds},{stepSeconds}]',
  950. 'mock': '/data/services/metrics/hdfs/file_operations.json',
  951. 'testInProduction': true
  952. },
  953. 'service.metrics.hdfs.gc': {
  954. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  955. 'mock': '/data/services/metrics/hdfs/gc.json',
  956. 'testInProduction': true
  957. },
  958. 'service.metrics.hdfs.io': {
  959. 'real': '/clusters/{clusterName}/services/HDFS/components/DATANODE?fields=metrics/dfs/datanode/bytes_written[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/datanode/bytes_read[{fromSeconds},{toSeconds},{stepSeconds}]',
  960. 'mock': '/data/services/metrics/hdfs/io.json',
  961. 'testInProduction': true
  962. },
  963. 'service.metrics.hdfs.jvm_heap': {
  964. '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}]',
  965. 'mock': '/data/services/metrics/hdfs/jvm_heap.json',
  966. 'testInProduction': true
  967. },
  968. 'service.metrics.hdfs.jvm_threads': {
  969. '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}]',
  970. 'mock': '/data/services/metrics/hdfs/jvm_threads.json',
  971. 'testInProduction': true
  972. },
  973. 'service.metrics.hdfs.rpc': {
  974. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  975. 'mock': '/data/services/metrics/hdfs/rpc.json',
  976. 'testInProduction': true
  977. },
  978. 'service.metrics.hdfs.space_utilization': {
  979. '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}]',
  980. 'mock': '/data/services/metrics/hdfs/space_utilization.json',
  981. 'testInProduction': true
  982. },
  983. 'service.metrics.yarn.gc': {
  984. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  985. 'mock': '/data/services/metrics/yarn/gc.json',
  986. 'testInProduction': true
  987. },
  988. 'service.metrics.yarn.jobs_threads': {
  989. '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}]',
  990. 'mock': '/data/services/metrics/yarn/jvm_threads.json',
  991. 'testInProduction': true
  992. },
  993. 'service.metrics.yarn.rpc': {
  994. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  995. 'mock': '/data/services/metrics/yarn/rpc.json',
  996. 'testInProduction': true
  997. },
  998. 'service.metrics.yarn.jobs_heap': {
  999. '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}]',
  1000. 'mock': '/data/services/metrics/yarn/jvm_heap.json',
  1001. 'testInProduction': true
  1002. },
  1003. 'service.metrics.yarn.queue.allocated': {
  1004. '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}]',
  1005. 'mock': '',
  1006. 'testInProduction': true
  1007. },
  1008. 'service.metrics.yarn.queue.allocated.container': {
  1009. '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}]',
  1010. 'mock': '',
  1011. 'testInProduction': true
  1012. },
  1013. 'service.metrics.yarn.node.manager.statuses': {
  1014. '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}]',
  1015. 'mock': '',
  1016. 'testInProduction': true
  1017. },
  1018. 'service.metrics.yarn.queue.memory.resource': {
  1019. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=',
  1020. 'mock': '',
  1021. 'format': function (data, opt) {
  1022. var field1 = 'metrics/yarn/Queue/{queueName}/AllocatedMB[{fromSeconds},{toSeconds},{stepSeconds}]';
  1023. var field2 = 'metrics/yarn/Queue/{queueName}/AvailableMB[{fromSeconds},{toSeconds},{stepSeconds}]';
  1024. if (opt.url != null && data.queueNames != null && data.queueNames.length > 0) {
  1025. data.queueNames.forEach(function (q) {
  1026. data.queueName = q;
  1027. opt.url += (formatUrl(field1, data) + ",");
  1028. opt.url += (formatUrl(field2, data) + ",");
  1029. });
  1030. } else {
  1031. opt.url += (formatUrl(field1, data) + ",");
  1032. opt.url += (formatUrl(field2, data) + ",");
  1033. }
  1034. },
  1035. 'testInProduction': true
  1036. },
  1037. 'service.metrics.yarn.queue.apps.states.current': {
  1038. '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}]',
  1039. 'mock': '',
  1040. 'testInProduction': true
  1041. },
  1042. 'service.metrics.yarn.queue.apps.states.finished': {
  1043. '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}]',
  1044. 'mock': '',
  1045. 'testInProduction': true
  1046. },
  1047. 'service.metrics.kafka.broker.topic': {
  1048. '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}]',
  1049. 'mock': ''
  1050. },
  1051. 'service.metrics.kafka.controller.KafkaController': {
  1052. 'real': '/clusters/{clusterName}/services/KAFKA/components/KAFKA_BROKER?fields=metrics/kafka/controller/KafkaController/ActiveControllerCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  1053. 'mock': ''
  1054. },
  1055. 'service.metrics.kafka.controller.ControllerStats': {
  1056. '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}]',
  1057. 'mock': ''
  1058. },
  1059. 'service.metrics.kafka.log.LogFlushStats': {
  1060. 'real': '/clusters/{clusterName}/services/KAFKA/components/KAFKA_BROKER?fields=metrics/kafka/log/LogFlushStats/LogFlushRateAndTimeMs/1MinuteRate[{fromSeconds},{toSeconds},{stepSeconds}]',
  1061. 'mock': ''
  1062. },
  1063. 'service.metrics.kafka.server.ReplicaManager': {
  1064. '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}]',
  1065. 'mock': ''
  1066. },
  1067. 'service.metrics.kafka.server.ReplicaFetcherManager': {
  1068. 'real': '/clusters/{clusterName}/services/KAFKA/components/KAFKA_BROKER?fields=metrics/kafka/server/ReplicaFetcherManager/Replica-MaxLag[{fromSeconds},{toSeconds},{stepSeconds}]',
  1069. 'mock': ''
  1070. },
  1071. 'service.metrics.storm.nimbus': {
  1072. 'real': '/clusters/{clusterName}/services/STORM/components/NIMBUS?fields={metricsTemplate}',
  1073. 'mock': ''
  1074. },
  1075. 'dashboard.cluster_metrics.cpu': {
  1076. 'real': '/clusters/{clusterName}?fields=metrics/cpu/Nice._avg[{fromSeconds},{toSeconds},{stepSeconds}],metrics/cpu/System._avg[{fromSeconds},{toSeconds},{stepSeconds}],metrics/cpu/User._avg[{fromSeconds},{toSeconds},{stepSeconds}],metrics/cpu/Idle._avg[{fromSeconds},{toSeconds},{stepSeconds}]',
  1077. 'mock': '/data/cluster_metrics/cpu_1hr.json',
  1078. 'testInProduction': true
  1079. },
  1080. 'dashboard.cluster_metrics.load': {
  1081. 'real': '/clusters/{clusterName}/?fields=metrics/load/1-min._avg[{fromSeconds},{toSeconds},{stepSeconds}],metrics/load/CPUs._avg[{fromSeconds},{toSeconds},{stepSeconds}],metrics/load/Nodes._avg[{fromSeconds},{toSeconds},{stepSeconds}],metrics/load/Procs._avg[{fromSeconds},{toSeconds},{stepSeconds}]',
  1082. 'mock': '/data/cluster_metrics/load_1hr.json',
  1083. 'testInProduction': true
  1084. },
  1085. 'dashboard.cluster_metrics.memory': {
  1086. 'real': '/clusters/{clusterName}/?fields=metrics/memory/Buffer._avg[{fromSeconds},{toSeconds},{stepSeconds}],metrics/memory/Cache._avg[{fromSeconds},{toSeconds},{stepSeconds}],metrics/memory/Share._avg[{fromSeconds},{toSeconds},{stepSeconds}],metrics/memory/Swap._avg[{fromSeconds},{toSeconds},{stepSeconds}], metrics/memory/Total._avg[{fromSeconds},{toSeconds},{stepSeconds}], metrics/memory/Use._avg[{fromSeconds},{toSeconds},{stepSeconds}]',
  1087. 'mock': '/data/cluster_metrics/memory_1hr.json',
  1088. 'testInProduction': true
  1089. },
  1090. 'dashboard.cluster_metrics.network': {
  1091. 'real': '/clusters/{clusterName}/?fields=metrics/network/In._avg[{fromSeconds},{toSeconds},{stepSeconds}],metrics/network/Out._avg[{fromSeconds},{toSeconds},{stepSeconds}]',
  1092. 'mock': '/data/cluster_metrics/network_1hr.json',
  1093. 'testInProduction': true
  1094. },
  1095. 'host.metrics.cpu': {
  1096. '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}]',
  1097. 'mock': '/data/hosts/metrics/cpu.json',
  1098. 'testInProduction': true
  1099. },
  1100. 'host.metrics.disk': {
  1101. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/disk/disk_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/disk/disk_free[{fromSeconds},{toSeconds},{stepSeconds}]',
  1102. 'mock': '/data/hosts/metrics/disk.json',
  1103. 'testInProduction': true
  1104. },
  1105. 'host.metrics.load': {
  1106. '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}]',
  1107. 'mock': '/data/hosts/metrics/load.json',
  1108. 'testInProduction': true
  1109. },
  1110. 'host.metrics.memory': {
  1111. '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}]',
  1112. 'mock': '/data/hosts/metrics/memory.json',
  1113. 'testInProduction': true
  1114. },
  1115. 'host.metrics.network': {
  1116. '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}]',
  1117. 'mock': '/data/hosts/metrics/network.json',
  1118. 'testInProduction': true
  1119. },
  1120. 'host.metrics.processes': {
  1121. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/process/proc_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/process/proc_run[{fromSeconds},{toSeconds},{stepSeconds}]',
  1122. 'mock': '/data/hosts/metrics/processes.json',
  1123. 'testInProduction': true
  1124. },
  1125. 'admin.security_status': {
  1126. 'real': '/clusters/{clusterName}?fields=Clusters/security_type',
  1127. 'mock': '',
  1128. 'format': function () {
  1129. return {
  1130. timeout: 10000
  1131. };
  1132. }
  1133. },
  1134. 'settings.get.user_pref': {
  1135. 'real': '/persist/{key}',
  1136. 'mock': '/data/user_settings/{key}.json'
  1137. },
  1138. 'settings.post.user_pref': {
  1139. 'real': '/persist',
  1140. 'mock': '',
  1141. 'type': 'POST',
  1142. 'format': function (data) {
  1143. return {
  1144. data: JSON.stringify(data.keyValuePair)
  1145. }
  1146. }
  1147. },
  1148. 'cluster.load_cluster_name': {
  1149. 'real': '/clusters',
  1150. 'mock': '/data/clusters/info.json'
  1151. },
  1152. 'cluster.load_last_upgrade': {
  1153. 'real': '/clusters/{clusterName}/upgrades?fields=Upgrade/request_status,Upgrade/request_id,Upgrade/to_version,Upgrade/direction',
  1154. 'mock': '/data/stack_versions/upgrades.json'
  1155. },
  1156. 'cluster.update_upgrade_version': {
  1157. 'real': '/stacks/{stackName}/versions?fields=services/StackServices,Versions',
  1158. 'mock': '/data/wizard/stack/stacks.json',
  1159. 'format': function (data) {
  1160. return {
  1161. data: data.data
  1162. };
  1163. }
  1164. },
  1165. 'cluster.load_repositories': {
  1166. 'real': '/stacks/{stackName}/versions/{stackVersion}/operating_systems?fields=repositories/*',
  1167. 'mock': '/data/stacks/HDP-2.1/operating_systems.json',
  1168. 'format': function (data) {
  1169. return {
  1170. data: data.data
  1171. };
  1172. }
  1173. },
  1174. 'cluster.load_detailed_repo_version': {
  1175. 'real': '/clusters/{clusterName}/stack_versions?ClusterStackVersions/state=CURRENT&fields=repository_versions/RepositoryVersions/repository_version&minimal_response=true',
  1176. 'mock': '/data/stack_versions/stack_version_all.json'
  1177. },
  1178. 'cluster.save_provisioning_state': {
  1179. 'real': '/clusters/{clusterName}',
  1180. 'type': 'PUT',
  1181. 'format': function (data) {
  1182. return {
  1183. data: JSON.stringify({
  1184. "Clusters": {
  1185. "provisioning_state": data.state
  1186. }
  1187. })
  1188. };
  1189. }
  1190. },
  1191. 'admin.high_availability.polling': {
  1192. 'real': '/clusters/{clusterName}/requests/{requestId}?fields=tasks/*,Requests/*',
  1193. 'mock': '/data/background_operations/host_upgrade_tasks.json'
  1194. },
  1195. 'admin.high_availability.getNnCheckPointStatus': {
  1196. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/NAMENODE',
  1197. 'mock': ''
  1198. },
  1199. 'admin.high_availability.getJnCheckPointStatus': {
  1200. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/JOURNALNODE?fields=metrics',
  1201. 'mock': ''
  1202. },
  1203. 'admin.high_availability.getHostComponent': {
  1204. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  1205. 'mock': ''
  1206. },
  1207. 'admin.high_availability.create_component': {
  1208. 'real': '/clusters/{clusterName}/hosts?Hosts/host_name={hostName}',
  1209. 'mock': '',
  1210. 'type': 'POST',
  1211. 'format': function (data) {
  1212. return {
  1213. data: JSON.stringify({
  1214. "host_components": [
  1215. {
  1216. "HostRoles": {
  1217. "component_name": data.componentName
  1218. }
  1219. }
  1220. ]
  1221. })
  1222. }
  1223. }
  1224. },
  1225. 'admin.high_availability.create_journalnode': {
  1226. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  1227. 'mock': '',
  1228. 'type': 'POST',
  1229. 'format': function () {
  1230. return {
  1231. data: JSON.stringify({
  1232. "components": [
  1233. {
  1234. "ServiceComponentInfo": {
  1235. "component_name": "JOURNALNODE"
  1236. }
  1237. }
  1238. ]
  1239. })
  1240. }
  1241. }
  1242. },
  1243. 'admin.high_availability.check_journalnode': {
  1244. 'real': '/clusters/{clusterName}/services/HDFS/components/JOURNALNODE?fields=ServiceComponentInfo/state',
  1245. 'mock': ''
  1246. },
  1247. 'common.create_component': {
  1248. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name={serviceName}',
  1249. 'mock': '',
  1250. 'type': 'POST',
  1251. 'format': function (data) {
  1252. return {
  1253. data: JSON.stringify({
  1254. "components": [
  1255. {
  1256. "ServiceComponentInfo": {
  1257. "component_name": data.componentName
  1258. }
  1259. }
  1260. ]
  1261. })
  1262. }
  1263. }
  1264. },
  1265. 'admin.high_availability.create_zkfc': {
  1266. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  1267. 'mock': '',
  1268. 'type': 'POST',
  1269. 'format': function () {
  1270. return {
  1271. data: JSON.stringify({
  1272. "components": [
  1273. {
  1274. "ServiceComponentInfo": {
  1275. "component_name": "ZKFC"
  1276. }
  1277. }
  1278. ]
  1279. })
  1280. }
  1281. }
  1282. },
  1283. 'admin.high_availability.load_configs': {
  1284. 'real': '/clusters/{clusterName}/configurations?(type=core-site&tag={coreSiteTag})|(type=hdfs-site&tag={hdfsSiteTag})',
  1285. 'mock': ''
  1286. },
  1287. 'admin.high_availability.save_configs': {
  1288. 'real': '/clusters/{clusterName}',
  1289. 'mock': '',
  1290. 'type': 'PUT',
  1291. 'format': function (data) {
  1292. return {
  1293. data: JSON.stringify({
  1294. Clusters: {
  1295. desired_config: {
  1296. "type": data.siteName,
  1297. "tag": 'version' + (new Date).getTime(),
  1298. "properties": data.properties
  1299. }
  1300. }
  1301. })
  1302. }
  1303. }
  1304. },
  1305. 'admin.high_availability.load_hbase_configs': {
  1306. 'real': '/clusters/{clusterName}/configurations?type=hbase-site&tag={hbaseSiteTag}',
  1307. 'mock': ''
  1308. },
  1309. 'admin.security.cluster_configs': {
  1310. 'real': '/clusters/{clusterName}',
  1311. 'mock': '',
  1312. 'format': function () {
  1313. return {
  1314. timeout: 10000
  1315. };
  1316. }
  1317. },
  1318. 'admin.security.cluster_configs.kerberos': {
  1319. 'real': '/clusters/{clusterName}/configurations?type=kerberos-env&fields=properties/*',
  1320. 'mock': '',
  1321. 'format': function () {
  1322. return {
  1323. timeout: 10000
  1324. };
  1325. }
  1326. },
  1327. 'admin.get.all_configurations': {
  1328. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  1329. 'mock': '',
  1330. 'format': function () {
  1331. return {
  1332. timeout: 10000
  1333. };
  1334. }
  1335. },
  1336. 'admin.security.add.cluster_configs': {
  1337. 'real': '/clusters/{clusterName}' + '?fields=Clusters/desired_configs',
  1338. 'mock': '',
  1339. 'format': function () {
  1340. return {
  1341. timeout: 10000
  1342. };
  1343. }
  1344. },
  1345. 'kerberos.session.state': {
  1346. 'real': '/clusters/{clusterName}/services/KERBEROS?fields=Services/attributes/kdc_validation_result,Services/attributes/kdc_validation_failure_details',
  1347. 'mock': ''
  1348. },
  1349. 'admin.kerberize.cluster': {
  1350. 'type': 'PUT',
  1351. 'real': '/clusters/{clusterName}',
  1352. 'mock': '/data/wizard/kerberos/kerberize_cluster.json',
  1353. 'format' : function (data) {
  1354. return {
  1355. data: JSON.stringify(data.data)
  1356. }
  1357. }
  1358. },
  1359. 'admin.unkerberize.cluster': {
  1360. 'type': 'PUT',
  1361. 'real': '/clusters/{clusterName}',
  1362. 'format': function (data) {
  1363. return {
  1364. data: JSON.stringify({
  1365. Clusters: {
  1366. security_type: "NONE"
  1367. }
  1368. })
  1369. }
  1370. }
  1371. },
  1372. 'admin.unkerberize.cluster.skip': {
  1373. 'type': 'PUT',
  1374. 'real': '/clusters/{clusterName}?manage_kerberos_identities=false',
  1375. 'mock': '',
  1376. 'format': function (data) {
  1377. return {
  1378. data: JSON.stringify({
  1379. Clusters: {
  1380. security_type: "NONE"
  1381. }
  1382. })
  1383. }
  1384. }
  1385. },
  1386. 'get.cluster.artifact': {
  1387. 'real': '/clusters/{clusterName}/artifacts/{artifactName}?fields=artifact_data',
  1388. 'mock': '/data/wizard/kerberos/stack_descriptors.json'
  1389. },
  1390. 'admin.kerberize.stack_descriptor': {
  1391. 'real': '/stacks/{stackName}/versions/{stackVersionNumber}/artifacts/kerberos_descriptor?fields=artifact_data',
  1392. 'mock': '/data/wizard/kerberos/stack_descriptors.json'
  1393. },
  1394. 'admin.kerberize.cluster_descriptor': {
  1395. 'real': '/clusters/{clusterName}/artifacts/kerberos_descriptor?fields=artifact_data',
  1396. 'mock': '/data/wizard/kerberos/stack_descriptors.json'
  1397. },
  1398. 'admin.kerberos.cluster.artifact.create': {
  1399. 'type': 'POST',
  1400. 'real': '/clusters/{clusterName}/artifacts/{artifactName}',
  1401. 'format' : function (data) {
  1402. return {
  1403. data: JSON.stringify(data.data)
  1404. }
  1405. }
  1406. },
  1407. 'admin.kerberos.cluster.artifact.update': {
  1408. 'type': 'PUT',
  1409. 'real': '/clusters/{clusterName}/artifacts/{artifactName}',
  1410. 'format' : function (data) {
  1411. return {
  1412. data: JSON.stringify(data.data)
  1413. }
  1414. }
  1415. },
  1416. 'admin.kerberos.cluster.csv': {
  1417. 'real': '/clusters/{clusterName}/kerberos_identities?fields=*&format=csv',
  1418. 'mock': '',
  1419. 'format': function(data) {
  1420. return {
  1421. dataType: 'text',
  1422. data: data.data
  1423. }
  1424. }
  1425. },
  1426. 'admin.poll.kerberize.cluster.request': {
  1427. 'real': '/clusters/{clusterName}/requests/{requestId}?fields=stages/Stage/context,stages/Stage/status,stages/Stage/progress_percent,stages/tasks/*,Requests/*',
  1428. 'mock': '/data/wizard/kerberos/kerberize_cluster.json'
  1429. },
  1430. 'admin.stack_upgrade.run_upgrade': {
  1431. 'real': '/clusters/{clusterName}',
  1432. 'mock': '',
  1433. 'format': function (data) {
  1434. return {
  1435. type: 'PUT',
  1436. data: data.data
  1437. };
  1438. }
  1439. },
  1440. 'admin.user.create': {
  1441. 'real': '/users/{user}',
  1442. 'mock': '/data/users/users.json',
  1443. 'format': function (data) {
  1444. return {
  1445. type: 'POST',
  1446. data: JSON.stringify(data.data)
  1447. }
  1448. }
  1449. },
  1450. 'admin.user.edit': {
  1451. 'real': '/users/{user}',
  1452. 'mock': '/data/users/users.json',
  1453. 'format': function (data) {
  1454. return {
  1455. type: 'PUT',
  1456. data: data.data
  1457. }
  1458. }
  1459. },
  1460. 'admin.stack_upgrade.do_poll': {
  1461. 'real': '/clusters/{cluster}/requests/{requestId}?fields=tasks/*',
  1462. 'mock': '/data/wizard/{mock}'
  1463. },
  1464. 'admin.upgrade.data': {
  1465. 'real': '/clusters/{clusterName}/upgrades/{id}?upgrade_groups/UpgradeGroup/status!=PENDING&fields=' +
  1466. 'Upgrade/progress_percent,Upgrade/request_context,Upgrade/request_status,Upgrade/direction,' +
  1467. 'upgrade_groups/UpgradeGroup,' +
  1468. 'upgrade_groups/upgrade_items/UpgradeItem/status,' +
  1469. 'upgrade_groups/upgrade_items/UpgradeItem/context,' +
  1470. 'upgrade_groups/upgrade_items/UpgradeItem/group_id,' +
  1471. 'upgrade_groups/upgrade_items/UpgradeItem/progress_percent,' +
  1472. 'upgrade_groups/upgrade_items/UpgradeItem/request_id,' +
  1473. 'upgrade_groups/upgrade_items/UpgradeItem/skippable,' +
  1474. 'upgrade_groups/upgrade_items/UpgradeItem/stage_id,' +
  1475. 'upgrade_groups/upgrade_items/UpgradeItem/status,' +
  1476. 'upgrade_groups/upgrade_items/UpgradeItem/text&' +
  1477. 'minimal_response=true',
  1478. 'mock': '/data/stack_versions/upgrade.json'
  1479. },
  1480. 'admin.upgrade.state': {
  1481. 'real': '/clusters/{clusterName}/upgrades/{id}?fields=Upgrade',
  1482. 'mock': '/data/stack_versions/upgrade.json'
  1483. },
  1484. 'admin.upgrade.upgrade_item': {
  1485. 'real': '/clusters/{clusterName}/upgrades/{upgradeId}/upgrade_groups/{groupId}/upgrade_items/{stageId}?fields=' +
  1486. 'UpgradeItem/group_id,' +
  1487. 'UpgradeItem/stage_id,' +
  1488. 'tasks/Tasks/*&' +
  1489. 'minimal_response=true',
  1490. 'mock': '/data/stack_versions/upgrade_item.json'
  1491. },
  1492. 'admin.upgrade.service_checks': {
  1493. 'real': '/clusters/{clusterName}/upgrades/{upgradeId}/upgrade_groups?upgrade_items/UpgradeItem/status=COMPLETED&upgrade_items/tasks/Tasks/status.in(FAILED,ABORTED,TIMEDOUT)&upgrade_items/tasks/Tasks/command=SERVICE_CHECK&fields=upgrade_items/tasks/Tasks/command_detail,upgrade_items/tasks/Tasks/status&minimal_response=true'
  1494. },
  1495. 'admin.upgrade.start': {
  1496. 'real': '/clusters/{clusterName}/upgrades',
  1497. 'mock': '/data/stack_versions/start_upgrade.json',
  1498. 'type': 'POST',
  1499. 'format': function (data) {
  1500. return {
  1501. data: JSON.stringify({
  1502. "Upgrade": {
  1503. "repository_version": data.value
  1504. }
  1505. })
  1506. }
  1507. }
  1508. },
  1509. 'admin.downgrade.start': {
  1510. 'real': '/clusters/{clusterName}/upgrades',
  1511. 'mock': '/data/stack_versions/start_upgrade.json',
  1512. 'type': 'POST',
  1513. 'format': function (data) {
  1514. return {
  1515. data: JSON.stringify({
  1516. "RequestInfo": {
  1517. "downgrade": "true"
  1518. },
  1519. "Upgrade": {
  1520. "repository_version": data.value
  1521. }
  1522. })
  1523. }
  1524. }
  1525. },
  1526. 'admin.upgrade.abort': {
  1527. 'real': '/clusters/{clusterName}/upgrades/{upgradeId}',
  1528. 'mock': '',
  1529. 'type': 'PUT',
  1530. 'format': function (data) {
  1531. return {
  1532. data: JSON.stringify({
  1533. "Upgrade": {
  1534. "request_status": "ABORTED"
  1535. }
  1536. })
  1537. }
  1538. }
  1539. },
  1540. 'admin.upgrade.upgradeItem.setState': {
  1541. 'real': '/clusters/{clusterName}/upgrades/{upgradeId}/upgrade_groups/{groupId}/upgrade_items/{itemId}',
  1542. 'mock': '',
  1543. type: 'PUT',
  1544. 'format': function (data) {
  1545. return {
  1546. data: JSON.stringify({
  1547. "UpgradeItem" : {
  1548. "status" : data.status
  1549. }
  1550. })
  1551. };
  1552. }
  1553. },
  1554. 'admin.stack_versions.all': {
  1555. 'real': '/clusters/{clusterName}/stack_versions?fields=ClusterStackVersions/*,repository_versions/RepositoryVersions/*&minimal_response=true',
  1556. 'mock': '/data/stack_versions/stack_version_all.json'
  1557. },
  1558. 'admin.stack_version.install.repo_version': {
  1559. 'real': '/clusters/{clusterName}/stack_versions',
  1560. 'format': function (data) {
  1561. return {
  1562. type: 'POST',
  1563. data: JSON.stringify({
  1564. ClusterStackVersions: data.ClusterStackVersions
  1565. })
  1566. }
  1567. },
  1568. 'mock': ''
  1569. },
  1570. 'admin.stack_versions.edit.repo': {
  1571. 'real': '/stacks/{stackName}/versions/{stackVersion}/repository_versions/{repoVersionId}',
  1572. 'mock': '',
  1573. 'type': 'PUT',
  1574. 'format': function (data) {
  1575. return {
  1576. data: JSON.stringify(data.repoVersion)
  1577. }
  1578. }
  1579. },
  1580. 'admin.stack_versions.validate.repo': {
  1581. 'real': '/stacks/{stackName}/versions/{stackVersion}/operating_systems/{osType}/repositories/{repoId}?validate_only=true',
  1582. 'mock': '',
  1583. 'type': 'POST',
  1584. 'format': function (data) {
  1585. return {
  1586. data: JSON.stringify({
  1587. "Repositories": {
  1588. "base_url": data.baseUrl
  1589. }
  1590. })
  1591. }
  1592. }
  1593. },
  1594. 'admin.rolling_upgrade.pre_upgrade_check': {
  1595. 'real': '/clusters/{clusterName}/rolling_upgrades_check?fields=*&UpgradeChecks/repository_version={value}',
  1596. 'mock': '/data/stack_versions/pre_upgrade_check.json'
  1597. },
  1598. 'admin.kerberos_security.checks': {
  1599. //TODO when api will be known
  1600. 'real': '',
  1601. 'mock': '/data/stack_versions/pre_upgrade_check.json'
  1602. },
  1603. 'admin.kerberos_security.test_connection': {
  1604. 'real': '/kdc_check/{kdcHostname}',
  1605. 'mock': '',
  1606. 'format': function () {
  1607. return {
  1608. dataType: 'text'
  1609. };
  1610. }
  1611. },
  1612. 'admin.kerberos_security.regenerate_keytabs': {
  1613. 'real': '/clusters/{clusterName}?regenerate_keytabs={type}',
  1614. 'mock': '',
  1615. 'type': 'PUT',
  1616. 'format': function (data) {
  1617. return {
  1618. data: JSON.stringify({
  1619. "Clusters" : {
  1620. "security_type" : "KERBEROS"
  1621. }
  1622. })
  1623. }
  1624. }
  1625. },
  1626. 'wizard.advanced_repositories.valid_url': {
  1627. 'real': '/stacks/{stackName}/versions/{stackVersion}/operating_systems/{osType}/repositories/{repoId}',
  1628. 'mock': '',
  1629. 'type': 'PUT',
  1630. 'format': function (data) {
  1631. return {
  1632. data: JSON.stringify(data.data)
  1633. }
  1634. }
  1635. },
  1636. 'wizard.service_components': {
  1637. 'real': '{stackUrl}/services?fields=StackServices/*,components/*,components/dependencies/Dependencies/scope,artifacts/Artifacts/artifact_name',
  1638. 'mock': '/data/stacks/HDP-2.1/service_components.json',
  1639. 'format': function (data) {
  1640. return {
  1641. timeout: 10000
  1642. };
  1643. }
  1644. },
  1645. 'wizard.step9.installer.get_host_status': {
  1646. 'real': '/clusters/{cluster}/hosts?fields=Hosts/host_state,host_components/HostRoles/state',
  1647. 'mock': '/data/wizard/deploy/5_hosts/get_host_state.json'
  1648. },
  1649. 'wizard.step9.load_log': {
  1650. 'real': '/clusters/{cluster}/requests/{requestId}?fields=tasks/Tasks/command,tasks/Tasks/command_detail,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',
  1651. 'mock': '/data/wizard/deploy/5_hosts/poll_{numPolls}.json',
  1652. 'format': function () {
  1653. return {
  1654. dataType: 'text'
  1655. };
  1656. }
  1657. },
  1658. 'wizard.step8.existing_cluster_names': {
  1659. 'real': '/clusters',
  1660. 'mock': ''
  1661. },
  1662. 'wizard.step8.create_cluster': {
  1663. 'real': '/clusters/{cluster}',
  1664. 'mock': '',
  1665. 'format': function (data) {
  1666. return {
  1667. type: 'POST',
  1668. dataType: 'text',
  1669. data: data.data
  1670. }
  1671. }
  1672. },
  1673. 'wizard.step8.create_selected_services': {
  1674. 'type': 'POST',
  1675. 'real': '/clusters/{cluster}/services',
  1676. 'mock': '/data/stacks/HDP-2.1/recommendations.json',
  1677. 'format': function (data) {
  1678. return {
  1679. dataType: 'text',
  1680. data: data.data
  1681. }
  1682. }
  1683. },
  1684. 'wizard.step8.create_components': {
  1685. 'real': '/clusters/{cluster}/services?ServiceInfo/service_name={serviceName}',
  1686. 'mock': '',
  1687. 'format': function (data) {
  1688. return {
  1689. type: 'POST',
  1690. dataType: 'text',
  1691. data: data.data
  1692. }
  1693. }
  1694. },
  1695. 'wizard.step8.register_host_to_cluster': {
  1696. 'real': '/clusters/{cluster}/hosts',
  1697. 'mock': '',
  1698. 'format': function (data) {
  1699. return {
  1700. type: 'POST',
  1701. dataType: 'text',
  1702. data: data.data
  1703. }
  1704. }
  1705. },
  1706. 'wizard.step8.register_host_to_component': {
  1707. 'real': '/clusters/{cluster}/hosts',
  1708. 'mock': '',
  1709. 'format': function (data) {
  1710. return {
  1711. type: 'POST',
  1712. dataType: 'text',
  1713. data: data.data
  1714. }
  1715. }
  1716. },
  1717. 'wizard.step8.apply_configuration_groups': {
  1718. 'real': '/clusters/{cluster}/config_groups',
  1719. 'mock': '',
  1720. 'format': function (data) {
  1721. return {
  1722. type: 'POST',
  1723. dataType: 'text',
  1724. data: data.data
  1725. }
  1726. }
  1727. },
  1728. 'wizard.step8.set_local_repos': {
  1729. 'real': '{stackVersionURL}/operating_systems/{osType}/repositories/{repoId}',
  1730. 'mock': '',
  1731. 'format': function (data) {
  1732. return {
  1733. type: 'PUT',
  1734. dataType: 'text',
  1735. data: data.data
  1736. }
  1737. }
  1738. },
  1739. 'wizard.step3.jdk_check': {
  1740. 'real': '/requests',
  1741. 'mock': '',
  1742. 'format': function (data) {
  1743. return {
  1744. type: 'POST',
  1745. data: JSON.stringify({
  1746. "RequestInfo": {
  1747. "context": "Check hosts",
  1748. "action": "check_host",
  1749. "parameters": {
  1750. "threshold": "60",
  1751. "java_home": data.java_home,
  1752. "jdk_location": data.jdk_location,
  1753. "check_execute_list": "java_home_check"
  1754. }
  1755. },
  1756. "Requests/resource_filters": [{
  1757. "hosts": data.host_names
  1758. }]
  1759. })
  1760. }
  1761. }
  1762. },
  1763. 'wizard.step3.jdk_check.get_results': {
  1764. 'real': '/requests/{requestIndex}?fields=*,tasks/Tasks/host_name,tasks/Tasks/status,tasks/Tasks/structured_out',
  1765. 'mock': '/data/requests/host_check/jdk_check_results.json'
  1766. },
  1767. 'wizard.step3.host_info': {
  1768. '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/os_family,Hosts/ip',
  1769. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  1770. 'format': function () {
  1771. return {
  1772. contentType: 'application/json'
  1773. };
  1774. }
  1775. },
  1776. 'wizard.loadrecommendations': {
  1777. 'real': '{stackVersionUrl}/recommendations',
  1778. 'mock': '/data/stacks/HDP-2.1/recommendations.json',
  1779. 'type': 'POST',
  1780. 'format': function (data) {
  1781. var q = {
  1782. hosts: data.hosts,
  1783. services: data.services,
  1784. recommend: data.recommend
  1785. };
  1786. if (data.recommendations) {
  1787. q.recommendations = data.recommendations;
  1788. }
  1789. return {
  1790. data: JSON.stringify(q)
  1791. }
  1792. }
  1793. },
  1794. // TODO: merge with wizard.loadrecommendations query
  1795. 'config.recommendations': {
  1796. 'real': '{stackVersionUrl}/recommendations',
  1797. 'mock': '/data/configurations/recommendations/configuration_dependencies.json',
  1798. //'mock': '/data/stacks/HDP-2.1/recommendations_configs.json',
  1799. 'type': 'POST',
  1800. 'format': function (data) {
  1801. return {
  1802. data: JSON.stringify(data.dataToSend)
  1803. }
  1804. }
  1805. },
  1806. 'config.validations': {
  1807. 'real': '{stackVersionUrl}/validations',
  1808. 'mock': '/data/stacks/HDP-2.1/validations.json',
  1809. 'type': 'POST',
  1810. 'format': function (data) {
  1811. return {
  1812. data: JSON.stringify({
  1813. hosts: data.hosts,
  1814. services: data.services,
  1815. validate: data.validate,
  1816. recommendations: data.recommendations
  1817. })
  1818. }
  1819. }
  1820. },
  1821. 'preinstalled.checks': {
  1822. 'real': '/requests',
  1823. 'mock': '',
  1824. 'format': function (data) {
  1825. return {
  1826. type: 'POST',
  1827. data: JSON.stringify({
  1828. "RequestInfo": data.RequestInfo,
  1829. "Requests/resource_filters": [data.resource_filters]
  1830. })
  1831. }
  1832. }
  1833. },
  1834. 'preinstalled.checks.tasks': {
  1835. 'real': '/requests/{requestId}?fields=tasks/Tasks,Requests/inputs,Requests/request_status',
  1836. 'mock': '/data/requests/host_check/1.json'
  1837. },
  1838. 'wizard.step3.rerun_checks': {
  1839. 'real': '/hosts?fields=Hosts/last_agent_env',
  1840. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  1841. 'format': function () {
  1842. return {
  1843. contentType: 'application/json'
  1844. };
  1845. }
  1846. },
  1847. 'wizard.step3.bootstrap': {
  1848. 'real': '/bootstrap/{bootRequestId}',
  1849. 'mock': '/data/wizard/bootstrap/poll_{numPolls}.json'
  1850. },
  1851. 'wizard.step3.is_hosts_registered': {
  1852. 'real': '/hosts?fields=Hosts/host_status',
  1853. 'mock': '/data/wizard/bootstrap/single_host_registration.json'
  1854. },
  1855. 'wizard.stacks': {
  1856. 'real': '/stacks',
  1857. 'mock': '/data/wizard/stack/stacks2.json'
  1858. },
  1859. 'wizard.stacks_versions': {
  1860. 'real': '/stacks/{stackName}/versions?fields=Versions,operating_systems/repositories/Repositories',
  1861. 'mock': '/data/wizard/stack/{stackName}_versions.json'
  1862. },
  1863. 'wizard.launch_bootstrap': {
  1864. 'real': '/bootstrap',
  1865. 'mock': '/data/wizard/bootstrap/bootstrap.json',
  1866. 'type': 'POST',
  1867. 'format': function (data) {
  1868. return {
  1869. contentType: 'application/json',
  1870. data: data.bootStrapData,
  1871. popup: data.popup
  1872. }
  1873. }
  1874. },
  1875. 'router.login': {
  1876. 'real': '/users/{loginName}?fields=*,privileges/PrivilegeInfo/cluster_name,privileges/PrivilegeInfo/permission_name',
  1877. 'mock': '/data/users/user_{usr}.json',
  1878. 'format': function (data) {
  1879. var statusCode = jQuery.extend({}, require('data/statusCodes'));
  1880. statusCode['403'] = function () {
  1881. console.log("Error code 403: Forbidden.");
  1882. };
  1883. return {
  1884. statusCode: statusCode
  1885. };
  1886. }
  1887. },
  1888. 'users.all': {
  1889. real: '/users/?fields=*',
  1890. mock: '/data/users/users.json'
  1891. },
  1892. 'users.privileges': {
  1893. real: '/privileges?fields=*',
  1894. mock: '/data/users/privileges.json'
  1895. },
  1896. 'router.user.privileges': {
  1897. real: '/privileges?PrivilegeInfo/principal_name={userName}&fields=*',
  1898. mock: '/data/users/privileges_{userName}.json'
  1899. },
  1900. 'router.login.clusters': {
  1901. 'real': '/clusters?fields=Clusters/provisioning_state',
  1902. 'mock': '/data/clusters/info.json'
  1903. },
  1904. 'router.logoff': {
  1905. 'real': '/logout',
  1906. 'mock': ''
  1907. },
  1908. 'ambari.service': {
  1909. 'real': '/services/AMBARI/components/AMBARI_SERVER{fields}',
  1910. 'mock': '/data/services/ambari_server.json'
  1911. },
  1912. 'config_groups.create': {
  1913. 'real': '/clusters/{clusterName}/config_groups',
  1914. 'mock': '',
  1915. 'format': function (data) {
  1916. return {
  1917. type: 'POST',
  1918. data: JSON.stringify([{
  1919. "ConfigGroup": {
  1920. "group_name": data.group_name,
  1921. "tag": data.service_id,
  1922. "description": data.description,
  1923. "desired_configs": data.desired_configs,
  1924. "hosts": data.hosts
  1925. }
  1926. }])
  1927. }
  1928. }
  1929. },
  1930. 'config_groups.update': {
  1931. 'real': '/clusters/{clusterName}/config_groups/{id}',
  1932. 'mock': '',
  1933. 'format': function (data) {
  1934. return {
  1935. type: 'PUT',
  1936. data: JSON.stringify(data.data)
  1937. }
  1938. }
  1939. },
  1940. 'rolling_restart.post': {
  1941. 'real': '/clusters/{clusterName}/request_schedules',
  1942. 'mock': '',
  1943. 'format': function (data) {
  1944. return {
  1945. type: 'POST',
  1946. data: JSON.stringify([{
  1947. "RequestSchedule": {
  1948. "batch": [{
  1949. "requests": data.batches
  1950. }, {
  1951. "batch_settings": {
  1952. "batch_separation_in_seconds": data.intervalTimeSeconds,
  1953. "task_failure_tolerance": data.tolerateSize
  1954. }
  1955. }]
  1956. }
  1957. }])
  1958. }
  1959. }
  1960. },
  1961. 'request_schedule.get': {
  1962. 'real': '/clusters/{clusterName}/request_schedules/{request_schedule_id}',
  1963. 'mock': ''
  1964. },
  1965. 'restart.hostComponents': {
  1966. 'real': '/clusters/{clusterName}/requests',
  1967. 'mock': '',
  1968. 'format': function (data) {
  1969. return {
  1970. type: 'POST',
  1971. data: JSON.stringify({
  1972. "RequestInfo": {
  1973. "command": "RESTART",
  1974. "context": data.context,
  1975. "operation_level": data.operation_level
  1976. },
  1977. "Requests/resource_filters": data.resource_filters
  1978. })
  1979. }
  1980. }
  1981. },
  1982. 'bulk_request.decommission': {
  1983. 'real': '/clusters/{clusterName}/requests',
  1984. 'mock': '',
  1985. 'format': function (data) {
  1986. return {
  1987. type: 'POST',
  1988. data: JSON.stringify({
  1989. 'RequestInfo': {
  1990. 'context': data.context,
  1991. 'command': 'DECOMMISSION',
  1992. 'parameters': data.parameters,
  1993. 'operation_level': {
  1994. 'level': "CLUSTER",
  1995. 'cluster_name': data.clusterName
  1996. }
  1997. },
  1998. "Requests/resource_filters": [{"service_name": data.serviceName, "component_name": data.componentName}]
  1999. })
  2000. }
  2001. }
  2002. },
  2003. 'bulk_request.hosts.passive_state': {
  2004. 'real': '/clusters/{clusterName}/hosts',
  2005. 'mock': '',
  2006. 'format': function (data) {
  2007. return {
  2008. type: 'PUT',
  2009. data: JSON.stringify({
  2010. RequestInfo: {
  2011. context: data.requestInfo,
  2012. query: 'Hosts/host_name.in(' + data.hostNames + ')'
  2013. },
  2014. Body: {
  2015. Hosts: {
  2016. maintenance_state: data.passive_state
  2017. }
  2018. }
  2019. })
  2020. }
  2021. }
  2022. },
  2023. 'bulk_request.hosts.update_rack_id': {
  2024. 'real': '/clusters/{clusterName}/hosts',
  2025. 'mock': '',
  2026. 'format': function(data) {
  2027. return {
  2028. type: 'PUT',
  2029. data: JSON.stringify({
  2030. RequestInfo: {
  2031. context: data.requestInfo,
  2032. query: 'Hosts/host_name.in(' + data.hostNames + ')'
  2033. },
  2034. Body: {
  2035. Hosts: {
  2036. rack_info: data.rackId
  2037. }
  2038. }
  2039. })
  2040. }
  2041. }
  2042. },
  2043. 'bulk_request.hosts.all_components.passive_state': {
  2044. 'real': '/clusters/{clusterName}/host_components',
  2045. 'mock': '',
  2046. 'format': function (data) {
  2047. return {
  2048. type: 'PUT',
  2049. data: JSON.stringify({
  2050. RequestInfo: {
  2051. context: data.requestInfo,
  2052. query: data.query
  2053. },
  2054. Body: {
  2055. HostRoles: {
  2056. maintenance_state: data.passive_state
  2057. }
  2058. }
  2059. })
  2060. }
  2061. }
  2062. },
  2063. 'views.info': {
  2064. 'real': '/views',
  2065. 'mock': '/data/views/views.json'
  2066. },
  2067. /**
  2068. * Get all instances of all views across versions
  2069. */
  2070. 'views.instances': {
  2071. 'real': '/views?fields=versions/instances/ViewInstanceInfo,versions/ViewVersionInfo/label&versions/ViewVersionInfo/system=false',
  2072. 'mock': '/data/views/instances.json'
  2073. },
  2074. 'host.host_component.flume.metrics': {
  2075. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/FLUME_HANDLER?fields=metrics/flume/flume/{flumeComponent}/*',
  2076. 'mock': ''
  2077. },
  2078. 'host.host_component.flume.metrics.timeseries': {
  2079. 'real': '',
  2080. 'mock': '',
  2081. format: function (data) {
  2082. return {
  2083. url: data.url
  2084. }
  2085. }
  2086. },
  2087. 'host.host_components.filtered': {
  2088. 'real': '/clusters/{clusterName}/hosts?{fields}',
  2089. 'mock': '',
  2090. format: function (data) {
  2091. return {
  2092. headers: {
  2093. 'X-Http-Method-Override': 'GET'
  2094. },
  2095. type: 'POST',
  2096. data: JSON.stringify({
  2097. "RequestInfo": {"query": data.parameters}
  2098. })
  2099. };
  2100. }
  2101. },
  2102. 'host.status.counters': {
  2103. 'real': '/clusters/{clusterName}?fields=Clusters/health_report,Clusters/total_hosts,alerts_summary_hosts&minimal_response=true',
  2104. 'mock': '/data/hosts/HDP2/host_status_counters.json'
  2105. },
  2106. 'host.stack_versions.install': {
  2107. 'real': '/clusters/{clusterName}/hosts/{hostName}/stack_versions',
  2108. 'mock': '',
  2109. 'type': 'POST',
  2110. 'format': function (data) {
  2111. return {
  2112. data: JSON.stringify({
  2113. "HostStackVersions": {
  2114. "stack": data.version.get('stack'),
  2115. "version": data.version.get('version'),
  2116. "repository_version": data.version.get('repoVersion')
  2117. }
  2118. })
  2119. }
  2120. }
  2121. },
  2122. 'components.filter_by_status': {
  2123. 'real': '/clusters/{clusterName}/components?fields=host_components/HostRoles/host_name,ServiceComponentInfo/component_name,ServiceComponentInfo/started_count{urlParams}&minimal_response=true',
  2124. 'mock': ''
  2125. },
  2126. 'hosts.all.install': {
  2127. 'real': '/hosts?minimal_response=true',
  2128. 'mock': ''
  2129. },
  2130. 'hosts.all': {
  2131. 'real': '/clusters/{clusterName}/hosts?minimal_response=true',
  2132. 'mock': '/data/hosts/HDP2/hosts.json'
  2133. },
  2134. 'hosts.with_public_host_names': {
  2135. 'real': '/clusters/{clusterName}/hosts?fields=Hosts/public_host_name&minimal_response=true',
  2136. 'mock': ''
  2137. },
  2138. 'hosts.for_quick_links': {
  2139. 'real': '/clusters/{clusterName}/hosts?Hosts/host_name.in({masterHosts})&fields=Hosts/public_host_name,host_components/HostRoles/component_name{urlParams}&minimal_response=true',
  2140. 'mock': '/data/hosts/quick_links.json'
  2141. },
  2142. 'hosts.confirmed.install': {
  2143. 'real': '/hosts?fields=Hosts/cpu_count,Hosts/disk_info,Hosts/total_mem&minimal_response=true',
  2144. 'mock': ''
  2145. },
  2146. 'hosts.confirmed': {
  2147. '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',
  2148. 'mock': '/data/hosts/HDP2/hosts.json'
  2149. },
  2150. 'host_components.all': {
  2151. 'real': '/clusters/{clusterName}/host_components?fields=HostRoles/host_name&minimal_response=true',
  2152. 'mock': ''
  2153. },
  2154. 'host_components.with_services_names': {
  2155. 'real': '/clusters/{clusterName}/host_components?fields=component/ServiceComponentInfo/service_name,HostRoles/host_name&minimal_response=true',
  2156. 'mock': ''
  2157. },
  2158. 'components.get_installed': {
  2159. 'real': '/clusters/{clusterName}/components',
  2160. 'mock': ''
  2161. },
  2162. 'hosts.heatmaps': {
  2163. 'real': '/clusters/{clusterName}/hosts?fields=Hosts/rack_info,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',
  2164. 'mock': '/data/hosts/HDP2/hosts.json'
  2165. },
  2166. 'namenode.cpu_wio': {
  2167. 'real': '/clusters/{clusterName}/hosts/{nnHost}?fields=metrics/cpu',
  2168. 'mock': '/data/cluster_metrics/cpu.json'
  2169. },
  2170. 'custom_action.create': {
  2171. 'real': '/requests',
  2172. 'mock': '',
  2173. 'format': function (data) {
  2174. var requestInfo = {
  2175. context: 'Check host',
  2176. action: 'check_host',
  2177. parameters: {}
  2178. };
  2179. $.extend(true, requestInfo, data.requestInfo);
  2180. return {
  2181. type: 'POST',
  2182. data: JSON.stringify({
  2183. 'RequestInfo': requestInfo,
  2184. 'Requests/resource_filters': [{
  2185. hosts: data.filteredHosts.join(',')
  2186. }]
  2187. })
  2188. }
  2189. }
  2190. },
  2191. 'custom_action.request': {
  2192. 'real': '/requests/{requestId}/tasks/{taskId}',
  2193. 'mock': '/data/requests/1.json',
  2194. 'format': function (data) {
  2195. return {
  2196. requestId: data.requestId,
  2197. taskId: data.taskId || ''
  2198. }
  2199. }
  2200. },
  2201. 'hosts.high_availability.wizard': {
  2202. 'real': '/clusters/{clusterName}/hosts?fields=Hosts/cpu_count,Hosts/disk_info,Hosts/total_mem&minimal_response=true',
  2203. 'mock': ''
  2204. },
  2205. 'hosts.security.wizard': {
  2206. 'real': '/clusters/{clusterName}/hosts?fields=host_components/HostRoles/service_name&minimal_response=true',
  2207. 'mock': ''
  2208. },
  2209. 'host_component.installed.on_hosts': {
  2210. 'real': '/clusters/{clusterName}/host_components?HostRoles/component_name={componentName}&HostRoles/host_name.in({hostNames})&fields=HostRoles/host_name&minimal_response=true',
  2211. 'mock': ''
  2212. },
  2213. 'hosts.by_component.one': {
  2214. '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',
  2215. 'mock': ''
  2216. },
  2217. 'hosts.by_component.all': {
  2218. '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',
  2219. 'mock': ''
  2220. },
  2221. 'hosts.config_groups': {
  2222. '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',
  2223. 'mock': ''
  2224. },
  2225. 'hosts.host_components.pre_load': {
  2226. real: '',
  2227. mock: '/data/hosts/HDP2/hosts.json',
  2228. format: function (data) {
  2229. return {
  2230. url: data.url
  2231. }
  2232. }
  2233. },
  2234. 'hosts.bulk.operations': {
  2235. real: '/clusters/{clusterName}/hosts?fields=Hosts/host_name,Hosts/maintenance_state,' +
  2236. 'host_components/HostRoles/state,host_components/HostRoles/maintenance_state,' +
  2237. 'Hosts/total_mem,stack_versions/HostStackVersions,stack_versions/repository_versions/RepositoryVersions/repository_version,' +
  2238. 'stack_versions/repository_versions/RepositoryVersions/id,' +
  2239. 'host_components/HostRoles/stale_configs' +
  2240. 'host_components/HostRoles/service_name&minimal_response=true',
  2241. mock: '',
  2242. format: function (data) {
  2243. return {
  2244. headers: {
  2245. 'X-Http-Method-Override': 'GET'
  2246. },
  2247. type: 'POST',
  2248. data: JSON.stringify({
  2249. "RequestInfo": {"query": data.parameters}
  2250. })
  2251. }
  2252. }
  2253. },
  2254. 'service.serviceConfigVersions.get': {
  2255. 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,stack_id,is_cluster_compatible&minimal_response=true',
  2256. mock: '/data/configurations/service_versions.json'
  2257. },
  2258. 'service.serviceConfigVersions.get.current': {
  2259. real: '/clusters/{clusterName}?fields=Clusters/desired_service_config_versions&minimal_response=true',
  2260. mock: ''
  2261. },
  2262. 'service.serviceConfigVersions.get.total': {
  2263. real: '/clusters/{clusterName}/configurations/service_config_versions?page_size=1&minimal_response=true',
  2264. mock: '/data/configurations/service_versions_total.json'
  2265. },
  2266. 'service.serviceConfigVersion.get': {
  2267. real: '/clusters/{clusterName}/configurations/service_config_versions?service_name={serviceName}&service_config_version={serviceConfigVersion}',
  2268. mock: '/data/configurations/service_version.json'
  2269. },
  2270. 'service.serviceConfigVersions.get.multiple': {
  2271. real: '/clusters/{clusterName}/configurations/service_config_versions?service_name={serviceName}&service_config_version.in({serviceConfigVersions}){additionalParams}',
  2272. mock: '/data/configurations/service_version.json',
  2273. format: function (data) {
  2274. return {
  2275. serviceConfigVersions: data.serviceConfigVersions.join(','),
  2276. additionalParams: data.additionalParams || ''
  2277. }
  2278. }
  2279. },
  2280. 'service.serviceConfigVersion.revert': {
  2281. 'real': '/clusters/{clusterName}',
  2282. 'mock': '',
  2283. 'type': 'PUT',
  2284. 'format': function (data) {
  2285. return {
  2286. data: JSON.stringify(data.data)
  2287. }
  2288. }
  2289. },
  2290. 'service.mysql.clean': {
  2291. 'real': '/clusters/{clusterName}/requests',
  2292. 'mock': '',
  2293. 'format': function (data) {
  2294. return {
  2295. type: 'POST',
  2296. data: JSON.stringify({
  2297. "RequestInfo": {
  2298. "command" : "CLEAN", "context" : "Clean MYSQL Server"
  2299. },
  2300. "Requests/resource_filters": [{
  2301. "service_name" : "HIVE",
  2302. "component_name" : "MYSQL_SERVER",
  2303. "hosts": data.host
  2304. }]
  2305. })
  2306. }
  2307. }
  2308. },
  2309. 'service.mysql.configure': {
  2310. 'real': '/clusters/{clusterName}/requests',
  2311. 'mock': '',
  2312. 'format': function (data) {
  2313. return {
  2314. type: 'POST',
  2315. data: JSON.stringify({
  2316. "RequestInfo": {
  2317. "command" : "CONFIGURE", "context" : "Configure MYSQL Server"
  2318. },
  2319. "Requests/resource_filters": [{
  2320. "service_name" : "HIVE",
  2321. "component_name" : "MYSQL_SERVER",
  2322. "hosts": data.host
  2323. }]
  2324. })
  2325. }
  2326. }
  2327. },
  2328. 'service.mysql.testHiveConnection': {
  2329. 'real': '/requests',
  2330. 'mock': '',
  2331. 'format': function (data) {
  2332. return {
  2333. type: 'POST',
  2334. data: JSON.stringify({
  2335. "RequestInfo": {
  2336. "context": "Check host",
  2337. "action": "check_host",
  2338. "parameters":{
  2339. "db_name": data.db_name,
  2340. "user_name": data.db_user,
  2341. "user_passwd": data.db_pass,
  2342. "db_connection_url": data.db_connection_url,
  2343. "jdk_location": data.jdk_location,
  2344. "threshold":"60",
  2345. "ambari_server_host": "c6403.ambari.apache.org",
  2346. "check_execute_list":"db_connection_check",
  2347. "java_home": data.java_home,
  2348. "jdk_name": data.jdk_name
  2349. }
  2350. },
  2351. "Requests/resource_filters": [{"hosts": data.hosts}]})
  2352. }
  2353. }
  2354. },
  2355. 'widgets.get': {
  2356. real: '/clusters/{clusterName}/widgets?{urlParams}',
  2357. mock: '/data/widget_layouts/{sectionName}_WIDGETS.json'
  2358. },
  2359. 'widgets.all.shared.get': {
  2360. real: '/clusters/{clusterName}/widgets?WidgetInfo/scope=CLUSTER&fields=*',
  2361. mock: '/data/widget_layouts/all_shared_widgets.json'
  2362. },
  2363. 'widgets.all.mine.get': {
  2364. real: '/clusters/{clusterName}/widgets?WidgetInfo/scope=USER&WidgetInfo/author={loginName}&fields=*',
  2365. mock: '/data/widget_layouts/all_mine_widgets.json'
  2366. },
  2367. 'widgets.layout.stackDefined.get': {
  2368. real: '{stackVersionURL}/services/{serviceName}/artifacts/widget_descriptor',
  2369. mock: '/data/widget_layouts/HBASE/stack_layout.json'
  2370. },
  2371. 'widget.layout.id.get': {
  2372. real: '/clusters/{clusterName}/widget_layouts/{layoutId}',
  2373. mock: '/data/widget_layouts/{serviceName}/default_dashboard.json'
  2374. },
  2375. 'widget.layout.get': {
  2376. real: '/clusters/{clusterName}/widget_layouts?{urlParams}',
  2377. mock: '/data/widget_layouts/{serviceName}/default_dashboard.json'
  2378. },
  2379. 'widget.layout.edit': {
  2380. real: '/clusters/{clusterName}/widget_layouts/{layoutId}',
  2381. mock: '',
  2382. format: function (data) {
  2383. return {
  2384. type: 'PUT',
  2385. data: JSON.stringify(data.data)
  2386. }
  2387. }
  2388. },
  2389. 'widget.layout.create': {
  2390. real: '/clusters/{clusterName}/widget_layouts',
  2391. mock: '',
  2392. format: function (data) {
  2393. return {
  2394. type: 'POST',
  2395. data: JSON.stringify(data.data)
  2396. }
  2397. }
  2398. },
  2399. 'widgets.layout.userDefined.get': {
  2400. real: '/users/{loginName}/widget_layouts?section_name={sectionName}',
  2401. mock: '/data/widget_layouts/HBASE/empty_user_layout.json'
  2402. },
  2403. 'widgets.layouts.get': {
  2404. real: '/users?widget_layouts/section_name={sectionName}&widget_layouts/scope=CLUSTER',
  2405. mock: '/data/widget_layouts/HBASE/layouts.json'
  2406. },
  2407. 'widgets.layouts.active.get': {
  2408. real: '/users/{userName}/activeWidgetLayouts?{urlParams}',
  2409. mock: '/data/widget_layouts/{sectionName}.json'
  2410. },
  2411. 'widgets.layouts.all.active.get': {
  2412. real: '/users/{userName}/activeWidgetLayouts',
  2413. mock: ''
  2414. },
  2415. 'widget.activelayouts.edit': {
  2416. real: '/users/{userName}/activeWidgetLayouts/',
  2417. mock: '',
  2418. format: function (data) {
  2419. return {
  2420. type: 'PUT',
  2421. data: JSON.stringify(data.data)
  2422. }
  2423. }
  2424. },
  2425. 'widget.action.delete': {
  2426. real: '/clusters/{clusterName}/widgets/{id}',
  2427. mock: '',
  2428. format: function (data) {
  2429. return {
  2430. type: 'DELETE'
  2431. }
  2432. }
  2433. },
  2434. 'widgets.serviceComponent.metrics.get': {
  2435. real: '/clusters/{clusterName}/services/{serviceName}/components/{componentName}?fields={metricPaths}&format=null_padding',
  2436. mock: '/data/metrics/{serviceName}/Append_num_ops_&_Delete_num_ops.json'
  2437. },
  2438. 'widgets.hostComponent.metrics.get': {
  2439. real: '/clusters/{clusterName}/host_components?HostRoles/component_name={componentName}{hostComponentCriteria}&fields={metricPaths}&format=null_padding',
  2440. mock: '/data/metrics/{serviceName}/Append_num_ops.json'
  2441. },
  2442. 'widgets.hosts.metrics.get': {
  2443. real: '/clusters/{clusterName}/hosts?fields={metricPaths}&format=null_padding',
  2444. mock: '/data/metrics/{serviceName}/Append_num_ops.json'
  2445. },
  2446. 'widgets.wizard.metrics.get': {
  2447. real: '{stackVersionURL}/services?artifacts/Artifacts/artifact_name=metrics_descriptor&StackServices/service_name.in({serviceNames})&fields=artifacts/*',
  2448. mock: '/data/metrics/HBASE/definition.json'
  2449. },
  2450. 'widgets.wizard.add': {
  2451. real: '/clusters/{clusterName}/widgets/',
  2452. mock: '',
  2453. 'format': function (data) {
  2454. return {
  2455. type: 'POST',
  2456. data: JSON.stringify(data.data)
  2457. };
  2458. }
  2459. },
  2460. 'widgets.wizard.edit': {
  2461. real: '/clusters/{clusterName}/widgets/{widgetId}',
  2462. mock: '',
  2463. 'format': function (data) {
  2464. return {
  2465. type: 'PUT',
  2466. data: JSON.stringify(data.data)
  2467. };
  2468. }
  2469. }
  2470. };
  2471. /**
  2472. * Replace data-placeholders to its values
  2473. *
  2474. * @param {String} url
  2475. * @param {Object} data
  2476. * @return {String}
  2477. */
  2478. var formatUrl = function (url, data) {
  2479. if (!url) return null;
  2480. var keys = url.match(/\{\w+\}/g);
  2481. keys = (keys === null) ? [] : keys;
  2482. if (keys) {
  2483. keys.forEach(function (key) {
  2484. var raw_key = key.substr(1, key.length - 2);
  2485. var replace;
  2486. if (!data || !data[raw_key]) {
  2487. replace = '';
  2488. }
  2489. else {
  2490. replace = data[raw_key];
  2491. }
  2492. url = url.replace(new RegExp(key, 'g'), replace);
  2493. });
  2494. }
  2495. return url;
  2496. };
  2497. /**
  2498. * this = object from config
  2499. * @return {Object}
  2500. */
  2501. var formatRequest = function (data) {
  2502. var opt = {
  2503. type: this.type || 'GET',
  2504. timeout: App.timeout,
  2505. dataType: 'json',
  2506. statusCode: require('data/statusCodes')
  2507. };
  2508. if (App.get('testMode')) {
  2509. opt.url = formatUrl(this.mock ? this.mock : '', data);
  2510. opt.type = 'GET';
  2511. }
  2512. else {
  2513. var prefix = this.apiPrefix != null ? this.apiPrefix : App.apiPrefix;
  2514. opt.url = prefix + formatUrl(this.real, data);
  2515. }
  2516. if (this.format) {
  2517. jQuery.extend(opt, this.format(data, opt));
  2518. }
  2519. return opt;
  2520. };
  2521. /**
  2522. * Wrapper for all ajax requests
  2523. *
  2524. * @type {Object}
  2525. */
  2526. var ajax = Em.Object.extend({
  2527. /**
  2528. * Send ajax request
  2529. *
  2530. * @param {Object} config
  2531. * @return {$.ajax} jquery ajax object
  2532. *
  2533. * config fields:
  2534. * name - url-key in the urls-object *required*
  2535. * sender - object that send request (need for proper callback initialization) *required*
  2536. * data - object with data for url-format
  2537. * beforeSend - method-name for ajax beforeSend response callback
  2538. * success - method-name for ajax success response callback
  2539. * error - method-name for ajax error response callback
  2540. * callback - callback from <code>App.updater.run</code> library
  2541. */
  2542. send: function (config) {
  2543. if (!config.sender) {
  2544. console.warn('Ajax sender should be defined!');
  2545. return null;
  2546. }
  2547. // default parameters
  2548. var params = {
  2549. clusterName: (App.get('clusterName') || App.clusterStatus.get('clusterName'))
  2550. };
  2551. // extend default parameters with provided
  2552. if (config.data) {
  2553. jQuery.extend(params, config.data);
  2554. }
  2555. var opt = {};
  2556. if (!urls[config.name]) {
  2557. console.warn('Invalid name provided!');
  2558. return null;
  2559. }
  2560. opt = formatRequest.call(urls[config.name], params);
  2561. opt.context = this;
  2562. // object sender should be provided for processing beforeSend, success and error responses
  2563. opt.beforeSend = function (xhr) {
  2564. if (config.beforeSend) {
  2565. config.sender[config.beforeSend](opt, xhr, params);
  2566. }
  2567. };
  2568. opt.success = function (data, textStatus, request) {
  2569. console.log("TRACE: The url is: " + opt.url);
  2570. if (config.success) {
  2571. config.sender[config.success](data, opt, params, request);
  2572. }
  2573. };
  2574. opt.error = function (request, ajaxOptions, error) {
  2575. var KDCErrorMsg = this.getKDCErrorMgs(request);
  2576. if (!Em.isNone(KDCErrorMsg)) {
  2577. /**
  2578. * run this handler before show KDC error popup
  2579. */
  2580. if (config.kdcFailHandler) {
  2581. config.sender[config.kdcFailHandler](request, ajaxOptions, error, opt, params);
  2582. }
  2583. /**
  2584. * run this handler when click cancle on KDC error popup
  2585. */
  2586. if (config.kdcCancelHandler) {
  2587. opt.kdcCancelHandler = function() {
  2588. config.sender[config.kdcCancelHandler]();
  2589. };
  2590. }
  2591. this.defaultErrorKDCHandler(opt, KDCErrorMsg);
  2592. } else if (config.error) {
  2593. config.sender[config.error](request, ajaxOptions, error, opt, params);
  2594. } else {
  2595. this.defaultErrorHandler(request, opt.url, opt.type);
  2596. }
  2597. };
  2598. opt.complete = function () {
  2599. if (config.callback) {
  2600. config.callback();
  2601. }
  2602. };
  2603. if ($.mocho) {
  2604. opt.url = 'http://' + $.hostName + opt.url;
  2605. }
  2606. return $.ajax(opt);
  2607. },
  2608. // A single instance of App.ModalPopup view
  2609. modalPopup: null,
  2610. /**
  2611. * defaultErrorHandler function is referred from App.ajax.send function and App.HttpClient.defaultErrorHandler function
  2612. * @jqXHR {jqXHR Object}
  2613. * @url {string}
  2614. * @method {String} Http method
  2615. * @showStatus {number} HTTP response code which should be shown. Default is 500.
  2616. */
  2617. defaultErrorHandler: function (jqXHR, url, method, showStatus) {
  2618. method = method || 'GET';
  2619. var self = this;
  2620. try {
  2621. var json = $.parseJSON(jqXHR.responseText);
  2622. var message = json.message;
  2623. } catch (err) {
  2624. }
  2625. if (!showStatus) {
  2626. showStatus = 500;
  2627. }
  2628. if (jqXHR.status === showStatus && !this.get('modalPopup')) {
  2629. this.set('modalPopup', App.ModalPopup.show({
  2630. header: Em.I18n.t('common.error'),
  2631. secondary: false,
  2632. onPrimary: function () {
  2633. this.hide();
  2634. self.set('modalPopup', null);
  2635. },
  2636. bodyClass: App.AjaxDefaultErrorPopupBodyView.extend({
  2637. type: method,
  2638. url: url,
  2639. status: jqXHR.status,
  2640. message: message
  2641. })
  2642. }));
  2643. }
  2644. },
  2645. /**
  2646. * defines if it's admin session expiration error
  2647. * and if so returns short error message
  2648. * @param jqXHR
  2649. * @returns {string|null}
  2650. */
  2651. getKDCErrorMgs: function(jqXHR) {
  2652. try {
  2653. var message = $.parseJSON(jqXHR.responseText).message;
  2654. } catch (err) {}
  2655. if (jqXHR.status === 400 && message) {
  2656. return App.format.kdcErrorMsg(message, true);
  2657. }
  2658. },
  2659. /**
  2660. * default handler for admin session expiration error
  2661. * @param {object} opt
  2662. * @param {string} msg
  2663. * @returns {*}
  2664. */
  2665. defaultErrorKDCHandler: function(opt, msg) {
  2666. return App.showInvalidKDCPopup(opt, msg);
  2667. }
  2668. });
  2669. /**
  2670. * Add few access-methods for test purposes
  2671. */
  2672. if ($.mocho) {
  2673. ajax.reopen({
  2674. /**
  2675. * Don't use it anywhere except tests!
  2676. * @returns {Array}
  2677. */
  2678. fakeGetUrlNames: function () {
  2679. return Em.keys(urls);
  2680. },
  2681. /**
  2682. * Don't use it anywhere except tests!
  2683. * @param name
  2684. * @returns {*}
  2685. */
  2686. fakeGetUrl: function (name) {
  2687. return urls[name];
  2688. },
  2689. /**
  2690. * Don't use it anywhere except tests!
  2691. * @param url
  2692. * @param data
  2693. * @returns {String}
  2694. */
  2695. fakeFormatUrl: function (url, data) {
  2696. return formatUrl(url, data);
  2697. },
  2698. /**
  2699. * Don't use it anywhere except tests!
  2700. * @param urlObj
  2701. * @param data
  2702. * @returns {Object}
  2703. */
  2704. fakeFormatRequest: function (urlObj, data) {
  2705. return formatRequest.call(urlObj, data);
  2706. }
  2707. });
  2708. }
  2709. App.ajax = ajax.create({});