step8_controller.js 66 KB

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