step7_controller.js 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343
  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. /**
  20. * By Step 7, we have the following information stored in App.db and set on this
  21. * controller by the router.
  22. *
  23. * selectedServices: App.db.selectedServices (the services that the user selected in Step 4)
  24. * masterComponentHosts: App.db.masterComponentHosts (master-components-to-hosts mapping the user selected in Step 5)
  25. * slaveComponentHosts: App.db.slaveComponentHosts (slave-components-to-hosts mapping the user selected in Step 6)
  26. *
  27. */
  28. App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, {
  29. name: 'wizardStep7Controller',
  30. /**
  31. * Contains all field properties that are viewed in this step
  32. * @type {object[]}
  33. */
  34. stepConfigs: [],
  35. selectedService: null,
  36. slaveHostToGroup: null,
  37. addMiscTabToPage: true,
  38. /**
  39. * Is Submit-click processing now
  40. * @type {bool}
  41. */
  42. submitButtonClicked: false,
  43. isRecommendedLoaded: false,
  44. /**
  45. * used in services_config.js view to mark a config with security icon
  46. */
  47. secureConfigs: function () {
  48. if (App.get('isHadoop2Stack')) {
  49. return require('data/HDP2/secure_mapping');
  50. } else {
  51. return require('data/secure_mapping');
  52. }
  53. }.property('isHadoop2Stack'),
  54. /**
  55. * config categories with secure properties
  56. * use only for add service wizard when security is enabled;
  57. */
  58. secureServices: function () {
  59. return (App.get('isHadoop2Stack')) ?
  60. $.extend(true, [], require('data/HDP2/secure_configs')) :
  61. $.extend(true, [], require('data/secure_configs'));
  62. }.property('App.isHadoop2Stack'),
  63. /**
  64. * uses for add service - find out is security is enabled
  65. */
  66. securityEnabled: function () {
  67. return App.router.get('mainAdminSecurityController.securityEnabled');
  68. }.property('App.router.mainAdminSecurityController.securityEnabled'),
  69. /**
  70. * If miscConfigChange Modal is shown
  71. * @type {bool}
  72. */
  73. miscModalVisible: false,
  74. gangliaAvailableSpace: null,
  75. /**
  76. * @type {string}
  77. */
  78. gangliaMoutDir: '/',
  79. overrideToAdd: null,
  80. /**
  81. * Is installer controller used
  82. * @type {bool}
  83. */
  84. isInstaller: true,
  85. /**
  86. * List of config groups
  87. * @type {object[]}
  88. */
  89. configGroups: [],
  90. /**
  91. * List of config group to be deleted
  92. * @type {object[]}
  93. */
  94. groupsToDelete: [],
  95. preSelectedConfigGroup: null,
  96. /**
  97. * Currently selected config group
  98. * @type {object}
  99. */
  100. selectedConfigGroup: null,
  101. /**
  102. * Config tags of actually installed services
  103. * @type {array}
  104. */
  105. serviceConfigTags: [],
  106. /**
  107. * Are advanced configs loaded
  108. * @type {bool}
  109. */
  110. isAdvancedConfigLoaded: true,
  111. /**
  112. * Are applied to service configs loaded
  113. * @type {bool}
  114. */
  115. isAppliedConfigLoaded: true,
  116. isConfigsLoaded: function () {
  117. return (this.get('isAdvancedConfigLoaded') && this.get('isAppliedConfigLoaded'));
  118. }.property('isAdvancedConfigLoaded', 'isAppliedConfigLoaded'),
  119. /**
  120. * Should Next-button be disabled
  121. * @type {bool}
  122. */
  123. isSubmitDisabled: function () {
  124. if (!this.get('stepConfigs.length')) return true;
  125. if (this.get('submitButtonClicked')) return true;
  126. return (!this.get('stepConfigs').filterProperty('showConfig', true).everyProperty('errorCount', 0) || this.get("miscModalVisible"));
  127. }.property('stepConfigs.@each.errorCount', 'miscModalVisible', 'submitButtonClicked'),
  128. /**
  129. * List of selected to install service names
  130. * @type {string[]}
  131. */
  132. selectedServiceNames: function () {
  133. return this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).mapProperty('serviceName');
  134. }.property('content.services', 'content.services.@each.isSelected', 'content.services.@each.isInstalled', 'content.stacks.@each.isSelected').cacheable(),
  135. /**
  136. * List of installed and selected to install service names
  137. * @type {string[]}
  138. */
  139. allSelectedServiceNames: function () {
  140. return this.get('content.services').filter(function (service) {
  141. return service.get('isInstalled') || service.get('isSelected');
  142. }).mapProperty('serviceName');
  143. }.property('content.services', 'content.services.@each.isSelected', 'content.services.@each.isInstalled', 'content.stacks.@each.isSelected').cacheable(),
  144. /**
  145. * List of installed service names
  146. * @type {string[]}
  147. */
  148. installedServiceNames: function () {
  149. var serviceNames = this.get('content.services').filterProperty('isInstalled').mapProperty('serviceName');
  150. if (this.get('content.controllerName') !== 'installerController') {
  151. serviceNames = serviceNames.filter(function (_serviceName) {
  152. return !App.get('services.noConfigTypes').contains(_serviceName);
  153. });
  154. }
  155. return serviceNames;
  156. }.property('content.services').cacheable(),
  157. /**
  158. * List of master components
  159. * @type {Ember.Enumerable}
  160. */
  161. masterComponentHosts: function () {
  162. return this.get('content.masterComponentHosts');
  163. }.property('content.masterComponentHosts'),
  164. /**
  165. * List of slave components
  166. * @type {Ember.Enumerable}
  167. */
  168. slaveComponentHosts: function () {
  169. return this.get('content.slaveGroupProperties');
  170. }.property('content.slaveGroupProperties', 'content.slaveComponentHosts'),
  171. customData: [],
  172. /**
  173. * Filter text will be located here
  174. * @type {string}
  175. */
  176. filter: '',
  177. /**
  178. * List of filters for config properties to populate filter combobox
  179. */
  180. propertyFilters: [
  181. {
  182. attributeName: 'isOverridden',
  183. attributeValue: true,
  184. caption: 'common.combobox.dropdown.overridden'
  185. },
  186. {
  187. attributeName: 'isFinal',
  188. attributeValue: true,
  189. caption: 'common.combobox.dropdown.final'
  190. },
  191. {
  192. attributeName: 'isValid',
  193. attributeValue: false,
  194. caption: 'common.combobox.dropdown.issues'
  195. },
  196. {
  197. attributeName: 'warn',
  198. attributeValue: true,
  199. caption: 'common.combobox.dropdown.warnings'
  200. }
  201. ],
  202. /**
  203. * Dropdown menu items in filter combobox
  204. */
  205. filterColumns: function () {
  206. return this.get('propertyFilters').map(function (filter) {
  207. return Ember.Object.create({
  208. attributeName: filter.attributeName,
  209. attributeValue: filter.attributeValue,
  210. name: this.t(filter.caption),
  211. selected: false
  212. });
  213. }, this);
  214. }.property('propertyFilters'),
  215. /**
  216. * Clear controller's properties:
  217. * <ul>
  218. * <li>stepConfigs</li>
  219. * <li>filter</li>
  220. * </ul>
  221. * and desect all <code>filterColumns</code>
  222. * @method clearStep
  223. */
  224. clearStep: function () {
  225. this.set('configValidationGlobalMessage', []);
  226. this.set('submitButtonClicked', false);
  227. this.set('isSubmitDisabled', true);
  228. this.set('isRecommendedLoaded', false);
  229. this.get('stepConfigs').clear();
  230. this.set('filter', '');
  231. this.get('filterColumns').setEach('selected', false);
  232. },
  233. /**
  234. * Load config groups for installed services
  235. * One ajax-request for each service
  236. * @param {string[]} servicesNames
  237. * @method loadInstalledServicesConfigGroups
  238. */
  239. loadInstalledServicesConfigGroups: function (servicesNames) {
  240. servicesNames.forEach(function (serviceName) {
  241. App.ajax.send({
  242. name: 'config.tags_and_groups',
  243. sender: this,
  244. data: {
  245. serviceName: serviceName,
  246. serviceConfigsDef: App.config.get('preDefinedServiceConfigs').findProperty('serviceName', serviceName)
  247. },
  248. success: 'loadServiceTagsSuccess'
  249. });
  250. }, this);
  251. },
  252. /**
  253. * Create site to tag map. Format:
  254. * <code>
  255. * {
  256. * site1: tag1,
  257. * site1: tag2,
  258. * site2: tag3
  259. * ...
  260. * }
  261. * </code>
  262. * @param {object} desired_configs
  263. * @param {string[]} sites
  264. * @returns {object}
  265. * @private
  266. * @method _createSiteToTagMap
  267. */
  268. _createSiteToTagMap: function (desired_configs, sites) {
  269. var siteToTagMap = {};
  270. for (var site in desired_configs) {
  271. if (desired_configs.hasOwnProperty(site)) {
  272. if (!!sites[site]) {
  273. siteToTagMap[site] = desired_configs[site].tag;
  274. }
  275. }
  276. }
  277. return siteToTagMap;
  278. },
  279. /**
  280. * Load config groups success callback
  281. * @param {object} data
  282. * @param {object} opt
  283. * @param {object} params
  284. * @method loadServiceTagsSuccess
  285. */
  286. loadServiceTagsSuccess: function (data, opt, params) {
  287. var serviceName = params.serviceName,
  288. service = this.get('stepConfigs').findProperty('serviceName', serviceName),
  289. defaultConfigGroupHosts = this.get('wizardController.allHosts').mapProperty('hostName'),
  290. siteToTagMap = this._createSiteToTagMap(data.Clusters.desired_configs, params.serviceConfigsDef.get('configTypes')),
  291. selectedConfigGroup,
  292. manageCGController = App.router.get('manageConfigGroupsController');
  293. this.set('loadedClusterSiteToTagMap', siteToTagMap);
  294. //parse loaded config groups
  295. var configGroups = [];
  296. if (data.config_groups.length) {
  297. data.config_groups.forEach(function (item) {
  298. item = item.ConfigGroup;
  299. if (item.tag === serviceName) {
  300. var groupHosts = item.hosts.mapProperty('host_name');
  301. var newConfigGroup = App.ConfigGroup.create({
  302. id: item.id,
  303. name: item.group_name,
  304. description: item.description,
  305. isDefault: false,
  306. parentConfigGroup: null,
  307. service: App.Service.find().findProperty('serviceName', item.tag),
  308. hosts: groupHosts,
  309. publicHosts: manageCGController.hostsToPublic(groupHosts),
  310. configSiteTags: []
  311. });
  312. groupHosts.forEach(function (host) {
  313. defaultConfigGroupHosts = defaultConfigGroupHosts.without(host);
  314. }, this);
  315. item.desired_configs.forEach(function (config) {
  316. newConfigGroup.configSiteTags.push(App.ConfigSiteTag.create({
  317. site: config.type,
  318. tag: config.tag
  319. }));
  320. }, this);
  321. configGroups.push(newConfigGroup);
  322. }
  323. }, this);
  324. }
  325. var defaultConfigGroup = App.ConfigGroup.create({
  326. name: App.format.role(serviceName) + " Default",
  327. description: "Default cluster level " + serviceName + " configuration",
  328. isDefault: true,
  329. hosts: defaultConfigGroupHosts,
  330. publicHosts: manageCGController.hostsToPublic(defaultConfigGroupHosts),
  331. parentConfigGroup: null,
  332. service: Em.Object.create({
  333. id: serviceName
  334. }),
  335. serviceName: serviceName,
  336. configSiteTags: []
  337. });
  338. if (!selectedConfigGroup) {
  339. selectedConfigGroup = defaultConfigGroup;
  340. }
  341. configGroups = configGroups.sortProperty('name');
  342. configGroups.unshift(defaultConfigGroup);
  343. service.set('configGroups', configGroups);
  344. var loadedGroupToOverrideSiteToTagMap = {};
  345. var configGroupsWithOverrides = selectedConfigGroup.get('isDefault') ? service.get('configGroups') : [selectedConfigGroup];
  346. configGroupsWithOverrides.forEach(function (item) {
  347. var groupName = item.get('name');
  348. loadedGroupToOverrideSiteToTagMap[groupName] = {};
  349. item.get('configSiteTags').forEach(function (siteTag) {
  350. var site = siteTag.get('site');
  351. loadedGroupToOverrideSiteToTagMap[groupName][site] = siteTag.get('tag');
  352. }, this);
  353. }, this);
  354. this.set('preSelectedConfigGroup', selectedConfigGroup);
  355. App.config.loadServiceConfigGroupOverrides(service.get('configs'), loadedGroupToOverrideSiteToTagMap, service.get('configGroups'), this.onLoadOverrides, this);
  356. },
  357. onLoadOverrides: function (configs) {
  358. var serviceName = configs[0].serviceName,
  359. service = this.get('stepConfigs').findProperty('serviceName', serviceName);
  360. var serviceConfig = App.config.createServiceConfig(serviceName);
  361. if (serviceConfig.get('serviceName') === 'HDFS') {
  362. App.config.OnNnHAHideSnn(serviceConfig);
  363. }
  364. service.set('selectedConfigGroup', this.get('preSelectedConfigGroup'));
  365. this.loadComponentConfigs(service.get('configs'), serviceConfig, service);
  366. service.set('configs', serviceConfig.get('configs'));
  367. },
  368. /**
  369. * By default <code>value</code>-property is string "true|false".
  370. * Should update it to boolean type
  371. * Also affects <code>defaultValue</code>
  372. * @param {Ember.Object} serviceConfigProperty
  373. * @returns {Ember.Object} Updated config-object
  374. * @method _updateValueForCheckBoxConfig
  375. */
  376. _updateValueForCheckBoxConfig: function (serviceConfigProperty) {
  377. var v = serviceConfigProperty.get('value');
  378. switch (serviceConfigProperty.get('value')) {
  379. case 'true':
  380. v = true;
  381. break;
  382. case 'false':
  383. v = false;
  384. break;
  385. }
  386. serviceConfigProperty.setProperties({value: v, defaultValue: v});
  387. return serviceConfigProperty;
  388. },
  389. /**
  390. * Set <code>isEditable</code>-property to <code>serviceConfigProperty</code>
  391. * Based on user's permissions and selected config group
  392. * @param {Ember.Object} serviceConfigProperty
  393. * @param {bool} defaultGroupSelected
  394. * @returns {Ember.Object} Updated config-object
  395. * @method _updateIsEditableFlagForConfig
  396. */
  397. _updateIsEditableFlagForConfig: function (serviceConfigProperty, defaultGroupSelected) {
  398. if (App.isAccessible('ADMIN')) {
  399. if (defaultGroupSelected && !this.get('isHostsConfigsPage') && !Em.get(serviceConfigProperty, 'group')) {
  400. serviceConfigProperty.set('isEditable', serviceConfigProperty.get('isReconfigurable'));
  401. } else if (Em.get(serviceConfigProperty, 'group') && Em.get(serviceConfigProperty, 'group.name') == this.get('selectedConfigGroup.name')) {
  402. serviceConfigProperty.set('isEditable', true);
  403. } else {
  404. serviceConfigProperty.set('isEditable', false);
  405. }
  406. }
  407. else {
  408. serviceConfigProperty.set('isEditable', false);
  409. }
  410. return serviceConfigProperty;
  411. },
  412. /**
  413. * Set <code>overrides</code>-property to <code>serviceConfigProperty<code>
  414. * @param {Ember.Object} serviceConfigProperty
  415. * @param {Ember.Object} component
  416. * @return {Ember.Object} Updated config-object
  417. * @method _updateOverridesForConfig
  418. */
  419. _updateOverridesForConfig: function (serviceConfigProperty, component) {
  420. var overrides = serviceConfigProperty.get('overrides');
  421. if (Em.isNone(overrides)) {
  422. serviceConfigProperty.set('overrides', Em.A([]));
  423. return serviceConfigProperty;
  424. }
  425. serviceConfigProperty.set('overrides', null);
  426. var defaultGroupSelected = component.get('selectedConfigGroup.isDefault');
  427. // Wrap each override to App.ServiceConfigProperty
  428. overrides.forEach(function (override) {
  429. var newSCP = App.ServiceConfigProperty.create(serviceConfigProperty);
  430. newSCP.set('value', override.value);
  431. newSCP.set('isOriginalSCP', false); // indicated this is overridden value,
  432. newSCP.set('parentSCP', serviceConfigProperty);
  433. if (defaultGroupSelected) {
  434. var group = component.get('configGroups').findProperty('name', override.group.get('name'));
  435. // prevent cycle in proto object, clean link
  436. if (group.get('properties').length == 0) {
  437. group.set('properties', Em.A([]));
  438. }
  439. group.get('properties').push(newSCP);
  440. newSCP.set('group', override.group);
  441. newSCP.set('isEditable', false);
  442. }
  443. var parentOverridesArray = serviceConfigProperty.get('overrides');
  444. if (Em.isNone(parentOverridesArray)) {
  445. parentOverridesArray = Em.A([]);
  446. serviceConfigProperty.set('overrides', parentOverridesArray);
  447. }
  448. serviceConfigProperty.get('overrides').pushObject(newSCP);
  449. }, this);
  450. return serviceConfigProperty;
  451. },
  452. /**
  453. * Set configs with overrides, recommended defaults to component
  454. * @param {Ember.Object[]} configs
  455. * @param {Ember.Object} componentConfig
  456. * @param {Ember.Object} component
  457. * @method loadComponentConfigs
  458. */
  459. loadComponentConfigs: function (configs, componentConfig, component) {
  460. var defaultGroupSelected = component.get('selectedConfigGroup.isDefault');
  461. configs.forEach(function (serviceConfigProperty) {
  462. if (!serviceConfigProperty) return;
  463. if (Em.isNone(serviceConfigProperty.get('isOverridable'))) {
  464. serviceConfigProperty.set('isOverridable', true);
  465. }
  466. if (serviceConfigProperty.get('displayType') === 'checkbox') {
  467. this._updateValueForCheckBoxConfig(serviceConfigProperty);
  468. }
  469. this._updateOverridesForConfig(serviceConfigProperty, component);
  470. this._updateIsEditableFlagForConfig(serviceConfigProperty, defaultGroupSelected);
  471. componentConfig.get('configs').pushObject(serviceConfigProperty);
  472. serviceConfigProperty.validate();
  473. }, this);
  474. component.get('configGroups').filterProperty('isDefault', false).forEach(function (configGroup) {
  475. configGroup.set('hash', this.get('wizardController').getConfigGroupHash(configGroup));
  476. }, this);
  477. var overrideToAdd = this.get('overrideToAdd');
  478. if (overrideToAdd) {
  479. overrideToAdd = componentConfig.get('configs').findProperty('name', overrideToAdd.name);
  480. if (overrideToAdd) {
  481. this.addOverrideProperty(overrideToAdd);
  482. component.set('overrideToAdd', null);
  483. }
  484. }
  485. },
  486. /**
  487. * Resolve dependency between configs.
  488. * @param serviceName {String}
  489. * @param configs {Ember.Enumerable}
  490. */
  491. resolveServiceDependencyConfigs: function (serviceName, configs) {
  492. switch (serviceName) {
  493. case 'STORM':
  494. this.resolveStormConfigs(configs);
  495. break;
  496. case 'YARN':
  497. this.resolveYarnConfigs(configs);
  498. default:
  499. break;
  500. }
  501. },
  502. /**
  503. * Update some Storm configs
  504. * If Ganglia is selected to install or already installed, Ganglia host should be added to configs
  505. * @param {Ember.Enumerable} configs
  506. * @method resolveStormConfigs
  507. */
  508. resolveStormConfigs: function (configs) {
  509. var dependentConfigs, gangliaServerHost, gangliaHostId, hosts;
  510. dependentConfigs = ['nimbus.childopts', 'supervisor.childopts', 'worker.childopts'];
  511. // if Ganglia selected or installed, set ganglia host to configs
  512. if (this.get('installedServiceNames').contains('STORM') && this.get('installedServiceNames').contains('GANGLIA')) return;
  513. if (this.get('allSelectedServiceNames').contains('GANGLIA') || this.get('installedServiceNames').contains('GANGLIA')) {
  514. if (this.get('wizardController.name') === 'addServiceController') {
  515. gangliaServerHost = this.get('wizardController').getDBProperty('masterComponentHosts').findProperty('component', 'GANGLIA_SERVER').hostName;
  516. } else {
  517. hosts = this.get('wizardController').getDBProperty('hosts');
  518. gangliaHostId = this.get('wizardController').getDBProperty('masterComponentHosts').findProperty('component', 'GANGLIA_SERVER').host_id;
  519. for (var hostName in hosts) {
  520. if (hosts[hostName].id == gangliaHostId) gangliaServerHost = hosts[hostName].name;
  521. }
  522. }
  523. dependentConfigs.forEach(function (configName) {
  524. var config = configs.findProperty('name', configName);
  525. if (!Em.isNone(config.value)) {
  526. var replaceStr = config.value.match(/.jar=host[^,]+/)[0];
  527. var replaceWith = replaceStr.slice(0, replaceStr.lastIndexOf('=') - replaceStr.length + 1) + gangliaServerHost;
  528. config.value = config.defaultValue = config.value.replace(replaceStr, replaceWith);
  529. }
  530. config.forceUpdate = true;
  531. }, this);
  532. }
  533. },
  534. /**
  535. * Update some Storm configs
  536. * If SLIDER is selected to install or already installed,
  537. * some Yarn properties must be changed
  538. * @param {Ember.Enumerable} configs
  539. * @method resolveYarnConfigs
  540. */
  541. resolveYarnConfigs: function (configs) {
  542. var cfgToChange = configs.findProperty('name', 'hadoop.registry.rm.enabled');
  543. if (cfgToChange) {
  544. var res = this.get('allSelectedServiceNames').contains('SLIDER');
  545. if (Em.get(cfgToChange, 'value') !== res) {
  546. Em.set(cfgToChange, 'defaultValue', res);
  547. Em.set(cfgToChange, 'value', res);
  548. Em.set(cfgToChange, 'forceUpdate', true);
  549. }
  550. }
  551. },
  552. /**
  553. * On load function
  554. * @method loadStep
  555. */
  556. loadStep: function () {
  557. console.log("TRACE: Loading step7: Configure Services");
  558. if (!this.get('isConfigsLoaded')) {
  559. return;
  560. }
  561. this.clearStep();
  562. var self = this;
  563. //STEP 1: Load advanced configs
  564. var advancedConfigs = this.get('content.advancedServiceConfig');
  565. //STEP 2: Load on-site configs by service from local DB
  566. var storedConfigs = this.get('content.serviceConfigProperties');
  567. //STEP 3: Merge pre-defined configs with loaded on-site configs
  568. var configs = App.config.mergePreDefinedWithStored(
  569. storedConfigs,
  570. advancedConfigs,
  571. this.get('selectedServiceNames').concat(this.get('installedServiceNames'))
  572. );
  573. App.config.setPreDefinedServiceConfigs(this.get('addMiscTabToPage'));
  574. //STEP 4: Add advanced configs
  575. App.config.addAdvancedConfigs(configs, advancedConfigs);
  576. //STEP 5: Add custom configs
  577. App.config.addCustomConfigs(configs);
  578. this.set('groupsToDelete', this.get('wizardController').getDBProperty('groupsToDelete') || []);
  579. if (this.get('wizardController.name') === 'addServiceController') {
  580. App.router.get('configurationController').getConfigsByTags(this.get('serviceConfigTags')).done(function (loadedConfigs) {
  581. self.setInstalledServiceConfigs(self.get('serviceConfigTags'), configs, loadedConfigs, self.get('installedServiceNames'));
  582. self.applyServicesConfigs(configs, storedConfigs);
  583. });
  584. } else {
  585. this.applyServicesConfigs(configs, storedConfigs);
  586. }
  587. },
  588. applyServicesConfigs: function (configs, storedConfigs) {
  589. if (this.get('allSelectedServiceNames').contains('YARN')) {
  590. configs = App.config.fileConfigsIntoTextarea(configs, 'capacity-scheduler.xml');
  591. }
  592. var dependendServices = ["STORM", "YARN"];
  593. dependendServices.forEach(function (serviceName) {
  594. if (this.get('allSelectedServiceNames').contains(serviceName)) {
  595. this.resolveServiceDependencyConfigs(serviceName, configs);
  596. }
  597. }, this);
  598. //STEP 6: Distribute configs by service and wrap each one in App.ServiceConfigProperty (configs -> serviceConfigs)
  599. var self = this;
  600. this.loadServerSideConfigsRecommendations().always(function () {
  601. self.set('isRecommendedLoaded', true);
  602. self.setStepConfigs(configs, storedConfigs);
  603. self.checkHostOverrideInstaller();
  604. self.activateSpecialConfigs();
  605. self.selectProperService();
  606. if (self.get('content.skipConfigStep')) {
  607. App.router.send('next');
  608. }
  609. });
  610. },
  611. /**
  612. * Load config groups
  613. * and (if some services are already installed) load config groups for installed services
  614. * @method checkHostOverrideInstaller
  615. */
  616. checkHostOverrideInstaller: function () {
  617. if (this.get('wizardController.name') !== 'kerberosWizardController') {
  618. this.loadConfigGroups(this.get('content.configGroups'));
  619. }
  620. if (this.get('installedServiceNames').length > 0) {
  621. this.loadInstalledServicesConfigGroups(this.get('installedServiceNames'));
  622. }
  623. },
  624. /**
  625. * Set init <code>stepConfigs</code> value
  626. * Set <code>selected</code> for addable services if addServiceController is used
  627. * Remove SNameNode if HA is enabled (and if addServiceController is used)
  628. * @param {Ember.Object[]} configs
  629. * @param {Ember.Object[]} storedConfigs
  630. * @method setStepConfigs
  631. */
  632. setStepConfigs: function (configs, storedConfigs) {
  633. var localDB = {
  634. hosts: this.get('wizardController.content.hosts'),
  635. masterComponentHosts: this.get('wizardController.content.masterComponentHosts'),
  636. slaveComponentHosts: this.get('wizardController.content.slaveComponentHosts')
  637. };
  638. var serviceConfigs = App.config.renderConfigs(configs, storedConfigs, this.get('allSelectedServiceNames'), this.get('installedServiceNames'), localDB, this.get('recommendationsConfigs'));
  639. if (this.get('wizardController.name') === 'addServiceController') {
  640. serviceConfigs.setEach('showConfig', true);
  641. serviceConfigs.setEach('selected', false);
  642. this.get('selectedServiceNames').forEach(function (serviceName) {
  643. if (!serviceConfigs.findProperty('serviceName', serviceName)) return;
  644. var selectedService = serviceConfigs.findProperty('serviceName', serviceName).set('selected', true);
  645. // add secure configs when security is enabled
  646. if (this.get('securityEnabled')) {
  647. this.addSecureConfigs(selectedService, serviceName);
  648. }
  649. }, this);
  650. this.get('installedServiceNames').forEach(function (serviceName) {
  651. var serviceConfigObj = serviceConfigs.findProperty('serviceName', serviceName);
  652. var isInstallableService = App.StackService.find(serviceName).get('isInstallable');
  653. if (!isInstallableService) serviceConfigObj.set('showConfig', false);
  654. if (this.get('securityEnabled')) {
  655. this.setSecureConfigs(serviceConfigObj, serviceName);
  656. }
  657. }, this);
  658. // Remove SNameNode if HA is enabled
  659. if (App.get('isHaEnabled')) {
  660. var c = serviceConfigs.findProperty('serviceName', 'HDFS').configs;
  661. var removedConfigs = c.filterProperty('category', 'SECONDARY_NAMENODE');
  662. removedConfigs.map(function (config) {
  663. c = c.without(config);
  664. });
  665. serviceConfigs.findProperty('serviceName', 'HDFS').configs = c;
  666. }
  667. // Remove Notifications from MISC if it isn't Installer Controller
  668. if (this.get('wizardController.name') !== 'installerController') {
  669. var miscService = serviceConfigs.findProperty('serviceName', 'MISC');
  670. if (miscService) {
  671. c = miscService.configs;
  672. removedConfigs = c.filterProperty('category', 'Notifications');
  673. removedConfigs.map(function (config) {
  674. c = c.without(config);
  675. });
  676. miscService.configs = c;
  677. }
  678. }
  679. }
  680. this.set('stepConfigs', serviceConfigs);
  681. },
  682. /**
  683. * Set secure properties for installed services. Mark secure properties and
  684. * properties with default empty value as non required to pass validation.
  685. *
  686. * @param {Em.Object} serviceConfigObj
  687. * @param {String} serviceName
  688. */
  689. setSecureConfigs: function (serviceConfigObj, serviceName) {
  690. var configProperties = serviceConfigObj.get('configs');
  691. if (!configProperties) return;
  692. var secureConfigs = this.get('secureConfigs').filterProperty('serviceName', serviceName);
  693. secureConfigs.forEach(function (secureConfig) {
  694. var property = configProperties.findProperty('name', secureConfig.name);
  695. if (property) {
  696. property.set('isRequired', secureConfig.value != "");
  697. if (!property.get('isRequired')) property.set('errorMessage', '');
  698. }
  699. });
  700. },
  701. /**
  702. *
  703. * @param selectedService
  704. * @param serviceName
  705. */
  706. addSecureConfigs: function (selectedService, serviceName) {
  707. var secureService = this.get('secureServices').findProperty('serviceName', serviceName);
  708. if (!secureService) {
  709. return;
  710. }
  711. secureService.configCategories.forEach(function (category) {
  712. selectedService.get('configCategories').push(category);
  713. });
  714. secureService.configs.forEach(function (conf) {
  715. conf.isVisible = !conf.displayType.contains('masterHost') && !conf.displayType.contains('slaveHost');
  716. var config = App.ServiceConfigProperty.create(conf);
  717. selectedService.get('configs').push(config);
  718. }, this);
  719. },
  720. /**
  721. * Select first addable service for <code>addServiceWizard</code>
  722. * Select first service at all in other cases
  723. * @method selectProperService
  724. */
  725. selectProperService: function () {
  726. if (this.get('wizardController.name') === 'addServiceController') {
  727. this.set('selectedService', this.get('stepConfigs').filterProperty('selected', true).get('firstObject'));
  728. } else {
  729. this.set('selectedService', this.get('stepConfigs').filterProperty('showConfig', true).objectAt(0));
  730. }
  731. },
  732. /**
  733. * Load config tags
  734. * @return {$.ajax|null}
  735. * @method getConfigTags
  736. */
  737. getConfigTags: function () {
  738. this.set('isAppliedConfigLoaded', false);
  739. return App.ajax.send({
  740. name: 'config.tags',
  741. sender: this,
  742. success: 'getConfigTagsSuccess'
  743. });
  744. },
  745. /**
  746. * Success callback for config tags request
  747. * Updates <code>serviceConfigTags</code> with tags received from server
  748. * @param {object} data
  749. * @method getConfigTagsSuccess
  750. */
  751. getConfigTagsSuccess: function (data) {
  752. var installedServiceSites = [];
  753. App.StackService.find().filterProperty('isInstalled').forEach(function (service) {
  754. if (!service.get('configTypes')) return;
  755. var configTypes = Object.keys(service.get('configTypes'));
  756. installedServiceSites = installedServiceSites.concat(configTypes);
  757. }, this);
  758. installedServiceSites = installedServiceSites.uniq();
  759. var serviceConfigTags = [];
  760. for (var site in data.Clusters.desired_configs) {
  761. if (data.Clusters.desired_configs.hasOwnProperty(site)) {
  762. if (installedServiceSites.contains(site)) {
  763. serviceConfigTags.push({
  764. siteName: site,
  765. tagName: data.Clusters.desired_configs[site].tag,
  766. newTagName: null
  767. });
  768. }
  769. }
  770. }
  771. this.set('serviceConfigTags', serviceConfigTags);
  772. this.set('isAppliedConfigLoaded', true);
  773. },
  774. /**
  775. * set configs actual values from server
  776. * @param serviceConfigTags
  777. * @param configs
  778. * @param configsByTags
  779. * @param installedServiceNames
  780. * @method setInstalledServiceConfigs
  781. */
  782. setInstalledServiceConfigs: function (serviceConfigTags, configs, configsByTags, installedServiceNames) {
  783. var configsMap = {};
  784. var configTypeMap = {};
  785. var configMixin = App.get('config');
  786. var self = this;
  787. configsByTags.forEach(function (configSite) {
  788. configsMap[configSite.type] = configSite.properties;
  789. });
  790. configs.forEach(function (_config) {
  791. var nonServiceTab = require('data/service_configs');
  792. var type = _config.filename ? App.config.getConfigTagFromFileName(_config.filename) : null;
  793. var mappedConfigValue = type && configsMap[type] ? configsMap[type][_config.name] : null;
  794. if (!Em.isNone(mappedConfigValue) && ((installedServiceNames && installedServiceNames.contains(_config.serviceName) || nonServiceTab.someProperty('serviceName', _config.serviceName)))) {
  795. // prevent overriding already edited properties
  796. if (_config.defaultValue != mappedConfigValue) {
  797. _config.value = mappedConfigValue;
  798. }
  799. _config.defaultValue = mappedConfigValue;
  800. _config.hasInitialValue = true;
  801. App.config.handleSpecialProperties(_config);
  802. delete configsMap[type][_config.name];
  803. }
  804. });
  805. self.setServiceDatabaseConfigs(configs);
  806. //add user properties
  807. Em.keys(configsMap).forEach(function (filename) {
  808. Em.keys(configsMap[filename]).forEach(function (propertyName) {
  809. configs.push(configMixin.addUserProperty({
  810. id: 'site property',
  811. name: propertyName,
  812. serviceName: configMixin.getServiceNameByConfigType(filename),
  813. value: configsMap[filename][propertyName],
  814. defaultValue: configsMap[filename][propertyName],
  815. filename: configMixin.get('filenameExceptions').contains(filename) ? filename : filename + '.xml',
  816. category: 'Advanced',
  817. hasInitialValue: true,
  818. isUserProperty: true,
  819. isOverridable: true,
  820. overrides: [],
  821. isRequired: true,
  822. isVisible: true,
  823. showLabel: true
  824. }, false, []));
  825. });
  826. });
  827. },
  828. /**
  829. * Check if Oozie, Hive or MetricsSink use existing database then need
  830. * to restore missed properties
  831. *
  832. * @param {Object[]} configs
  833. **/
  834. setServiceDatabaseConfigs: function (configs) {
  835. var serviceNames = this.get('installedServiceNames').filter(function (serviceName) {
  836. return ['OOZIE', 'HIVE', 'HDFS'].contains(serviceName);
  837. });
  838. serviceNames.forEach(function (serviceName) {
  839. var propertyPrefix = serviceName.toLowerCase();
  840. if (/HDFS/gi.test(serviceName)) propertyPrefix = 'sink';
  841. var dbTypeConfig = configs.findProperty('name', propertyPrefix + '_database');
  842. if (!/existing/gi.test(dbTypeConfig.value)) return;
  843. var dbHostName = propertyPrefix + '_hostname';
  844. var database = dbTypeConfig.value.match(/MySQL|PostgreSQL|Oracle|Derby|MSSQL/gi)[0];
  845. var dbPrefix = database.toLowerCase();
  846. if (database.toLowerCase() == 'mssql') {
  847. dbHostName = 'sink.dbservername';
  848. if (/integrated/gi.test(dbTypeConfig.value)) {
  849. dbPrefix = 'mssql_server';
  850. } else {
  851. dbPrefix = 'mssql_server_2';
  852. }
  853. }
  854. var propertyName = propertyPrefix + '_existing_' + dbPrefix + '_host';
  855. var existingDBConfig = configs.findProperty('name', propertyName);
  856. if (!existingDBConfig.value)
  857. existingDBConfig.value = existingDBConfig.defaultValue = configs.findProperty('name', dbHostName).value;
  858. }, this);
  859. },
  860. /**
  861. * Add group ids to <code>groupsToDelete</code>
  862. * Also save <code>groupsToDelete</code> to local storage
  863. * @param {Ember.Object[]} groups
  864. * @method setGroupsToDelete
  865. */
  866. setGroupsToDelete: function (groups) {
  867. var groupsToDelete = this.get('groupsToDelete');
  868. groups.forEach(function (group) {
  869. if (group.get('id'))
  870. groupsToDelete.push({
  871. id: group.get('id')
  872. });
  873. });
  874. this.get('wizardController').setDBProperty('groupsToDelete', groupsToDelete);
  875. },
  876. /**
  877. * Update <code>configGroups</code> with selected service configGroups
  878. * Also set default group to first position
  879. * Update <code>selectedConfigGroup</code> with new default group
  880. * @method selectedServiceObserver
  881. */
  882. selectedServiceObserver: function () {
  883. if (this.get('selectedService') && (this.get('selectedService.serviceName') !== 'MISC')) {
  884. var serviceGroups = this.get('selectedService.configGroups');
  885. serviceGroups.forEach(function (item, index, array) {
  886. if (item.isDefault) {
  887. array.unshift(item);
  888. array.splice(index + 1, 1);
  889. }
  890. });
  891. this.set('configGroups', serviceGroups);
  892. this.set('selectedConfigGroup', serviceGroups.findProperty('isDefault'));
  893. }
  894. }.observes('selectedService.configGroups.@each'),
  895. /**
  896. * load default groups for each service in case of initial load
  897. * @param serviceConfigGroups
  898. * @method loadConfigGroups
  899. */
  900. loadConfigGroups: function (serviceConfigGroups) {
  901. var services = this.get('stepConfigs');
  902. var hosts = this.get('wizardController.allHosts').mapProperty('hostName');
  903. var manageCGController = App.router.get('manageConfigGroupsController');
  904. this.setupManageConfigGroupsController();
  905. services.forEach(function (service) {
  906. if (service.get('serviceName') === 'MISC') return;
  907. var serviceRawGroups = serviceConfigGroups.filterProperty('service.id', service.serviceName);
  908. if (!serviceRawGroups.length) {
  909. service.set('configGroups', [
  910. App.ConfigGroup.create({
  911. name: service.displayName + " Default",
  912. description: "Default cluster level " + service.serviceName + " configuration",
  913. isDefault: true,
  914. hosts: Em.copy(hosts),
  915. publicHosts: Em.copy(manageCGController.hostsToPublic(hosts)),
  916. service: Em.Object.create({
  917. id: service.serviceName
  918. }),
  919. serviceName: service.serviceName
  920. })
  921. ]);
  922. }
  923. else {
  924. var defaultGroup = App.ConfigGroup.create(serviceRawGroups.findProperty('isDefault'));
  925. var serviceGroups = service.get('configGroups');
  926. serviceRawGroups.filterProperty('isDefault', false).forEach(function (configGroup) {
  927. var readyGroup = App.ConfigGroup.create(configGroup);
  928. var wrappedProperties = [];
  929. readyGroup.get('properties').forEach(function (propertyData) {
  930. var parentSCP = service.configs.filterProperty('filename', propertyData.filename).findProperty('name', propertyData.name);
  931. var overriddenSCP = App.ServiceConfigProperty.create(parentSCP);
  932. overriddenSCP.set('isOriginalSCP', false);
  933. overriddenSCP.set('parentSCP', parentSCP);
  934. overriddenSCP.set('group', readyGroup);
  935. overriddenSCP.setProperties(propertyData);
  936. wrappedProperties.pushObject(App.ServiceConfigProperty.create(overriddenSCP));
  937. });
  938. wrappedProperties.setEach('group', readyGroup);
  939. readyGroup.set('properties', wrappedProperties);
  940. readyGroup.set('parentConfigGroup', defaultGroup);
  941. serviceGroups.pushObject(readyGroup);
  942. });
  943. defaultGroup.set('childConfigGroups', serviceGroups);
  944. serviceGroups.pushObject(defaultGroup);
  945. }
  946. });
  947. },
  948. setupManageConfigGroupsController: function () {
  949. var manageCGController = App.router.get('manageConfigGroupsController');
  950. manageCGController.set('isInstaller', true);
  951. manageCGController.set('isAddService', this.get('wizardController.name') === 'addServiceController');
  952. },
  953. /**
  954. * Click-handler on config-group to make it selected
  955. * @param {object} event
  956. * @method selectConfigGroup
  957. */
  958. selectConfigGroup: function (event) {
  959. this.set('selectedConfigGroup', event.context);
  960. },
  961. /**
  962. * Rebuild list of configs switch of config group:
  963. * on default - display all configs from default group and configs from non-default groups as disabled
  964. * on non-default - display all from default group as disabled and configs from selected non-default group
  965. * @method switchConfigGroupConfigs
  966. */
  967. switchConfigGroupConfigs: function () {
  968. var serviceConfigs = this.get('selectedService.configs'),
  969. selectedGroup = this.get('selectedConfigGroup'),
  970. overrideToAdd = this.get('overrideToAdd'),
  971. overrides = [];
  972. if (!selectedGroup) return;
  973. var displayedConfigGroups = this._getDisplayedConfigGroups();
  974. displayedConfigGroups.forEach(function (group) {
  975. overrides.pushObjects(group.get('properties'));
  976. });
  977. serviceConfigs.forEach(function (config) {
  978. this._setEditableValue(config);
  979. this._setOverrides(config, overrides);
  980. }, this);
  981. }.observes('selectedConfigGroup'),
  982. /**
  983. * Get list of config groups to display
  984. * Returns empty array if no <code>selectedConfigGroup</code>
  985. * @return {Array}
  986. * @method _getDisplayedConfigGroups
  987. */
  988. _getDisplayedConfigGroups: function () {
  989. var selectedGroup = this.get('selectedConfigGroup');
  990. if (!selectedGroup) return [];
  991. return (selectedGroup.get('isDefault')) ?
  992. this.get('selectedService.configGroups').filterProperty('isDefault', false) :
  993. [this.get('selectedConfigGroup')];
  994. },
  995. /**
  996. * Set <code>isEditable</code> property to <code>config</code>
  997. * @param {Ember.Object} config
  998. * @return {Ember.Object} updated config-object
  999. * @method _setEditableValue
  1000. */
  1001. _setEditableValue: function (config) {
  1002. var selectedGroup = this.get('selectedConfigGroup');
  1003. if (!selectedGroup) return config;
  1004. var isEditable = config.get('isEditable'),
  1005. isServiceInstalled = this.get('installedServiceNames').contains(this.get('selectedService.serviceName'));
  1006. if (isServiceInstalled) {
  1007. isEditable = (!isEditable && !config.get('isReconfigurable')) ? false : selectedGroup.get('isDefault');
  1008. }
  1009. else {
  1010. isEditable = selectedGroup.get('isDefault');
  1011. }
  1012. if (config.get('group')) {
  1013. isEditable = config.get('group.name') == this.get('selectedConfigGroup.name');
  1014. }
  1015. config.set('isEditable', isEditable);
  1016. return config;
  1017. },
  1018. /**
  1019. * Set <code>overrides</code> property to <code>config</code>
  1020. * @param {Ember.Object} config
  1021. * @param {Ember.Enumerable} overrides
  1022. * @returns {Ember.Object}
  1023. * @method _setOverrides
  1024. */
  1025. _setOverrides: function (config, overrides) {
  1026. var selectedGroup = this.get('selectedConfigGroup'),
  1027. overrideToAdd = this.get('overrideToAdd'),
  1028. configOverrides = overrides.filterProperty('name', config.get('name'));
  1029. if (!selectedGroup) return config;
  1030. if (overrideToAdd && overrideToAdd.get('name') === config.get('name')) {
  1031. configOverrides.push(this.addOverrideProperty(config));
  1032. this.set('overrideToAdd', null);
  1033. }
  1034. configOverrides.setEach('isEditable', !selectedGroup.get('isDefault'));
  1035. configOverrides.setEach('parentSCP', config);
  1036. config.set('overrides', configOverrides);
  1037. return config;
  1038. },
  1039. /**
  1040. * create overriden property and push it into Config group
  1041. * @param {App.ServiceConfigProperty} serviceConfigProperty
  1042. * @return {App.ServiceConfigProperty}
  1043. * @method addOverrideProperty
  1044. */
  1045. addOverrideProperty: function (serviceConfigProperty) {
  1046. var overrides = serviceConfigProperty.get('overrides') || [];
  1047. var newSCP = App.ServiceConfigProperty.create(serviceConfigProperty);
  1048. var group = this.get('selectedService.configGroups').findProperty('name', this.get('selectedConfigGroup.name'));
  1049. newSCP.set('group', group);
  1050. newSCP.set('value', '');
  1051. newSCP.set('isOriginalSCP', false); // indicated this is overridden value,
  1052. newSCP.set('parentSCP', serviceConfigProperty);
  1053. newSCP.set('isEditable', true);
  1054. group.get('properties').pushObject(newSCP);
  1055. overrides.pushObject(newSCP);
  1056. return newSCP;
  1057. },
  1058. /**
  1059. * @method manageConfigurationGroup
  1060. */
  1061. manageConfigurationGroup: function () {
  1062. App.router.get('mainServiceInfoConfigsController').manageConfigurationGroups(this);
  1063. },
  1064. /**
  1065. * Make some configs visible depending on active services
  1066. * @method activateSpecialConfigs
  1067. */
  1068. activateSpecialConfigs: function () {
  1069. if (this.get('addMiscTabToPage')) {
  1070. var miscConfigs = this.get('stepConfigs').findProperty('serviceName', 'MISC').configs;
  1071. if (this.get('wizardController.name') == "addServiceController") {
  1072. miscConfigs.findProperty('name', 'smokeuser').set('value', this.get('content.smokeuser')).set('isEditable', false);
  1073. miscConfigs.findProperty('name', 'user_group').set('value', this.get('content.group')).set('isEditable', false);
  1074. }
  1075. App.config.miscConfigVisibleProperty(miscConfigs, this.get('selectedServiceNames'));
  1076. }
  1077. var wizardController = this.get('wizardController');
  1078. if (wizardController.get('name') === "kerberosWizardController") {
  1079. var kerberosConfigs = this.get('stepConfigs').findProperty('serviceName', 'KERBEROS').configs;
  1080. kerberosConfigs.findProperty('name', 'kdc_type').set('value', wizardController.get('content.kerberosOption'));
  1081. }
  1082. },
  1083. /**
  1084. * Check whether hive New MySQL database is on the same host as Ambari server MySQL server
  1085. * @return {$.ajax|null}
  1086. * @method checkMySQLHost
  1087. */
  1088. checkMySQLHost: function () {
  1089. // get ambari database type and hostname
  1090. return App.ajax.send({
  1091. name: 'config.ambari.database.info',
  1092. sender: this,
  1093. success: 'getAmbariDatabaseSuccess'
  1094. });
  1095. },
  1096. /**
  1097. * Success callback for ambari database, get Ambari DB type and DB server hostname, then
  1098. * Check whether hive New MySQL database is on the same host as Ambari server MySQL server
  1099. * @param {object} data
  1100. * @method getAmbariDatabaseSuccess
  1101. */
  1102. getAmbariDatabaseSuccess: function (data) {
  1103. var hiveDBHostname = this.get('stepConfigs').findProperty('serviceName', 'HIVE').configs.findProperty('name', 'hivemetastore_host').value;
  1104. var ambariServiceHostComponents = data.hostComponents;
  1105. if (!!ambariServiceHostComponents.length) {
  1106. var ambariDBInfo = JSON.stringify(ambariServiceHostComponents[0].RootServiceHostComponents.properties);
  1107. this.set('mySQLServerConflict', ambariDBInfo.indexOf('mysql') > 0 && ambariDBInfo.indexOf(hiveDBHostname) > 0);
  1108. } else {
  1109. this.set('mySQLServerConflict', false);
  1110. }
  1111. },
  1112. /**
  1113. * Check if new MySql database was chosen for Hive service
  1114. * and it is not located on the same host as Ambari server
  1115. * that using MySql database too.
  1116. *
  1117. * @method resolveHiveMysqlDatabase
  1118. **/
  1119. resolveHiveMysqlDatabase: function () {
  1120. var hiveService = this.get('content.services').findProperty('serviceName', 'HIVE');
  1121. if (!hiveService || !hiveService.get('isSelected') || hiveService.get('isInstalled')) {
  1122. this.moveNext();
  1123. return;
  1124. }
  1125. var hiveDBType = this.get('stepConfigs').findProperty('serviceName', 'HIVE').configs.findProperty('name', 'hive_database').value;
  1126. if (hiveDBType == 'New MySQL Database') {
  1127. var self = this;
  1128. this.checkMySQLHost().done(function () {
  1129. if (self.get('mySQLServerConflict')) {
  1130. // error popup before you can proceed
  1131. return App.ModalPopup.show({
  1132. header: Em.I18n.t('installer.step7.popup.mySQLWarning.header'),
  1133. bodyClass: Ember.View.extend({
  1134. template: Ember.Handlebars.compile(Em.I18n.t('installer.step7.popup.mySQLWarning.body'))
  1135. }),
  1136. secondary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.gotostep5'),
  1137. primary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.dismiss'),
  1138. onSecondary: function () {
  1139. var parent = this;
  1140. return App.ModalPopup.show({
  1141. header: Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.header'),
  1142. bodyClass: Ember.View.extend({
  1143. template: Ember.Handlebars.compile(Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.body'))
  1144. }),
  1145. onPrimary: function () {
  1146. this.hide();
  1147. parent.hide();
  1148. // go back to step 5: assign masters and disable default navigation warning
  1149. App.router.get('installerController').gotoStep(5, true);
  1150. }
  1151. });
  1152. }
  1153. });
  1154. } else {
  1155. self.moveNext();
  1156. }
  1157. });
  1158. } else {
  1159. this.moveNext();
  1160. }
  1161. },
  1162. checkDatabaseConnectionTest: function () {
  1163. var deferred = $.Deferred();
  1164. var configMap = [
  1165. {
  1166. serviceName: 'OOZIE',
  1167. ignored: [Em.I18n.t('installer.step7.oozie.database.new')]
  1168. },
  1169. {
  1170. serviceName: 'HIVE',
  1171. ignored: [Em.I18n.t('installer.step7.hive.database.new.mysql'), Em.I18n.t('installer.step7.hive.database.new.postgres')]
  1172. }
  1173. ];
  1174. configMap.forEach(function (config) {
  1175. var isConnectionNotTested = false;
  1176. var service = this.get('content.services').findProperty('serviceName', config.serviceName);
  1177. if (service && service.get('isSelected') && !service.get('isInstalled')) {
  1178. var serviceConfigs = this.get('stepConfigs').findProperty('serviceName', config.serviceName).configs;
  1179. var serviceDatabase = serviceConfigs.findProperty('name', config.serviceName.toLowerCase() + '_database').get('value');
  1180. if (!config.ignored.contains(serviceDatabase)) {
  1181. var filledProperties = App.db.get('tmp', config.serviceName + '_connection');
  1182. if (!filledProperties || App.isEmptyObject(filledProperties)) {
  1183. isConnectionNotTested = true;
  1184. } else {
  1185. for (var key in filledProperties) {
  1186. if (serviceConfigs.findProperty('name', key).get('value') !== filledProperties[key])
  1187. isConnectionNotTested = true;
  1188. }
  1189. }
  1190. }
  1191. }
  1192. config.isCheckIgnored = isConnectionNotTested;
  1193. }, this);
  1194. var ignoredServices = configMap.filterProperty('isCheckIgnored', true);
  1195. if (ignoredServices.length) {
  1196. var displayedServiceNames = ignoredServices.mapProperty('serviceName').map(function (serviceName) {
  1197. return this.get('content.services').findProperty('serviceName', serviceName).get('displayName');
  1198. }, this);
  1199. this.showDatabaseConnectionWarningPopup(displayedServiceNames, deferred);
  1200. }
  1201. else {
  1202. deferred.resolve();
  1203. }
  1204. return deferred;
  1205. },
  1206. showDatabaseConnectionWarningPopup: function (serviceNames, deferred) {
  1207. return App.ModalPopup.show({
  1208. header: Em.I18n.t('installer.step7.popup.database.connection.header'),
  1209. body: Em.I18n.t('installer.step7.popup.database.connection.body').format(serviceNames.join(', ')),
  1210. secondary: Em.I18n.t('common.cancel'),
  1211. primary: Em.I18n.t('common.proceedAnyway'),
  1212. onPrimary: function () {
  1213. deferred.resolve();
  1214. this._super();
  1215. },
  1216. onSecondary: function () {
  1217. deferred.reject();
  1218. this._super();
  1219. }
  1220. })
  1221. },
  1222. /**
  1223. * Proceed to the next step
  1224. **/
  1225. moveNext: function () {
  1226. App.router.send('next');
  1227. },
  1228. /**
  1229. * Click-handler on Next button
  1230. * Disable "Submit"-button while server-side processes are running
  1231. * @method submit
  1232. */
  1233. submit: function () {
  1234. if (this.get('isSubmitDisabled')) {
  1235. return;
  1236. }
  1237. var self = this;
  1238. this.set('submitButtonClicked', true);
  1239. this.serverSideValidation().done(function () {
  1240. self.checkDatabaseConnectionTest().done(function () {
  1241. self.resolveHiveMysqlDatabase();
  1242. self.set('submitButtonClicked', false);
  1243. });
  1244. }).fail(function (value) {
  1245. if ("invalid_configs" == value) {
  1246. self.set('submitButtonClicked', false);
  1247. } else {
  1248. // Failed due to validation mechanism failure.
  1249. // Should proceed with other checks
  1250. self.checkDatabaseConnectionTest().done(function () {
  1251. self.resolveHiveMysqlDatabase();
  1252. self.set('submitButtonClicked', false);
  1253. });
  1254. }
  1255. });
  1256. }
  1257. });