ajax.js 88 KB

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