ajax.js 86 KB

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