step7_controller.js 44 KB

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