step8_controller.js 69 KB

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