ajax.js 85 KB

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