ajax.js 87 KB

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