step7_controller.js 44 KB

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