step8_controller.js 66 KB

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