ajax.js 95 KB

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