step8_controller.js 66 KB

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