step8_controller.js 68 KB

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