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('mainAdminSecurityController.securityEnabled');
  111. }.property('App.router.mainAdminSecurityController.securityEnabled'),
  112. /**
  113. * Selected config group
  114. * @type {Object}
  115. */
  116. selectedConfigGroup: null,
  117. /**
  118. * List of config groups
  119. * @type {Object[]}
  120. */
  121. configGroups: [],
  122. /**
  123. * List of selected but not installed services
  124. * @type {Object[]}
  125. */
  126. selectedServices: function () {
  127. return this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false);
  128. }.property('content.services.@each.isSelected','content.services.@each.isInstalled').cacheable(),
  129. /**
  130. * List of installed services
  131. * @type {Object[]}
  132. */
  133. installedServices: function () {
  134. return this.get('content.services').filterProperty('isInstalled');
  135. }.property('content.services').cacheable(),
  136. /**
  137. * Current cluster name
  138. * @type {string}
  139. */
  140. clusterName: function () {
  141. return this.get('content.cluster.name');
  142. }.property('content.cluster.name'),
  143. /**
  144. * List of existing cluster names
  145. * @type {string[]}
  146. */
  147. clusterNames: [],
  148. /**
  149. * 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. if (this.get('content.controllerName') != 'installerController' && this.get('securityEnabled')) {
  192. this.prepareSecureConfigs();
  193. this.get('content.services').filterProperty('isSelected', true)
  194. .mapProperty('serviceName').forEach(function (serviceName) {
  195. var config = this.get('secureConfigs').findProperty('serviceName', serviceName);
  196. if (config) {
  197. this.setPrincipalValue(serviceName, config.name);
  198. }
  199. }, this);
  200. }
  201. }
  202. this.loadClusterInfo();
  203. this.loadServices();
  204. this.set('isSubmitDisabled', false);
  205. this.set('isBackBtnDisabled', false);
  206. },
  207. /**
  208. * replace whitespace character with coma between directories
  209. * @method formatProperties
  210. */
  211. formatProperties: function () {
  212. this.get('content.serviceConfigProperties').forEach(function (_configProperty) {
  213. _configProperty.value = App.config.trimProperty(_configProperty, false);
  214. });
  215. },
  216. /**
  217. * Remove unused Hive configs
  218. * @param {Ember.Enumerable} configs
  219. * @returns {Ember.Enumerable}
  220. * @method removeHiveConfigs
  221. */
  222. removeHiveConfigs: function (configs) {
  223. var hiveDb = configs.findProperty('name', 'hive_database');
  224. var hiveDbType = configs.findProperty('name', 'hive_database_type');
  225. if (hiveDbType) {
  226. var hive_properties = Em.A([]);
  227. switch (hiveDb.value) {
  228. case 'New MySQL Database':
  229. if (configs.someProperty('name', 'hive_ambari_host')) {
  230. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_ambari_host').value;
  231. }
  232. hive_properties = Em.A(['hive_existing_mysql_database', 'hive_existing_oracle_database', 'hive_existing_postgresql_database',
  233. 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_2_database']);
  234. break;
  235. case 'New PostgreSQL Database':
  236. if (configs.someProperty('name', 'hive_ambari_host')) {
  237. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_ambari_host').value;
  238. }
  239. hive_properties = Em.A(['hive_existing_mysql_database', 'hive_existing_oracle_database', 'hive_existing_postgresql_database']);
  240. break;
  241. case 'Existing MySQL Database':
  242. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_mysql_host').value;
  243. hive_properties = Em.A(['hive_ambari_database', 'hive_existing_oracle_database', 'hive_existing_postgresql_database',
  244. 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_2_database']);
  245. break;
  246. case Em.I18n.t('services.service.config.hive.oozie.postgresql'):
  247. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_postgresql_host').value;
  248. hive_properties = Em.A(['hive_ambari_database', 'hive_existing_oracle_database', 'hive_existing_mysql_database',
  249. 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_2_database']);
  250. break;
  251. case 'Existing MSSQL Server database with integrated authentication':
  252. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_mssql_server_2_host').value;
  253. hive_properties = Em.A(['hive_ambari_database', 'hive_existing_oracle_database', 'hive_existing_postgresql_database',
  254. 'hive_existing_mysql_database', 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_2_database']);
  255. break;
  256. case 'Existing MSSQL Server database with sql auth':
  257. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_mssql_server_host').value;
  258. hive_properties = Em.A(['hive_ambari_database', 'hive_existing_oracle_database', 'hive_existing_postgresql_database',
  259. 'hive_existing_mysql_database', 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_database']);
  260. break;
  261. default:
  262. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_oracle_host').value;
  263. hive_properties = Em.A(['hive_ambari_database', 'hive_existing_mysql_database', 'hive_existing_postgresql_database',
  264. 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_2_database']);
  265. break;
  266. }
  267. hive_properties.push('hive_master_hosts');
  268. hive_properties.forEach(function (property) {
  269. configs = configs.without(configs.findProperty('name', property));
  270. });
  271. }
  272. return configs;
  273. },
  274. /**
  275. * Remove unused Oozie configs
  276. * @param {Ember.Enumerable} configs
  277. * @returns {Ember.Enumerable}
  278. * @method removeOozieConfigs
  279. */
  280. removeOozieConfigs: function (configs) {
  281. var oozieDb = configs.findProperty('name', 'oozie_database');
  282. if (oozieDb) {
  283. var oozie_properties = Em.A(['oozie_ambari_host', 'oozie_ambari_database']);
  284. switch (oozieDb.value) {
  285. case 'New Derby Database':
  286. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_ambari_host').value;
  287. oozie_properties = Em.A(['oozie_ambari_database', 'oozie_existing_mysql_database', 'oozie_existing_oracle_database',
  288. 'oozie_existing_postgresql_database', 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_2_database']);
  289. break;
  290. case 'Existing MySQL Database':
  291. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_existing_mysql_host').value;
  292. oozie_properties = Em.A(['oozie_ambari_database', 'oozie_existing_oracle_database', 'oozie_derby_database',
  293. 'oozie_existing_postgresql_database', 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_2_database']);
  294. break;
  295. case Em.I18n.t('services.service.config.hive.oozie.postgresql'):
  296. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_existing_postgresql_host').value;
  297. oozie_properties = Em.A(['oozie_ambari_database', 'oozie_existing_oracle_database', 'oozie_existing_mysql_database',
  298. 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_2_database']);
  299. break;
  300. case 'Existing MSSQL Server database with integrated authentication':
  301. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_existing_mysql_host').value;
  302. oozie_properties = Em.A(['oozie_existing_oracle_database', 'oozie_existing_postgresql_database',
  303. 'oozie_existing_mysql_database', 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_2_database']);
  304. break;
  305. case 'Existing MSSQL Server database with sql auth':
  306. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_existing_mysql_host').value;
  307. oozie_properties = Em.A(['oozie_existing_oracle_database', 'oozie_existing_postgresql_database',
  308. 'oozie_existing_mysql_database', 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_database']);
  309. break;
  310. default:
  311. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_existing_oracle_host').value;
  312. oozie_properties = Em.A(['oozie_ambari_database', 'oozie_existing_mysql_database', 'oozie_derby_database',
  313. 'oozie_existing_postgresql_database', 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_2_database']);
  314. break;
  315. }
  316. oozie_properties.forEach(function (property) {
  317. configs = configs.without(configs.findProperty('name', property));
  318. });
  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 configs = configMapping.filterProperty('foreignKey', null);
  361. this.addDynamicProperties(configs);
  362. configs.forEach(function (_config) {
  363. var valueWithOverrides = this.getGlobConfigValueWithOverrides(_config.templateName, _config.value, _config.name);
  364. uiConfig.pushObject({
  365. "id": "site property",
  366. "name": _config.name,
  367. "value": valueWithOverrides.value,
  368. "filename": _config.filename,
  369. "overrides": valueWithOverrides.overrides
  370. });
  371. }, this);
  372. var dependentConfig = $.extend(true, [], configMapping.filterProperty('foreignKey'));
  373. dependentConfig.forEach(function (_config) {
  374. App.config.setConfigValue(uiConfig, this.get('content.serviceConfigProperties'), _config);
  375. if(!_config.noMatchSoSkipThisConfig)
  376. uiConfig.pushObject({
  377. "id": "site property",
  378. "name": _config._name || _config.name,
  379. "value": _config.value,
  380. "filename": _config.filename
  381. });
  382. }, this);
  383. return uiConfig;
  384. },
  385. /**
  386. * Add dynamic properties to configs
  387. * @param {Array} configs
  388. * @method addDynamicProperties
  389. */
  390. addDynamicProperties: function (configs) {
  391. var templetonHiveProperty = this.get('content.serviceConfigProperties').someProperty('name', 'templeton.hive.properties');
  392. if (!templetonHiveProperty) {
  393. configs.pushObject({
  394. "name": "templeton.hive.properties",
  395. "templateName": ["hive.metastore.uris"],
  396. "foreignKey": null,
  397. "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",
  398. "filename": "webhcat-site.xml"
  399. });
  400. }
  401. },
  402. /**
  403. * Format <code>content.hosts</code> from Object to Array
  404. * @returns {Array}
  405. * @method getRegisteredHosts
  406. */
  407. getRegisteredHosts: function () {
  408. var allHosts = this.get('content.hosts');
  409. var hosts = [];
  410. for (var hostName in allHosts) {
  411. if (allHosts.hasOwnProperty(hostName)) {
  412. if (allHosts[hostName].bootStatus == 'REGISTERED') {
  413. allHosts[hostName].hostName = allHosts[hostName].name;
  414. hosts.pushObject(allHosts[hostName]);
  415. }
  416. }
  417. }
  418. return hosts;
  419. },
  420. /**
  421. * Set all site property that are derived from other puppet-variable
  422. * @param {String} templateName
  423. * @param {String} expression
  424. * @param {String} name
  425. * @return {Object}
  426. * example: <code>{
  427. * value: '...',
  428. * overrides: [
  429. * {
  430. * value: 'v1',
  431. * hosts: ['h1', 'h2']
  432. * },
  433. * {
  434. * value: 'v2',
  435. * hosts: ['h2', 'h3']
  436. * },
  437. * ....
  438. * ]
  439. * }</code>
  440. * @method getGlobConfigValueWithOverrides
  441. */
  442. getGlobConfigValueWithOverrides: function (templateName, expression, name) {
  443. var express = expression.match(/<(.*?)>/g);
  444. var value = expression;
  445. if (express == null) {
  446. return { value: expression, overrides: []}; // if site property do not map any global property then return the value
  447. }
  448. var overrideHostToValue = {};
  449. express.forEach(function (_express) {
  450. //console.log("The value of template is: " + _express);
  451. var index = parseInt(_express.match(/\[([\d]*)(?=\])/)[1]);
  452. if (this.get('configs').someProperty('name', templateName[index])) {
  453. //console.log("The name of the variable is: " + this.get('content.serviceConfigProperties').findProperty('name', templateName[index]).name);
  454. var globalObj = this.get('configs').findProperty('name', templateName[index]);
  455. var globValue = globalObj.value;
  456. // Hack for templeton.zookeeper.hosts
  457. var preReplaceValue = null;
  458. 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
  459. preReplaceValue = value;
  460. value = App.config.replaceConfigValues(name, _express, value, globValue);
  461. }
  462. if (globalObj.overrides != null) {
  463. globalObj.overrides.forEach(function (override) {
  464. var ov = override.value;
  465. var hostsArray = override.hosts;
  466. hostsArray.forEach(function (host) {
  467. if (!(host in overrideHostToValue)) {
  468. overrideHostToValue[host] = App.config.replaceConfigValues(name, _express, preReplaceValue, ov);
  469. } else {
  470. overrideHostToValue[host] = App.config.replaceConfigValues(name, _express, overrideHostToValue[host], ov);
  471. }
  472. }, this);
  473. }, this);
  474. }
  475. } else {
  476. /*
  477. console.log("ERROR: The variable name is: " + templateName[index]);
  478. console.log("ERROR: mapped config from configMapping file has no corresponding variable in " +
  479. "content.serviceConfigProperties. Two possible reasons for the error could be: 1) The service is not selected. " +
  480. "and/OR 2) The service_config metadata file has no corresponding global var for the site property variable");
  481. */
  482. value = null;
  483. }
  484. }, this);
  485. var valueWithOverrides = {
  486. value: value,
  487. overrides: []
  488. };
  489. var overrideValueToHostMap = {};
  490. if (!jQuery.isEmptyObject(overrideHostToValue)) {
  491. for (var host in overrideHostToValue) {
  492. var hostVal = overrideHostToValue[host];
  493. if (!(hostVal in overrideValueToHostMap)) {
  494. overrideValueToHostMap[hostVal] = [];
  495. }
  496. overrideValueToHostMap[hostVal].push(host);
  497. }
  498. }
  499. for (var val in overrideValueToHostMap) {
  500. valueWithOverrides.overrides.push({
  501. value: val,
  502. hosts: overrideValueToHostMap[val]
  503. });
  504. }
  505. return valueWithOverrides;
  506. },
  507. /**
  508. * Load all info about cluster to <code>clusterInfo</code> variable
  509. * @method loadClusterInfo
  510. */
  511. loadClusterInfo: function () {
  512. //Admin name
  513. var admin = this.rawContent.findProperty('config_name', 'Admin');
  514. admin.config_value = App.db.getLoginName();
  515. console.log("STEP8: the value of content cluster name: " + App.db.getLoginName());
  516. if (admin.config_value) {
  517. this.get('clusterInfo').pushObject(Ember.Object.create(admin));
  518. }
  519. // cluster name
  520. var cluster = this.rawContent.findProperty('config_name', 'cluster');
  521. cluster.config_value = this.get('content.cluster.name');
  522. console.log("STEP8: the value of content cluster name: " + this.get('content.cluster.name'));
  523. this.get('clusterInfo').pushObject(Ember.Object.create(cluster));
  524. //hosts
  525. var newHostsCount = 0;
  526. var totalHostsCount = 0;
  527. var hosts = this.get('content.hosts');
  528. for (var hostName in hosts) {
  529. newHostsCount += ~~(!hosts[hostName].isInstalled);
  530. totalHostsCount++;
  531. }
  532. var totalHostsObj = this.rawContent.findProperty('config_name', 'hosts');
  533. totalHostsObj.config_value = totalHostsCount + ' (' + newHostsCount + ' new)';
  534. this.get('clusterInfo').pushObject(Em.Object.create(totalHostsObj));
  535. //repo
  536. if (['addHostController', 'addServiceController'].contains(this.get('content.controllerName'))) {
  537. this.loadRepoInfo();
  538. } else {
  539. // from install wizard
  540. var selectedStack = App.Stack.find().findProperty('isSelected');
  541. var allRepos = [];
  542. if (selectedStack && selectedStack.get('operatingSystems')) {
  543. selectedStack.get('operatingSystems').forEach(function (os) {
  544. if (os.get('isSelected')) {
  545. os.get('repositories').forEach(function(repo) {
  546. allRepos.push(Em.Object.create({
  547. base_url: repo.get('baseUrl'),
  548. os_type: repo.get('osType'),
  549. repo_id: repo.get('repoId')
  550. }));
  551. }, this);
  552. }
  553. }, this);
  554. }
  555. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  556. this.get('clusterInfo').set('repoInfo', allRepos);
  557. }
  558. },
  559. /**
  560. * Load repo info for add Service/Host wizard review page
  561. * @return {$.ajax|null}
  562. * @method loadRepoInfo
  563. */
  564. loadRepoInfo: function () {
  565. var nameVersionCombo = App.get('currentStackVersion').split('-');
  566. return App.ajax.send({
  567. name: 'cluster.load_repositories',
  568. sender: this,
  569. data: {
  570. stackName: nameVersionCombo[0],
  571. stackVersion: nameVersionCombo[1]
  572. },
  573. success: 'loadRepoInfoSuccessCallback',
  574. error: 'loadRepoInfoErrorCallback'
  575. });
  576. },
  577. /**
  578. * Save all repo base URL of all OS type to <code>repoInfo<code>
  579. * @param {object} data
  580. * @method loadRepoInfoSuccessCallback
  581. */
  582. loadRepoInfoSuccessCallback: function (data) {
  583. var allRepos = [];
  584. data.items.forEach(function (os) {
  585. os.repositories.forEach(function (repository) {
  586. allRepos.push(Em.Object.create({
  587. base_url: repository.Repositories.base_url,
  588. os_type: repository.Repositories.os_type,
  589. repo_id: repository.Repositories.repo_id
  590. }));
  591. });
  592. }, this);
  593. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  594. this.get('clusterInfo').set('repoInfo', allRepos);
  595. },
  596. /**
  597. * @param {object} request
  598. * @method loadRepoInfoErrorCallback
  599. */
  600. loadRepoInfoErrorCallback: function (request) {
  601. console.log('Error message is: ' + request.responseText);
  602. var allRepos = [];
  603. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  604. this.get('clusterInfo').set('repoInfo', allRepos);
  605. },
  606. /**
  607. * Load all info about services to <code>services</code> variable
  608. * @method loadServices
  609. */
  610. loadServices: function () {
  611. this.get('selectedServices').filterProperty('isHiddenOnSelectServicePage', false).forEach(function (service) {
  612. console.log('INFO: step8: Name of the service from getService function: ' + service.get('serviceName'));
  613. var serviceObj = Em.Object.create({
  614. service_name: service.get('serviceName'),
  615. display_name: service.get('displayNameOnSelectServicePage'),
  616. service_components: Em.A([])
  617. });
  618. service.get('serviceComponents').forEach(function (component) {
  619. // show clients for services that have only clients components
  620. if ((component.get('isClient') || component.get('isRequiredOnAllHosts')) && !service.get('isClientOnlyService')) return;
  621. // skip components that was hide on assign master page
  622. if (component.get('isMaster') && !component.get('isShownOnInstallerAssignMasterPage')) return;
  623. // no HA component
  624. if (component.get('isHAComponentOnly')) return;
  625. var displayName;
  626. if (component.get('isClient')) {
  627. displayName = Em.I18n.t('common.clients')
  628. } else {
  629. // remove service name from component display name
  630. displayName = App.format.role(component.get('componentName')).replace(new RegExp('^' + service.get('serviceName') + '\\s', 'i'), '');
  631. }
  632. serviceObj.get('service_components').pushObject(Em.Object.create({
  633. component_name: component.get('isClient') ? Em.I18n.t('common.client').toUpperCase() : component.get('componentName'),
  634. display_name: displayName,
  635. component_value: this.assignComponentHosts(component)
  636. }));
  637. }, this);
  638. if (service.get('customReviewHandler')) {
  639. for (var displayName in service.get('customReviewHandler')) {
  640. serviceObj.get('service_components').pushObject(Em.Object.create({
  641. display_name: displayName,
  642. component_value: this.assignComponentHosts(Em.Object.create({
  643. customHandler: service.get('customReviewHandler.' + displayName)
  644. }))
  645. }));
  646. }
  647. }
  648. this.get('services').pushObject(serviceObj);
  649. }, this);
  650. },
  651. /**
  652. * Set <code>component_value</code> property to <code>component</code>
  653. * @param {Em.Object} component
  654. * @return {String}
  655. * @method assignComponentHosts
  656. */
  657. assignComponentHosts: function (component) {
  658. var componentValue;
  659. if (component.get('customHandler')) {
  660. componentValue = this[component.get('customHandler')].call(this, component);
  661. }
  662. else {
  663. if (component.get('isMaster')) {
  664. componentValue = this.getMasterComponentValue(component.get('componentName'));
  665. }
  666. else {
  667. console.log(' --- ---INFO: step8: NOT component isMaster');
  668. var componentName = component.get('isClient') ? Em.I18n.t('common.client').toUpperCase() : component.get('componentName');
  669. var hostsLength = this.get('content.slaveComponentHosts')
  670. .findProperty('componentName', componentName).hosts.length;
  671. componentValue = hostsLength + Em.I18n.t('installer.step8.host' + ((hostsLength > 1) ? 's' : ''));
  672. }
  673. }
  674. return componentValue;
  675. },
  676. getMasterComponentValue: function (componentName) {
  677. var masterComponents = this.get('content.masterComponentHosts');
  678. var hostsCount = masterComponents.filterProperty('component', componentName).length;
  679. return stringUtils.pluralize(hostsCount,
  680. masterComponents.findProperty('component', componentName).hostName,
  681. hostsCount + ' ' + Em.I18n.t('installer.step8.hosts'));
  682. },
  683. /**
  684. * Set displayed Hive DB value based on DB type
  685. * @method loadHiveDbValue
  686. */
  687. loadHiveDbValue: function () {
  688. var db, serviceConfigPreoprties = this.get('wizardController').getDBProperty('serviceConfigProperties'),
  689. hiveDb = serviceConfigPreoprties.findProperty('name', 'hive_database');
  690. if (hiveDb.value === 'New MySQL Database') {
  691. return 'MySQL (New Database)';
  692. } else if (hiveDb.value === 'New PostgreSQL Database') {
  693. return 'Postgres (New Database)';
  694. }
  695. else {
  696. if (hiveDb.value === 'Existing MySQL Database') {
  697. db = serviceConfigPreoprties.findProperty('name', 'hive_existing_mysql_database');
  698. return db.value + ' (' + hiveDb.value + ')';
  699. }
  700. else {
  701. if (hiveDb.value === Em.I18n.t('services.service.config.hive.oozie.postgresql')) {
  702. db = serviceConfigPreoprties.findProperty('name', 'hive_existing_postgresql_database');
  703. return db.value + ' (' + hiveDb.value + ')';
  704. }
  705. else {
  706. if (hiveDb.value === 'Existing MSSQL Server database with integrated authentication') {
  707. db = serviceConfigPreoprties.findProperty('name', 'hive_existing_mssql_server_database');
  708. return db.value + ' (' + hiveDb.value + ')';
  709. }
  710. else {
  711. if (hiveDb.value === 'Existing MSSQL Server database with sql auth') {
  712. db = serviceConfigPreoprties.findProperty('name', 'hive_existing_mssql_server_2_database');
  713. return db.value + ' (' + hiveDb.value + ')';
  714. }
  715. else {
  716. // existing oracle database
  717. db = serviceConfigPreoprties.findProperty('name', 'hive_existing_oracle_database');
  718. return db.value + ' (' + hiveDb.value + ')';
  719. }
  720. }
  721. }
  722. }
  723. }
  724. },
  725. /**
  726. * Set displayed HBase master value
  727. * @param {Object} hbaseMaster
  728. * @method loadHbaseMasterValue
  729. */
  730. loadHbaseMasterValue: function (hbaseMaster) {
  731. var hbaseHostName = this.get('content.masterComponentHosts').filterProperty('component', hbaseMaster.component_name);
  732. if (hbaseHostName.length == 1) {
  733. hbaseMaster.set('component_value', hbaseHostName[0].hostName);
  734. } else {
  735. hbaseMaster.set('component_value', hbaseHostName[0].hostName + " " + Em.I18n.t('installer.step8.other').format(hbaseHostName.length - 1));
  736. }
  737. },
  738. /**
  739. * Set displayed ZooKeeper Server value
  740. * @param {Object} serverComponent
  741. * @method loadZkServerValue
  742. */
  743. loadZkServerValue: function (serverComponent) {
  744. var zkHostNames = this.get('content.masterComponentHosts').filterProperty('component', serverComponent.component_name).length;
  745. var hostSuffix;
  746. if (zkHostNames === 1) {
  747. hostSuffix = Em.I18n.t('installer.step8.host');
  748. } else {
  749. hostSuffix = Em.I18n.t('installer.step8.hosts');
  750. }
  751. serverComponent.set('component_value', zkHostNames + hostSuffix);
  752. },
  753. /**
  754. * Set displayed Oozie DB value based on DB type
  755. * @method loadOozieDbValue
  756. */
  757. loadOozieDbValue: function () {
  758. var db, oozieDb = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_database');
  759. if (oozieDb.value === 'New Derby Database') {
  760. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_derby_database');
  761. return db.value + ' (' + oozieDb.value + ')';
  762. }
  763. else {
  764. if (oozieDb.value === 'Existing MySQL Database') {
  765. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_mysql_database');
  766. return db.value + ' (' + oozieDb.value + ')';
  767. }
  768. else {
  769. if (oozieDb.value === Em.I18n.t('services.service.config.hive.oozie.postgresql')) {
  770. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_postgresql_database');
  771. return db.value + ' (' + oozieDb.value + ')';
  772. }
  773. else {
  774. if (oozieDb.value === 'Existing MSSQL Server database with integrated authentication') {
  775. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_mssql_server_database');
  776. return db.value + ' (' + oozieDb.value + ')';
  777. }
  778. else {
  779. if (oozieDb.value === 'Existing MSSQL Server database with sql auth') {
  780. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_mssql_server_2_database');
  781. return db.value + ' (' + oozieDb.value + ')';
  782. }
  783. else {
  784. // existing oracle database
  785. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_oracle_database');
  786. return db.value + ' (' + oozieDb.value + ')';
  787. }
  788. }
  789. }
  790. }
  791. }
  792. },
  793. /**
  794. * Set displayed Nagion Admin value
  795. * @method loadNagiosAdminValue
  796. */
  797. loadNagiosAdminValue: function () {
  798. var config = this.get('content.serviceConfigProperties');
  799. var adminLoginName = config.findProperty('name', 'nagios_web_login');
  800. var adminEmail = config.findProperty('name', 'nagios_contact');
  801. return adminLoginName.value + ' / (' + adminEmail.value + ')';
  802. },
  803. /**
  804. * Onclick handler for <code>next</code> button
  805. * @method submit
  806. * @return {App.ModalPopup|null}
  807. */
  808. submit: function () {
  809. if (this.get('isSubmitDisabled')) return null;
  810. if ((this.get('content.controllerName') == 'addHostController') && this.get('securityEnabled')) {
  811. var self = this;
  812. return App.showConfirmationPopup(function () {
  813. self.submitProceed();
  814. }, Em.I18n.t('installer.step8.securityConfirmationPopupBody'));
  815. } else {
  816. return this.submitProceed();
  817. }
  818. },
  819. /**
  820. * Update configurations for installed services.
  821. * Do separated PUT-request for each siteName for each service
  822. *
  823. * @param {Array} fileNamesToUpdate - file names that should be updated
  824. * @method updateConfigurations
  825. */
  826. updateConfigurations: function (fileNamesToUpdate) {
  827. var configurationController = App.router.get('mainServiceInfoConfigsController');
  828. var configs = this.get('configs').slice(0);
  829. var configsMap = [];
  830. fileNamesToUpdate.forEach(function (fileName) {
  831. if (!fileName || /^(core)/.test(fileName)) return;
  832. var tagName = 'version' + (new Date).getTime();
  833. var configsToSave = configs.filterProperty('filename', fileName);
  834. configsToSave.forEach(function (item) {
  835. item.value = App.config.trimProperty(item, false);
  836. });
  837. configsMap.push(configurationController.createSiteObj(fileName.replace(".xml", ""), tagName, configsToSave));
  838. }, this);
  839. if (!configsMap.length) return;
  840. this.applyConfigurationsToCluster(configsMap);
  841. },
  842. /**
  843. * Prepare <code>ajaxQueue</code> and start to execute it
  844. * @method submitProceed
  845. */
  846. submitProceed: function () {
  847. var self = this;
  848. this.setProperties({
  849. isSubmitDisabled: true,
  850. isBackBtnDisabled: true,
  851. clusterDeleteRequestsCompleted: 0
  852. });
  853. this.get('clusterDeleteErrorViews').clear();
  854. if (this.get('content.controllerName') == 'addHostController') {
  855. App.router.get('addHostController').setLowerStepsDisable(4);
  856. }
  857. // checkpoint the cluster status on the server so that the user can resume from where they left off
  858. switch (this.get('content.controllerName')) {
  859. case 'installerController':
  860. App.clusterStatus.setClusterStatus({
  861. clusterName: this.get('clusterName'),
  862. clusterState: 'CLUSTER_DEPLOY_PREP_2',
  863. wizardControllerName: this.get('content.controllerName'),
  864. localdb: App.db.data
  865. });
  866. break;
  867. case 'addHostController':
  868. App.clusterStatus.setClusterStatus({
  869. clusterName: this.get('clusterName'),
  870. clusterState: 'ADD_HOSTS_DEPLOY_PREP_2',
  871. wizardControllerName: this.get('content.controllerName'),
  872. localdb: App.db.data
  873. });
  874. break;
  875. case 'addServiceController':
  876. App.clusterStatus.setClusterStatus({
  877. clusterName: this.get('clusterName'),
  878. clusterState: 'ADD_SERVICES_DEPLOY_PREP_2',
  879. wizardControllerName: this.get('content.controllerName'),
  880. localdb: App.db.data
  881. });
  882. break;
  883. default:
  884. break;
  885. }
  886. // delete any existing clusters to start from a clean slate
  887. // before creating a new cluster in install wizard
  888. // TODO: modify for multi-cluster support
  889. this.getExistingClusterNames().complete(function () {
  890. var clusterNames = self.get('clusterNames');
  891. if (self.get('content.controllerName') == 'installerController' && (!App.get('testMode')) && clusterNames.length) {
  892. self.deleteClusters(clusterNames);
  893. } else {
  894. self.startDeploy();
  895. }
  896. });
  897. },
  898. /**
  899. * Get list of existing cluster names
  900. * @returns {object|null}
  901. * returns an array of existing cluster names.
  902. * returns an empty array if there are no existing clusters.
  903. * @method getExistingClusterNames
  904. */
  905. getExistingClusterNames: function () {
  906. return App.ajax.send({
  907. name: 'wizard.step8.existing_cluster_names',
  908. sender: this,
  909. success: 'getExistingClusterNamesSuccessCallBack',
  910. error: 'getExistingClusterNamesErrorCallback'
  911. });
  912. },
  913. /**
  914. * Save received list to <code>clusterNames</code>
  915. * @param {Object} data
  916. * @method getExistingClusterNamesSuccessCallBack
  917. */
  918. getExistingClusterNamesSuccessCallBack: function (data) {
  919. var clusterNames = data.items.mapProperty('Clusters.cluster_name');
  920. console.log("Got existing cluster names: " + clusterNames);
  921. this.set('clusterNames', clusterNames);
  922. },
  923. /**
  924. * If error appears, set <code>clusterNames</code> to <code>[]</code>
  925. * @method getExistingClusterNamesErrorCallback
  926. */
  927. getExistingClusterNamesErrorCallback: function () {
  928. console.log("Failed to get existing cluster names");
  929. this.set('clusterNames', []);
  930. },
  931. /**
  932. * Delete cluster by name
  933. * One request for one cluster!
  934. * @param {string[]} clusterNames
  935. * @method deleteClusters
  936. */
  937. deleteClusters: function (clusterNames) {
  938. this.get('clusterDeleteErrorViews').clear();
  939. clusterNames.forEach(function (clusterName, index) {
  940. App.ajax.send({
  941. name: 'common.delete.cluster',
  942. sender: this,
  943. data: {
  944. name: clusterName,
  945. isLast: index == clusterNames.length - 1
  946. },
  947. success: 'deleteClusterSuccessCallback',
  948. error: 'deleteClusterErrorCallback'
  949. });
  950. }, this);
  951. },
  952. /**
  953. * Method to execute after successful cluster deletion
  954. * @method deleteClusterSuccessCallback
  955. */
  956. deleteClusterSuccessCallback: function () {
  957. this.incrementProperty('clusterDeleteRequestsCompleted');
  958. if (this.get('isAllClusterDeleteRequestsCompleted')) {
  959. if (this.get('clusterDeleteErrorViews.length')) {
  960. this.showDeleteClustersErrorPopup();
  961. } else {
  962. this.startDeploy();
  963. }
  964. }
  965. },
  966. /**
  967. * Method to execute after failed cluster deletion
  968. * @param {object} request
  969. * @param {string} ajaxOptions
  970. * @param {string} error
  971. * @param {object} opt
  972. * @method deleteClusterErrorCallback
  973. */
  974. deleteClusterErrorCallback: function (request, ajaxOptions, error, opt) {
  975. this.incrementProperty('clusterDeleteRequestsCompleted');
  976. try {
  977. var json = $.parseJSON(request.responseText);
  978. var message = json.message;
  979. } catch (err) {
  980. }
  981. this.get('clusterDeleteErrorViews').pushObject(App.AjaxDefaultErrorPopupBodyView.create({
  982. url: opt.url,
  983. type: opt.type,
  984. status: request.status,
  985. message: message
  986. }));
  987. if (this.get('isAllClusterDeleteRequestsCompleted')) {
  988. this.showDeleteClustersErrorPopup();
  989. }
  990. },
  991. /**
  992. * Show error popup if cluster deletion failed
  993. * @method showDeleteClustersErrorPopup
  994. */
  995. showDeleteClustersErrorPopup: function () {
  996. var self = this;
  997. this.setProperties({
  998. isSubmitDisabled: false,
  999. isBackBtnDisabled: false
  1000. });
  1001. App.ModalPopup.show({
  1002. header: Em.I18n.t('common.error'),
  1003. secondary: false,
  1004. onPrimary: function () {
  1005. this.hide();
  1006. },
  1007. bodyClass: Em.ContainerView.extend({
  1008. childViews: self.get('clusterDeleteErrorViews')
  1009. })
  1010. });
  1011. },
  1012. /**
  1013. * Start deploy process
  1014. * @method startDeploy
  1015. */
  1016. startDeploy: function () {
  1017. this.createCluster();
  1018. this.createSelectedServices();
  1019. if (this.get('content.controllerName') !== 'addHostController') {
  1020. if (this.get('wizardController').getDBProperty('fileNamesToUpdate') && this.get('wizardController').getDBProperty('fileNamesToUpdate').length) {
  1021. this.updateConfigurations(this.get('wizardController').getDBProperty('fileNamesToUpdate'));
  1022. }
  1023. this.createConfigurations();
  1024. this.applyConfigurationsToCluster(this.get('serviceConfigTags'));
  1025. }
  1026. this.createComponents();
  1027. this.registerHostsToCluster();
  1028. this.createConfigurationGroups();
  1029. this.createMasterHostComponents();
  1030. this.createSlaveAndClientsHostComponents();
  1031. if (this.get('content.controllerName') === 'addServiceController') {
  1032. this.createAdditionalClientComponents();
  1033. }
  1034. this.createAdditionalHostComponents();
  1035. this.set('ajaxQueueLength', this.get('ajaxRequestsQueue.queue.length'));
  1036. this.get('ajaxRequestsQueue').start();
  1037. },
  1038. /**
  1039. * *******************************************************************
  1040. * The following create* functions are called upon submitting Step 8.
  1041. * *******************************************************************
  1042. */
  1043. /**
  1044. * Create cluster using selected stack version
  1045. * Queued request
  1046. * @method createCluster
  1047. */
  1048. createCluster: function () {
  1049. if (this.get('content.controllerName') !== 'installerController') return;
  1050. var stackVersion = (this.get('content.installOptions.localRepo')) ? App.currentStackVersion.replace(/(-\d+(\.\d)*)/ig, "Local$&") : App.currentStackVersion;
  1051. this.addRequestToAjaxQueue({
  1052. name: 'wizard.step8.create_cluster',
  1053. data: {
  1054. data: JSON.stringify({ "Clusters": {"version": stackVersion }})
  1055. },
  1056. success: 'createClusterSuccess'
  1057. });
  1058. },
  1059. createClusterSuccess: function (data, xhr, params) {
  1060. App.set('clusterName', params.cluster)
  1061. },
  1062. /**
  1063. * Create selected to install services
  1064. * Queued request
  1065. * Skipped if no services where selected!
  1066. * @method createSelectedServices
  1067. */
  1068. createSelectedServices: function () {
  1069. var data = this.createSelectedServicesData();
  1070. if (!data.length) return;
  1071. this.addRequestToAjaxQueue({
  1072. name: 'wizard.step8.create_selected_services',
  1073. data: {
  1074. data: JSON.stringify(data)
  1075. }
  1076. });
  1077. },
  1078. /**
  1079. * Format data for <code>createSelectedServices</code> request
  1080. * @returns {Object[]}
  1081. * @method createSelectedServicesData
  1082. */
  1083. createSelectedServicesData: function () {
  1084. return this.get('selectedServices').map(function (_service) {
  1085. return {"ServiceInfo": { "service_name": _service.get('serviceName') }};
  1086. });
  1087. },
  1088. /**
  1089. * Create components for selected services
  1090. * Queued requests
  1091. * One request for each service!
  1092. * @method createComponents
  1093. */
  1094. createComponents: function () {
  1095. var serviceComponents = App.StackServiceComponent.find();
  1096. this.get('selectedServices').forEach(function (_service) {
  1097. var serviceName = _service.get('serviceName');
  1098. var componentsData = serviceComponents.filterProperty('serviceName', serviceName).map(function (_component) {
  1099. return { "ServiceComponentInfo": { "component_name": _component.get('componentName') } };
  1100. });
  1101. // Service must be specified in terms of a query for creating multiple components at the same time.
  1102. // See AMBARI-1018.
  1103. this.addRequestToAjaxQueue({
  1104. name: 'wizard.step8.create_components',
  1105. data: {
  1106. data: JSON.stringify({"components": componentsData}),
  1107. serviceName: serviceName
  1108. }
  1109. });
  1110. }, this);
  1111. },
  1112. /**
  1113. * Error callback for new service component request
  1114. * So, if component doesn't exist we should create it
  1115. * @param {object} request
  1116. * @param {object} ajaxOptions
  1117. * @param {string} error
  1118. * @param {object} opt
  1119. * @param {object} params
  1120. * @method newServiceComponentErrorCallback
  1121. */
  1122. newServiceComponentErrorCallback: function (request, ajaxOptions, error, opt, params) {
  1123. this.addRequestToAjaxQueue({
  1124. name: 'wizard.step8.create_components',
  1125. data: {
  1126. serviceName: params.serviceName,
  1127. data: JSON.stringify({
  1128. "components": [
  1129. {
  1130. "ServiceComponentInfo": {
  1131. "component_name": params.componentName
  1132. }
  1133. }
  1134. ]
  1135. })
  1136. }
  1137. });
  1138. },
  1139. /**
  1140. * Register hosts
  1141. * Queued request
  1142. * @method registerHostsToCluster
  1143. */
  1144. registerHostsToCluster: function () {
  1145. var data = this.createRegisterHostData();
  1146. if (!data.length) return;
  1147. this.addRequestToAjaxQueue({
  1148. name: 'wizard.step8.register_host_to_cluster',
  1149. data: {
  1150. data: JSON.stringify(data)
  1151. }
  1152. });
  1153. },
  1154. /**
  1155. * Format request-data for <code>registerHostsToCluster</code>
  1156. * @returns {Object}
  1157. * @method createRegisterHostData
  1158. */
  1159. createRegisterHostData: function () {
  1160. return this.getRegisteredHosts().filterProperty('isInstalled', false).map(function (host) {
  1161. return {"Hosts": { "host_name": host.hostName}};
  1162. });
  1163. },
  1164. /**
  1165. * Register new master components
  1166. * @uses registerHostsToComponent
  1167. * @method createMasterHostComponents
  1168. */
  1169. createMasterHostComponents: function () {
  1170. // create master components for only selected services.
  1171. var selectedMasterComponents = this.get('content.masterComponentHosts').filter(function (_component) {
  1172. return this.get('selectedServices').mapProperty('serviceName').contains(_component.serviceId)
  1173. }, this);
  1174. selectedMasterComponents.mapProperty('component').uniq().forEach(function (component) {
  1175. var hostNames = selectedMasterComponents.filterProperty('component', component).filterProperty('isInstalled', false).mapProperty('hostName');
  1176. this.registerHostsToComponent(hostNames, component);
  1177. }, this);
  1178. },
  1179. getClientsToMasterMap: function () {
  1180. var clientNames = App.StackServiceComponent.find().filterProperty('isClient').mapProperty('componentName'),
  1181. clientsMap = {},
  1182. dependedComponents = App.StackServiceComponent.find().filterProperty('isMaster');
  1183. clientNames.forEach(function (clientName) {
  1184. clientsMap[clientName] = Em.A([]);
  1185. dependedComponents.forEach(function (component) {
  1186. if (component.get('dependencies').mapProperty('componentName').contains(clientName)) clientsMap[clientName].push(component.get('componentName'));
  1187. });
  1188. if (!clientsMap[clientName].length) delete clientsMap[clientName];
  1189. });
  1190. return clientsMap;
  1191. },
  1192. /**
  1193. * Register slave components and clients
  1194. * @uses registerHostsToComponent
  1195. * @method createSlaveAndClientsHostComponents
  1196. */
  1197. createSlaveAndClientsHostComponents: function () {
  1198. var masterHosts = this.get('content.masterComponentHosts');
  1199. var slaveHosts = this.get('content.slaveComponentHosts');
  1200. var clients = this.get('content.clients').filterProperty('isInstalled', false);
  1201. /**
  1202. * Determines on which hosts client should be installed (based on availability of master components on hosts)
  1203. * @type {Object}
  1204. * Format:
  1205. * <code>
  1206. * {
  1207. * CLIENT1: Em.A([MASTER1, MASTER2, ...]),
  1208. * CLIENT2: Em.A([MASTER3, MASTER1, ...])
  1209. * ...
  1210. * }
  1211. * </code>
  1212. */
  1213. var clientsToMasterMap = this.getClientsToMasterMap();
  1214. slaveHosts.forEach(function (_slave) {
  1215. if (_slave.componentName !== 'CLIENT') {
  1216. var hostNames = _slave.hosts.filterProperty('isInstalled', false).mapProperty('hostName');
  1217. this.registerHostsToComponent(hostNames, _slave.componentName);
  1218. }
  1219. else {
  1220. clients.forEach(function (_client) {
  1221. var hostNames = _slave.hosts.mapProperty('hostName');
  1222. // The below logic to install clients to existing/New master hosts should not be applied to Add Host wizard.
  1223. // This is with the presumption that Add Host controller does not add any new Master component to the cluster
  1224. if (this.get('content.controllerName') !== 'addHostController') {
  1225. if (clientsToMasterMap[_client.component_name]) {
  1226. clientsToMasterMap[_client.component_name].forEach(function (componentName) {
  1227. masterHosts.filterProperty('component', componentName).forEach(function (_masterHost) {
  1228. hostNames.pushObject(_masterHost.hostName);
  1229. });
  1230. });
  1231. }
  1232. }
  1233. hostNames = hostNames.uniq();
  1234. this.registerHostsToComponent(hostNames, _client.component_name);
  1235. }, this);
  1236. }
  1237. }, this);
  1238. },
  1239. /**
  1240. * This function is specific to addServiceController
  1241. * Newly introduced master components requires some existing client components to be hosted along with them
  1242. */
  1243. createAdditionalClientComponents: function () {
  1244. var masterHosts = this.get('content.masterComponentHosts');
  1245. var clientsToMasterMap = this.getClientsToMasterMap();
  1246. var installedClients = [];
  1247. // Get all the installed Client components
  1248. this.get('content.services').filterProperty('isInstalled').forEach(function (_service) {
  1249. var serviceClients = App.StackServiceComponent.find().filterProperty('serviceName', _service.get('serviceName')).filterProperty('isClient');
  1250. serviceClients.forEach(function (client) {
  1251. installedClients.push(client.get('componentName'));
  1252. }, this);
  1253. }, this);
  1254. // Check if there is a dependency for being co-hosted between existing client and selected new master
  1255. installedClients.forEach(function (_clientName) {
  1256. if (clientsToMasterMap[_clientName]) {
  1257. var hostNames = [];
  1258. clientsToMasterMap[_clientName].forEach(function (componentName) {
  1259. masterHosts.filterProperty('component', componentName).filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1260. hostNames.pushObject(_masterHost.hostName);
  1261. }, this);
  1262. }, this);
  1263. hostNames = hostNames.uniq();
  1264. if (hostNames.length > 0) {
  1265. this.get('content.additionalClients').pushObject({hostNames: hostNames, componentName: _clientName});
  1266. // If a dependency for being co-hosted is derived between existing client and selected new master but that
  1267. // dependency is already satisfied in the cluster then disregard the derived dependency
  1268. this.removeClientsFromList(_clientName, hostNames);
  1269. this.registerHostsToComponent(hostNames, _clientName);
  1270. }
  1271. }
  1272. }, this);
  1273. },
  1274. /**
  1275. *
  1276. * @param clientName
  1277. * @param hostList
  1278. */
  1279. removeClientsFromList: function (clientName, hostList) {
  1280. var clientHosts = [];
  1281. var installedHosts = this.get('content.hosts');
  1282. for (var hostName in installedHosts) {
  1283. if (installedHosts[hostName].isInstalled) {
  1284. if (installedHosts[hostName].hostComponents.mapProperty('HostRoles.component_name').contains(clientName)) {
  1285. clientHosts.push(hostName);
  1286. }
  1287. }
  1288. }
  1289. if (clientHosts.length > 0) {
  1290. clientHosts.forEach(function (hostName) {
  1291. if (hostList.contains(hostName)) {
  1292. hostList.splice(hostList.indexOf(hostName), 1);
  1293. }
  1294. }, this);
  1295. }
  1296. },
  1297. /**
  1298. * Register additional components
  1299. * Based on availability of some services
  1300. * @uses registerHostsToComponent
  1301. * @method createAdditionalHostComponents
  1302. */
  1303. createAdditionalHostComponents: function () {
  1304. var masterHosts = this.get('content.masterComponentHosts');
  1305. // add all components with cardinality == ALL of selected services
  1306. var registeredHosts = this.getRegisteredHosts();
  1307. var notInstalledHosts = registeredHosts.filterProperty('isInstalled', false);
  1308. this.get('content.services').filterProperty('isSelected').forEach(function (service) {
  1309. service.get('serviceComponents').filterProperty('isRequiredOnAllHosts').forEach(function (component) {
  1310. if (service.get('isInstalled') && notInstalledHosts.length) {
  1311. this.registerHostsToComponent(notInstalledHosts.mapProperty('hostName'), component.get('componentName'));
  1312. } else if (!service.get('isInstalled') && registeredHosts.length) {
  1313. this.registerHostsToComponent(registeredHosts.mapProperty('hostName'), component.get('componentName'));
  1314. }
  1315. }, this);
  1316. }, this);
  1317. // add MySQL Server if Hive is selected
  1318. var hiveService = this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).findProperty('serviceName', 'HIVE');
  1319. if (hiveService) {
  1320. var hiveDb = this.get('content.serviceConfigProperties').findProperty('name', 'hive_database');
  1321. if (hiveDb.value == "New MySQL Database") {
  1322. this.registerHostsToComponent(masterHosts.filterProperty('component', 'HIVE_SERVER').mapProperty('hostName'), 'MYSQL_SERVER');
  1323. } else if (hiveDb.value === "New PostgreSQL Database") {
  1324. this.registerHostsToComponent(masterHosts.filterProperty('component', 'HIVE_SERVER').mapProperty('hostName'), 'POSTGRESQL_SERVER');
  1325. }
  1326. }
  1327. },
  1328. /**
  1329. * Register component to hosts
  1330. * Queued request
  1331. * @param {String[]} hostNames
  1332. * @param {String} componentName
  1333. * @method registerHostsToComponent
  1334. */
  1335. registerHostsToComponent: function (hostNames, componentName) {
  1336. if (!hostNames.length) return;
  1337. var queryStr = '';
  1338. hostNames.forEach(function (hostName) {
  1339. queryStr += 'Hosts/host_name=' + hostName + '|';
  1340. });
  1341. //slice off last symbol '|'
  1342. queryStr = queryStr.slice(0, -1);
  1343. var data = {
  1344. "RequestInfo": {
  1345. "query": queryStr
  1346. },
  1347. "Body": {
  1348. "host_components": [
  1349. {
  1350. "HostRoles": {
  1351. "component_name": componentName
  1352. }
  1353. }
  1354. ]
  1355. }
  1356. };
  1357. this.addRequestToAjaxQueue({
  1358. name: 'wizard.step8.register_host_to_component',
  1359. data: {
  1360. data: JSON.stringify(data)
  1361. }
  1362. });
  1363. },
  1364. /**
  1365. * Compare generated config object with current configs that were filled
  1366. * on "Customize Services" page.
  1367. *
  1368. * @param {Object} properties - generated by createSiteObj|createCoreSiteObj
  1369. * @param {Array} configs - current configs to compare
  1370. * @return {Boolean}
  1371. * @method isConfigsChanged
  1372. **/
  1373. isConfigsChanged: function (properties, configs) {
  1374. var isChanged = false;
  1375. for (var property in properties) {
  1376. var config = configs.findProperty('name', property);
  1377. // if config not found then it's looks like a new config
  1378. if (!config) {
  1379. isChanged = true;
  1380. } else {
  1381. if (!config.hasInitialValue || config.isNotDefaultValue) {
  1382. isChanged = true;
  1383. }
  1384. }
  1385. }
  1386. return isChanged;
  1387. },
  1388. /**
  1389. * Create config objects for cluster and services
  1390. * @method createConfigurations
  1391. */
  1392. createConfigurations: function () {
  1393. var selectedServices = this.get('selectedServices');
  1394. var coreSiteObject = this.createCoreSiteObj();
  1395. var tag = 'version1';
  1396. var clusterSiteObj = this.createSiteObj('cluster-env', tag);
  1397. if (this.get('content.controllerName') == 'installerController') {
  1398. this.get('serviceConfigTags').pushObject(clusterSiteObj);
  1399. }
  1400. if (this.get('content.controllerName') == 'addServiceController') {
  1401. tag = 'version' + (new Date).getTime();
  1402. coreSiteObject.tag = tag;
  1403. var coreSiteConfigs = this.get('configs').filterProperty('filename', 'core-site.xml');
  1404. if (this.isConfigsChanged(coreSiteObject.properties, coreSiteConfigs)) {
  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. data: apiObject
  1738. }
  1739. });
  1740. }
  1741. });