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