step8_controller.js 68 KB

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