ajax.js 74 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160
  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.services.update' : {
  33. 'real': '/clusters/{clusterName}/services?{urlParams}',
  34. 'mock': '/data/wizard/deploy/poll_1.json',
  35. 'format': function (data) {
  36. return {
  37. type: 'PUT',
  38. data: JSON.stringify({
  39. RequestInfo: {
  40. "context": data.context,
  41. "operation_level": {
  42. "level": "CLUSTER",
  43. "cluster_name" : data.clusterName
  44. }
  45. },
  46. Body: {
  47. ServiceInfo: data.ServiceInfo
  48. }
  49. })
  50. };
  51. }
  52. },
  53. 'common.service.update' : {
  54. 'real': '/clusters/{clusterName}/services/{serviceName}',
  55. 'mock': '/data/wizard/deploy/poll_1.json',
  56. 'format': function (data) {
  57. return {
  58. type: 'PUT',
  59. data: JSON.stringify({
  60. RequestInfo: {
  61. "context": data.context,
  62. "operation_level": {
  63. "level": "SERVICE",
  64. "cluster_name" : data.clusterName,
  65. "service_name" : data.serviceName
  66. }
  67. },
  68. Body: {
  69. ServiceInfo: data.ServiceInfo
  70. }
  71. })
  72. };
  73. }
  74. },
  75. 'common.host_component.update': {
  76. 'real': '/clusters/{clusterName}/host_components',
  77. 'mock': '',
  78. 'type': 'PUT',
  79. 'format': function (data) {
  80. return {
  81. data: JSON.stringify({
  82. RequestInfo: {
  83. context: data.context,
  84. query: data.query
  85. },
  86. Body: {
  87. "HostRoles": data.HostRoles
  88. }
  89. })
  90. }
  91. }
  92. },
  93. 'common.host.host_components.update': {
  94. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components?{urlParams}',
  95. 'mock': '',
  96. 'type': 'PUT',
  97. 'format': function (data) {
  98. return {
  99. data: JSON.stringify({
  100. RequestInfo: {
  101. "context": data.context,
  102. "operation_level": {
  103. level: "HOST",
  104. cluster_name: data.clusterName,
  105. host_names: data.hostName
  106. },
  107. query: data.query
  108. },
  109. Body: {
  110. "HostRoles": data.HostRoles
  111. }
  112. })
  113. }
  114. }
  115. },
  116. 'common.host.host_component.update': {
  117. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}?{urlParams}',
  118. 'mock': '/data/wizard/deploy/poll_1.json',
  119. 'type': 'PUT',
  120. 'format': function (data) {
  121. return {
  122. data: JSON.stringify({
  123. RequestInfo: {
  124. "context": data.context,
  125. "operation_level": {
  126. level: "HOST_COMPONENT",
  127. cluster_name: data.clusterName,
  128. host_name: data.hostName,
  129. service_name: data.serviceName || null
  130. }
  131. },
  132. Body: {
  133. "HostRoles": data.HostRoles
  134. }
  135. })
  136. }
  137. }
  138. },
  139. 'common.service.configurations': {
  140. 'real':'/clusters/{clusterName}',
  141. 'mock':'',
  142. 'format': function (data) {
  143. return {
  144. type: 'PUT',
  145. data: JSON.stringify({
  146. Clusters: {
  147. desired_config: data.desired_config
  148. }
  149. })
  150. }
  151. }
  152. },
  153. 'common.across.services.configurations': {
  154. 'real':'/clusters/{clusterName}',
  155. 'mock':'',
  156. 'format': function(data) {
  157. return {
  158. type: 'PUT',
  159. dataType: 'text',
  160. data: data.data
  161. }
  162. }
  163. },
  164. 'service.flume.agent.command': {
  165. 'real': '/clusters/{clusterName}/hosts/{host}/host_components/FLUME_HANDLER',
  166. 'mock': '',
  167. 'format': function (data) {
  168. return {
  169. type: 'PUT',
  170. data: JSON.stringify({
  171. "RequestInfo": {
  172. "context": data.context,
  173. "flume_handler": data.agentName,
  174. "operation_level": {
  175. level: "HOST_COMPONENT",
  176. cluster_name: data.clusterName,
  177. service_name: "FLUME",
  178. host_name: data.host
  179. }
  180. },
  181. "Body": {
  182. "HostRoles": {
  183. "state": data.state
  184. }
  185. }
  186. })
  187. }
  188. }
  189. },
  190. 'common.host_components.update': {
  191. 'real': '/clusters/{clusterName}/host_components?{urlParams}',
  192. 'mock': '/data/wizard/deploy/poll_1.json',
  193. 'type': 'PUT',
  194. 'format': function (data) {
  195. return {
  196. data: JSON.stringify({
  197. RequestInfo: {
  198. "context": data.context,
  199. "operation_level": {
  200. level: data.level || "CLUSTER",
  201. cluster_name: data.clusterName
  202. },
  203. query: data.query
  204. },
  205. Body: {
  206. "HostRoles": data.HostRoles
  207. }
  208. })
  209. }
  210. }
  211. },
  212. 'common.service.passive': {
  213. 'real': '/clusters/{clusterName}/services/{serviceName}',
  214. 'mock': '',
  215. 'format': function (data) {
  216. return {
  217. type: 'PUT',
  218. data: JSON.stringify({
  219. RequestInfo: {
  220. "context": data.requestInfo
  221. },
  222. Body: {
  223. ServiceInfo: {
  224. maintenance_state: data.passive_state
  225. }
  226. }
  227. })
  228. };
  229. }
  230. },
  231. 'common.host.host_component.passive': {
  232. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  233. 'mock': '',
  234. 'type': 'PUT',
  235. 'format': function(data) {
  236. return {
  237. data: JSON.stringify({
  238. RequestInfo: {
  239. "context": data.context
  240. },
  241. Body: {
  242. HostRoles: {
  243. maintenance_state: data.passive_state
  244. }
  245. }
  246. })
  247. };
  248. }
  249. },
  250. 'common.host.with_host_component': {
  251. 'real': '/clusters/{clusterName}/hosts?host_components/HostRoles/component_name={componentName}&minimal_response=true',
  252. 'mock': ''
  253. },
  254. 'common.delete.host': {
  255. 'real': '/clusters/{clusterName}/hosts/{hostName}',
  256. 'type': 'DELETE'
  257. },
  258. 'common.delete.host_component': {
  259. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  260. 'type': 'DELETE'
  261. },
  262. 'common.delete.user': {
  263. 'real': '/users/{user}',
  264. 'type': 'DELETE'
  265. },
  266. 'common.delete.config_group': {
  267. 'real': '/clusters/{clusterName}/config_groups/{id}',
  268. 'type': 'DELETE'
  269. },
  270. 'common.delete.cluster': {
  271. 'real': '/clusters/{name}',
  272. 'type': 'DELETE'
  273. },
  274. 'common.delete.request_schedule': {
  275. 'real': '/clusters/{clusterName}/request_schedules/{request_schedule_id}',
  276. 'type': 'DELETE'
  277. },
  278. 'alerts.get_by_service': {
  279. 'real': '/clusters/{clusterName}/services/{serviceName}?fields=alerts',
  280. 'mock': '/data/alerts/HDP2/service_alerts.json'
  281. },
  282. 'alerts.get_by_host': {
  283. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=alerts',
  284. 'mock': '/data/alerts/HDP2/host_alerts.json'
  285. },
  286. 'background_operations.get_most_recent': {
  287. 'real': '/clusters/{clusterName}/requests?to=end&page_size={operationsCount}&fields=Requests',
  288. 'mock': '/data/background_operations/list_on_start.json',
  289. 'testInProduction': true
  290. },
  291. 'background_operations.get_by_request': {
  292. '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',
  293. 'mock': '/data/background_operations/task_by_request{requestId}.json',
  294. 'testInProduction': true
  295. },
  296. 'background_operations.get_by_task': {
  297. 'real': '/clusters/{clusterName}/requests/{requestId}/tasks/{taskId}',
  298. 'mock': '/data/background_operations/list_on_start.json',
  299. 'testInProduction': true
  300. },
  301. 'background_operations.abort_request': {
  302. 'real': '/clusters/{clusterName}/requests/{requestId}',
  303. 'mock': '',
  304. 'format': function () {
  305. return {
  306. type: 'PUT',
  307. data: JSON.stringify({
  308. "Requests": {
  309. "request_status": "ABORTED",
  310. "abort_reason": Em.I18n.t('hostPopup.bgop.abortRequest.reason')
  311. }
  312. })
  313. };
  314. }
  315. },
  316. 'service.item.smoke': {
  317. 'real': '/clusters/{clusterName}/requests',
  318. 'mock': '/data/wizard/deploy/poll_1.json',
  319. 'format': function (data) {
  320. return {
  321. 'type': 'POST',
  322. data: JSON.stringify({
  323. "RequestInfo": {
  324. "context": data.displayName + " Service Check",
  325. "command" : data.actionName
  326. },
  327. "Requests/resource_filters": [{"service_name" : data.serviceName}]
  328. })
  329. };
  330. }
  331. },
  332. 'service.item.rebalanceHdfsNodes' : {
  333. 'real' : '/clusters/{clusterName}/requests',
  334. 'mock' : '',
  335. 'format' : function(data) {
  336. return {
  337. type : 'POST',
  338. data : JSON.stringify({
  339. RequestInfo : {
  340. 'context' : Em.I18n.t('services.service.actions.run.rebalanceHdfsNodes.context'),
  341. 'command' : 'REBALANCEHDFS',
  342. 'namenode' : JSON.stringify({threshold: data.threshold})
  343. },
  344. "Requests/resource_filters" : [ {
  345. 'service_name' : 'HDFS',
  346. 'component_name' : 'NAMENODE',
  347. 'hosts' : data.hosts
  348. } ]
  349. })
  350. }
  351. }
  352. },
  353. 'cancel.background.operation' : {
  354. 'real' : '/clusters/{clusterName}/requests/{requestId}',
  355. 'mock' : '',
  356. 'format' : function(data) {
  357. return {
  358. type : 'PUT',
  359. data : JSON.stringify({
  360. RequestInfo : {
  361. 'context' : 'Cancel operation',
  362. "parameters" : {
  363. "cancel_policy" : "SIGKILL"
  364. }
  365. },
  366. "Requests/request_status":'ABORTED',
  367. "Requests/abort_reason": "Cancel background operation"
  368. })
  369. }
  370. }
  371. },
  372. 'service.item.refreshQueueYarnRequest':{
  373. 'real': '/clusters/{clusterName}/requests',
  374. 'mock': '',
  375. 'format' : function(data) {
  376. return {
  377. type : 'POST',
  378. data : JSON.stringify({
  379. RequestInfo: {
  380. 'context': data.context,
  381. 'command': data.command,
  382. 'parameters/forceRefreshConfigTags' : data.forceRefreshConfigTags
  383. },
  384. "Requests/resource_filters": [{"service_name" : data.serviceName, "component_name" : data.componentName, 'hosts': data.hosts}]
  385. })
  386. }
  387. }
  388. },
  389. 'service.load_config_groups': {
  390. 'real': '/clusters/{clusterName}/config_groups?ConfigGroup/tag={serviceName}&fields=*',
  391. 'mock': '/data/configurations/config_group.json'
  392. },
  393. 'reassign.load_configs': {
  394. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  395. 'mock': ''
  396. },
  397. 'reassign.save_configs': {
  398. 'real': '/clusters/{clusterName}',
  399. 'mock': '',
  400. 'type': 'PUT',
  401. 'format': function (data) {
  402. return {
  403. data: JSON.stringify({
  404. Clusters: {
  405. desired_config: {
  406. "type": data.siteName,
  407. "tag": 'version' + (new Date).getTime(),
  408. "properties": data.properties,
  409. "service_config_version_note": data.service_config_version_note
  410. }
  411. }
  412. })
  413. }
  414. }
  415. },
  416. 'config.cluster': {
  417. 'real': '{stackVersionUrl}/configurations?fields=*',
  418. 'mock': ''
  419. },
  420. 'config.advanced': {
  421. 'real': '{stackVersionUrl}/services/{serviceName}/configurations?fields=*',
  422. 'mock': '/data/wizard/stack/hdp/version{stackVersion}/{serviceName}.json'
  423. },
  424. 'config.config_types': {
  425. 'real': '{stackVersionUrl}/services/{serviceName}?fields=StackServices/config_types',
  426. 'mock': ''
  427. },
  428. 'config.tags': {
  429. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  430. 'mock': '/data/clusters/cluster.json'
  431. },
  432. 'config.tags_and_groups': {
  433. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs,config_groups/*{urlParams}',
  434. 'mock': '/data/clusters/tags_and_groups.json'
  435. },
  436. 'config.ambari.database.info': {
  437. 'real': '/services/AMBARI/components/AMBARI_SERVER?fields=hostComponents/RootServiceHostComponents/properties/server.jdbc.database_name,hostComponents/RootServiceHostComponents/properties/server.jdbc.url',
  438. 'mock': ''
  439. },
  440. 'config_groups.all_fields': {
  441. 'real': '/clusters/{clusterName}/config_groups?fields=*',
  442. 'mock': ''
  443. },
  444. 'config_groups.get_config_group_by_id': {
  445. 'real': '/clusters/{clusterName}/config_groups/{id}',
  446. 'mock': ''
  447. },
  448. 'config_groups.update_config_group': {
  449. 'real': '/clusters/{clusterName}/config_groups/{id}',
  450. 'mock': '',
  451. 'type': 'PUT',
  452. 'format': function (data) {
  453. return {
  454. data: JSON.stringify(
  455. [
  456. data.configGroup
  457. ]
  458. )
  459. }
  460. }
  461. },
  462. 'config.on_site': {
  463. 'real': '/clusters/{clusterName}/configurations?{params}',
  464. 'mock': '/data/configurations/cluster_level_configs.json?{params}'
  465. },
  466. 'config.host_overrides': {
  467. 'real': '/clusters/{clusterName}/configurations?{params}',
  468. 'mock': '/data/configurations/host_level_overrides_configs.json?{params}'
  469. },
  470. 'host.host_component.add_new_component': {
  471. 'real': '/clusters/{clusterName}/hosts?Hosts/host_name={hostName}',
  472. 'mock': '/data/wizard/deploy/poll_1.json',
  473. 'format': function(data) {
  474. return {
  475. type: 'POST',
  476. data: data.data
  477. }
  478. }
  479. },
  480. 'host.host_component.slave_desired_admin_state': {
  481. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}/?fields=HostRoles/desired_admin_state',
  482. 'mock': ''
  483. },
  484. 'host.host_component.decommission_status': {
  485. 'real': '/clusters/{clusterName}/services/{serviceName}/components/{componentName}/?fields=ServiceComponentInfo,host_components/HostRoles/state',
  486. 'mock': ''
  487. },
  488. 'host_components.hbase_regionserver.active': {
  489. 'real': '/clusters/{clusterName}/host_components?HostRoles/component_name=HBASE_REGIONSERVER&HostRoles/maintenance_state=OFF&HostRoles/desired_admin_state=INSERVICE&HostRoles/host_name.in({hostNames})',
  490. 'mock': ''
  491. },
  492. 'host.host_component.decommission_status_datanode': {
  493. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}?fields=metrics/dfs/namenode',
  494. 'mock': ''
  495. },
  496. 'host.host_component.decommission_slave': {
  497. 'real' : '/clusters/{clusterName}/requests',
  498. 'mock' : '',
  499. 'format' : function(data) {
  500. return {
  501. type : 'POST',
  502. data : JSON.stringify({
  503. RequestInfo: {
  504. 'context': data.context,
  505. 'command': data.command,
  506. 'parameters': {
  507. 'slave_type': data.slaveType,
  508. 'excluded_hosts': data.hostName
  509. },
  510. 'operation_level': {
  511. level: "HOST_COMPONENT",
  512. cluster_name: data.clusterName,
  513. host_name: data.hostName,
  514. service_name: data.serviceName
  515. }
  516. },
  517. "Requests/resource_filters": [{"service_name" : data.serviceName, "component_name" : data.componentName}]
  518. })
  519. }
  520. }
  521. },
  522. 'host.host_component.recommission_and_restart': {
  523. 'real': '/clusters/{clusterName}/request_schedules',
  524. 'mock': '',
  525. 'format' : function(data) {
  526. return {
  527. type : 'POST',
  528. data : JSON.stringify([ {
  529. "RequestSchedule" : {
  530. "batch" : [ {
  531. "requests" : data.batches
  532. }, {
  533. "batch_settings" : {
  534. "batch_separation_in_seconds" : data.intervalTimeSeconds,
  535. "task_failure_tolerance" : data.tolerateSize
  536. }
  537. } ]
  538. }
  539. } ])
  540. }
  541. }
  542. },
  543. 'host.host_component.refresh_configs': {
  544. 'real':'/clusters/{clusterName}/requests',
  545. 'mock':'',
  546. 'format': function(data) {
  547. return {
  548. type : 'POST',
  549. data : JSON.stringify({
  550. "RequestInfo": {
  551. "command": "CONFIGURE",
  552. "context": data.context
  553. },
  554. "Requests/resource_filters": data.resource_filters
  555. })
  556. }
  557. }
  558. },
  559. 'hosts.metrics': {
  560. 'real': '/clusters/{clusterName}/hosts?fields={metricName}',
  561. 'mock': '/data/cluster_metrics/cpu_1hr.json'
  562. },
  563. 'hosts.metrics.host_component': {
  564. 'real': '/clusters/{clusterName}/services/{serviceName}/components/{componentName}?fields=host_components/{metricName}',
  565. 'mock': '/data/cluster_metrics/cpu_1hr.json'
  566. },
  567. 'service.metrics.flume.channel_fill_percent': {
  568. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/flume/flume/CHANNEL/*/ChannelFillPercentage[{fromSeconds},{toSeconds},{stepSeconds}]',
  569. 'mock': '/data/services/metrics/flume/channelFillPct.json',
  570. 'testInProduction': true
  571. },
  572. 'service.metrics.flume.channel_size': {
  573. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/flume/flume/CHANNEL/*/ChannelSize[{fromSeconds},{toSeconds},{stepSeconds}]',
  574. 'mock': '/data/services/metrics/flume/channelSize.json',
  575. 'testInProduction': true
  576. },
  577. 'service.metrics.flume.sink_drain_success': {
  578. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/flume/flume/SINK/*/EventDrainSuccessCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  579. 'mock': '/data/services/metrics/flume/sinkDrainSuccessCount.json',
  580. 'testInProduction': true
  581. },
  582. 'service.metrics.flume.sink_connection_failed': {
  583. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/flume/flume/SINK/*/ConnectionFailedCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  584. 'mock': '/data/services/metrics/flume/sinkConnectionFailedCount.json',
  585. 'testInProduction': true
  586. },
  587. 'service.metrics.flume.source_accepted': {
  588. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/flume/flume/SOURCE/*/EventAcceptedCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  589. 'mock': '/data/services/metrics/flume/sourceEventAccepted.json',
  590. 'testInProduction': true
  591. },
  592. 'service.metrics.flume.channel_size_for_all': {
  593. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=metrics/flume/flume/CHANNEL/ChannelSize/_sum[{fromSeconds},{toSeconds},{stepSeconds}]'
  594. },
  595. 'service.metrics.flume.gc': {
  596. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  597. 'mock': '/data/services/metrics/flume/jvmGcTime.json',
  598. 'testInProduction': true
  599. },
  600. 'service.metrics.flume.jvm_heap_used': {
  601. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/jvm/memHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}]',
  602. 'mock': '/data/services/metrics/flume/jvmMemHeapUsedM.json',
  603. 'testInProduction': true
  604. },
  605. 'service.metrics.flume.jvm_threads_runnable': {
  606. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/jvm/threadsRunnable[{fromSeconds},{toSeconds},{stepSeconds}]',
  607. 'mock': '/data/services/metrics/flume/jvmThreadsRunnable.json',
  608. 'testInProduction': true
  609. },
  610. 'service.metrics.flume.cpu_user': {
  611. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/cpu/cpu_user[{fromSeconds},{toSeconds},{stepSeconds}]',
  612. 'mock': '',
  613. 'testInProduction': true
  614. },
  615. 'service.metrics.flume.incoming_event_put_successCount': {
  616. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=metrics/flume/flume/CHANNEL/EventPutSuccessCount/rate[{fromSeconds},{toSeconds},{stepSeconds}]'
  617. },
  618. 'service.metrics.flume.outgoing_event_take_success_count': {
  619. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=metrics/flume/flume/CHANNEL/EventTakeSuccessCount/rate[{fromSeconds},{toSeconds},{stepSeconds}]'
  620. },
  621. 'service.metrics.hbase.cluster_requests': {
  622. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/cluster_requests[{fromSeconds},{toSeconds},{stepSeconds}]',
  623. 'mock': '/data/services/metrics/hbase/cluster_requests.json',
  624. 'testInProduction': true
  625. },
  626. 'service.metrics.hbase.hlog_split_size': {
  627. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitSize_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  628. 'mock': '/data/services/metrics/hbase/hlog_split_size.json',
  629. 'testInProduction': true
  630. },
  631. 'service.metrics.hbase.hlog_split_time': {
  632. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  633. 'mock': '/data/services/metrics/hbase/hlog_split_time.json',
  634. 'testInProduction': true
  635. },
  636. 'service.metrics.hbase.regionserver_queuesize': {
  637. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/flushQueueSize[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/compactionQueueSize[{fromSeconds},{toSeconds},{stepSeconds}]',
  638. 'mock': '/data/services/metrics/hbase/regionserver_queuesize.json',
  639. 'testInProduction': true
  640. },
  641. 'service.metrics.hbase.regionserver_regions': {
  642. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/regions[{fromSeconds},{toSeconds},{stepSeconds}]',
  643. 'mock': '/data/services/metrics/hbase/regionserver_regions.json',
  644. 'testInProduction': true
  645. },
  646. 'service.metrics.hbase.regionserver_rw_requests': {
  647. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/readRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/writeRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  648. 'mock': '/data/services/metrics/hbase/regionserver_rw_requests.json',
  649. 'testInProduction': true
  650. },
  651. 'service.metrics.mapreduce.gc': {
  652. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  653. 'mock': '/data/services/metrics/mapreduce/gc.json',
  654. 'testInProduction': true
  655. },
  656. 'service.metrics.mapreduce.jobs_status': {
  657. '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}]',
  658. 'mock': '/data/services/metrics/mapreduce/jobs_status.json',
  659. 'testInProduction': true
  660. },
  661. 'service.metrics.mapreduce.jobs_heap': {
  662. '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}]',
  663. 'mock': '/data/services/metrics/mapreduce/jvm_heap.json',
  664. 'testInProduction': true
  665. },
  666. 'service.metrics.mapreduce.jobs_threads': {
  667. '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}]',
  668. 'mock': '/data/services/metrics/mapreduce/jvm_threads.json',
  669. 'testInProduction': true
  670. },
  671. 'service.metrics.mapreduce.map_slots': {
  672. '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}]',
  673. 'mock': '/data/services/metrics/mapreduce/map_slots.json',
  674. 'testInProduction': true
  675. },
  676. 'service.metrics.mapreduce.reduce_slots': {
  677. '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}]',
  678. 'mock': '/data/services/metrics/mapreduce/reduce_slots.json',
  679. 'testInProduction': true
  680. },
  681. 'service.metrics.mapreduce.rpc': {
  682. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  683. 'mock': '/data/services/metrics/mapreduce/rpc.json',
  684. 'testInProduction': true
  685. },
  686. 'service.metrics.mapreduce.tasks_running_waiting': {
  687. '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}]',
  688. 'mock': '/data/services/metrics/mapreduce/tasks_running_waiting.json',
  689. 'testInProduction': true
  690. },
  691. 'service.metrics.hdfs.block_status': {
  692. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/FSNamesystem/PendingReplicationBlocks[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/FSNamesystem/UnderReplicatedBlocks[{fromSeconds},{toSeconds},{stepSeconds}]',
  693. 'mock': '/data/services/metrics/hdfs/block_status.json',
  694. 'testInProduction': true
  695. },
  696. 'service.metrics.hdfs.file_operations': {
  697. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/namenode/FileInfoOps[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/namenode/CreateFileOps[{fromSeconds},{toSeconds},{stepSeconds}]',
  698. 'mock': '/data/services/metrics/hdfs/file_operations.json',
  699. 'testInProduction': true
  700. },
  701. 'service.metrics.hdfs.gc': {
  702. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  703. 'mock': '/data/services/metrics/hdfs/gc.json',
  704. 'testInProduction': true
  705. },
  706. 'service.metrics.hdfs.io': {
  707. 'real': '/clusters/{clusterName}/services/HDFS/components/DATANODE?fields=metrics/dfs/datanode/bytes_written[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/datanode/bytes_read[{fromSeconds},{toSeconds},{stepSeconds}]',
  708. 'mock': '/data/services/metrics/hdfs/io.json',
  709. 'testInProduction': true
  710. },
  711. 'service.metrics.hdfs.jvm_heap': {
  712. '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}]',
  713. 'mock': '/data/services/metrics/hdfs/jvm_heap.json',
  714. 'testInProduction': true
  715. },
  716. 'service.metrics.hdfs.jvm_threads': {
  717. '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}]',
  718. 'mock': '/data/services/metrics/hdfs/jvm_threads.json',
  719. 'testInProduction': true
  720. },
  721. 'service.metrics.hdfs.rpc': {
  722. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  723. 'mock': '/data/services/metrics/hdfs/rpc.json',
  724. 'testInProduction': true
  725. },
  726. 'service.metrics.hdfs.space_utilization': {
  727. '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}]',
  728. 'mock': '/data/services/metrics/hdfs/space_utilization.json',
  729. 'testInProduction': true
  730. },
  731. 'service.metrics.yarn.gc': {
  732. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  733. 'mock': '/data/services/metrics/yarn/gc.json',
  734. 'testInProduction': true
  735. },
  736. 'service.metrics.yarn.jobs_threads': {
  737. '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}]',
  738. 'mock': '/data/services/metrics/yarn/jvm_threads.json',
  739. 'testInProduction': true
  740. },
  741. 'service.metrics.yarn.rpc': {
  742. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  743. 'mock': '/data/services/metrics/yarn/rpc.json',
  744. 'testInProduction': true
  745. },
  746. 'service.metrics.yarn.jobs_heap': {
  747. '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}]',
  748. 'mock': '/data/services/metrics/yarn/jvm_heap.json',
  749. 'testInProduction': true
  750. },
  751. 'service.metrics.yarn.queue.allocated': {
  752. '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}]',
  753. 'mock': '',
  754. 'testInProduction': true
  755. },
  756. 'service.metrics.yarn.queue.allocated.container': {
  757. '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}]',
  758. 'mock': '',
  759. 'testInProduction': true
  760. },
  761. 'service.metrics.yarn.node.manager.statuses': {
  762. '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}]',
  763. 'mock': '',
  764. 'testInProduction': true
  765. },
  766. 'service.metrics.yarn.queue.memory.resource': {
  767. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=',
  768. 'mock': '',
  769. 'format': function (data, opt) {
  770. var field1 = 'metrics/yarn/Queue/{queueName}/AllocatedMB[{fromSeconds},{toSeconds},{stepSeconds}]';
  771. var field2 = 'metrics/yarn/Queue/{queueName}/AvailableMB[{fromSeconds},{toSeconds},{stepSeconds}]';
  772. if (opt.url != null && data.queueNames != null && data.queueNames.length > 0) {
  773. data.queueNames.forEach(function (q) {
  774. data.queueName = q;
  775. opt.url += (formatUrl(field1, data) + ",");
  776. opt.url += (formatUrl(field2, data) + ",");
  777. });
  778. } else {
  779. opt.url += (formatUrl(field1, data) + ",");
  780. opt.url += (formatUrl(field2, data) + ",");
  781. }
  782. },
  783. 'testInProduction': true
  784. },
  785. 'service.metrics.yarn.queue.apps.states.current': {
  786. '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}]',
  787. 'mock': '',
  788. 'testInProduction': true
  789. },
  790. 'service.metrics.yarn.queue.apps.states.finished': {
  791. '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}]',
  792. 'mock': '',
  793. 'testInProduction': true
  794. },
  795. 'service.metrics.storm.nimbus': {
  796. 'real': '/clusters/{clusterName}/services/STORM/components/NIMBUS?fields={metricsTemplate}',
  797. 'mock': ''
  798. },
  799. 'dashboard.cluster_metrics.cpu': {
  800. 'real': '/clusters/{clusterName}/?fields=metrics/cpu[{fromSeconds},{toSeconds},{stepSeconds}]',
  801. 'mock': '/data/cluster_metrics/cpu_1hr.json',
  802. 'testInProduction': true
  803. },
  804. 'dashboard.cluster_metrics.load': {
  805. 'real': '/clusters/{clusterName}/?fields=metrics/load[{fromSeconds},{toSeconds},{stepSeconds}]',
  806. 'mock': '/data/cluster_metrics/load_1hr.json',
  807. 'testInProduction': true
  808. },
  809. 'dashboard.cluster_metrics.memory': {
  810. 'real': '/clusters/{clusterName}/?fields=metrics/memory[{fromSeconds},{toSeconds},{stepSeconds}]',
  811. 'mock': '/data/cluster_metrics/memory_1hr.json',
  812. 'testInProduction': true
  813. },
  814. 'dashboard.cluster_metrics.network': {
  815. 'real': '/clusters/{clusterName}/?fields=metrics/network[{fromSeconds},{toSeconds},{stepSeconds}]',
  816. 'mock': '/data/cluster_metrics/network_1hr.json',
  817. 'testInProduction': true
  818. },
  819. 'host.metrics.cpu': {
  820. '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}]',
  821. 'mock': '/data/hosts/metrics/cpu.json',
  822. 'testInProduction': true
  823. },
  824. 'host.metrics.disk': {
  825. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/disk/disk_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/disk/disk_free[{fromSeconds},{toSeconds},{stepSeconds}]',
  826. 'mock': '/data/hosts/metrics/disk.json',
  827. 'testInProduction': true
  828. },
  829. 'host.metrics.load': {
  830. '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}]',
  831. 'mock': '/data/hosts/metrics/load.json',
  832. 'testInProduction': true
  833. },
  834. 'host.metrics.memory': {
  835. '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}]',
  836. 'mock': '/data/hosts/metrics/memory.json',
  837. 'testInProduction': true
  838. },
  839. 'host.metrics.network': {
  840. '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}]',
  841. 'mock': '/data/hosts/metrics/network.json',
  842. 'testInProduction': true
  843. },
  844. 'host.metrics.processes': {
  845. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/process/proc_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/process/proc_run[{fromSeconds},{toSeconds},{stepSeconds}]',
  846. 'mock': '/data/hosts/metrics/processes.json',
  847. 'testInProduction': true
  848. },
  849. 'admin.security_status': {
  850. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  851. 'mock': '',
  852. 'format': function() {
  853. return {
  854. timeout: 10000
  855. };
  856. }
  857. },
  858. 'settings.get.user_pref': {
  859. 'real': '/persist/{key}',
  860. 'mock': '/data/user_settings/{key}.json'
  861. },
  862. 'settings.post.user_pref': {
  863. 'real': '/persist',
  864. 'mock': '',
  865. 'type': 'POST',
  866. 'format': function (data) {
  867. return {
  868. data: JSON.stringify(data.keyValuePair)
  869. }
  870. }
  871. },
  872. 'cluster.load_cluster_name': {
  873. 'real': '/clusters',
  874. 'mock': '/data/clusters/info.json'
  875. },
  876. 'cluster.update_upgrade_version': {
  877. 'real': '/stacks/{stackName}/versions?fields=stackServices/StackServices,Versions',
  878. 'mock': '/data/wizard/stack/stacks.json'
  879. },
  880. 'cluster.load_repositories': {
  881. 'real': '/stacks/{stackName}/versions/{stackVersion}/operating_systems?fields=repositories/*',
  882. 'mock': '/data/stacks/HDP-2.1/operating_systems.json',
  883. 'format': function (data) {
  884. return {
  885. data: data.data
  886. };
  887. }
  888. },
  889. 'cluster.save_provisioning_state': {
  890. 'real': '/clusters/{clusterName}',
  891. 'type': 'PUT',
  892. 'format': function (data) {
  893. return {
  894. data: JSON.stringify({
  895. "Clusters": {
  896. "provisioning_state": data.state
  897. }
  898. })
  899. };
  900. }
  901. },
  902. 'admin.high_availability.polling': {
  903. 'real': '/clusters/{clusterName}/requests/{requestId}?fields=tasks/*,Requests/*',
  904. 'mock': ''
  905. },
  906. 'admin.high_availability.getNnCheckPointStatus': {
  907. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/NAMENODE',
  908. 'mock': ''
  909. },
  910. 'admin.high_availability.getJnCheckPointStatus': {
  911. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/JOURNALNODE?fields=metrics',
  912. 'mock': ''
  913. },
  914. 'admin.high_availability.getHostComponent': {
  915. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  916. 'mock': ''
  917. },
  918. 'admin.high_availability.create_component': {
  919. 'real': '/clusters/{clusterName}/hosts?Hosts/host_name={hostName}',
  920. 'mock': '',
  921. 'type': 'POST',
  922. 'format': function (data) {
  923. return {
  924. data: JSON.stringify({
  925. "host_components": [
  926. {
  927. "HostRoles": {
  928. "component_name": data.componentName
  929. }
  930. }
  931. ]
  932. })
  933. }
  934. }
  935. },
  936. 'admin.high_availability.create_journalnode': {
  937. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  938. 'mock': '',
  939. 'type': 'POST',
  940. 'format': function() {
  941. return {
  942. data: JSON.stringify({
  943. "components": [
  944. {
  945. "ServiceComponentInfo": {
  946. "component_name": "JOURNALNODE"
  947. }
  948. }
  949. ]
  950. })
  951. }
  952. }
  953. },
  954. 'admin.high_availability.create_zkfc': {
  955. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  956. 'mock': '',
  957. 'type': 'POST',
  958. 'format': function() {
  959. return {
  960. data: JSON.stringify({
  961. "components": [
  962. {
  963. "ServiceComponentInfo": {
  964. "component_name": "ZKFC"
  965. }
  966. }
  967. ]
  968. })
  969. }
  970. }
  971. },
  972. 'admin.high_availability.load_configs': {
  973. 'real': '/clusters/{clusterName}/configurations?(type=core-site&tag={coreSiteTag})|(type=hdfs-site&tag={hdfsSiteTag})',
  974. 'mock': ''
  975. },
  976. 'admin.high_availability.save_configs': {
  977. 'real': '/clusters/{clusterName}',
  978. 'mock': '',
  979. 'type': 'PUT',
  980. 'format': function (data) {
  981. return {
  982. data: JSON.stringify({
  983. Clusters: {
  984. desired_config: {
  985. "type": data.siteName,
  986. "tag": 'version' + (new Date).getTime(),
  987. "properties": data.properties
  988. }
  989. }
  990. })
  991. }
  992. }
  993. },
  994. 'admin.high_availability.load_hbase_configs': {
  995. 'real': '/clusters/{clusterName}/configurations?type=hbase-site&tag={hbaseSiteTag}',
  996. 'mock': ''
  997. },
  998. 'admin.security.cluster_configs': {
  999. 'real': '/clusters/{clusterName}',
  1000. 'mock': '',
  1001. 'format': function() {
  1002. return {
  1003. timeout: 10000
  1004. };
  1005. }
  1006. },
  1007. 'admin.get.all_configurations': {
  1008. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  1009. 'mock': '',
  1010. 'format': function() {
  1011. return {
  1012. timeout: 10000
  1013. };
  1014. }
  1015. },
  1016. 'admin.security.add.cluster_configs': {
  1017. 'real': '/clusters/{clusterName}' + '?fields=Clusters/desired_configs',
  1018. 'mock': '',
  1019. 'format': function() {
  1020. return {
  1021. timeout: 10000
  1022. };
  1023. }
  1024. },
  1025. 'admin.stack_upgrade.run_upgrade': {
  1026. 'real': '/clusters/{clusterName}',
  1027. 'mock': '',
  1028. 'format': function (data) {
  1029. return {
  1030. type: 'PUT',
  1031. data: data.data
  1032. };
  1033. }
  1034. },
  1035. 'admin.user.create': {
  1036. 'real': '/users/{user}',
  1037. 'mock': '/data/users/users.json',
  1038. 'format': function(data) {
  1039. return {
  1040. type: 'POST',
  1041. data: JSON.stringify(data.data)
  1042. }
  1043. }
  1044. },
  1045. 'admin.user.edit': {
  1046. 'real': '/users/{user}',
  1047. 'mock':'/data/users/users.json',
  1048. 'format': function(data) {
  1049. return {
  1050. type: 'PUT',
  1051. data: data.data
  1052. }
  1053. }
  1054. },
  1055. 'admin.stack_upgrade.do_poll': {
  1056. 'real': '/clusters/{cluster}/requests/{requestId}?fields=tasks/*',
  1057. 'mock': '/data/wizard/{mock}'
  1058. },
  1059. 'wizard.advanced_repositories.valid_url': {
  1060. 'real': '/stacks/{stackName}/versions/{stackVersion}/operating_systems/{osType}/repositories/{repoId}',
  1061. 'mock': '',
  1062. 'type': 'PUT',
  1063. 'format': function (data) {
  1064. return {
  1065. data: JSON.stringify(data.data)
  1066. }
  1067. }
  1068. },
  1069. 'wizard.service_components': {
  1070. 'real': '{stackUrl}/services?fields=StackServices/*,serviceComponents/*',
  1071. 'mock': '/data/stacks/HDP-2.1/service_components.json',
  1072. 'format': function(data) {
  1073. return {
  1074. timeout: 10000
  1075. };
  1076. }
  1077. },
  1078. 'wizard.step9.installer.get_host_status': {
  1079. 'real': '/clusters/{cluster}/hosts?fields=Hosts/host_state,host_components/HostRoles/state',
  1080. 'mock': '/data/wizard/deploy/5_hosts/get_host_state.json'
  1081. },
  1082. 'wizard.step9.load_log': {
  1083. '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',
  1084. 'mock': '/data/wizard/deploy/5_hosts/poll_{numPolls}.json',
  1085. 'format': function () {
  1086. return {
  1087. dataType: 'text'
  1088. };
  1089. }
  1090. },
  1091. 'wizard.step8.existing_cluster_names': {
  1092. 'real': '/clusters',
  1093. 'mock': ''
  1094. },
  1095. 'wizard.step8.create_cluster': {
  1096. 'real':'/clusters/{cluster}',
  1097. 'mock':'',
  1098. 'format': function(data) {
  1099. return {
  1100. type: 'POST',
  1101. dataType: 'text',
  1102. data: data.data
  1103. }
  1104. }
  1105. },
  1106. 'wizard.step8.create_selected_services': {
  1107. 'real':'/clusters/{cluster}/services',
  1108. 'mock':'',
  1109. 'format': function(data) {
  1110. return {
  1111. type: 'POST',
  1112. dataType: 'text',
  1113. data: data.data
  1114. }
  1115. }
  1116. },
  1117. 'wizard.step8.create_components': {
  1118. 'real':'/clusters/{cluster}/services?ServiceInfo/service_name={serviceName}',
  1119. 'mock':'',
  1120. 'format': function(data) {
  1121. return {
  1122. type: 'POST',
  1123. dataType: 'text',
  1124. data: data.data
  1125. }
  1126. }
  1127. },
  1128. 'wizard.step8.register_host_to_cluster': {
  1129. 'real':'/clusters/{cluster}/hosts',
  1130. 'mock':'',
  1131. 'format': function(data) {
  1132. return {
  1133. type: 'POST',
  1134. dataType: 'text',
  1135. data: data.data
  1136. }
  1137. }
  1138. },
  1139. 'wizard.step8.register_host_to_component': {
  1140. 'real':'/clusters/{cluster}/hosts',
  1141. 'mock':'',
  1142. 'format': function(data) {
  1143. return {
  1144. type: 'POST',
  1145. dataType: 'text',
  1146. data: data.data
  1147. }
  1148. }
  1149. },
  1150. 'wizard.step8.apply_configuration_groups': {
  1151. 'real':'/clusters/{cluster}/config_groups',
  1152. 'mock':'',
  1153. 'format': function(data) {
  1154. return {
  1155. type: 'POST',
  1156. dataType: 'text',
  1157. data: data.data
  1158. }
  1159. }
  1160. },
  1161. 'wizard.step8.set_local_repos': {
  1162. 'real':'{stackVersionURL}/operating_systems/{osType}/repositories/{repoId}',
  1163. 'mock':'',
  1164. 'format': function(data) {
  1165. return {
  1166. type: 'PUT',
  1167. dataType: 'text',
  1168. data: data.data
  1169. }
  1170. }
  1171. },
  1172. 'wizard.step3.jdk_check': {
  1173. 'real': '/requests',
  1174. 'mock': '',
  1175. 'format': function (data) {
  1176. return {
  1177. type: 'POST',
  1178. data: JSON.stringify({
  1179. "RequestInfo": {
  1180. "context": "Check hosts",
  1181. "action": "check_host",
  1182. "parameters" : {
  1183. "threshold" : "60",
  1184. "java_home" : data.java_home,
  1185. "jdk_location": data.jdk_location,
  1186. "check_execute_list" : "java_home_check"
  1187. }
  1188. },
  1189. "Requests/resource_filters": [{
  1190. "hosts": data.host_names
  1191. }]
  1192. })
  1193. }
  1194. }
  1195. },
  1196. 'wizard.step3.jdk_check.get_results': {
  1197. 'real': '/requests/{requestIndex}?fields=*,tasks/Tasks/host_name,tasks/Tasks/status,tasks/Tasks/structured_out',
  1198. 'mock': '/data/requests/host_check/jdk_check_results.json'
  1199. },
  1200. 'wizard.step3.host_info': {
  1201. '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',
  1202. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  1203. 'format': function() {
  1204. return {
  1205. contentType: 'application/json'
  1206. };
  1207. }
  1208. },
  1209. 'wizard.loadrecommendations': {
  1210. 'real': '{stackVersionUrl}/recommendations',
  1211. 'mock': '/data/stacks/HDP-2.1/recommendations.json',
  1212. 'type': 'POST',
  1213. 'format': function (data) {
  1214. var q = {
  1215. hosts: data.hosts,
  1216. services: data.services,
  1217. recommend: data.recommend
  1218. };
  1219. if (data.recommendations) {
  1220. q.recommendations = data.recommendations;
  1221. }
  1222. return {
  1223. data: JSON.stringify(q)
  1224. }
  1225. }
  1226. },
  1227. // TODO: merge with wizard.loadrecommendations query
  1228. 'wizard.step7.loadrecommendations.configs': {
  1229. 'real': '{stackVersionUrl}/recommendations',
  1230. 'mock': '/data/stacks/HDP-2.1/recommendations_configs.json',
  1231. 'type': 'POST',
  1232. 'format': function (data) {
  1233. return {
  1234. data: JSON.stringify({
  1235. hosts: data.hosts,
  1236. services: data.services,
  1237. recommendations: data.recommendations,
  1238. recommend: "configurations"
  1239. })
  1240. }
  1241. }
  1242. },
  1243. 'config.validations': {
  1244. 'real': '{stackVersionUrl}/validations',
  1245. 'mock': '/data/stacks/HDP-2.1/validations.json',
  1246. 'type': 'POST',
  1247. 'format': function (data) {
  1248. return {
  1249. data: JSON.stringify({
  1250. hosts: data.hosts,
  1251. services: data.services,
  1252. validate: data.validate,
  1253. recommendations: data.recommendations
  1254. })
  1255. }
  1256. }
  1257. },
  1258. 'preinstalled.checks': {
  1259. 'real':'/requests',
  1260. 'mock':'',
  1261. 'format': function(data) {
  1262. return {
  1263. type : 'POST',
  1264. data : JSON.stringify({
  1265. "RequestInfo": data.RequestInfo,
  1266. "Requests/resource_filters": [data.resource_filters]
  1267. })
  1268. }
  1269. }
  1270. },
  1271. 'preinstalled.checks.tasks': {
  1272. 'real':'/requests/{requestId}?fields=tasks/Tasks',
  1273. 'mock':'/data/requests/host_check/1.json'
  1274. },
  1275. 'wizard.step3.rerun_checks': {
  1276. 'real': '/hosts?fields=Hosts/last_agent_env',
  1277. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  1278. 'format': function() {
  1279. return {
  1280. contentType: 'application/json'
  1281. };
  1282. }
  1283. },
  1284. 'wizard.step3.bootstrap': {
  1285. 'real': '/bootstrap/{bootRequestId}',
  1286. 'mock': '/data/wizard/bootstrap/poll_{numPolls}.json'
  1287. },
  1288. 'wizard.step3.is_hosts_registered': {
  1289. 'real': '/hosts',
  1290. 'mock': '/data/wizard/bootstrap/single_host_registration.json'
  1291. },
  1292. 'wizard.stacks': {
  1293. 'real': '/stacks',
  1294. 'mock': '/data/wizard/stack/stacks2.json'
  1295. },
  1296. 'wizard.stacks_versions': {
  1297. 'real': '/stacks/{stackName}/versions?fields=Versions,operatingSystems/repositories/Repositories',
  1298. 'mock': '/data/wizard/stack/{stackName}_versions.json'
  1299. },
  1300. 'wizard.launch_bootstrap': {
  1301. 'real': '/bootstrap',
  1302. 'mock': '/data/wizard/bootstrap/bootstrap.json',
  1303. 'type': 'POST',
  1304. 'format': function (data) {
  1305. return {
  1306. contentType: 'application/json',
  1307. data: data.bootStrapData,
  1308. popup: data.popup
  1309. }
  1310. }
  1311. },
  1312. 'router.login': {
  1313. 'real': '/users/{loginName}',
  1314. 'mock': '/data/users/user_{usr}.json',
  1315. 'format': function (data) {
  1316. var statusCode = jQuery.extend({}, require('data/statusCodes'));
  1317. statusCode['403'] = function () {
  1318. console.log("Error code 403: Forbidden.");
  1319. };
  1320. return {
  1321. statusCode: statusCode
  1322. };
  1323. }
  1324. },
  1325. 'users.all': {
  1326. real: '/users/?fields=*',
  1327. mock: '/data/users/users.json'
  1328. },
  1329. 'users.privileges': {
  1330. real: '/privileges?fields=*',
  1331. mock: '/data/users/privileges.json'
  1332. },
  1333. 'router.user.privileges': {
  1334. real: '/privileges?PrivilegeInfo/principal_name={userName}&fields=*',
  1335. mock: '/data/users/privileges_{userName}.json'
  1336. },
  1337. 'router.login.clusters': {
  1338. 'real': '/clusters?fields=Clusters/provisioning_state',
  1339. 'mock': '/data/clusters/info.json'
  1340. },
  1341. 'router.logoff': {
  1342. 'real': '/logout',
  1343. 'mock': ''
  1344. },
  1345. 'router.authentication': {
  1346. 'real': '/clusters?fields=Clusters/provisioning_state',
  1347. 'mock': '/data/clusters/info.json',
  1348. 'format': function() {
  1349. return {
  1350. async: false
  1351. };
  1352. }
  1353. },
  1354. 'ambari.service.load_jdk_name': {
  1355. 'real': '/services/AMBARI/components/AMBARI_SERVER?fields=RootServiceComponents/properties/jdk.name,RootServiceComponents/properties/java.home,RootServiceComponents/properties/jdk_location',
  1356. 'mock': '/data/requests/host_check/jdk_name.json'
  1357. },
  1358. 'ambari.service.load_server_version': {
  1359. 'real': '/services/AMBARI/components/AMBARI_SERVER?fields=RootServiceComponents/component_version',
  1360. 'mock': ''
  1361. },
  1362. 'ambari.service': {
  1363. 'real': '/services/AMBARI/components/AMBARI_SERVER',
  1364. 'mock': '/data/services/ambari_server.json'
  1365. },
  1366. 'ambari.service.load_server_clock': {
  1367. 'real': '/services/AMBARI/components/AMBARI_SERVER?fields=RootServiceComponents/server_clock',
  1368. 'mock': ''
  1369. },
  1370. 'config_groups.create': {
  1371. 'real': '/clusters/{clusterName}/config_groups',
  1372. 'mock': '',
  1373. 'format': function (data) {
  1374. return {
  1375. type: 'POST',
  1376. data: JSON.stringify([{
  1377. "ConfigGroup": {
  1378. "group_name": data.group_name,
  1379. "tag": data.service_id,
  1380. "description": data.description,
  1381. "desired_configs": data.desired_configs,
  1382. "hosts": data.hosts
  1383. }
  1384. }])
  1385. }
  1386. }
  1387. },
  1388. 'config_groups.update': {
  1389. 'real': '/clusters/{clusterName}/config_groups/{id}',
  1390. 'mock': '',
  1391. 'format': function (data) {
  1392. return {
  1393. type: 'PUT',
  1394. data: JSON.stringify(data.data)
  1395. }
  1396. }
  1397. },
  1398. 'rolling_restart.post': {
  1399. 'real': '/clusters/{clusterName}/request_schedules',
  1400. 'mock': '',
  1401. 'format' : function(data) {
  1402. return {
  1403. type : 'POST',
  1404. data : JSON.stringify([ {
  1405. "RequestSchedule" : {
  1406. "batch" : [ {
  1407. "requests" : data.batches
  1408. }, {
  1409. "batch_settings" : {
  1410. "batch_separation_in_seconds" : data.intervalTimeSeconds,
  1411. "task_failure_tolerance" : data.tolerateSize
  1412. }
  1413. } ]
  1414. }
  1415. } ])
  1416. }
  1417. }
  1418. },
  1419. 'request_schedule.get': {
  1420. 'real': '/clusters/{clusterName}/request_schedules/{request_schedule_id}',
  1421. 'mock': ''
  1422. },
  1423. 'restart.hostComponents': {
  1424. 'real':'/clusters/{clusterName}/requests',
  1425. 'mock':'',
  1426. 'format': function(data) {
  1427. return {
  1428. type : 'POST',
  1429. data : JSON.stringify({
  1430. "RequestInfo": {
  1431. "command": "RESTART",
  1432. "context": data.context,
  1433. "operation_level": data.operation_level
  1434. },
  1435. "Requests/resource_filters": data.resource_filters
  1436. })
  1437. }
  1438. }
  1439. },
  1440. 'mirroring.get_all_entities': {
  1441. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/list/{type}?fields=status&user.name=ambari-qa',
  1442. 'mock': '/data/mirroring/{type}s.xml',
  1443. 'apiPrefix': '',
  1444. 'format': function () {
  1445. return {
  1446. dataType: 'xml'
  1447. }
  1448. }
  1449. },
  1450. 'mirroring.get_definition': {
  1451. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/definition/{type}/{name}?user.name=ambari-qa',
  1452. 'mock': '/data/mirroring/{name}_definition.xml',
  1453. 'apiPrefix': '',
  1454. 'format': function () {
  1455. return {
  1456. cache: true,
  1457. dataType: 'xml'
  1458. }
  1459. }
  1460. },
  1461. 'mirroring.dataset.get_all_instances': {
  1462. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/status/feed/{dataset}?start={start}&end={end}&user.name=ambari-qa',
  1463. 'mock': '/data/mirroring/{dataset}_instances.json',
  1464. 'apiPrefix': ''
  1465. },
  1466. 'mirroring.create_new_dataset': {
  1467. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/submitAndSchedule/feed?user.name=ambari-qa',
  1468. 'mock': '/data/mirroring/succeeded.json',
  1469. 'apiPrefix': '',
  1470. 'type': 'POST',
  1471. 'format': function (data) {
  1472. return {
  1473. contentType: 'text/xml',
  1474. dataType: 'xml',
  1475. data: data.entity,
  1476. headers: {
  1477. 'AmbariProxy-Content-Type': 'text/xml'
  1478. }
  1479. }
  1480. }
  1481. },
  1482. 'mirroring.submit_entity': {
  1483. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/submit/{type}?user.name=ambari-qa',
  1484. 'mock': '/data/mirroring/succeeded.json',
  1485. 'apiPrefix': '',
  1486. 'type': 'POST',
  1487. 'format': function (data) {
  1488. return {
  1489. contentType: 'text/xml',
  1490. dataType: 'xml',
  1491. data: data.entity,
  1492. headers: {
  1493. 'AmbariProxy-Content-Type': 'text/xml'
  1494. }
  1495. }
  1496. }
  1497. },
  1498. 'mirroring.update_entity': {
  1499. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/update/{type}/{name}?user.name=ambari-qa',
  1500. 'mock': '/data/mirroring/succeeded.json',
  1501. 'apiPrefix': '',
  1502. 'type': 'POST',
  1503. 'format': function (data) {
  1504. return {
  1505. contentType: 'text/xml',
  1506. dataType: 'xml',
  1507. data: data.entity,
  1508. headers: {
  1509. 'AmbariProxy-Content-Type': 'text/xml'
  1510. }
  1511. }
  1512. }
  1513. },
  1514. 'mirroring.delete_entity': {
  1515. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/delete/{type}/{name}?user.name=ambari-qa',
  1516. 'mock': '/data/mirroring/succeeded.json',
  1517. 'apiPrefix': '',
  1518. 'type': 'DELETE',
  1519. 'format': function () {
  1520. return {
  1521. dataType: 'xml'
  1522. }
  1523. }
  1524. },
  1525. 'mirroring.suspend_entity': {
  1526. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/suspend/{type}/{name}?user.name=ambari-qa',
  1527. 'mock': '/data/mirroring/succeeded.json',
  1528. 'apiPrefix': '',
  1529. 'type': 'POST',
  1530. 'format': function (data) {
  1531. return {
  1532. dataType: 'xml',
  1533. data: data.entity
  1534. }
  1535. }
  1536. },
  1537. 'mirroring.resume_entity': {
  1538. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/resume/{type}/{name}?user.name=ambari-qa',
  1539. 'mock': '/data/mirroring/succeeded.json',
  1540. 'apiPrefix': '',
  1541. 'type': 'POST',
  1542. 'format': function () {
  1543. return {
  1544. dataType: 'xml'
  1545. }
  1546. }
  1547. },
  1548. 'mirroring.schedule_entity': {
  1549. 'real': '/proxy?url=http://{falconServer}:15000/api/entities/schedule/{type}/{name}?user.name=ambari-qa',
  1550. 'mock': '/data/mirroring/succeeded.json',
  1551. 'apiPrefix': '',
  1552. 'type': 'POST',
  1553. 'format': function () {
  1554. return {
  1555. dataType: 'xml'
  1556. }
  1557. }
  1558. },
  1559. 'mirroring.suspend_instance': {
  1560. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/suspend/feed/{feed}?start={name}&user.name=ambari-qa',
  1561. 'mock': '/data/mirroring/succeeded.json',
  1562. 'apiPrefix': '',
  1563. 'type': 'POST'
  1564. },
  1565. 'mirroring.resume_instance': {
  1566. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/resume/feed/{feed}?start={name}&user.name=ambari-qa',
  1567. 'mock': '/data/mirroring/succeeded.json',
  1568. 'apiPrefix': '',
  1569. 'type': 'POST'
  1570. },
  1571. 'mirroring.kill_instance': {
  1572. 'real': '/proxy?url=http://{falconServer}:15000/api/instance/kill/feed/{feed}?start={name}&user.name=ambari-qa',
  1573. 'mock': '/data/mirroring/succeeded.json',
  1574. 'apiPrefix': '',
  1575. 'type': 'POST'
  1576. },
  1577. 'bulk_request.decommission': {
  1578. 'real' : '/clusters/{clusterName}/requests',
  1579. 'mock' : '',
  1580. 'format': function(data) {
  1581. return {
  1582. type: 'POST',
  1583. data: JSON.stringify({
  1584. 'RequestInfo': {
  1585. 'context': data.context,
  1586. 'command': 'DECOMMISSION',
  1587. 'parameters': data.parameters,
  1588. 'operation_level': {
  1589. 'level': "CLUSTER",
  1590. 'cluster_name': data.clusterName
  1591. }
  1592. },
  1593. "Requests/resource_filters": [{"service_name" : data.serviceName, "component_name" : data.componentName}]
  1594. })
  1595. }
  1596. }
  1597. },
  1598. 'bulk_request.hosts.passive_state': {
  1599. 'real': '/clusters/{clusterName}/hosts',
  1600. 'mock': '',
  1601. 'format': function(data) {
  1602. return {
  1603. type: 'PUT',
  1604. data: JSON.stringify({
  1605. RequestInfo: {
  1606. context: data.requestInfo,
  1607. query: 'Hosts/host_name.in(' + data.hostNames + ')'
  1608. },
  1609. Body: {
  1610. Hosts: {
  1611. maintenance_state: data.passive_state
  1612. }
  1613. }
  1614. })
  1615. }
  1616. }
  1617. },
  1618. 'bulk_request.hosts.all_components.passive_state': {
  1619. 'real': '/clusters/{clusterName}/host_components',
  1620. 'mock': '',
  1621. 'format': function(data) {
  1622. return {
  1623. type: 'PUT',
  1624. data: JSON.stringify({
  1625. RequestInfo: {
  1626. context: data.requestInfo,
  1627. query: data.query
  1628. },
  1629. Body: {
  1630. HostRoles: {
  1631. maintenance_state: data.passive_state
  1632. }
  1633. }
  1634. })
  1635. }
  1636. }
  1637. },
  1638. 'jobs.lastID': {
  1639. 'real': '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/HIVE_QUERY_ID?limit=1&secondaryFilter=tez:true',
  1640. 'mock': 'data/jobs/hive-queries.json',
  1641. 'apiPrefix': ''
  1642. },
  1643. 'jobs.tezDag.NametoID': {
  1644. 'real': '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/TEZ_DAG_ID?primaryFilter=dagName:{tezDagName}',
  1645. 'mock': '/data/jobs/tezDag-name-to-id.json',
  1646. 'apiPrefix': ''
  1647. },
  1648. 'jobs.tezDag.tezDagId': {
  1649. 'real': '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/TEZ_DAG_ID/{tezDagId}?fields=relatedentities,otherinfo',
  1650. 'mock': '/data/jobs/tezDag.json',
  1651. 'apiPrefix': ''
  1652. },
  1653. 'jobs.tezDag.tezDagVertexId': {
  1654. 'real': '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/TEZ_VERTEX_ID/{tezDagVertexId}?fields=otherinfo',
  1655. 'mock': '/data/jobs/tezDagVertex.json',
  1656. 'apiPrefix': ''
  1657. },
  1658. 'views.info': {
  1659. 'real': '/views',
  1660. 'mock': '/data/views/views.json'
  1661. },
  1662. /**
  1663. * Get all instances of all views across versions
  1664. */
  1665. 'views.instances': {
  1666. 'real': '/views?fields=versions/instances/ViewInstanceInfo,versions/ViewVersionInfo/label&versions/ViewVersionInfo/system=false',
  1667. 'mock': '/data/views/instances.json'
  1668. },
  1669. 'host.host_component.flume.metrics': {
  1670. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/FLUME_HANDLER?fields=metrics/flume/flume/{flumeComponent}/*',
  1671. 'mock': ''
  1672. },
  1673. 'host.host_component.flume.metrics.timeseries': {
  1674. 'real': '',
  1675. 'mock': '',
  1676. format: function (data) {
  1677. return {
  1678. url: data.url
  1679. }
  1680. }
  1681. },
  1682. 'host.host_components.filtered': {
  1683. 'real': '/clusters/{clusterName}/hosts?{fields}',
  1684. 'mock': '',
  1685. format: function(data) {
  1686. return {
  1687. headers: {
  1688. 'X-Http-Method-Override': 'GET'
  1689. },
  1690. type: 'POST',
  1691. data: JSON.stringify({
  1692. "RequestInfo": {"query" : data.parameters}
  1693. })
  1694. };
  1695. }
  1696. },
  1697. 'host.status.counters': {
  1698. 'real': '/clusters/{clusterName}?fields=alerts,Clusters/health_report,Clusters/total_hosts&minimal_response=true',
  1699. 'mock': '/data/hosts/HDP2/host_status_counters.json'
  1700. },
  1701. 'components.filter_by_status': {
  1702. 'real': '/clusters/{clusterName}/components?fields=host_components/HostRoles/host_name,ServiceComponentInfo/component_name,ServiceComponentInfo/started_count{urlParams}&minimal_response=true',
  1703. 'mock': ''
  1704. },
  1705. 'hosts.all.install': {
  1706. 'real': '/hosts?minimal_response=true',
  1707. 'mock': ''
  1708. },
  1709. 'hosts.all': {
  1710. 'real': '/clusters/{clusterName}/hosts?minimal_response=true',
  1711. 'mock': ''
  1712. },
  1713. 'hosts.with_public_host_names': {
  1714. 'real': '/clusters/{clusterName}/hosts?fields=Hosts/public_host_name&minimal_response=true',
  1715. 'mock': ''
  1716. },
  1717. 'hosts.for_quick_links': {
  1718. 'real': '/clusters/{clusterName}/hosts?Hosts/host_name.in({masterHosts})&fields=Hosts/public_host_name,host_components/HostRoles/component_name{urlParams}&minimal_response=true',
  1719. 'mock': '/data/hosts/quick_links.json'
  1720. },
  1721. 'hosts.confirmed.install': {
  1722. 'real': '/hosts?fields=Hosts/cpu_count,Hosts/disk_info,Hosts/total_mem&minimal_response=true',
  1723. 'mock': ''
  1724. },
  1725. 'hosts.confirmed': {
  1726. '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',
  1727. 'mock': ''
  1728. },
  1729. 'host_components.all': {
  1730. 'real': '/clusters/{clusterName}/host_components?fields=HostRoles/host_name&minimal_response=true',
  1731. 'mock': ''
  1732. },
  1733. 'host_components.with_services_names': {
  1734. 'real': '/clusters/{clusterName}/host_components?fields=component/ServiceComponentInfo/service_name,HostRoles/host_name&minimal_response=true',
  1735. 'mock': ''
  1736. },
  1737. 'components.get_installed': {
  1738. 'real': '/clusters/{clusterName}/components',
  1739. 'mock': ''
  1740. },
  1741. 'hosts.heatmaps': {
  1742. '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',
  1743. 'mock': ''
  1744. },
  1745. 'namenode.cpu_wio': {
  1746. 'real': '/clusters/{clusterName}/hosts/{nnHost}?fields=metrics/cpu',
  1747. 'mock': ''
  1748. },
  1749. 'custom_action.create': {
  1750. 'real': '/requests',
  1751. 'mock': '',
  1752. 'format': function(data) {
  1753. var requestInfo = {
  1754. context: 'Check host',
  1755. action: 'check_host',
  1756. parameters: { }
  1757. };
  1758. $.extend(true, requestInfo, data.requestInfo)
  1759. return {
  1760. type: 'POST',
  1761. data: JSON.stringify({
  1762. 'RequestInfo': requestInfo,
  1763. 'Requests/resource_filters': [{
  1764. hosts: data.filteredHosts.join(',')
  1765. }]
  1766. })
  1767. }
  1768. }
  1769. },
  1770. 'custom_action.request': {
  1771. 'real': '/requests/{requestId}/tasks/{taskId}',
  1772. 'mock': '',
  1773. 'format': function(data) {
  1774. return {
  1775. requestId: data.requestId,
  1776. taskId: data.taskId || ''
  1777. }
  1778. }
  1779. },
  1780. 'hosts.high_availability.wizard': {
  1781. 'real': '/clusters/{clusterName}/hosts?fields=Hosts/cpu_count,Hosts/disk_info,Hosts/total_mem&minimal_response=true',
  1782. 'mock': ''
  1783. },
  1784. 'hosts.security.wizard': {
  1785. 'real': '/clusters/{clusterName}/hosts?fields=host_components/HostRoles/service_name&minimal_response=true',
  1786. 'mock': ''
  1787. },
  1788. 'host_component.installed.on_hosts': {
  1789. 'real': '/clusters/{clusterName}/host_components?HostRoles/component_name={componentName}&HostRoles/host_name.in({hostNames})&fields=HostRoles/host_name&minimal_response=true',
  1790. 'mock': ''
  1791. },
  1792. 'hosts.by_component.one': {
  1793. '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',
  1794. 'mock': ''
  1795. },
  1796. 'hosts.by_component.all': {
  1797. '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',
  1798. 'mock': ''
  1799. },
  1800. 'hosts.config_groups': {
  1801. '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',
  1802. 'mock': ''
  1803. },
  1804. 'cluster.fields': {
  1805. real: '/clusters/{clusterName}?fields={fields}',
  1806. mock: '',
  1807. format: function(data) {
  1808. return {
  1809. async: true,
  1810. fields: data.fields.join(',')
  1811. }
  1812. }
  1813. },
  1814. 'hosts.host_components.pre_load': {
  1815. real: '',
  1816. mock: '',
  1817. format: function(data) {
  1818. return {
  1819. url: data.url
  1820. }
  1821. }
  1822. },
  1823. 'hosts.bulk.operations': {
  1824. real: '/clusters/{clusterName}/hosts?fields=Hosts/host_name,Hosts/maintenance_state,' +
  1825. 'host_components/HostRoles/state,host_components/HostRoles/maintenance_state,' +
  1826. 'host_components/HostRoles/stale_configs&minimal_response=true',
  1827. mock: '',
  1828. format: function(data) {
  1829. return {
  1830. headers: {
  1831. 'X-Http-Method-Override': 'GET'
  1832. },
  1833. type: 'POST',
  1834. data: JSON.stringify({
  1835. "RequestInfo": {"query" : data.parameters }
  1836. })
  1837. }
  1838. }
  1839. },
  1840. 'service.serviceConfigVersions.get': {
  1841. real: '/clusters/{clusterName}/configurations/service_config_versions?service_name={serviceName}&fields=service_config_version,user,group_id,group_name,is_current,createtime,service_name,service_config_version_note&minimal_response=true',
  1842. mock: '/data/configurations/service_versions.json'
  1843. },
  1844. 'service.serviceConfigVersions.get.current': {
  1845. real: '/clusters/{clusterName}?fields=Clusters/desired_service_config_versions&minimal_response=true',
  1846. mock: ''
  1847. },
  1848. 'service.serviceConfigVersions.get.total': {
  1849. real: '/clusters/{clusterName}/configurations/service_config_versions?page_size=1&minimal_response=true',
  1850. mock: ''
  1851. },
  1852. 'service.serviceConfigVersion.get': {
  1853. real: '/clusters/{clusterName}/configurations/service_config_versions?service_name={serviceName}&service_config_version={serviceConfigVersion}',
  1854. mock: '/data/configurations/service_version.json'
  1855. },
  1856. 'service.serviceConfigVersions.get.multiple': {
  1857. real: '/clusters/{clusterName}/configurations/service_config_versions?service_name={serviceName}&service_config_version.in({serviceConfigVersions})',
  1858. mock: '/data/configurations/service_version.json',
  1859. format: function(data) {
  1860. return {
  1861. serviceConfigVersions: data.serviceConfigVersions.join(',')
  1862. }
  1863. }
  1864. },
  1865. 'service.serviceConfigVersion.revert': {
  1866. 'real': '/clusters/{clusterName}',
  1867. 'mock': '',
  1868. 'type': 'PUT',
  1869. 'format': function (data) {
  1870. return {
  1871. data: JSON.stringify(data.data)
  1872. }
  1873. }
  1874. }
  1875. };
  1876. /**
  1877. * Replace data-placeholders to its values
  1878. *
  1879. * @param {String} url
  1880. * @param {Object} data
  1881. * @return {String}
  1882. */
  1883. var formatUrl = function (url, data) {
  1884. if (!url) return null;
  1885. var keys = url.match(/\{\w+\}/g);
  1886. keys = (keys === null) ? [] : keys;
  1887. if (keys) {
  1888. keys.forEach(function (key) {
  1889. var raw_key = key.substr(1, key.length - 2);
  1890. var replace;
  1891. if (!data || !data[raw_key]) {
  1892. replace = '';
  1893. }
  1894. else {
  1895. replace = data[raw_key];
  1896. }
  1897. url = url.replace(new RegExp(key, 'g'), replace);
  1898. });
  1899. }
  1900. return url;
  1901. };
  1902. /**
  1903. * this = object from config
  1904. * @return {Object}
  1905. */
  1906. var formatRequest = function (data) {
  1907. var opt = {
  1908. type: this.type || 'GET',
  1909. timeout: App.timeout,
  1910. dataType: 'json',
  1911. statusCode: require('data/statusCodes')
  1912. };
  1913. if (App.get('testMode')) {
  1914. opt.url = formatUrl(this.mock ? this.mock : '', data);
  1915. opt.type = 'GET';
  1916. }
  1917. else {
  1918. var prefix = this.apiPrefix != null ? this.apiPrefix : App.apiPrefix;
  1919. opt.url = prefix + formatUrl(this.real, data);
  1920. }
  1921. if (this.format) {
  1922. jQuery.extend(opt, this.format(data, opt));
  1923. }
  1924. return opt;
  1925. };
  1926. /**
  1927. * Wrapper for all ajax requests
  1928. *
  1929. * @type {Object}
  1930. */
  1931. var ajax = Em.Object.extend({
  1932. /**
  1933. * Send ajax request
  1934. *
  1935. * @param {Object} config
  1936. * @return {$.ajax} jquery ajax object
  1937. *
  1938. * config fields:
  1939. * name - url-key in the urls-object *required*
  1940. * sender - object that send request (need for proper callback initialization) *required*
  1941. * data - object with data for url-format
  1942. * beforeSend - method-name for ajax beforeSend response callback
  1943. * success - method-name for ajax success response callback
  1944. * error - method-name for ajax error response callback
  1945. * callback - callback from <code>App.updater.run</code> library
  1946. */
  1947. send: function (config) {
  1948. if (!config.sender) {
  1949. console.warn('Ajax sender should be defined!');
  1950. return null;
  1951. }
  1952. // default parameters
  1953. var params = {
  1954. clusterName: (App.get('clusterName') || App.clusterStatus.get('clusterName'))
  1955. };
  1956. // extend default parameters with provided
  1957. if (config.data) {
  1958. jQuery.extend(params, config.data);
  1959. }
  1960. var opt = {};
  1961. if (!urls[config.name]) {
  1962. console.warn('Invalid name provided!');
  1963. return null;
  1964. }
  1965. opt = formatRequest.call(urls[config.name], params);
  1966. opt.context = this;
  1967. // object sender should be provided for processing beforeSend, success and error responses
  1968. opt.beforeSend = function (xhr) {
  1969. if (config.beforeSend) {
  1970. config.sender[config.beforeSend](opt, xhr, params);
  1971. }
  1972. };
  1973. opt.success = function (data) {
  1974. console.log("TRACE: The url is: " + opt.url);
  1975. if (config.success) {
  1976. config.sender[config.success](data, opt, params);
  1977. }
  1978. };
  1979. opt.error = function (request, ajaxOptions, error) {
  1980. if (config.error) {
  1981. config.sender[config.error](request, ajaxOptions, error, opt, params);
  1982. } else {
  1983. this.defaultErrorHandler(request, opt.url, opt.type);
  1984. }
  1985. };
  1986. opt.complete = function () {
  1987. if (config.callback) {
  1988. config.callback();
  1989. }
  1990. };
  1991. if ($.mocho) {
  1992. opt.url = 'http://' + $.hostName + opt.url;
  1993. }
  1994. return $.ajax(opt);
  1995. },
  1996. // A single instance of App.ModalPopup view
  1997. modalPopup: null,
  1998. /**
  1999. * defaultErrorHandler function is referred from App.ajax.send function and App.HttpClient.defaultErrorHandler function
  2000. * @jqXHR {jqXHR Object}
  2001. * @url {string}
  2002. * @method {String} Http method
  2003. * @showStatus {number} HTTP response code which should be shown. Default is 500.
  2004. */
  2005. defaultErrorHandler: function (jqXHR, url, method, showStatus) {
  2006. method = method || 'GET';
  2007. var self = this;
  2008. var api = " received on " + method + " method for API: " + url;
  2009. try {
  2010. var json = $.parseJSON(jqXHR.responseText);
  2011. var message = json.message;
  2012. } catch (err) {
  2013. }
  2014. if (!showStatus) {
  2015. showStatus = 500;
  2016. }
  2017. var statusCode = jqXHR.status + " status code";
  2018. if (jqXHR.status === showStatus && !this.get('modalPopup')) {
  2019. this.set('modalPopup', App.ModalPopup.show({
  2020. header: Em.I18n.t('common.error'),
  2021. secondary: false,
  2022. onPrimary: function () {
  2023. this.hide();
  2024. self.set('modalPopup', null);
  2025. },
  2026. bodyClass: Ember.View.extend({
  2027. classNames: ['api-error'],
  2028. templateName: require('templates/utils/ajax'),
  2029. api: api,
  2030. statusCode: statusCode,
  2031. message: message,
  2032. showMessage: !!message
  2033. })
  2034. }));
  2035. }
  2036. }
  2037. });
  2038. /**
  2039. * Add few access-methods for test purposes
  2040. */
  2041. if ($.mocho) {
  2042. ajax.reopen({
  2043. /**
  2044. * Don't use it anywhere except tests!
  2045. * @returns {Array}
  2046. */
  2047. fakeGetUrlNames: function() {
  2048. return Em.keys(urls);
  2049. },
  2050. /**
  2051. * Don't use it anywhere except tests!
  2052. * @param name
  2053. * @returns {*}
  2054. */
  2055. fakeGetUrl: function(name) {
  2056. return urls[name];
  2057. },
  2058. /**
  2059. * Don't use it anywhere except tests!
  2060. * @param url
  2061. * @param data
  2062. * @returns {String}
  2063. */
  2064. fakeFormatUrl: function(url, data) {
  2065. return formatUrl(url, data);
  2066. },
  2067. /**
  2068. * Don't use it anywhere except tests!
  2069. * @param urlObj
  2070. * @param data
  2071. * @returns {Object}
  2072. */
  2073. fakeFormatRequest: function(urlObj, data) {
  2074. return formatRequest.call(urlObj, data);
  2075. }
  2076. });
  2077. }
  2078. App.ajax = ajax.create({});