step8_controller.js 69 KB

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