ajax.js 98 KB

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