step8_controller.js 70 KB

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