step8_controller.js 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825
  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. var stringUtils = require('utils/string_utils');
  20. App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wizardDeployProgressControllerMixin, {
  21. name: 'wizardStep8Controller',
  22. /**
  23. * List of raw data about cluster that should be displayed
  24. * @type {Array}
  25. */
  26. rawContent: [
  27. {
  28. config_name: 'Admin',
  29. display_name: 'Admin Name',
  30. config_value: ''
  31. },
  32. {
  33. config_name: 'cluster',
  34. display_name: 'Cluster Name',
  35. config_value: ''
  36. },
  37. {
  38. config_name: 'hosts',
  39. display_name: 'Total Hosts',
  40. config_value: ''
  41. },
  42. {
  43. config_name: 'Repo',
  44. display_name: 'Local Repository',
  45. config_value: ''
  46. }
  47. ],
  48. /**
  49. * List of data about cluster (based on formatted <code>rawContent</code>)
  50. * @type {Object[]}
  51. */
  52. clusterInfo: [],
  53. /**
  54. * List of services with components assigned to hosts
  55. * @type {Object[]}
  56. */
  57. services: [],
  58. /**
  59. * @type {Object[]}
  60. */
  61. configs: [],
  62. /**
  63. * All configs
  64. * @type {Array}
  65. */
  66. configMapping: function () {
  67. return App.config.get('configMapping').all(true);
  68. }.property('App.config.configMapping'),
  69. /**
  70. *
  71. */
  72. slaveComponentConfig: null,
  73. /**
  74. * Should Submit button be disabled
  75. * @type {bool}
  76. */
  77. isSubmitDisabled: false,
  78. /**
  79. * Should Back button be disabled
  80. * @type {bool}
  81. */
  82. isBackBtnDisabled: false,
  83. /**
  84. * This flag when turned to true launches deploy progress bar
  85. */
  86. isDeployStarted: function() {
  87. this.get('isSubmitDisabled');
  88. }.property('isSubmitDisabled'),
  89. /**
  90. * Is error appears while <code>ajaxQueue</code> executes
  91. * @type {bool}
  92. */
  93. hasErrorOccurred: false,
  94. /**
  95. * Are services installed
  96. * Used to hide Deploy Progress Bar
  97. * @type {bool}
  98. */
  99. servicesInstalled: false,
  100. /**
  101. * List of service config tags
  102. * @type {Object[]}
  103. */
  104. serviceConfigTags: [],
  105. /**
  106. * Is cluster security enabled
  107. * @type {bool}
  108. */
  109. securityEnabled: function () {
  110. return App.router.get('mainAdminSecurityController.securityEnabled');
  111. }.property('App.router.mainAdminSecurityController.securityEnabled'),
  112. /**
  113. * Selected config group
  114. * @type {Object}
  115. */
  116. selectedConfigGroup: null,
  117. /**
  118. * List of config groups
  119. * @type {Object[]}
  120. */
  121. configGroups: [],
  122. /**
  123. * List of selected but not installed services
  124. * @type {Object[]}
  125. */
  126. selectedServices: function () {
  127. return this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false);
  128. }.property('content.services.@each.isSelected','content.services.@each.isInstalled').cacheable(),
  129. /**
  130. * List of installed services
  131. * @type {Object[]}
  132. */
  133. installedServices: function () {
  134. return this.get('content.services').filterProperty('isInstalled');
  135. }.property('content.services').cacheable(),
  136. /**
  137. * Current cluster name
  138. * @type {string}
  139. */
  140. clusterName: function () {
  141. return this.get('content.cluster.name');
  142. }.property('content.cluster.name'),
  143. /**
  144. * List of existing cluster names
  145. * @type {string[]}
  146. */
  147. clusterNames: [],
  148. /**
  149. * Clear current step data
  150. * @method clearStep
  151. */
  152. clearStep: function () {
  153. this.get('services').clear();
  154. this.get('configs').clear();
  155. this.get('clusterInfo').clear();
  156. this.get('serviceConfigTags').clear();
  157. this.set('servicesInstalled', false);
  158. this.set('ajaxQueueLength', 0);
  159. this.set('ajaxRequestsQueue', App.ajaxQueue.create());
  160. this.set('ajaxRequestsQueue.finishedCallback', this.ajaxQueueFinished);
  161. },
  162. /**
  163. * Load current step data
  164. * @method loadStep
  165. */
  166. loadStep: function () {
  167. console.log("TRACE: Loading step8: Review Page");
  168. this.clearStep();
  169. if (this.get('content.serviceConfigProperties')) {
  170. this.formatProperties();
  171. this.loadConfigs();
  172. if (this.get('content.controllerName') != 'installerController' && this.get('securityEnabled')) {
  173. this.prepareSecureConfigs();
  174. this.get('content.services').filterProperty('isSelected', true)
  175. .mapProperty('serviceName').forEach(function (serviceName) {
  176. var config = this.get('secureConfigs').findProperty('serviceName', serviceName);
  177. if (config) {
  178. this.setPrincipalValue(serviceName, config.name);
  179. }
  180. }, this);
  181. }
  182. }
  183. this.loadClusterInfo();
  184. this.loadServices();
  185. this.set('isSubmitDisabled', false);
  186. this.set('isBackBtnDisabled', false);
  187. },
  188. /**
  189. * replace whitespace character with coma between directories
  190. * @method formatProperties
  191. */
  192. formatProperties: function () {
  193. this.get('content.serviceConfigProperties').forEach(function (_configProperty) {
  194. _configProperty.value = App.config.trimProperty(_configProperty, false);
  195. });
  196. },
  197. /**
  198. * Remove unused Sink configs
  199. * @param {Ember.Enumerable} configs
  200. * @returns {Ember.Enumerable}
  201. * @method removeSinkConfigs
  202. */
  203. removeSinkConfigs: function (configs) {
  204. var sinkDb = configs.findProperty('name', 'sink_database');
  205. var sinkDbType = configs.findProperty('name', 'sink_database_type');
  206. if (sinkDbType) {
  207. var sink_properties = Em.A([]);
  208. switch (sinkDb.value) {
  209. case 'Existing MSSQL Server database with integrated authentication':
  210. configs.findProperty('name', 'sink.dbservername').value = configs.findProperty('name', 'sink_existing_mssql_server_host').value;
  211. sinkDbType.value = 'mssql';
  212. sink_properties = Em.A(['sink_existing_mssql_server_2_database', 'sink_existing_mssql_server_2_host']);
  213. break;
  214. case 'Existing MSSQL Server database with sql auth':
  215. configs.findProperty('name', 'sink.dbservername').value = configs.findProperty('name', 'sink_existing_mssql_server_2_host').value;
  216. sinkDbType.value = 'mssql';
  217. sink_properties = Em.A(['sink_existing_mssql_server_database', 'sink_existing_mssql_server_host']);
  218. break;
  219. }
  220. sink_properties.forEach(function (property) {
  221. configs = configs.without(configs.findProperty('name', property));
  222. });
  223. }
  224. return configs;
  225. },
  226. /**
  227. * Remove unused Hive configs
  228. * @param {Ember.Enumerable} configs
  229. * @returns {Ember.Enumerable}
  230. * @method removeHiveConfigs
  231. */
  232. removeHiveConfigs: function (configs) {
  233. var hiveDb = configs.findProperty('name', 'hive_database');
  234. var hiveDbType = configs.findProperty('name', 'hive_database_type');
  235. if (hiveDbType) {
  236. var hive_properties = Em.A([]);
  237. switch (hiveDb.value) {
  238. case 'New MySQL Database':
  239. if (configs.someProperty('name', 'hive_ambari_host')) {
  240. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_ambari_host').value;
  241. }
  242. hive_properties = Em.A(['hive_existing_mysql_database', 'hive_existing_oracle_database', 'hive_existing_postgresql_database',
  243. 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_2_database']);
  244. break;
  245. case 'New PostgreSQL Database':
  246. if (configs.someProperty('name', 'hive_ambari_host')) {
  247. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_ambari_host').value;
  248. }
  249. hive_properties = Em.A(['hive_existing_mysql_database', 'hive_existing_oracle_database', 'hive_existing_postgresql_database']);
  250. break;
  251. case 'Existing MySQL Database':
  252. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_mysql_host').value;
  253. hive_properties = Em.A(['hive_ambari_database', 'hive_existing_oracle_database', 'hive_existing_postgresql_database',
  254. 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_2_database']);
  255. break;
  256. case Em.I18n.t('services.service.config.hive.oozie.postgresql'):
  257. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_postgresql_host').value;
  258. hive_properties = Em.A(['hive_ambari_database', 'hive_existing_oracle_database', 'hive_existing_mysql_database',
  259. 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_2_database']);
  260. break;
  261. case 'Existing MSSQL Server database with integrated authentication':
  262. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_mssql_server_2_host').value;
  263. hive_properties = Em.A(['hive_ambari_database', 'hive_existing_oracle_database', 'hive_existing_postgresql_database',
  264. 'hive_existing_mysql_database', 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_2_database']);
  265. break;
  266. case 'Existing MSSQL Server database with sql auth':
  267. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_mssql_server_host').value;
  268. hive_properties = Em.A(['hive_ambari_database', 'hive_existing_oracle_database', 'hive_existing_postgresql_database',
  269. 'hive_existing_mysql_database', 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_database']);
  270. break;
  271. default:
  272. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_oracle_host').value;
  273. hive_properties = Em.A(['hive_ambari_database', 'hive_existing_mysql_database', 'hive_existing_postgresql_database',
  274. 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_2_database']);
  275. break;
  276. }
  277. hive_properties.forEach(function (property) {
  278. configs = configs.without(configs.findProperty('name', property));
  279. });
  280. }
  281. return configs;
  282. },
  283. /**
  284. * Remove unused Oozie configs
  285. * @param {Ember.Enumerable} configs
  286. * @returns {Ember.Enumerable}
  287. * @method removeOozieConfigs
  288. */
  289. removeOozieConfigs: function (configs) {
  290. var oozieDb = configs.findProperty('name', 'oozie_database');
  291. if (oozieDb) {
  292. var oozie_properties = Em.A(['oozie_ambari_host', 'oozie_ambari_database']);
  293. switch (oozieDb.value) {
  294. case 'New Derby Database':
  295. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_ambari_host').value;
  296. oozie_properties = Em.A(['oozie_ambari_database', 'oozie_existing_mysql_database', 'oozie_existing_oracle_database',
  297. 'oozie_existing_postgresql_database', 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_2_database']);
  298. break;
  299. case 'Existing MySQL Database':
  300. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_existing_mysql_host').value;
  301. oozie_properties = Em.A(['oozie_ambari_database', 'oozie_existing_oracle_database', 'oozie_derby_database',
  302. 'oozie_existing_postgresql_database', 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_2_database']);
  303. break;
  304. case Em.I18n.t('services.service.config.hive.oozie.postgresql'):
  305. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_existing_postgresql_host').value;
  306. oozie_properties = Em.A(['oozie_ambari_database', 'oozie_existing_oracle_database', 'oozie_existing_mysql_database',
  307. 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_2_database']);
  308. break;
  309. case 'Existing MSSQL Server database with integrated authentication':
  310. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_existing_mysql_host').value;
  311. oozie_properties = Em.A(['oozie_existing_oracle_database', 'oozie_existing_postgresql_database',
  312. 'oozie_existing_mysql_database', 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_2_database']);
  313. break;
  314. case 'Existing MSSQL Server database with sql auth':
  315. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_existing_mysql_host').value;
  316. oozie_properties = Em.A(['oozie_existing_oracle_database', 'oozie_existing_postgresql_database',
  317. 'oozie_existing_mysql_database', 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_database']);
  318. break;
  319. default:
  320. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_existing_oracle_host').value;
  321. oozie_properties = Em.A(['oozie_ambari_database', 'oozie_existing_mysql_database', 'oozie_derby_database',
  322. 'oozie_existing_postgresql_database', 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_2_database']);
  323. break;
  324. }
  325. oozie_properties.forEach(function (property) {
  326. configs = configs.without(configs.findProperty('name', property));
  327. });
  328. }
  329. return configs;
  330. },
  331. /**
  332. * Load all site properties
  333. * @method loadConfigs
  334. */
  335. loadConfigs: function () {
  336. //storedConfigs contains custom configs as well
  337. var configs = this.get('content.serviceConfigProperties');
  338. if (configs.someProperty('name', 'hive_database')) {
  339. configs = this.removeHiveConfigs(configs);
  340. }
  341. if (configs.someProperty('name', 'sink_database')) {
  342. configs = this.removeSinkConfigs(configs);
  343. }
  344. if (configs.someProperty('name', 'oozie_database')) {
  345. configs = this.removeOozieConfigs(configs);
  346. }
  347. configs.forEach(function (_config) {
  348. _config.value = (typeof _config.value === "boolean") ? _config.value.toString() : _config.value;
  349. });
  350. var mappedConfigs = App.config.excludeUnsupportedConfigs(this.get('configMapping'), this.get('selectedServices').mapProperty('serviceName'));
  351. var uiConfigs = this.loadUiSideConfigs(mappedConfigs);
  352. var customGroupConfigs = [];
  353. var allConfigs = configs.concat(uiConfigs).filter(function (config) {
  354. if (config.group) {
  355. customGroupConfigs.push(config);
  356. return false;
  357. } else {
  358. return true;
  359. }
  360. });
  361. this.set('customNonDefaultGroupConfigs', customGroupConfigs);
  362. this.set('configs', allConfigs);
  363. },
  364. /**
  365. * Load UI configs
  366. * @param {Array} configMapping
  367. * @return {Array}
  368. * @method loadUiSideConfigs
  369. */
  370. loadUiSideConfigs: function (configMapping) {
  371. var uiConfig = [];
  372. var configs = configMapping.filterProperty('foreignKey', null);
  373. this.addDynamicProperties(configs);
  374. configs.forEach(function (_config) {
  375. var valueWithOverrides = this.getGlobConfigValueWithOverrides(_config.templateName, _config.value, _config.name);
  376. uiConfig.pushObject({
  377. "id": "site property",
  378. "name": _config.name,
  379. "value": valueWithOverrides.value,
  380. "filename": _config.filename,
  381. "overrides": valueWithOverrides.overrides
  382. });
  383. }, this);
  384. var dependentConfig = $.extend(true, [], configMapping.filterProperty('foreignKey'));
  385. dependentConfig.forEach(function (_config) {
  386. App.config.setConfigValue(uiConfig, this.get('content.serviceConfigProperties'), _config);
  387. if(!_config.noMatchSoSkipThisConfig)
  388. uiConfig.pushObject({
  389. "id": "site property",
  390. "name": _config._name || _config.name,
  391. "value": _config.value,
  392. "filename": _config.filename
  393. });
  394. }, this);
  395. return uiConfig;
  396. },
  397. /**
  398. * Add dynamic properties to configs
  399. * @param {Array} configs
  400. * @method addDynamicProperties
  401. */
  402. addDynamicProperties: function (configs) {
  403. var templetonHiveProperty = this.get('content.serviceConfigProperties').someProperty('name', 'templeton.hive.properties');
  404. if (!templetonHiveProperty) {
  405. configs.pushObject({
  406. "name": "templeton.hive.properties",
  407. "templateName": ["hive.metastore.uris"],
  408. "foreignKey": null,
  409. "value": "hive.metastore.local=false,hive.metastore.uris=<templateName[0]>,hive.metastore.sasl.enabled=yes,hive.metastore.execute.setugi=true,hive.metastore.warehouse.dir=/apps/hive/warehouse",
  410. "filename": "webhcat-site.xml"
  411. });
  412. }
  413. },
  414. /**
  415. * Format <code>content.hosts</code> from Object to Array
  416. * @returns {Array}
  417. * @method getRegisteredHosts
  418. */
  419. getRegisteredHosts: function () {
  420. var allHosts = this.get('content.hosts');
  421. var hosts = [];
  422. for (var hostName in allHosts) {
  423. if (allHosts.hasOwnProperty(hostName)) {
  424. if (allHosts[hostName].bootStatus == 'REGISTERED') {
  425. allHosts[hostName].hostName = allHosts[hostName].name;
  426. hosts.pushObject(allHosts[hostName]);
  427. }
  428. }
  429. }
  430. return hosts;
  431. },
  432. /**
  433. * Set all site property that are derived from other puppet-variable
  434. * @param {String} templateName
  435. * @param {String} expression
  436. * @param {String} name
  437. * @return {Object}
  438. * example: <code>{
  439. * value: '...',
  440. * overrides: [
  441. * {
  442. * value: 'v1',
  443. * hosts: ['h1', 'h2']
  444. * },
  445. * {
  446. * value: 'v2',
  447. * hosts: ['h2', 'h3']
  448. * },
  449. * ....
  450. * ]
  451. * }</code>
  452. * @method getGlobConfigValueWithOverrides
  453. */
  454. getGlobConfigValueWithOverrides: function (templateName, expression, name) {
  455. var express = expression.match(/<(.*?)>/g);
  456. var value = expression;
  457. if (express == null) {
  458. return { value: expression, overrides: []}; // if site property do not map any global property then return the value
  459. }
  460. var overrideHostToValue = {};
  461. express.forEach(function (_express) {
  462. //console.log("The value of template is: " + _express);
  463. var index = parseInt(_express.match(/\[([\d]*)(?=\])/)[1]);
  464. if (this.get('configs').someProperty('name', templateName[index])) {
  465. //console.log("The name of the variable is: " + this.get('content.serviceConfigProperties').findProperty('name', templateName[index]).name);
  466. var globalObj = this.get('configs').findProperty('name', templateName[index]);
  467. var globValue = globalObj.value;
  468. // Hack for templeton.zookeeper.hosts
  469. var preReplaceValue = null;
  470. if (value !== null) { // if the property depends on more than one template name like <templateName[0]>/<templateName[1]> then don't proceed to the next if the prior is null or not found in the global configs
  471. preReplaceValue = value;
  472. value = App.config.replaceConfigValues(name, _express, value, globValue);
  473. }
  474. if (globalObj.overrides != null) {
  475. globalObj.overrides.forEach(function (override) {
  476. var ov = override.value;
  477. var hostsArray = override.hosts;
  478. hostsArray.forEach(function (host) {
  479. if (!(host in overrideHostToValue)) {
  480. overrideHostToValue[host] = App.config.replaceConfigValues(name, _express, preReplaceValue, ov);
  481. } else {
  482. overrideHostToValue[host] = App.config.replaceConfigValues(name, _express, overrideHostToValue[host], ov);
  483. }
  484. }, this);
  485. }, this);
  486. }
  487. } else {
  488. /*
  489. console.log("ERROR: The variable name is: " + templateName[index]);
  490. console.log("ERROR: mapped config from configMapping file has no corresponding variable in " +
  491. "content.serviceConfigProperties. Two possible reasons for the error could be: 1) The service is not selected. " +
  492. "and/OR 2) The service_config metadata file has no corresponding global var for the site property variable");
  493. */
  494. value = null;
  495. }
  496. }, this);
  497. var valueWithOverrides = {
  498. value: value,
  499. overrides: []
  500. };
  501. var overrideValueToHostMap = {};
  502. if (!jQuery.isEmptyObject(overrideHostToValue)) {
  503. for (var host in overrideHostToValue) {
  504. var hostVal = overrideHostToValue[host];
  505. if (!(hostVal in overrideValueToHostMap)) {
  506. overrideValueToHostMap[hostVal] = [];
  507. }
  508. overrideValueToHostMap[hostVal].push(host);
  509. }
  510. }
  511. for (var val in overrideValueToHostMap) {
  512. valueWithOverrides.overrides.push({
  513. value: val,
  514. hosts: overrideValueToHostMap[val]
  515. });
  516. }
  517. return valueWithOverrides;
  518. },
  519. /**
  520. * Load all info about cluster to <code>clusterInfo</code> variable
  521. * @method loadClusterInfo
  522. */
  523. loadClusterInfo: function () {
  524. //Admin name
  525. var admin = this.rawContent.findProperty('config_name', 'Admin');
  526. admin.config_value = App.db.getLoginName();
  527. console.log("STEP8: the value of content cluster name: " + App.db.getLoginName());
  528. if (admin.config_value) {
  529. this.get('clusterInfo').pushObject(Ember.Object.create(admin));
  530. }
  531. // cluster name
  532. var cluster = this.rawContent.findProperty('config_name', 'cluster');
  533. cluster.config_value = this.get('content.cluster.name');
  534. console.log("STEP8: the value of content cluster name: " + this.get('content.cluster.name'));
  535. this.get('clusterInfo').pushObject(Ember.Object.create(cluster));
  536. //hosts
  537. var newHostsCount = 0;
  538. var totalHostsCount = 0;
  539. var hosts = this.get('content.hosts');
  540. for (var hostName in hosts) {
  541. newHostsCount += ~~(!hosts[hostName].isInstalled);
  542. totalHostsCount++;
  543. }
  544. var totalHostsObj = this.rawContent.findProperty('config_name', 'hosts');
  545. totalHostsObj.config_value = totalHostsCount + ' (' + newHostsCount + ' new)';
  546. this.get('clusterInfo').pushObject(Em.Object.create(totalHostsObj));
  547. //repo
  548. if (['addHostController', 'addServiceController'].contains(this.get('content.controllerName'))) {
  549. this.loadRepoInfo();
  550. } else {
  551. // from install wizard
  552. var selectedStack = App.Stack.find().findProperty('isSelected');
  553. var allRepos = [];
  554. if (selectedStack && selectedStack.get('operatingSystems')) {
  555. selectedStack.get('operatingSystems').forEach(function (os) {
  556. if (os.get('isSelected')) {
  557. os.get('repositories').forEach(function(repo) {
  558. allRepos.push(Em.Object.create({
  559. base_url: repo.get('baseUrl'),
  560. os_type: repo.get('osType'),
  561. repo_id: repo.get('repoId')
  562. }));
  563. }, this);
  564. }
  565. }, this);
  566. }
  567. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  568. this.get('clusterInfo').set('repoInfo', allRepos);
  569. }
  570. },
  571. /**
  572. * Load repo info for add Service/Host wizard review page
  573. * @return {$.ajax|null}
  574. * @method loadRepoInfo
  575. */
  576. loadRepoInfo: function () {
  577. var nameVersionCombo = App.get('currentStackVersion').split('-');
  578. return App.ajax.send({
  579. name: 'cluster.load_repositories',
  580. sender: this,
  581. data: {
  582. stackName: nameVersionCombo[0],
  583. stackVersion: nameVersionCombo[1]
  584. },
  585. success: 'loadRepoInfoSuccessCallback',
  586. error: 'loadRepoInfoErrorCallback'
  587. });
  588. },
  589. /**
  590. * Save all repo base URL of all OS type to <code>repoInfo<code>
  591. * @param {object} data
  592. * @method loadRepoInfoSuccessCallback
  593. */
  594. loadRepoInfoSuccessCallback: function (data) {
  595. var allRepos = [];
  596. data.items.forEach(function (os) {
  597. os.repositories.forEach(function (repository) {
  598. allRepos.push(Em.Object.create({
  599. base_url: repository.Repositories.base_url,
  600. os_type: repository.Repositories.os_type,
  601. repo_id: repository.Repositories.repo_id
  602. }));
  603. });
  604. }, this);
  605. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  606. this.get('clusterInfo').set('repoInfo', allRepos);
  607. },
  608. /**
  609. * @param {object} request
  610. * @method loadRepoInfoErrorCallback
  611. */
  612. loadRepoInfoErrorCallback: function (request) {
  613. console.log('Error message is: ' + request.responseText);
  614. var allRepos = [];
  615. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  616. this.get('clusterInfo').set('repoInfo', allRepos);
  617. },
  618. /**
  619. * Load all info about services to <code>services</code> variable
  620. * @method loadServices
  621. */
  622. loadServices: function () {
  623. this.get('selectedServices').filterProperty('isHiddenOnSelectServicePage', false).forEach(function (service) {
  624. console.log('INFO: step8: Name of the service from getService function: ' + service.get('serviceName'));
  625. var serviceObj = Em.Object.create({
  626. service_name: service.get('serviceName'),
  627. display_name: service.get('displayNameOnSelectServicePage'),
  628. service_components: Em.A([])
  629. });
  630. service.get('serviceComponents').forEach(function (component) {
  631. // show clients for services that have only clients components
  632. if ((component.get('isClient') || component.get('isRequiredOnAllHosts')) && !service.get('isClientOnlyService')) return;
  633. // skip components that was hide on assign master page
  634. if (component.get('isMaster') && !component.get('isShownOnInstallerAssignMasterPage')) return;
  635. // no HA component
  636. if (component.get('isHAComponentOnly')) return;
  637. var displayName;
  638. if (component.get('isClient')) {
  639. displayName = Em.I18n.t('common.clients')
  640. } else {
  641. // remove service name from component display name
  642. displayName = App.format.role(component.get('componentName')).replace(new RegExp('^' + service.get('serviceName') + '\\s', 'i'), '');
  643. }
  644. serviceObj.get('service_components').pushObject(Em.Object.create({
  645. component_name: component.get('isClient') ? Em.I18n.t('common.client').toUpperCase() : component.get('componentName'),
  646. display_name: displayName,
  647. component_value: this.assignComponentHosts(component)
  648. }));
  649. }, this);
  650. if (service.get('customReviewHandler')) {
  651. for (var displayName in service.get('customReviewHandler')) {
  652. serviceObj.get('service_components').pushObject(Em.Object.create({
  653. display_name: displayName,
  654. component_value: this.assignComponentHosts(Em.Object.create({
  655. customHandler: service.get('customReviewHandler.' + displayName)
  656. }))
  657. }));
  658. }
  659. }
  660. this.get('services').pushObject(serviceObj);
  661. }, this);
  662. },
  663. /**
  664. * Set <code>component_value</code> property to <code>component</code>
  665. * @param {Em.Object} component
  666. * @return {String}
  667. * @method assignComponentHosts
  668. */
  669. assignComponentHosts: function (component) {
  670. var componentValue;
  671. if (component.get('customHandler')) {
  672. componentValue = this[component.get('customHandler')].call(this, component);
  673. }
  674. else {
  675. if (component.get('isMaster')) {
  676. componentValue = this.getMasterComponentValue(component.get('componentName'));
  677. }
  678. else {
  679. console.log(' --- ---INFO: step8: NOT component isMaster');
  680. var componentName = component.get('isClient') ? Em.I18n.t('common.client').toUpperCase() : component.get('componentName');
  681. var hostsLength = this.get('content.slaveComponentHosts')
  682. .findProperty('componentName', componentName).hosts.length;
  683. componentValue = hostsLength + Em.I18n.t('installer.step8.host' + ((hostsLength > 1) ? 's' : ''));
  684. }
  685. }
  686. return componentValue;
  687. },
  688. getMasterComponentValue: function (componentName) {
  689. var masterComponents = this.get('content.masterComponentHosts');
  690. var hostsCount = masterComponents.filterProperty('component', componentName).length;
  691. return stringUtils.pluralize(hostsCount,
  692. masterComponents.findProperty('component', componentName).hostName,
  693. hostsCount + ' ' + Em.I18n.t('installer.step8.hosts'));
  694. },
  695. /**
  696. * Set displayed MetricsSink DB value based on DB type
  697. * @method loadSinkDbValue
  698. */
  699. loadSinkDbValue: function () {
  700. var db, serviceConfigProperties = this.get('wizardController').getDBProperty('serviceConfigProperties'),
  701. sinkDb = serviceConfigProperties.findProperty('name', 'sink_database');
  702. if (sinkDb.value === 'Existing MSSQL Server database with integrated authentication') {
  703. db = serviceConfigProperties.findProperty('name', 'sink_existing_mssql_server_database');
  704. return db.value + ' (' + sinkDb.value + ')';
  705. }
  706. else {
  707. if (sinkDb.value === 'Existing MSSQL Server database with sql auth') {
  708. db = serviceConfigProperties.findProperty('name', 'sink_existing_mssql_server_2_database');
  709. return db.value + ' (' + sinkDb.value + ')';
  710. }
  711. }
  712. },
  713. /**
  714. * Set displayed Hive DB value based on DB type
  715. * @method loadHiveDbValue
  716. */
  717. loadHiveDbValue: function () {
  718. var db, serviceConfigPreoprties = this.get('wizardController').getDBProperty('serviceConfigProperties'),
  719. hiveDb = serviceConfigPreoprties.findProperty('name', 'hive_database');
  720. if (hiveDb.value === 'New MySQL Database') {
  721. return 'MySQL (New Database)';
  722. } else if (hiveDb.value === 'New PostgreSQL Database') {
  723. return 'Postgres (New Database)';
  724. }
  725. else {
  726. if (hiveDb.value === 'Existing MySQL Database') {
  727. db = serviceConfigPreoprties.findProperty('name', 'hive_existing_mysql_database');
  728. return db.value + ' (' + hiveDb.value + ')';
  729. }
  730. else {
  731. if (hiveDb.value === Em.I18n.t('services.service.config.hive.oozie.postgresql')) {
  732. db = serviceConfigPreoprties.findProperty('name', 'hive_existing_postgresql_database');
  733. return db.value + ' (' + hiveDb.value + ')';
  734. }
  735. else {
  736. if (hiveDb.value === 'Existing MSSQL Server database with integrated authentication') {
  737. db = serviceConfigPreoprties.findProperty('name', 'hive_existing_mssql_server_database');
  738. return db.value + ' (' + hiveDb.value + ')';
  739. }
  740. else {
  741. if (hiveDb.value === 'Existing MSSQL Server database with sql auth') {
  742. db = serviceConfigPreoprties.findProperty('name', 'hive_existing_mssql_server_2_database');
  743. return db.value + ' (' + hiveDb.value + ')';
  744. }
  745. else {
  746. // existing oracle database
  747. db = serviceConfigPreoprties.findProperty('name', 'hive_existing_oracle_database');
  748. return db.value + ' (' + hiveDb.value + ')';
  749. }
  750. }
  751. }
  752. }
  753. }
  754. },
  755. /**
  756. * Set displayed HBase master value
  757. * @param {Object} hbaseMaster
  758. * @method loadHbaseMasterValue
  759. */
  760. loadHbaseMasterValue: function (hbaseMaster) {
  761. var hbaseHostName = this.get('content.masterComponentHosts').filterProperty('component', hbaseMaster.component_name);
  762. if (hbaseHostName.length == 1) {
  763. hbaseMaster.set('component_value', hbaseHostName[0].hostName);
  764. } else {
  765. hbaseMaster.set('component_value', hbaseHostName[0].hostName + " " + Em.I18n.t('installer.step8.other').format(hbaseHostName.length - 1));
  766. }
  767. },
  768. /**
  769. * Set displayed ZooKeeper Server value
  770. * @param {Object} serverComponent
  771. * @method loadZkServerValue
  772. */
  773. loadZkServerValue: function (serverComponent) {
  774. var zkHostNames = this.get('content.masterComponentHosts').filterProperty('component', serverComponent.component_name).length;
  775. var hostSuffix;
  776. if (zkHostNames === 1) {
  777. hostSuffix = Em.I18n.t('installer.step8.host');
  778. } else {
  779. hostSuffix = Em.I18n.t('installer.step8.hosts');
  780. }
  781. serverComponent.set('component_value', zkHostNames + hostSuffix);
  782. },
  783. /**
  784. * Set displayed Oozie DB value based on DB type
  785. * @method loadOozieDbValue
  786. */
  787. loadOozieDbValue: function () {
  788. var db, oozieDb = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_database');
  789. if (oozieDb.value === 'New Derby Database') {
  790. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_derby_database');
  791. return db.value + ' (' + oozieDb.value + ')';
  792. }
  793. else {
  794. if (oozieDb.value === 'Existing MySQL Database') {
  795. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_mysql_database');
  796. return db.value + ' (' + oozieDb.value + ')';
  797. }
  798. else {
  799. if (oozieDb.value === Em.I18n.t('services.service.config.hive.oozie.postgresql')) {
  800. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_postgresql_database');
  801. return db.value + ' (' + oozieDb.value + ')';
  802. }
  803. else {
  804. if (oozieDb.value === 'Existing MSSQL Server database with integrated authentication') {
  805. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_mssql_server_database');
  806. return db.value + ' (' + oozieDb.value + ')';
  807. }
  808. else {
  809. if (oozieDb.value === 'Existing MSSQL Server database with sql auth') {
  810. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_mssql_server_2_database');
  811. return db.value + ' (' + oozieDb.value + ')';
  812. }
  813. else {
  814. // existing oracle database
  815. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_oracle_database');
  816. return db.value + ' (' + oozieDb.value + ')';
  817. }
  818. }
  819. }
  820. }
  821. }
  822. },
  823. /**
  824. * Set displayed Nagion Admin value
  825. * @method loadNagiosAdminValue
  826. */
  827. loadNagiosAdminValue: function () {
  828. var config = this.get('content.serviceConfigProperties');
  829. var adminLoginName = config.findProperty('name', 'nagios_web_login');
  830. var adminEmail = config.findProperty('name', 'nagios_contact');
  831. return adminLoginName.value + ' / (' + adminEmail.value + ')';
  832. },
  833. /**
  834. * Onclick handler for <code>next</code> button
  835. * @method submit
  836. * @return {App.ModalPopup|null}
  837. */
  838. submit: function () {
  839. if (this.get('isSubmitDisabled')) return null;
  840. if ((this.get('content.controllerName') == 'addHostController') && this.get('securityEnabled')) {
  841. var self = this;
  842. return App.showConfirmationPopup(function () {
  843. self.submitProceed();
  844. }, Em.I18n.t('installer.step8.securityConfirmationPopupBody'));
  845. } else {
  846. return this.submitProceed();
  847. }
  848. },
  849. /**
  850. * Update configurations for installed services.
  851. * Do separated PUT-request for each siteName for each service
  852. *
  853. * @param {Array} fileNamesToUpdate - file names that should be updated
  854. * @method updateConfigurations
  855. */
  856. updateConfigurations: function (fileNamesToUpdate) {
  857. var configurationController = App.router.get('mainServiceInfoConfigsController');
  858. var configs = this.get('configs').slice(0);
  859. var configsMap = [];
  860. fileNamesToUpdate.forEach(function (fileName) {
  861. if (!fileName || /^(core)/.test(fileName)) return;
  862. var tagName = 'version' + (new Date).getTime();
  863. var configsToSave = configs.filterProperty('filename', fileName);
  864. configsToSave.forEach(function (item) {
  865. item.value = App.config.trimProperty(item, false);
  866. });
  867. configsMap.push(configurationController.createSiteObj(fileName.replace(".xml", ""), tagName, configsToSave));
  868. }, this);
  869. if (!configsMap.length) return;
  870. this.applyConfigurationsToCluster(configsMap);
  871. },
  872. /**
  873. * Prepare <code>ajaxQueue</code> and start to execute it
  874. * @method submitProceed
  875. */
  876. submitProceed: function () {
  877. var self = this;
  878. this.set('isSubmitDisabled', true);
  879. this.set('isBackBtnDisabled', true);
  880. if (this.get('content.controllerName') == 'addHostController') {
  881. App.router.get('addHostController').setLowerStepsDisable(4);
  882. }
  883. // checkpoint the cluster status on the server so that the user can resume from where they left off
  884. switch (this.get('content.controllerName')) {
  885. case 'installerController':
  886. App.clusterStatus.setClusterStatus({
  887. clusterName: this.get('clusterName'),
  888. clusterState: 'CLUSTER_DEPLOY_PREP_2',
  889. wizardControllerName: this.get('content.controllerName'),
  890. localdb: App.db.data
  891. });
  892. break;
  893. case 'addHostController':
  894. App.clusterStatus.setClusterStatus({
  895. clusterName: this.get('clusterName'),
  896. clusterState: 'ADD_HOSTS_DEPLOY_PREP_2',
  897. wizardControllerName: this.get('content.controllerName'),
  898. localdb: App.db.data
  899. });
  900. break;
  901. case 'addServiceController':
  902. App.clusterStatus.setClusterStatus({
  903. clusterName: this.get('clusterName'),
  904. clusterState: 'ADD_SERVICES_DEPLOY_PREP_2',
  905. wizardControllerName: this.get('content.controllerName'),
  906. localdb: App.db.data
  907. });
  908. break;
  909. default:
  910. break;
  911. }
  912. // delete any existing clusters to start from a clean slate
  913. // before creating a new cluster in install wizard
  914. // TODO: modify for multi-cluster support
  915. this.getExistingClusterNames().complete(function () {
  916. var clusterNames = self.get('clusterNames');
  917. if (self.get('content.controllerName') == 'installerController' && (!App.get('testMode')) && clusterNames.length) {
  918. self.deleteClusters(clusterNames);
  919. } else {
  920. self.deleteClustersCallback(null, null, {isLast: true});
  921. }
  922. });
  923. },
  924. /**
  925. * Get list of existing cluster names
  926. * @returns {object|null}
  927. * returns an array of existing cluster names.
  928. * returns an empty array if there are no existing clusters.
  929. * @method getExistingClusterNames
  930. */
  931. getExistingClusterNames: function () {
  932. return App.ajax.send({
  933. name: 'wizard.step8.existing_cluster_names',
  934. sender: this,
  935. success: 'getExistingClusterNamesSuccessCallBack',
  936. error: 'getExistingClusterNamesErrorCallback'
  937. });
  938. },
  939. /**
  940. * Save received list to <code>clusterNames</code>
  941. * @param {Object} data
  942. * @method getExistingClusterNamesSuccessCallBack
  943. */
  944. getExistingClusterNamesSuccessCallBack: function (data) {
  945. var clusterNames = data.items.mapProperty('Clusters.cluster_name');
  946. console.log("Got existing cluster names: " + clusterNames);
  947. this.set('clusterNames', clusterNames);
  948. },
  949. /**
  950. * If error appears, set <code>clusterNames</code> to <code>[]</code>
  951. * @method getExistingClusterNamesErrorCallback
  952. */
  953. getExistingClusterNamesErrorCallback: function () {
  954. console.log("Failed to get existing cluster names");
  955. this.set('clusterNames', []);
  956. },
  957. /**
  958. * Delete cluster by name
  959. * One request for one cluster!
  960. * @param {string[]} clusterNames
  961. * @method deleteClusters
  962. */
  963. deleteClusters: function (clusterNames) {
  964. clusterNames.forEach(function (clusterName, index) {
  965. App.ajax.send({
  966. name: 'common.delete.cluster',
  967. sender: this,
  968. data: {
  969. name: clusterName,
  970. isLast: index == clusterNames.length - 1
  971. },
  972. success: 'deleteClustersCallback',
  973. error: 'deleteClustersCallback'
  974. });
  975. }, this);
  976. },
  977. deleteClustersCallback: function (response, request, data) {
  978. if (data.isLast) {
  979. this.createCluster();
  980. this.createSelectedServices();
  981. if (this.get('content.controllerName') !== 'addHostController') {
  982. if (this.get('wizardController').getDBProperty('fileNamesToUpdate') && this.get('wizardController').getDBProperty('fileNamesToUpdate').length) {
  983. this.updateConfigurations(this.get('wizardController').getDBProperty('fileNamesToUpdate'));
  984. }
  985. this.createConfigurations();
  986. this.applyConfigurationsToCluster(this.get('serviceConfigTags'));
  987. }
  988. this.createComponents();
  989. this.registerHostsToCluster();
  990. this.createConfigurationGroups();
  991. this.createMasterHostComponents();
  992. this.createSlaveAndClientsHostComponents();
  993. if (this.get('content.controllerName') === 'addServiceController') {
  994. this.createAdditionalClientComponents();
  995. }
  996. this.createAdditionalHostComponents();
  997. this.set('ajaxQueueLength', this.get('ajaxRequestsQueue.queue.length'));
  998. this.get('ajaxRequestsQueue').start();
  999. }
  1000. },
  1001. /**
  1002. * *******************************************************************
  1003. * The following create* functions are called upon submitting Step 8.
  1004. * *******************************************************************
  1005. */
  1006. /**
  1007. * Create cluster using selected stack version
  1008. * Queued request
  1009. * @method createCluster
  1010. */
  1011. createCluster: function () {
  1012. if (this.get('content.controllerName') !== 'installerController') return;
  1013. var stackVersion = (this.get('content.installOptions.localRepo')) ? App.currentStackVersion.replace(/(-\d+(\.\d)*)/ig, "Local$&") : App.currentStackVersion;
  1014. this.addRequestToAjaxQueue({
  1015. name: 'wizard.step8.create_cluster',
  1016. data: {
  1017. data: JSON.stringify({ "Clusters": {"version": stackVersion }})
  1018. },
  1019. success: 'createClusterSuccess'
  1020. });
  1021. },
  1022. createClusterSuccess: function (data, xhr, params) {
  1023. App.set('clusterName', params.cluster)
  1024. },
  1025. /**
  1026. * Create selected to install services
  1027. * Queued request
  1028. * Skipped if no services where selected!
  1029. * @method createSelectedServices
  1030. */
  1031. createSelectedServices: function () {
  1032. var data = this.createSelectedServicesData();
  1033. if (!data.length) return;
  1034. this.addRequestToAjaxQueue({
  1035. name: 'wizard.step8.create_selected_services',
  1036. data: {
  1037. data: JSON.stringify(data)
  1038. }
  1039. });
  1040. },
  1041. /**
  1042. * Format data for <code>createSelectedServices</code> request
  1043. * @returns {Object[]}
  1044. * @method createSelectedServicesData
  1045. */
  1046. createSelectedServicesData: function () {
  1047. return this.get('selectedServices').map(function (_service) {
  1048. return {"ServiceInfo": { "service_name": _service.get('serviceName') }};
  1049. });
  1050. },
  1051. /**
  1052. * Create components for selected services
  1053. * Queued requests
  1054. * One request for each service!
  1055. * @method createComponents
  1056. */
  1057. createComponents: function () {
  1058. var serviceComponents = App.StackServiceComponent.find();
  1059. this.get('selectedServices').forEach(function (_service) {
  1060. var serviceName = _service.get('serviceName');
  1061. var componentsData = serviceComponents.filterProperty('serviceName', serviceName).map(function (_component) {
  1062. return { "ServiceComponentInfo": { "component_name": _component.get('componentName') } };
  1063. });
  1064. // Service must be specified in terms of a query for creating multiple components at the same time.
  1065. // See AMBARI-1018.
  1066. this.addRequestToAjaxQueue({
  1067. name: 'wizard.step8.create_components',
  1068. data: {
  1069. data: JSON.stringify({"components": componentsData}),
  1070. serviceName: serviceName
  1071. }
  1072. });
  1073. }, this);
  1074. },
  1075. /**
  1076. * Error callback for new service component request
  1077. * So, if component doesn't exist we should create it
  1078. * @param {object} request
  1079. * @param {object} ajaxOptions
  1080. * @param {string} error
  1081. * @param {object} opt
  1082. * @param {object} params
  1083. * @method newServiceComponentErrorCallback
  1084. */
  1085. newServiceComponentErrorCallback: function (request, ajaxOptions, error, opt, params) {
  1086. this.addRequestToAjaxQueue({
  1087. name: 'wizard.step8.create_components',
  1088. data: {
  1089. serviceName: params.serviceName,
  1090. data: JSON.stringify({
  1091. "components": [
  1092. {
  1093. "ServiceComponentInfo": {
  1094. "component_name": params.componentName
  1095. }
  1096. }
  1097. ]
  1098. })
  1099. }
  1100. });
  1101. },
  1102. /**
  1103. * Register hosts
  1104. * Queued request
  1105. * @method registerHostsToCluster
  1106. */
  1107. registerHostsToCluster: function () {
  1108. var data = this.createRegisterHostData();
  1109. if (!data.length) return;
  1110. this.addRequestToAjaxQueue({
  1111. name: 'wizard.step8.register_host_to_cluster',
  1112. data: {
  1113. data: JSON.stringify(data)
  1114. }
  1115. });
  1116. },
  1117. /**
  1118. * Format request-data for <code>registerHostsToCluster</code>
  1119. * @returns {Object}
  1120. * @method createRegisterHostData
  1121. */
  1122. createRegisterHostData: function () {
  1123. return this.getRegisteredHosts().filterProperty('isInstalled', false).map(function (host) {
  1124. return {"Hosts": { "host_name": host.hostName}};
  1125. });
  1126. },
  1127. /**
  1128. * Register new master components
  1129. * @uses registerHostsToComponent
  1130. * @method createMasterHostComponents
  1131. */
  1132. createMasterHostComponents: function () {
  1133. // create master components for only selected services.
  1134. var selectedMasterComponents = this.get('content.masterComponentHosts').filter(function (_component) {
  1135. return this.get('selectedServices').mapProperty('serviceName').contains(_component.serviceId)
  1136. }, this);
  1137. selectedMasterComponents.mapProperty('component').uniq().forEach(function (component) {
  1138. var hostNames = selectedMasterComponents.filterProperty('component', component).filterProperty('isInstalled', false).mapProperty('hostName');
  1139. this.registerHostsToComponent(hostNames, component);
  1140. }, this);
  1141. },
  1142. getClientsToMasterMap: function () {
  1143. var clientNames = App.StackServiceComponent.find().filterProperty('isClient').mapProperty('componentName'),
  1144. clientsMap = {},
  1145. dependedComponents = App.StackServiceComponent.find().filterProperty('isMaster');
  1146. clientNames.forEach(function (clientName) {
  1147. clientsMap[clientName] = Em.A([]);
  1148. dependedComponents.forEach(function (component) {
  1149. if (component.get('dependencies').mapProperty('componentName').contains(clientName)) clientsMap[clientName].push(component.get('componentName'));
  1150. });
  1151. if (!clientsMap[clientName].length) delete clientsMap[clientName];
  1152. });
  1153. return clientsMap;
  1154. },
  1155. /**
  1156. * Register slave components and clients
  1157. * @uses registerHostsToComponent
  1158. * @method createSlaveAndClientsHostComponents
  1159. */
  1160. createSlaveAndClientsHostComponents: function () {
  1161. var masterHosts = this.get('content.masterComponentHosts');
  1162. var slaveHosts = this.get('content.slaveComponentHosts');
  1163. var clients = this.get('content.clients').filterProperty('isInstalled', false);
  1164. /**
  1165. * Determines on which hosts client should be installed (based on availability of master components on hosts)
  1166. * @type {Object}
  1167. * Format:
  1168. * <code>
  1169. * {
  1170. * CLIENT1: Em.A([MASTER1, MASTER2, ...]),
  1171. * CLIENT2: Em.A([MASTER3, MASTER1, ...])
  1172. * ...
  1173. * }
  1174. * </code>
  1175. */
  1176. var clientsToMasterMap = this.getClientsToMasterMap();
  1177. slaveHosts.forEach(function (_slave) {
  1178. if (_slave.componentName !== 'CLIENT') {
  1179. var hostNames = _slave.hosts.filterProperty('isInstalled', false).mapProperty('hostName');
  1180. this.registerHostsToComponent(hostNames, _slave.componentName);
  1181. }
  1182. else {
  1183. clients.forEach(function (_client) {
  1184. var hostNames = _slave.hosts.mapProperty('hostName');
  1185. // The below logic to install clients to existing/New master hosts should not be applied to Add Host wizard.
  1186. // This is with the presumption that Add Host controller does not add any new Master component to the cluster
  1187. if (this.get('content.controllerName') !== 'addHostController') {
  1188. if (clientsToMasterMap[_client.component_name]) {
  1189. clientsToMasterMap[_client.component_name].forEach(function (componentName) {
  1190. masterHosts.filterProperty('component', componentName).forEach(function (_masterHost) {
  1191. hostNames.pushObject(_masterHost.hostName);
  1192. });
  1193. });
  1194. }
  1195. }
  1196. hostNames = hostNames.uniq();
  1197. this.registerHostsToComponent(hostNames, _client.component_name);
  1198. }, this);
  1199. }
  1200. }, this);
  1201. },
  1202. /**
  1203. * This function is specific to addServiceController
  1204. * Newly introduced master components requires some existing client components to be hosted along with them
  1205. */
  1206. createAdditionalClientComponents: function () {
  1207. var masterHosts = this.get('content.masterComponentHosts');
  1208. var clientsToMasterMap = this.getClientsToMasterMap();
  1209. var installedClients = [];
  1210. // Get all the installed Client components
  1211. this.get('content.services').filterProperty('isInstalled').forEach(function (_service) {
  1212. var serviceClients = App.StackServiceComponent.find().filterProperty('serviceName', _service.get('serviceName')).filterProperty('isClient');
  1213. serviceClients.forEach(function (client) {
  1214. installedClients.push(client.get('componentName'));
  1215. }, this);
  1216. }, this);
  1217. // Check if there is a dependency for being co-hosted between existing client and selected new master
  1218. installedClients.forEach(function (_clientName) {
  1219. if (clientsToMasterMap[_clientName]) {
  1220. var hostNames = [];
  1221. clientsToMasterMap[_clientName].forEach(function (componentName) {
  1222. masterHosts.filterProperty('component', componentName).filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1223. hostNames.pushObject(_masterHost.hostName);
  1224. }, this);
  1225. }, this);
  1226. hostNames = hostNames.uniq();
  1227. if (hostNames.length > 0) {
  1228. this.get('content.additionalClients').pushObject({hostNames: hostNames, componentName: _clientName});
  1229. // If a dependency for being co-hosted is derived between existing client and selected new master but that
  1230. // dependency is already satisfied in the cluster then disregard the derived dependency
  1231. this.removeClientsFromList(_clientName, hostNames);
  1232. this.registerHostsToComponent(hostNames, _clientName);
  1233. }
  1234. }
  1235. }, this);
  1236. },
  1237. /**
  1238. *
  1239. * @param clientName
  1240. * @param hostList
  1241. */
  1242. removeClientsFromList: function (clientName, hostList) {
  1243. var clientHosts = [];
  1244. var installedHosts = this.get('content.hosts');
  1245. for (var hostName in installedHosts) {
  1246. if (installedHosts[hostName].isInstalled) {
  1247. if (installedHosts[hostName].hostComponents.mapProperty('HostRoles.component_name').contains(clientName)) {
  1248. clientHosts.push(hostName);
  1249. }
  1250. }
  1251. }
  1252. if (clientHosts.length > 0) {
  1253. clientHosts.forEach(function (hostName) {
  1254. if (hostList.contains(hostName)) {
  1255. hostList.splice(hostList.indexOf(hostName), 1);
  1256. }
  1257. }, this);
  1258. }
  1259. },
  1260. /**
  1261. * Register additional components
  1262. * Based on availability of some services
  1263. * @uses registerHostsToComponent
  1264. * @method createAdditionalHostComponents
  1265. */
  1266. createAdditionalHostComponents: function () {
  1267. var masterHosts = this.get('content.masterComponentHosts');
  1268. // add all components with cardinality == ALL of selected services
  1269. var registeredHosts = this.getRegisteredHosts();
  1270. var notInstalledHosts = registeredHosts.filterProperty('isInstalled', false);
  1271. this.get('content.services').filterProperty('isSelected').forEach(function (service) {
  1272. service.get('serviceComponents').filterProperty('isRequiredOnAllHosts').forEach(function (component) {
  1273. if (service.get('isInstalled') && notInstalledHosts.length) {
  1274. this.registerHostsToComponent(notInstalledHosts.mapProperty('hostName'), component.get('componentName'));
  1275. } else if (!service.get('isInstalled') && registeredHosts.length) {
  1276. this.registerHostsToComponent(registeredHosts.mapProperty('hostName'), component.get('componentName'));
  1277. }
  1278. }, this);
  1279. }, this);
  1280. // add MySQL Server if Hive is selected
  1281. var hiveService = this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).findProperty('serviceName', 'HIVE');
  1282. if (hiveService) {
  1283. var hiveDb = this.get('content.serviceConfigProperties').findProperty('name', 'hive_database');
  1284. if (hiveDb.value == "New MySQL Database") {
  1285. this.registerHostsToComponent(masterHosts.filterProperty('component', 'HIVE_SERVER').mapProperty('hostName'), 'MYSQL_SERVER');
  1286. } else if (hiveDb.value === "New PostgreSQL Database") {
  1287. this.registerHostsToComponent(masterHosts.filterProperty('component', 'HIVE_SERVER').mapProperty('hostName'), 'POSTGRESQL_SERVER');
  1288. }
  1289. }
  1290. },
  1291. /**
  1292. * Register component to hosts
  1293. * Queued request
  1294. * @param {String[]} hostNames
  1295. * @param {String} componentName
  1296. * @method registerHostsToComponent
  1297. */
  1298. registerHostsToComponent: function (hostNames, componentName) {
  1299. if (!hostNames.length) return;
  1300. var queryStr = '';
  1301. hostNames.forEach(function (hostName) {
  1302. queryStr += 'Hosts/host_name=' + hostName + '|';
  1303. });
  1304. //slice off last symbol '|'
  1305. queryStr = queryStr.slice(0, -1);
  1306. var data = {
  1307. "RequestInfo": {
  1308. "query": queryStr
  1309. },
  1310. "Body": {
  1311. "host_components": [
  1312. {
  1313. "HostRoles": {
  1314. "component_name": componentName
  1315. }
  1316. }
  1317. ]
  1318. }
  1319. };
  1320. this.addRequestToAjaxQueue({
  1321. name: 'wizard.step8.register_host_to_component',
  1322. data: {
  1323. data: JSON.stringify(data)
  1324. }
  1325. });
  1326. },
  1327. /**
  1328. * Compare generated config object with current configs that were filled
  1329. * on "Customize Services" page.
  1330. *
  1331. * @param {Object} properties - generated by createSiteObj|createCoreSiteObj
  1332. * @param {Array} configs - current configs to compare
  1333. * @return {Boolean}
  1334. * @method isConfigsChanged
  1335. **/
  1336. isConfigsChanged: function (properties, configs) {
  1337. var isChanged = false;
  1338. for (var property in properties) {
  1339. var config = configs.findProperty('name', property);
  1340. // if config not found then it's looks like a new config
  1341. if (!config) {
  1342. isChanged = true;
  1343. } else {
  1344. if (!config.hasInitialValue || config.isNotDefaultValue) {
  1345. isChanged = true;
  1346. }
  1347. }
  1348. }
  1349. return isChanged;
  1350. },
  1351. /**
  1352. * Create config objects for cluster and services
  1353. * @method createConfigurations
  1354. */
  1355. createConfigurations: function () {
  1356. var selectedServices = this.get('selectedServices');
  1357. var coreSiteObject = this.createCoreSiteObj();
  1358. var tag = 'version1';
  1359. var clusterSiteObj = this.createSiteObj('cluster-env', tag);
  1360. if (this.get('content.controllerName') == 'installerController') {
  1361. this.get('serviceConfigTags').pushObject(clusterSiteObj);
  1362. }
  1363. if (this.get('content.controllerName') == 'addServiceController') {
  1364. tag = 'version' + (new Date).getTime();
  1365. coreSiteObject.tag = tag;
  1366. var coreSiteConfigs = this.get('configs').filterProperty('filename', 'core-site.xml');
  1367. if (this.isConfigsChanged(coreSiteObject.properties, coreSiteConfigs)) {
  1368. this.get('serviceConfigTags').pushObject(coreSiteObject);
  1369. }
  1370. }
  1371. selectedServices.forEach(function (service) {
  1372. Object.keys(service.get('configTypes')).forEach(function (type) {
  1373. if (!this.get('serviceConfigTags').someProperty('type', type)) {
  1374. var serviceVersionNotes = Em.I18n.t('dashboard.configHistory.table.notes.default').format(service.get('displayName'));
  1375. if (service.get('serviceName') === 'MAPREDUCE' && (type === 'capacity-scheduler' || type === 'mapred-queue-acls')) {
  1376. return;
  1377. } else if (type === 'core-site') {
  1378. coreSiteObject.service_config_version_note = serviceVersionNotes;
  1379. this.get('serviceConfigTags').pushObject(coreSiteObject);
  1380. } else if (type === 'storm-site') {
  1381. var obj = this.createStormSiteObj(tag);
  1382. obj.service_config_version_note = serviceVersionNotes;
  1383. this.get('serviceConfigTags').pushObject(obj);
  1384. } else {
  1385. var obj = this.createSiteObj(type, tag);
  1386. obj.service_config_version_note = serviceVersionNotes;
  1387. this.get('serviceConfigTags').pushObject(obj);
  1388. }
  1389. }
  1390. }, this);
  1391. }, this);
  1392. this.createNotification();
  1393. },
  1394. /**
  1395. * Send <code>serviceConfigTags</code> to server
  1396. * Queued request
  1397. * One request for each service config tag
  1398. * @param serviceConfigTags
  1399. * @method applyConfigurationsToCluster
  1400. */
  1401. applyConfigurationsToCluster: function (serviceConfigTags) {
  1402. var allServices = this.get('installedServices').concat(this.get('selectedServices'));
  1403. var allConfigData = [];
  1404. allServices.forEach(function (service) {
  1405. var serviceConfigData = [];
  1406. Object.keys(service.get('configTypesRendered')).forEach(function (type) {
  1407. var serviceConfigTag = serviceConfigTags.findProperty('type', type);
  1408. if (serviceConfigTag) {
  1409. serviceConfigData.pushObject(serviceConfigTag);
  1410. }
  1411. }, this);
  1412. if (serviceConfigData.length) {
  1413. allConfigData.pushObject(JSON.stringify({
  1414. Clusters: {
  1415. desired_config: serviceConfigData
  1416. }
  1417. }));
  1418. }
  1419. }, this);
  1420. var clusterConfig = serviceConfigTags.findProperty('type', 'cluster-env');
  1421. if (clusterConfig) {
  1422. allConfigData.pushObject(JSON.stringify({
  1423. Clusters: {
  1424. desired_config: [clusterConfig]
  1425. }
  1426. }));
  1427. }
  1428. this.addRequestToAjaxQueue({
  1429. name: 'common.across.services.configurations',
  1430. data: {
  1431. data: '[' + allConfigData.toString() + ']'
  1432. }
  1433. });
  1434. },
  1435. /**
  1436. * Create and update config groups
  1437. * @method createConfigurationGroups
  1438. */
  1439. createConfigurationGroups: function () {
  1440. var configGroups = this.get('content.configGroups').filterProperty('isDefault', false);
  1441. var clusterName = this.get('clusterName');
  1442. var sendData = [];
  1443. var updateData = [];
  1444. var serviceConfigController = App.router.get('mainServiceInfoConfigsController');
  1445. var timeTag = (new Date).getTime();
  1446. var groupsToDelete = App.router.get(this.get('content.controllerName')).getDBProperty('groupsToDelete');
  1447. if (groupsToDelete && groupsToDelete.length > 0) {
  1448. this.removeInstalledServicesConfigurationGroups(groupsToDelete);
  1449. }
  1450. configGroups.forEach(function (configGroup) {
  1451. var groupConfigs = [];
  1452. var groupData = {
  1453. "cluster_name": clusterName,
  1454. "group_name": configGroup.name,
  1455. "tag": configGroup.service.id,
  1456. "description": configGroup.description,
  1457. "hosts": [],
  1458. "desired_configs": []
  1459. };
  1460. configGroup.hosts.forEach(function (hostName) {
  1461. groupData.hosts.push({"host_name": hostName});
  1462. });
  1463. // get properties that was created for non-default config group
  1464. configGroup.properties = configGroup.properties.concat(this.get('customNonDefaultGroupConfigs').filterProperty('group', configGroup.name));
  1465. //wrap properties into Em.Object to make them compatible with buildGroupDesiredConfigs method
  1466. configGroup.properties.forEach(function (property) {
  1467. groupConfigs.push(Em.Object.create(property));
  1468. });
  1469. groupData.desired_configs = serviceConfigController.buildGroupDesiredConfigs.call(serviceConfigController, groupConfigs, timeTag);
  1470. // check for group from installed service
  1471. if (configGroup.isForInstalledService === true) {
  1472. // if group is a new one, create it
  1473. if (!configGroup.id) {
  1474. sendData.push({"ConfigGroup": groupData});
  1475. } else if (configGroup.isForUpdate){
  1476. // update an existing group
  1477. groupData.id = configGroup.id;
  1478. updateData.push({"ConfigGroup": groupData});
  1479. }
  1480. } else {
  1481. sendData.push({"ConfigGroup": groupData});
  1482. }
  1483. //each group should have unique tag to prevent overriding configs from common sites
  1484. timeTag++;
  1485. }, this);
  1486. if (sendData.length > 0) {
  1487. this.applyConfigurationGroups(sendData);
  1488. }
  1489. if (updateData.length > 0) {
  1490. this.applyInstalledServicesConfigurationGroup(updateData);
  1491. }
  1492. },
  1493. /**
  1494. * Create new config groups request
  1495. * Queued request
  1496. * @param {Object[]} sendData
  1497. * @method applyConfigurationGroups
  1498. */
  1499. applyConfigurationGroups: function (sendData) {
  1500. this.addRequestToAjaxQueue({
  1501. name: 'wizard.step8.apply_configuration_groups',
  1502. data: {
  1503. data: JSON.stringify(sendData)
  1504. }
  1505. });
  1506. },
  1507. /**
  1508. * Update existed config groups
  1509. * Separated request for each group
  1510. * @param {Object[]} updateData
  1511. * @method applyInstalledServicesConfigurationGroup
  1512. */
  1513. applyInstalledServicesConfigurationGroup: function (updateData) {
  1514. updateData.forEach(function (item) {
  1515. App.router.get('mainServiceInfoConfigsController').putConfigGroupChanges(item);
  1516. });
  1517. },
  1518. /**
  1519. * Delete selected config groups
  1520. * @param {Object[]} groupsToDelete
  1521. * @method removeInstalledServicesConfigurationGroups
  1522. */
  1523. removeInstalledServicesConfigurationGroups: function (groupsToDelete) {
  1524. groupsToDelete.forEach(function (item) {
  1525. App.config.deleteConfigGroup(Em.Object.create(item));
  1526. });
  1527. },
  1528. /**
  1529. * proxyuser configs which depend on service
  1530. * @type {{serviceName: string, user: string}[]}
  1531. */
  1532. optionalCoreSiteConfigs: [
  1533. {
  1534. serviceName: 'OOZIE',
  1535. user: 'oozie_user'
  1536. },
  1537. {
  1538. serviceName: 'HIVE',
  1539. user: 'hive_user'
  1540. },
  1541. {
  1542. serviceName: 'HIVE',
  1543. user: 'hcat_user'
  1544. },
  1545. {
  1546. serviceName: 'FALCON',
  1547. user: 'falcon_user'
  1548. }
  1549. ],
  1550. /**
  1551. * push proxyuser properties to core-site if they required by dependencies
  1552. * @param coreSiteObj
  1553. * @param installedAndSelectedServices
  1554. * @return {Object}
  1555. */
  1556. resolveProxyuserDependecies: function (coreSiteObj, installedAndSelectedServices) {
  1557. var coreSiteProperties = {};
  1558. var optionalCoreSiteConfigs = this.get('optionalCoreSiteConfigs');
  1559. var proxyuserGroup = this.get('configs').findProperty('name', 'proxyuser_group');
  1560. coreSiteObj.forEach(function (_coreSiteObj) {
  1561. //proxyuser_group property should be added only if proxyuser properties are used
  1562. if (proxyuserGroup && _coreSiteObj.name === proxyuserGroup.name) return;
  1563. // exclude some configs if service wasn't selected
  1564. var addProperty = optionalCoreSiteConfigs.every(function (config) {
  1565. var userValue = this.get('configs').someProperty('name', config.user) ? this.get('configs').findProperty('name', config.user).value : null
  1566. return (installedAndSelectedServices.someProperty('serviceName', config.serviceName) ||
  1567. (_coreSiteObj.name != 'hadoop.proxyuser.' + userValue + '.hosts' && _coreSiteObj.name != 'hadoop.proxyuser.' + userValue + '.groups'))
  1568. }, this);
  1569. if (addProperty) {
  1570. coreSiteProperties[_coreSiteObj.name] = _coreSiteObj.value;
  1571. }
  1572. }, this);
  1573. if (!App.isEmptyObject(coreSiteProperties) && proxyuserGroup) {
  1574. coreSiteProperties[proxyuserGroup.name] = proxyuserGroup.value;
  1575. }
  1576. return coreSiteProperties;
  1577. },
  1578. /**
  1579. * Create Core Site object
  1580. * @returns {{type: string, tag: string, properties: {}}}
  1581. * @method createCoreSiteObj
  1582. */
  1583. createCoreSiteObj: function () {
  1584. var installedAndSelectedServices = Em.A([]);
  1585. installedAndSelectedServices.pushObjects(this.get('installedServices'));
  1586. installedAndSelectedServices.pushObjects(this.get('selectedServices'));
  1587. var coreSiteObj = this.get('configs').filterProperty('filename', 'core-site.xml'),
  1588. coreSiteProperties = this.resolveProxyuserDependecies(coreSiteObj, installedAndSelectedServices),
  1589. isGLUSTERFSSelected = installedAndSelectedServices.someProperty('serviceName', 'GLUSTERFS');
  1590. coreSiteObj.forEach(function (_coreSiteObj) {
  1591. if (isGLUSTERFSSelected && _coreSiteObj.name == "fs.default.name") {
  1592. coreSiteProperties[_coreSiteObj.name] =
  1593. this.get('configs').someProperty('name', 'fs_glusterfs_default_name') ?
  1594. this.get('configs').findProperty('name', 'fs_glusterfs_default_name').value : null;
  1595. }
  1596. if (isGLUSTERFSSelected && _coreSiteObj.name == "fs.defaultFS") {
  1597. coreSiteProperties[_coreSiteObj.name] =
  1598. this.get('configs').someProperty('name', 'glusterfs_defaultFS_name') ?
  1599. this.get('configs').findProperty('name', 'glusterfs_defaultFS_name').value : null;
  1600. }
  1601. }, this);
  1602. var attributes = App.router.get('mainServiceInfoConfigsController').getConfigAttributes(coreSiteObj);
  1603. var configObj = {"type": "core-site", "tag": "version1", "properties": coreSiteProperties};
  1604. if (attributes) {
  1605. configObj['properties_attributes'] = attributes;
  1606. }
  1607. return configObj;
  1608. },
  1609. /**
  1610. * Create siteObj for custom service with it own configs
  1611. * @param {string} site
  1612. * @param tag
  1613. * @returns {{type: string, tag: string, properties: {}}}
  1614. * @method createSiteObj
  1615. */
  1616. createSiteObj: function (site, tag) {
  1617. var properties = {};
  1618. var configs = this.get('configs').filterProperty('filename', site + '.xml');
  1619. var attributes = App.router.get('mainServiceInfoConfigsController').getConfigAttributes(configs);
  1620. configs.forEach(function (_configProperty) {
  1621. var heapsizeExceptions = ['hadoop_heapsize', 'yarn_heapsize', 'nodemanager_heapsize', 'resourcemanager_heapsize', 'apptimelineserver_heapsize', 'jobhistory_heapsize'];
  1622. // do not pass any globals whose name ends with _host or _hosts
  1623. if (_configProperty.isRequiredByAgent !== false) {
  1624. // append "m" to JVM memory options except for heapsizeExtensions
  1625. if (/_heapsize|_newsize|_maxnewsize|_permsize|_maxpermsize$/.test(_configProperty.name) && !heapsizeExceptions.contains(_configProperty.name) && !(_configProperty.value).endsWith("m")) {
  1626. properties[_configProperty.name] = _configProperty.value + "m";
  1627. } else {
  1628. properties[_configProperty.name] = _configProperty.value;
  1629. }
  1630. }
  1631. }, this);
  1632. var configObj = {"type": site, "tag": tag, "properties": properties };
  1633. if (attributes) {
  1634. configObj['properties_attributes'] = attributes;
  1635. }
  1636. return configObj;
  1637. },
  1638. /**
  1639. * Create site obj for Storm
  1640. * Some config-properties should be modified in custom way
  1641. * @param tag
  1642. * @returns {{type: string, tag: string, properties: {}}}
  1643. * @method createStormSiteObj
  1644. */
  1645. createStormSiteObj: function (tag) {
  1646. var configs = this.get('configs').filterProperty('filename', 'storm-site.xml');
  1647. var stormProperties = {};
  1648. configs.forEach(function (_configProperty) {
  1649. if (_configProperty.name == "storm.zookeeper.servers") {
  1650. stormProperties[_configProperty.name] = JSON.stringify(_configProperty.value).replace(/"/g, "'");
  1651. } else {
  1652. stormProperties[_configProperty.name] = _configProperty.value;
  1653. }
  1654. }, this);
  1655. return {type: 'storm-site', tag: tag, properties: stormProperties};
  1656. },
  1657. /**
  1658. * Create one Alert Notification (if user select this on step7)
  1659. * Only for Install Wizard and stack
  1660. * @method createNotification
  1661. */
  1662. createNotification: function () {
  1663. if (this.get('content.controllerName') !== 'installerController') return;
  1664. var miscConfigs = this.get('configs').filterProperty('serviceName', 'MISC'),
  1665. createNotification = miscConfigs.findProperty('name', 'create_notification').value;
  1666. if (createNotification !== 'yes') return;
  1667. var predefinedNotificationConfigNames = require('data/HDP2/site_properties').configProperties.filterProperty('filename', 'alert_notification').mapProperty('name'),
  1668. configsForNotification = this.get('configs').filterProperty('filename', 'alert_notification');
  1669. var properties = {},
  1670. names = [
  1671. 'ambari.dispatch.recipients',
  1672. 'mail.smtp.host',
  1673. 'mail.smtp.port',
  1674. 'mail.smtp.from',
  1675. 'mail.smtp.starttls.enable',
  1676. 'mail.smtp.startssl.enable'
  1677. ];
  1678. if (miscConfigs.findProperty('name', 'smtp_use_auth').value == 'true') { // yes, it's not converted to boolean
  1679. names.pushObjects(['ambari.dispatch.credential.username', 'ambari.dispatch.credential.password']);
  1680. }
  1681. names.forEach(function (name) {
  1682. properties[name] = miscConfigs.findProperty('name', name).value;
  1683. });
  1684. properties['ambari.dispatch.recipients'] = properties['ambari.dispatch.recipients'].replace(/\s/g, '').split(',');
  1685. configsForNotification.forEach(function (config) {
  1686. if (predefinedNotificationConfigNames.contains(config.name)) return;
  1687. properties[config.name] = config.value;
  1688. });
  1689. var apiObject = {
  1690. AlertTarget: {
  1691. name: 'Initial Notification',
  1692. description: 'Notification created during cluster installing',
  1693. global: true,
  1694. notification_type: 'EMAIL',
  1695. alert_states: ['OK', 'WARNING', 'CRITICAL', 'UNKNOWN'],
  1696. properties: properties
  1697. }
  1698. };
  1699. this.addRequestToAjaxQueue({
  1700. name: 'alerts.create_alert_notification',
  1701. data: {
  1702. data: apiObject
  1703. }
  1704. });
  1705. }
  1706. });