step8_controller.js 68 KB

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