step8_controller.js 70 KB

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