ajax.js 49 KB

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