ajax.js 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386
  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. 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. 'background_operations.get_most_recent': {
  33. 'real': '/clusters/{clusterName}/requests?to=end&page_size=10&fields=Requests',
  34. 'mock': '/data/background_operations/list_on_start.json',
  35. 'testInProduction': true
  36. },
  37. 'background_operations.get_by_request': {
  38. 'real': '/clusters/{clusterName}/requests/{requestId}?fields=*,tasks/Tasks/command,tasks/Tasks/exit_code,tasks/Tasks/host_name,tasks/Tasks/id,tasks/Tasks/role,tasks/Tasks/status',
  39. 'mock': '/data/background_operations/task_by_request{requestId}.json',
  40. 'testInProduction': true,
  41. 'format': function (data) {
  42. return {
  43. async: !data.sync
  44. };
  45. }
  46. },
  47. 'background_operations.get_by_task': {
  48. 'real': '/clusters/{clusterName}/requests/{requestId}/tasks/{taskId}',
  49. 'mock': '/data/background_operations/list_on_start.json',
  50. 'testInProduction': true,
  51. 'format': function (data) {
  52. return {
  53. async: !data.sync
  54. };
  55. }
  56. },
  57. 'service.item.start_stop': {
  58. 'real': '/clusters/{clusterName}/services/{serviceName}',
  59. 'mock': '/data/wizard/deploy/poll_1.json',
  60. 'format': function (data, opt) {
  61. return {
  62. type: 'PUT',
  63. data: JSON.stringify({
  64. RequestInfo: {
  65. "context": data.requestInfo
  66. },
  67. Body: {
  68. ServiceInfo: {
  69. state: data.state
  70. }
  71. }
  72. })
  73. };
  74. }
  75. },
  76. 'service.item.smoke': {
  77. 'real': '/clusters/{clusterName}/requests',
  78. 'mock': '/data/wizard/deploy/poll_1.json',
  79. 'format': function (data) {
  80. return {
  81. 'type': 'POST',
  82. data: JSON.stringify({
  83. RequestInfo: {
  84. "context": data.displayName + " Smoke Test",
  85. "command" : data.actionName,
  86. "service_name" : data.serviceName
  87. }
  88. })
  89. };
  90. }
  91. },
  92. 'service.load_config_groups': {
  93. 'real': '/clusters/{clusterName}/config_groups?fields=*'
  94. },
  95. 'reassign.stop_services': {
  96. 'real': '/clusters/{clusterName}/services',
  97. 'mock': '',
  98. 'format': function (data, opt) {
  99. return {
  100. type: 'PUT',
  101. data: JSON.stringify({
  102. "RequestInfo": {
  103. "context": "Stop all services"
  104. },
  105. "Body": {
  106. "ServiceInfo": {
  107. "state": "INSTALLED"
  108. }
  109. }
  110. })
  111. }
  112. }
  113. },
  114. 'reassign.start_services': {
  115. 'real': '/clusters/{clusterName}/services?params/run_smoke_test=true',
  116. 'mock': '',
  117. 'format': function (data, opt) {
  118. return {
  119. type: 'PUT',
  120. data: JSON.stringify({
  121. "RequestInfo": {
  122. "context": "Start all services"
  123. },
  124. "Body": {
  125. "ServiceInfo": {
  126. "state": "STARTED"
  127. }
  128. }
  129. })
  130. }
  131. }
  132. },
  133. 'reassign.maintenance_mode': {
  134. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  135. 'mock': '',
  136. 'type': 'PUT',
  137. 'format': function () {
  138. return {
  139. data: JSON.stringify(
  140. {
  141. "HostRoles": {
  142. "state": "MAINTENANCE"
  143. }
  144. }
  145. )
  146. }
  147. }
  148. },
  149. 'reassign.remove_component': {
  150. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  151. 'mock': '',
  152. 'type': 'DELETE'
  153. },
  154. 'reassign.load_configs': {
  155. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  156. 'mock': ''
  157. },
  158. 'reassign.save_configs': {
  159. 'real': '/clusters/{clusterName}',
  160. 'mock': '',
  161. 'type': 'PUT',
  162. 'format': function (data) {
  163. return {
  164. async: false,
  165. data: JSON.stringify({
  166. Clusters: {
  167. desired_config: {
  168. "type": data.siteName,
  169. "tag": 'version' + (new Date).getTime(),
  170. "properties": data.properties
  171. }
  172. }
  173. })
  174. }
  175. }
  176. },
  177. 'config.advanced': {
  178. 'real': '{stack2VersionUrl}/stackServices/{serviceName}/configurations?fields=*',
  179. 'mock': '/data/wizard/stack/hdp/version{stackVersion}/{serviceName}.json',
  180. 'format': function (data) {
  181. return {
  182. async: false
  183. };
  184. }
  185. },
  186. 'config.advanced.global': {
  187. 'real': '{stack2VersionUrl}/stackServices?fields=configurations/StackConfigurations/type',
  188. 'mock': '/data/wizard/stack/hdp/version1.3.0/global.json',
  189. 'format': function (data) {
  190. return {
  191. async: false
  192. };
  193. }
  194. },
  195. 'config.tags': {
  196. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  197. 'mock': '/data/clusters/cluster.json'
  198. },
  199. 'config.tags_and_groups': {
  200. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs,config_groups/*',
  201. 'mock': '/data/clusters/tags_and_groups.json'
  202. },
  203. 'config.tags.sync': {
  204. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  205. 'mock': '/data/clusters/cluster.json',
  206. 'format': function (data) {
  207. return {
  208. async: false
  209. };
  210. }
  211. },
  212. 'config_groups.all_fields': {
  213. 'real': '/clusters/{clusterName}/config_groups?fields=*'
  214. },
  215. 'config_groups.get_config_group_by_id': {
  216. 'real': '/clusters/{clusterName}/config_groups/{id}'
  217. },
  218. 'config_groups.update_config_group': {
  219. 'real': '/clusters/{clusterName}/config_groups/{id}',
  220. 'mock': '',
  221. 'type': 'PUT',
  222. 'format': function (data) {
  223. return {
  224. async: false,
  225. data: JSON.stringify(
  226. [
  227. data.configGroup
  228. ]
  229. )
  230. }
  231. }
  232. },
  233. 'config_groups.delete_config_group': {
  234. 'real': '/clusters/{clusterName}/config_groups/{id}',
  235. 'mock': '',
  236. 'type': 'DELETE'
  237. },
  238. 'config.on_site': {
  239. 'real': '/clusters/{clusterName}/configurations?{params}',
  240. 'mock': '/data/configurations/cluster_level_configs.json?{params}',
  241. 'format': function (data) {
  242. return {
  243. async: false
  244. };
  245. }
  246. },
  247. 'config.host_overrides': {
  248. 'real': '/clusters/{clusterName}/configurations?{params}',
  249. 'mock': '/data/configurations/host_level_overrides_configs.json?{params}',
  250. 'format': function (data) {
  251. return {
  252. async: false
  253. };
  254. }
  255. },
  256. 'config.stale.stop_component': {
  257. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  258. 'mock': '',
  259. 'type': 'PUT',
  260. 'format': function (data) {
  261. return {
  262. data: JSON.stringify({
  263. RequestInfo: {
  264. "context": "Stop " + data.displayName
  265. },
  266. Body: {
  267. "HostRoles": {
  268. "state": "INSTALLED"
  269. }
  270. }
  271. })
  272. }
  273. }
  274. },
  275. 'config.stale.start_component': {
  276. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  277. 'mock': '',
  278. 'type': 'PUT',
  279. 'format': function (data) {
  280. return {
  281. data: JSON.stringify({
  282. RequestInfo: {
  283. "context": "Start " + data.displayName
  284. },
  285. Body: {
  286. "HostRoles": {
  287. "state": "STARTED"
  288. }
  289. }
  290. })
  291. }
  292. }
  293. },
  294. 'service.metrics.flume.channel_fill_percent': {
  295. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/CHANNEL/*/ChannelFillPercentage[{fromSeconds},{toSeconds},{stepSeconds}]',
  296. 'mock': '/data/services/metrics/flume/channelFillPct.json',
  297. 'testInProduction': true
  298. },
  299. 'service.metrics.flume.channel_size': {
  300. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/CHANNEL/*/ChannelSize[{fromSeconds},{toSeconds},{stepSeconds}]',
  301. 'mock': '/data/services/metrics/flume/channelSize.json',
  302. 'testInProduction': true
  303. },
  304. 'service.metrics.flume.sink_drain_success': {
  305. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/SINK/*/EventDrainSuccessCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  306. 'mock': '/data/services/metrics/flume/sinkDrainSuccessCount.json',
  307. 'testInProduction': true
  308. },
  309. 'service.metrics.flume.sink_connection_failed': {
  310. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/SINK/*/ConnectionFailedCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  311. 'mock': '/data/services/metrics/flume/sinkConnectionFailedCount.json',
  312. 'testInProduction': true
  313. },
  314. 'service.metrics.flume.gc': {
  315. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  316. 'mock': '/data/services/metrics/flume/jvmGcTime.json',
  317. 'testInProduction': true
  318. },
  319. 'service.metrics.flume.jvm_heap_used': {
  320. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/jvm/memHeapUsedM[{fromSeconds},{toSeconds},{stepSeconds}]',
  321. 'mock': '/data/services/metrics/flume/jvmMemHeapUsedM.json',
  322. 'testInProduction': true
  323. },
  324. 'service.metrics.flume.jvm_threads_runnable': {
  325. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/jvm/threadsRunnable[{fromSeconds},{toSeconds},{stepSeconds}]',
  326. 'mock': '/data/services/metrics/flume/jvmThreadsRunnable.json',
  327. 'testInProduction': true
  328. },
  329. 'service.metrics.flume.cpu_user': {
  330. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/cpu/cpu_user[{fromSeconds},{toSeconds},{stepSeconds}]',
  331. 'mock': '',
  332. 'testInProduction': true
  333. },
  334. 'service.metrics.flume.source_accepted': {
  335. 'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/SOURCE/*/EventAcceptedCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  336. 'mock': '/data/services/metrics/flume/sourceEventAccepted.json',
  337. 'testInProduction': true
  338. },
  339. 'service.metrics.hbase.cluster_requests': {
  340. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/cluster_requests[{fromSeconds},{toSeconds},{stepSeconds}]',
  341. 'mock': '/data/services/metrics/hbase/cluster_requests.json',
  342. 'testInProduction': true
  343. },
  344. 'service.metrics.hbase.hlog_split_size': {
  345. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitSize_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  346. 'mock': '/data/services/metrics/hbase/hlog_split_size.json',
  347. 'testInProduction': true
  348. },
  349. 'service.metrics.hbase.hlog_split_time': {
  350. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_MASTER?fields=metrics/hbase/master/splitTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  351. 'mock': '/data/services/metrics/hbase/hlog_split_time.json',
  352. 'testInProduction': true
  353. },
  354. 'service.metrics.hbase.regionserver_queuesize': {
  355. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/flushQueueSize[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/compactionQueueSize[{fromSeconds},{toSeconds},{stepSeconds}]',
  356. 'mock': '/data/services/metrics/hbase/regionserver_queuesize.json',
  357. 'testInProduction': true
  358. },
  359. 'service.metrics.hbase.regionserver_regions': {
  360. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/regions[{fromSeconds},{toSeconds},{stepSeconds}]',
  361. 'mock': '/data/services/metrics/hbase/regionserver_regions.json',
  362. 'testInProduction': true
  363. },
  364. 'service.metrics.hbase.regionserver_rw_requests': {
  365. 'real': '/clusters/{clusterName}/services/HBASE/components/HBASE_REGIONSERVER?fields=metrics/hbase/regionserver/readRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}],metrics/hbase/regionserver/writeRequestsCount[{fromSeconds},{toSeconds},{stepSeconds}]',
  366. 'mock': '/data/services/metrics/hbase/regionserver_rw_requests.json',
  367. 'testInProduction': true
  368. },
  369. 'service.metrics.mapreduce.gc': {
  370. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  371. 'mock': '/data/services/metrics/mapreduce/gc.json',
  372. 'testInProduction': true
  373. },
  374. 'service.metrics.mapreduce.jobs_status': {
  375. '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}]',
  376. 'mock': '/data/services/metrics/mapreduce/jobs_status.json',
  377. 'testInProduction': true
  378. },
  379. 'service.metrics.mapreduce.jobs_heap': {
  380. '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}]',
  381. 'mock': '/data/services/metrics/mapreduce/jvm_heap.json',
  382. 'testInProduction': true
  383. },
  384. 'service.metrics.mapreduce.jobs_threads': {
  385. '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}]',
  386. 'mock': '/data/services/metrics/mapreduce/jvm_threads.json',
  387. 'testInProduction': true
  388. },
  389. 'service.metrics.mapreduce.map_slots': {
  390. '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}]',
  391. 'mock': '/data/services/metrics/mapreduce/map_slots.json',
  392. 'testInProduction': true
  393. },
  394. 'service.metrics.mapreduce.reduce_slots': {
  395. '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}]',
  396. 'mock': '/data/services/metrics/mapreduce/reduce_slots.json',
  397. 'testInProduction': true
  398. },
  399. 'service.metrics.mapreduce.rpc': {
  400. 'real': '/clusters/{clusterName}/hosts/{jobTrackerNode}/host_components/JOBTRACKER?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  401. 'mock': '/data/services/metrics/mapreduce/rpc.json',
  402. 'testInProduction': true
  403. },
  404. 'service.metrics.mapreduce.tasks_running_waiting': {
  405. '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}]',
  406. 'mock': '/data/services/metrics/mapreduce/tasks_running_waiting.json',
  407. 'testInProduction': true
  408. },
  409. 'service.metrics.hdfs.block_status': {
  410. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/FSNamesystem/PendingReplicationBlocks[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/FSNamesystem/UnderReplicatedBlocks[{fromSeconds},{toSeconds},{stepSeconds}]',
  411. 'mock': '/data/services/metrics/hdfs/block_status.json',
  412. 'testInProduction': true
  413. },
  414. 'service.metrics.hdfs.file_operations': {
  415. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/namenode/FileInfoOps[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/namenode/CreateFileOps[{fromSeconds},{toSeconds},{stepSeconds}]',
  416. 'mock': '/data/services/metrics/hdfs/file_operations.json',
  417. 'testInProduction': true
  418. },
  419. 'service.metrics.hdfs.gc': {
  420. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  421. 'mock': '/data/services/metrics/hdfs/gc.json',
  422. 'testInProduction': true
  423. },
  424. 'service.metrics.hdfs.io': {
  425. 'real': '/clusters/{clusterName}/services/HDFS/components/DATANODE?fields=metrics/dfs/datanode/bytes_written[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/datanode/bytes_read[{fromSeconds},{toSeconds},{stepSeconds}]',
  426. 'mock': '/data/services/metrics/hdfs/io.json',
  427. 'testInProduction': true
  428. },
  429. 'service.metrics.hdfs.jvm_heap': {
  430. '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}]',
  431. 'mock': '/data/services/metrics/hdfs/jvm_heap.json',
  432. 'testInProduction': true
  433. },
  434. 'service.metrics.hdfs.jvm_threads': {
  435. '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}]',
  436. 'mock': '/data/services/metrics/hdfs/jvm_threads.json',
  437. 'testInProduction': true
  438. },
  439. 'service.metrics.hdfs.rpc': {
  440. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  441. 'mock': '/data/services/metrics/hdfs/rpc.json',
  442. 'testInProduction': true
  443. },
  444. 'service.metrics.hdfs.space_utilization': {
  445. 'real': '/clusters/{clusterName}/hosts/{nameNodeName}/host_components/NAMENODE?fields=metrics/dfs/FSNamesystem/CapacityRemainingGB[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/FSNamesystem/CapacityUsedGB[{fromSeconds},{toSeconds},{stepSeconds}],metrics/dfs/FSNamesystem/CapacityTotalGB[{fromSeconds},{toSeconds},{stepSeconds}]',
  446. 'mock': '/data/services/metrics/hdfs/space_utilization.json',
  447. 'testInProduction': true
  448. },
  449. 'service.start_stop': {
  450. 'real': '/clusters/{clusterName}/services?params/run_smoke_test=true',
  451. 'mock': '/data/mirroring/poll/poll_6.json',
  452. 'format': function (data, opt) {
  453. return {
  454. type: 'PUT',
  455. async: false,
  456. data: data.data
  457. };
  458. }
  459. },
  460. 'service.metrics.yarn.gc': {
  461. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]',
  462. 'mock': '/data/services/metrics/yarn/gc.json',
  463. 'testInProduction': true
  464. },
  465. 'service.metrics.yarn.jobs_threads': {
  466. '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}]',
  467. 'mock': '/data/services/metrics/yarn/jvm_threads.json',
  468. 'testInProduction': true
  469. },
  470. 'service.metrics.yarn.rpc': {
  471. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/rpc/RpcQueueTime_avg_time[{fromSeconds},{toSeconds},{stepSeconds}]',
  472. 'mock': '/data/services/metrics/yarn/rpc.json',
  473. 'testInProduction': true
  474. },
  475. 'service.metrics.yarn.jobs_heap': {
  476. '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}]',
  477. 'mock': '/data/services/metrics/yarn/jvm_heap.json',
  478. 'testInProduction': true
  479. },
  480. 'service.metrics.yarn.queue.allocated': {
  481. '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}]',
  482. 'mock': '',
  483. 'testInProduction': true
  484. },
  485. 'service.metrics.yarn.queue.allocated.container': {
  486. '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}]',
  487. 'mock': '',
  488. 'testInProduction': true
  489. },
  490. 'service.metrics.yarn.node.manager.statuses': {
  491. '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}]',
  492. 'mock': '',
  493. 'testInProduction': true
  494. },
  495. 'service.metrics.yarn.queue.memory.resource': {
  496. 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=',
  497. 'mock': '',
  498. 'format': function (data, opt) {
  499. var field1 = 'metrics/yarn/Queue/{queueName}/AllocatedMB[{fromSeconds},{toSeconds},{stepSeconds}]';
  500. var field2 = 'metrics/yarn/Queue/{queueName}/AvailableMB[{fromSeconds},{toSeconds},{stepSeconds}]';
  501. if (opt.url != null && data.queueNames != null) {
  502. data.queueNames.forEach(function (q) {
  503. data.queueName = q;
  504. opt.url += (formatUrl(field1, data) + ",");
  505. opt.url += (formatUrl(field2, data) + ",");
  506. });
  507. }
  508. },
  509. 'testInProduction': true
  510. },
  511. 'service.metrics.yarn.queue.apps.states.current': {
  512. '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}]',
  513. 'mock': '',
  514. 'testInProduction': true
  515. },
  516. 'service.metrics.yarn.queue.apps.states.finished': {
  517. '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}]',
  518. 'mock': '',
  519. 'testInProduction': true
  520. },
  521. 'dashboard.cluster_metrics.cpu': {
  522. 'real': '/clusters/{clusterName}/?fields=metrics/cpu[{fromSeconds},{toSeconds},{stepSeconds}]',
  523. 'mock': '/data/cluster_metrics/cpu_1hr.json',
  524. 'testInProduction': true
  525. },
  526. 'dashboard.cluster_metrics.load': {
  527. 'real': '/clusters/{clusterName}/?fields=metrics/load[{fromSeconds},{toSeconds},{stepSeconds}]',
  528. 'mock': '/data/cluster_metrics/load_1hr.json',
  529. 'testInProduction': true
  530. },
  531. 'dashboard.cluster_metrics.memory': {
  532. 'real': '/clusters/{clusterName}/?fields=metrics/memory[{fromSeconds},{toSeconds},{stepSeconds}]',
  533. 'mock': '/data/cluster_metrics/memory_1hr.json',
  534. 'testInProduction': true
  535. },
  536. 'dashboard.cluster_metrics.network': {
  537. 'real': '/clusters/{clusterName}/?fields=metrics/network[{fromSeconds},{toSeconds},{stepSeconds}]',
  538. 'mock': '/data/cluster_metrics/network_1hr.json',
  539. 'testInProduction': true
  540. },
  541. 'host.metrics.cpu': {
  542. '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}]',
  543. 'mock': '/data/hosts/metrics/cpu.json',
  544. 'testInProduction': true
  545. },
  546. 'host.metrics.disk': {
  547. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/disk/disk_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/disk/disk_free[{fromSeconds},{toSeconds},{stepSeconds}]',
  548. 'mock': '/data/hosts/metrics/disk.json',
  549. 'testInProduction': true
  550. },
  551. 'host.metrics.load': {
  552. '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}]',
  553. 'mock': '/data/hosts/metrics/load.json',
  554. 'testInProduction': true
  555. },
  556. 'host.metrics.memory': {
  557. '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}]',
  558. 'mock': '/data/hosts/metrics/memory.json',
  559. 'testInProduction': true
  560. },
  561. 'host.metrics.network': {
  562. '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}]',
  563. 'mock': '/data/hosts/metrics/network.json',
  564. 'testInProduction': true
  565. },
  566. 'host.metrics.processes': {
  567. 'real': '/clusters/{clusterName}/hosts/{hostName}?fields=metrics/process/proc_total[{fromSeconds},{toSeconds},{stepSeconds}],metrics/process/proc_run[{fromSeconds},{toSeconds},{stepSeconds}]',
  568. 'mock': '/data/hosts/metrics/processes.json',
  569. 'testInProduction': true
  570. },
  571. 'host.service_config_hosts_overrides': {
  572. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  573. 'mock': '',
  574. 'format': function (data, opt) {
  575. return {
  576. async: false,
  577. timeout: 10000
  578. };
  579. }
  580. },
  581. 'admin.security_status': {
  582. 'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
  583. 'mock': '',
  584. 'format': function (data, opt) {
  585. return {
  586. timeout: 10000
  587. };
  588. }
  589. },
  590. 'settings.get.user_pref': {
  591. 'real': '/persist/{key}',
  592. 'mock': '',
  593. 'type': 'GET',
  594. 'format': function (data, opt) {
  595. return {
  596. };
  597. }
  598. },
  599. 'settings.post.user_pref': {
  600. 'real': '/persist',
  601. 'mock': '',
  602. 'type': 'POST',
  603. 'format': function (data) {
  604. return {
  605. data: JSON.stringify(data.keyValuePair)
  606. }
  607. }
  608. },
  609. 'cluster.load_cluster_name': {
  610. 'real': '/clusters',
  611. 'mock': '/data/clusters/info.json',
  612. 'format': function (data, opt) {
  613. return {
  614. async: false
  615. };
  616. }
  617. },
  618. 'cluster.state': {
  619. 'type': 'POST',
  620. 'real': '/persist/',
  621. 'mock': '',
  622. 'format': function (data, opt) {
  623. return {
  624. async: false,
  625. data: JSON.stringify(data.keyValuePair)
  626. };
  627. }
  628. },
  629. 'cluster.update_upgrade_version': {
  630. 'real': '/stacks2/HDP/versions?fields=stackServices/StackServices,Versions',
  631. 'mock': '/data/wizard/stack/stacks.json',
  632. 'format': function (data, opt) {
  633. return {
  634. async: false
  635. };
  636. }
  637. },
  638. 'cluster.load_repositories': {
  639. 'real': '/stacks2/{stackName}/versions/{stackVersion}/operatingSystems?fields=repositories/*',
  640. 'mock': '',
  641. 'type': 'GET',
  642. 'format': function (data, opt) {
  643. return {
  644. data: data.data
  645. };
  646. }
  647. },
  648. 'admin.high_availability.stop_all_services': {
  649. 'real': '/clusters/{clusterName}/services',
  650. 'mock': '',
  651. 'format': function (data, opt) {
  652. return {
  653. type: 'PUT',
  654. data: JSON.stringify({
  655. "RequestInfo": {
  656. "context": "Stop all services"
  657. },
  658. "Body": {
  659. "ServiceInfo": {
  660. "state": "INSTALLED"
  661. }
  662. }
  663. })
  664. }
  665. }
  666. },
  667. 'admin.high_availability.start_all_services': {
  668. 'real': '/clusters/{clusterName}/services',
  669. 'mock': '',
  670. 'format': function (data, opt) {
  671. return {
  672. type: 'PUT',
  673. data: JSON.stringify({
  674. "RequestInfo": {
  675. "context": "Start all services"
  676. },
  677. "Body": {
  678. "ServiceInfo": {
  679. "state": "STARTED"
  680. }
  681. }
  682. })
  683. }
  684. }
  685. },
  686. 'admin.high_availability.polling': {
  687. 'real': '/clusters/{clusterName}/requests/{requestId}?fields=tasks/*',
  688. 'mock': '',
  689. 'type': 'GET'
  690. },
  691. 'admin.high_availability.getNnCheckPointStatus': {
  692. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/NAMENODE',
  693. 'mock': '',
  694. 'type': 'GET'
  695. },
  696. 'admin.high_availability.getJnCheckPointStatus': {
  697. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/JOURNALNODE?fields=metrics',
  698. 'mock': ''
  699. },
  700. 'admin.high_availability.getHostComponent': {
  701. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  702. 'mock': ''
  703. },
  704. 'admin.high_availability.create_component': {
  705. 'real': '/clusters/{clusterName}/hosts?Hosts/host_name={hostName}',
  706. 'mock': '',
  707. 'type': 'POST',
  708. 'format': function (data) {
  709. return {
  710. data: JSON.stringify({
  711. "host_components": [
  712. {
  713. "HostRoles": {
  714. "component_name": data.componentName
  715. }
  716. }
  717. ]
  718. })
  719. }
  720. }
  721. },
  722. 'admin.high_availability.create_journalnode': {
  723. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  724. 'mock': '',
  725. 'type': 'POST',
  726. 'format': function (data) {
  727. return {
  728. data: JSON.stringify({
  729. "components": [
  730. {
  731. "ServiceComponentInfo": {
  732. "component_name": "JOURNALNODE"
  733. }
  734. }
  735. ]
  736. })
  737. }
  738. }
  739. },
  740. 'admin.high_availability.create_zkfc': {
  741. 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name=HDFS',
  742. 'mock': '',
  743. 'type': 'POST',
  744. 'format': function (data) {
  745. return {
  746. data: JSON.stringify({
  747. "components": [
  748. {
  749. "ServiceComponentInfo": {
  750. "component_name": "ZKFC"
  751. }
  752. }
  753. ]
  754. })
  755. }
  756. }
  757. },
  758. 'admin.high_availability.install_component': {
  759. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  760. 'mock': '',
  761. 'type': 'PUT',
  762. 'format': function (data) {
  763. return {
  764. data: JSON.stringify({
  765. RequestInfo: {
  766. "context": "Install " + data.displayName
  767. },
  768. Body: {
  769. "HostRoles": {
  770. "state": "INSTALLED"
  771. }
  772. }
  773. })
  774. }
  775. }
  776. },
  777. 'admin.high_availability.start_component': {
  778. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  779. 'mock': '',
  780. 'type': 'PUT',
  781. 'format': function (data) {
  782. return {
  783. data: JSON.stringify({
  784. RequestInfo: {
  785. "context": "Start " + data.displayName
  786. },
  787. Body: {
  788. "HostRoles": {
  789. "state": "STARTED"
  790. }
  791. }
  792. })
  793. }
  794. }
  795. },
  796. 'admin.high_availability.maintenance_mode': {
  797. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  798. 'mock': '',
  799. 'type': 'PUT',
  800. 'format': function () {
  801. return {
  802. data: JSON.stringify({
  803. "HostRoles": {
  804. "state": "MAINTENANCE"
  805. }
  806. })
  807. }
  808. }
  809. },
  810. 'admin.high_availability.stop_component': {
  811. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  812. 'mock': '',
  813. 'type': 'PUT',
  814. 'format': function (data) {
  815. return {
  816. data: JSON.stringify({
  817. RequestInfo: {
  818. "context": "Stop " + data.displayName
  819. },
  820. Body: {
  821. "HostRoles": {
  822. "state": "INSTALLED"
  823. }
  824. }
  825. })
  826. }
  827. }
  828. },
  829. 'admin.high_availability.load_configs': {
  830. 'real': '/clusters/{clusterName}/configurations?(type=core-site&tag={coreSiteTag})|(type=hdfs-site&tag={hdfsSiteTag})',
  831. 'mock': '',
  832. 'type': 'GET'
  833. },
  834. 'admin.high_availability.save_configs': {
  835. 'real': '/clusters/{clusterName}',
  836. 'mock': '',
  837. 'type': 'PUT',
  838. 'format': function (data) {
  839. return {
  840. async: false,
  841. data: JSON.stringify({
  842. Clusters: {
  843. desired_config: {
  844. "type": data.siteName,
  845. "tag": 'version' + (new Date).getTime(),
  846. "properties": data.properties
  847. }
  848. }
  849. })
  850. }
  851. }
  852. },
  853. 'admin.high_availability.load_hbase_configs': {
  854. 'real': '/clusters/{clusterName}/configurations?type=hbase-site&tag={hbaseSiteTag}',
  855. 'mock': '',
  856. 'type': 'GET'
  857. },
  858. 'admin.high_availability.delete_component': {
  859. 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
  860. 'mock': '',
  861. 'type': 'DELETE'
  862. },
  863. 'admin.security.cluster_configs': {
  864. 'real': '/clusters/{clusterName}',
  865. 'mock': '',
  866. 'format': function (data, opt) {
  867. return {
  868. timeout: 10000
  869. };
  870. }
  871. },
  872. 'admin.delete_host': {
  873. 'real': '/clusters/{clusterName}/hosts/{hostName}',
  874. 'mock': '',
  875. 'type': 'DELETE'
  876. },
  877. 'admin.security.all_configurations': {
  878. 'real': '/clusters/{clusterName}/configurations?{urlParams}',
  879. 'mock': '',
  880. 'format': function (data, opt) {
  881. return {
  882. timeout: 10000
  883. };
  884. }
  885. },
  886. 'admin.security.apply_configurations': {
  887. 'real': '/clusters/{clusterName}',
  888. 'mock': '',
  889. 'format': function (data, opt) {
  890. return {
  891. type: 'PUT',
  892. timeout: 10000,
  893. data: data.configData
  894. };
  895. }
  896. },
  897. 'admin.security.apply_configuration': {
  898. 'real': '/clusters/{clusterName}',
  899. 'mock': '',
  900. 'format': function (data, opt) {
  901. return {
  902. type: 'PUT',
  903. async: false,
  904. timeout: 5000,
  905. data: JSON.stringify(data.clusterData)
  906. };
  907. }
  908. },
  909. 'admin.security.add.cluster_configs': {
  910. 'real': '/clusters/{clusterName}' + '?fields=Clusters/desired_configs',
  911. 'mock': '',
  912. 'format': function (data, opt) {
  913. return {
  914. timeout: 10000
  915. };
  916. }
  917. },
  918. 'admin.stack_upgrade.run_upgrade': {
  919. 'real': '/clusters/{clusterName}',
  920. 'mock': '',
  921. 'format': function (data, opt) {
  922. return {
  923. type: 'PUT',
  924. async: false,
  925. data: data.data
  926. };
  927. }
  928. },
  929. 'admin.stack_upgrade.stop_services': {
  930. 'real': '/clusters/{clusterName}/services?ServiceInfo/state=STARTED',
  931. 'mock': '',
  932. 'format': function (data, opt) {
  933. return {
  934. type: 'PUT',
  935. async: false,
  936. data: data.data
  937. };
  938. }
  939. },
  940. 'admin.stack_upgrade.do_poll': {
  941. 'real': '/clusters/{cluster}/requests/{requestId}?fields=tasks/*',
  942. 'mock': '/data/wizard/{mock}'
  943. },
  944. 'wizard.advanced_repositories.valid_url': {
  945. 'real': '/stacks2/{stackName}/versions/{stackVersion}/operatingSystems/{osType}/repositories/{nameVersionCombo}',
  946. 'mock': '',
  947. 'type': 'PUT',
  948. 'format': function (data) {
  949. return {
  950. async: true,
  951. data: JSON.stringify(data.data)
  952. }
  953. }
  954. },
  955. 'wizard.install_services.add_host_controller.is_retry': {
  956. 'real': '/clusters/{cluster}/host_components',
  957. 'mock': '',
  958. 'format': function (data, opt) {
  959. return {
  960. type: 'PUT',
  961. async: false,
  962. data: data.data
  963. };
  964. }
  965. },
  966. 'wizard.install_services.add_host_controller.not_is_retry': {
  967. 'real': '/clusters/{cluster}/host_components',
  968. 'mock': '',
  969. 'format': function (data, opt) {
  970. return {
  971. type: 'PUT',
  972. async: false,
  973. data: data.data
  974. };
  975. }
  976. },
  977. 'wizard.install_services.installer_controller.is_retry': {
  978. 'real': '/clusters/{cluster}/host_components?HostRoles/state=INSTALLED',
  979. 'mock': '/data/wizard/deploy/2_hosts/poll_1.json',
  980. 'type': 'PUT',
  981. 'format': function (data, opt) {
  982. return {
  983. async: false,
  984. data: data.data
  985. };
  986. }
  987. },
  988. 'wizard.install_services.installer_controller.not_is_retry': {
  989. 'real': '/clusters/{cluster}/services?ServiceInfo/state=INIT',
  990. 'mock': '/data/wizard/deploy/2_hosts/poll_1.json',
  991. 'type': 'PUT',
  992. 'format': function (data, opt) {
  993. return {
  994. async: false,
  995. data: data.data
  996. };
  997. }
  998. },
  999. 'wizard.install_services.add_service_controller.get_failed_host_components': {
  1000. 'real': '/clusters/{clusterName}/host_components?fields=HostRoles/state,component/ServiceComponentInfo/service_name',
  1001. 'mock': '',
  1002. 'format': function (data, opt) {
  1003. return {
  1004. async: false
  1005. };
  1006. }
  1007. },
  1008. 'wizard.service_components': {
  1009. 'real': '{stackUrl}/stackServices?fields=StackServices',
  1010. 'mock': '/data/wizard/stack/hdp/version/{stackVersion}.json',
  1011. 'format': function (data, opt) {
  1012. return {
  1013. timeout: 10000,
  1014. async: false
  1015. };
  1016. }
  1017. },
  1018. 'wizard.step9.installer.launch_start_services': {
  1019. 'real': '/clusters/{cluster}/services?ServiceInfo/state=INSTALLED&params/run_smoke_test=true&params/reconfigure_client=false',
  1020. 'mock': '/data/wizard/deploy/5_hosts/poll_6.json',
  1021. 'format': function (data, opt) {
  1022. var data = {
  1023. type: 'PUT',
  1024. async: false,
  1025. data: data.data
  1026. };
  1027. if (App.testMode) {
  1028. data.type = 'GET';
  1029. }
  1030. return data;
  1031. }
  1032. },
  1033. 'wizard.step9.add_host.launch_start_services': {
  1034. 'real': '/clusters/{cluster}/host_components',
  1035. 'mock': '/data/wizard/deploy/5_hosts/poll_6.json',
  1036. 'format': function (data, opt) {
  1037. return {
  1038. type: 'PUT',
  1039. async: false,
  1040. data: data.data
  1041. };
  1042. }
  1043. },
  1044. 'wizard.step8.delete_cluster': {
  1045. 'real': '/clusters/{name}',
  1046. 'mock': '',
  1047. 'format': function (data, opt) {
  1048. return {
  1049. type: 'DELETE',
  1050. async: false
  1051. };
  1052. }
  1053. },
  1054. 'wizard.step8.existing_cluster_names': {
  1055. 'real': '/clusters',
  1056. 'mock': '',
  1057. 'format': function (data, opt) {
  1058. return {
  1059. async: false
  1060. };
  1061. }
  1062. },
  1063. 'wizard.step3.host_info': {
  1064. 'real': '/hosts?fields=Hosts/total_mem,Hosts/cpu_count,Hosts/disk_info,Hosts/last_agent_env,Hosts/host_name,Hosts/os_type',
  1065. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  1066. 'format': function (data, opt) {
  1067. return {
  1068. contentType: 'application/json'
  1069. };
  1070. }
  1071. },
  1072. 'wizard.step3.rerun_checks': {
  1073. 'real': '/hosts?fields=Hosts/last_agent_env',
  1074. 'mock': '/data/wizard/bootstrap/two_hosts_information.json',
  1075. 'format': function (data, opt) {
  1076. return {
  1077. contentType: 'application/json'
  1078. };
  1079. }
  1080. },
  1081. 'wizard.step3.bootstrap': {
  1082. 'real': '/bootstrap/{bootRequestId}',
  1083. 'mock': '/data/wizard/bootstrap/poll_{numPolls}.json'
  1084. },
  1085. 'wizard.step3.is_hosts_registered': {
  1086. 'real': '/hosts',
  1087. 'mock': '/data/wizard/bootstrap/single_host_registration.json'
  1088. },
  1089. 'wizard.stacks': {
  1090. 'real': '/stacks2',
  1091. 'mock': '/data/wizard/stack/stacks2.json',
  1092. 'format': function (data) {
  1093. return {
  1094. async: false
  1095. };
  1096. }
  1097. },
  1098. 'wizard.stacks_versions': {
  1099. 'real': '/stacks2/{stackName}/versions?fields=Versions,operatingSystems/repositories/Repositories',
  1100. 'mock': '/data/wizard/stack/{stackName}_versions.json',
  1101. 'format': function (data) {
  1102. return {
  1103. async: false
  1104. };
  1105. }
  1106. },
  1107. 'wizard.launch_bootstrap': {
  1108. 'real': '/bootstrap',
  1109. 'mock': '/data/wizard/bootstrap/bootstrap.json',
  1110. 'type': 'POST',
  1111. 'format': function (data) {
  1112. return {
  1113. async: false,
  1114. contentType: 'application/json',
  1115. data: data.bootStrapData
  1116. }
  1117. }
  1118. },
  1119. 'router.login': {
  1120. 'real': '/users/{loginName}',
  1121. 'mock': '/data/users/user_{usr}.json',
  1122. 'format': function (data, opt) {
  1123. var statusCode = jQuery.extend({}, require('data/statusCodes'));
  1124. statusCode['403'] = function () {
  1125. console.log("Error code 403: Forbidden.");
  1126. }
  1127. return {
  1128. statusCode: statusCode
  1129. };
  1130. }
  1131. },
  1132. 'router.login2': {
  1133. 'real': '/clusters',
  1134. 'mock': '/data/clusters/info.json'
  1135. },
  1136. 'router.logoff': {
  1137. 'real': '/logout'
  1138. },
  1139. 'router.set_ambari_stacks': {
  1140. 'real': '/stacks',
  1141. 'mock': '/data/wizard/stack/stacks.json',
  1142. 'format': function (data, opt) {
  1143. return {
  1144. async: false
  1145. };
  1146. }
  1147. },
  1148. 'router.authentication': {
  1149. 'real': '/clusters',
  1150. 'mock': '/data/clusters/info.json',
  1151. 'format': function (data, opt) {
  1152. return {
  1153. async: false
  1154. };
  1155. }
  1156. },
  1157. 'ambari.service': {
  1158. 'real': '/services/AMBARI/components/AMBARI_SERVER',
  1159. 'mock': ''
  1160. },
  1161. 'dashboard.get.user_pref': {
  1162. 'real': '/persist/{key}',
  1163. 'mock': '',
  1164. 'format': function (data, opt) {
  1165. return {
  1166. async: false
  1167. };
  1168. }
  1169. },
  1170. 'dashboard.post.user_pref': {
  1171. 'real': '/persist',
  1172. 'mock': '',
  1173. 'type': 'POST',
  1174. 'format': function (data) {
  1175. return {
  1176. async: false,
  1177. data: JSON.stringify(data.keyValuePair)
  1178. }
  1179. }
  1180. },
  1181. 'config_groups.create': {
  1182. 'real': '/clusters/{clusterName}/config_groups',
  1183. 'mock': '',
  1184. 'format': function (data) {
  1185. return {
  1186. async: false,
  1187. type: 'POST',
  1188. data: JSON.stringify([{
  1189. "ConfigGroup": {
  1190. "group_name": data.group_name,
  1191. "tag": data.service_id,
  1192. "description": data.description,
  1193. "desired_configs": data.desired_configs
  1194. }
  1195. }])
  1196. }
  1197. }
  1198. },
  1199. 'config_groups.update': {
  1200. 'real': '/clusters/{clusterName}/config_groups/{id}',
  1201. 'mock': '',
  1202. 'format': function (data) {
  1203. return {
  1204. async: true,
  1205. type: 'PUT',
  1206. data: JSON.stringify(data.data)
  1207. }
  1208. }
  1209. }
  1210. };
  1211. /**
  1212. * Replace data-placeholders to its values
  1213. *
  1214. * @param {String} url
  1215. * @param {Object} data
  1216. * @return {String}
  1217. */
  1218. var formatUrl = function (url, data) {
  1219. var keys = url.match(/\{\w+\}/g);
  1220. keys = (keys === null) ? [] : keys;
  1221. if (keys) {
  1222. keys.forEach(function (key) {
  1223. var raw_key = key.substr(1, key.length - 2);
  1224. var replace;
  1225. if (!data[raw_key]) {
  1226. replace = '';
  1227. }
  1228. else {
  1229. replace = data[raw_key];
  1230. }
  1231. url = url.replace(new RegExp(key, 'g'), replace);
  1232. });
  1233. }
  1234. return url;
  1235. };
  1236. /**
  1237. * this = object from config
  1238. * @return {Object}
  1239. */
  1240. var formatRequest = function (data) {
  1241. var opt = {
  1242. type: this.type || 'GET',
  1243. timeout: App.timeout,
  1244. dataType: 'json',
  1245. statusCode: require('data/statusCodes')
  1246. };
  1247. if (App.testMode) {
  1248. opt.url = formatUrl(this.mock ? this.mock : '', data);
  1249. opt.type = 'GET';
  1250. }
  1251. else {
  1252. opt.url = App.apiPrefix + formatUrl(this.real, data);
  1253. }
  1254. if (this.format) {
  1255. jQuery.extend(opt, this.format(data, opt));
  1256. }
  1257. return opt;
  1258. };
  1259. /**
  1260. * Wrapper for all ajax requests
  1261. *
  1262. * @type {Object}
  1263. */
  1264. App.ajax = {
  1265. /**
  1266. * Send ajax request
  1267. *
  1268. * @param {Object} config
  1269. * @return Object jquery ajax object
  1270. *
  1271. * config fields:
  1272. * name - url-key in the urls-object *required*
  1273. * sender - object that send request (need for proper callback initialization) *required*
  1274. * data - object with data for url-format
  1275. * beforeSend - method-name for ajax beforeSend response callback
  1276. * success - method-name for ajax success response callback
  1277. * error - method-name for ajax error response callback
  1278. * callback - callback from <code>App.updater.run</code> library
  1279. */
  1280. send: function (config) {
  1281. console.warn('============== ajax ==============', config.name, config.data);
  1282. if (!config.sender) {
  1283. console.warn('Ajax sender should be defined!');
  1284. return null;
  1285. }
  1286. // default parameters
  1287. var params = {
  1288. clusterName: App.get('clusterName')
  1289. };
  1290. // extend default parameters with provided
  1291. if (config.data) {
  1292. jQuery.extend(params, config.data);
  1293. }
  1294. var opt = {};
  1295. opt = formatRequest.call(urls[config.name], params);
  1296. opt.context = this;
  1297. // object sender should be provided for processing beforeSend, success and error responses
  1298. opt.beforeSend = function (xhr) {
  1299. if (config.beforeSend) {
  1300. config.sender[config.beforeSend](opt, xhr, params);
  1301. }
  1302. };
  1303. opt.success = function (data, textStatus, xhr) {
  1304. console.log("TRACE: The url is: " + opt.url);
  1305. if (config.success) {
  1306. config.sender[config.success](data, opt, params);
  1307. }
  1308. };
  1309. opt.error = function (request, ajaxOptions, error) {
  1310. if (config.error) {
  1311. config.sender[config.error](request, ajaxOptions, error, opt);
  1312. } else {
  1313. this.defaultErrorHandler(request, opt.url, opt.type);
  1314. }
  1315. };
  1316. opt.complete = function () {
  1317. if (config.callback) {
  1318. config.callback();
  1319. }
  1320. };
  1321. if ($.mocho) {
  1322. opt.url = 'http://' + $.hostName + opt.url;
  1323. }
  1324. return $.ajax(opt);
  1325. },
  1326. // A single instance of App.ModalPopup view
  1327. modalPopup: null,
  1328. /**
  1329. * defaultErrorHandler function is referred from App.ajax.send function and App.HttpClient.defaultErrorHandler function
  1330. * @jqXHR {jqXHR Object}
  1331. * @url {string}
  1332. * @method {String} Http method
  1333. * @showStatus {number} HTTP response code which should be shown. Default is 500.
  1334. */
  1335. defaultErrorHandler: function (jqXHR, url, method, showStatus) {
  1336. method = method || 'GET';
  1337. var self = this;
  1338. var api = " received on " + method + " method for API: " + url;
  1339. var showMessage = true;
  1340. try {
  1341. var json = $.parseJSON(jqXHR.responseText);
  1342. var message = json.message;
  1343. } catch (err) {
  1344. }
  1345. if (showStatus === null) {
  1346. showStatus = 500;
  1347. }
  1348. if (message === undefined) {
  1349. showMessage = false;
  1350. }
  1351. var statusCode = jqXHR.status + " status code";
  1352. if (jqXHR.status === showStatus && !this.modalPopup) {
  1353. this.modalPopup = App.ModalPopup.show({
  1354. header: jqXHR.statusText,
  1355. secondary: false,
  1356. onPrimary: function () {
  1357. this.hide();
  1358. self.modalPopup = null;
  1359. },
  1360. bodyClass: Ember.View.extend({
  1361. classNames: ['api-error'],
  1362. templateName: require('templates/utils/ajax'),
  1363. api: api,
  1364. statusCode: statusCode,
  1365. message: message,
  1366. showMessage: showMessage
  1367. })
  1368. });
  1369. }
  1370. }
  1371. };