step7_controller.js 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249
  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', 'content.stacks.@each.isSelected').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', 'content.stacks.@each.isSelected').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. var self = this;
  591. //STEP 1: Load advanced configs
  592. var advancedConfigs = this.get('content.advancedServiceConfig');
  593. //STEP 2: Load on-site configs by service from local DB
  594. var storedConfigs = this.get('content.serviceConfigProperties');
  595. //STEP 3: Merge pre-defined configs with loaded on-site configs
  596. var configs = App.config.mergePreDefinedWithStored(
  597. storedConfigs,
  598. advancedConfigs,
  599. this.get('selectedServiceNames').concat(this.get('installedServiceNames'))
  600. );
  601. //STEP 4: Add advanced configs
  602. App.config.addAdvancedConfigs(configs, advancedConfigs);
  603. //STEP 5: Add custom configs
  604. App.config.addCustomConfigs(configs);
  605. //put properties from capacity-scheduler.xml into one config with textarea view
  606. if (this.get('allSelectedServiceNames').contains('YARN') && !App.get('supports.capacitySchedulerUi')) {
  607. configs = App.config.fileConfigsIntoTextarea(configs, 'capacity-scheduler.xml');
  608. }
  609. this.set('groupsToDelete', this.get('wizardController').getDBProperty('groupsToDelete') || []);
  610. if (this.get('wizardController.name') === 'addServiceController') {
  611. App.router.get('configurationController').getConfigsByTags(this.get('serviceConfigTags')).done(function (loadedConfigs) {
  612. self.setInstalledServiceConfigs(self.get('serviceConfigTags'), configs, loadedConfigs);
  613. self.applyServicesConfigs(configs, storedConfigs);
  614. });
  615. } else {
  616. this.applyServicesConfigs(configs, storedConfigs);
  617. }
  618. },
  619. applyServicesConfigs: function (configs, storedConfigs) {
  620. if (this.get('allSelectedServiceNames').contains('STORM') || this.get('installedServiceNames').contains('STORM')) {
  621. this.resolveServiceDependencyConfigs('STORM', configs);
  622. }
  623. //STEP 6: Distribute configs by service and wrap each one in App.ServiceConfigProperty (configs -> serviceConfigs)
  624. this.setStepConfigs(configs, storedConfigs);
  625. this.checkHostOverrideInstaller();
  626. this.activateSpecialConfigs();
  627. this.selectProperService();
  628. if (this.get('content.skipConfigStep')) {
  629. App.router.send('next');
  630. }
  631. },
  632. /**
  633. * If <code>App.supports.hostOverridesInstaller</code> is enabled should load config groups
  634. * and (if some services are already installed) load config groups for installed services
  635. * @method checkHostOverrideInstaller
  636. */
  637. checkHostOverrideInstaller: function () {
  638. if (App.get('supports.hostOverridesInstaller')) {
  639. this.loadConfigGroups(this.get('content.configGroups'));
  640. if (this.get('installedServiceNames').length > 0) {
  641. this.loadInstalledServicesConfigGroups(this.get('installedServiceNames'));
  642. }
  643. }
  644. },
  645. /**
  646. * Set init <code>stepConfigs</code> value
  647. * Set <code>selected</code> for addable services if addServiceController is used
  648. * Remove SNameNode if HA is enabled (and if addServiceController is used)
  649. * @param {Ember.Object[]} configs
  650. * @param {Ember.Object[]} storedConfigs
  651. * @method setStepConfigs
  652. */
  653. setStepConfigs: function (configs, storedConfigs) {
  654. var localDB = {
  655. hosts: this.get('wizardController.content.hosts'),
  656. masterComponentHosts: this.get('wizardController.content.masterComponentHosts'),
  657. slaveComponentHosts: this.get('wizardController.content.slaveComponentHosts')
  658. };
  659. var serviceConfigs = App.config.renderConfigs(configs, storedConfigs, this.get('allSelectedServiceNames'), this.get('installedServiceNames'), localDB);
  660. if (this.get('wizardController.name') === 'addServiceController') {
  661. serviceConfigs.setEach('showConfig', true);
  662. serviceConfigs.setEach('selected', false);
  663. this.get('selectedServiceNames').forEach(function (serviceName) {
  664. if (!serviceConfigs.findProperty('serviceName', serviceName)) return;
  665. serviceConfigs.findProperty('serviceName', serviceName).set('selected', true);
  666. });
  667. // Remove SNameNode if HA is enabled
  668. if (App.get('isHaEnabled')) {
  669. var c = serviceConfigs.findProperty('serviceName', 'HDFS').configs;
  670. var removedConfigs = c.filterProperty('category', 'SECONDARY_NAMENODE');
  671. removedConfigs.map(function (config) {
  672. c = c.without(config);
  673. });
  674. serviceConfigs.findProperty('serviceName', 'HDFS').configs = c;
  675. }
  676. }
  677. this.set('stepConfigs', serviceConfigs);
  678. },
  679. /**
  680. * Select first addable service for <code>addServiceWizard</code>
  681. * Select first service at all in other cases
  682. * @method selectProperService
  683. */
  684. selectProperService: function () {
  685. if (this.get('wizardController.name') === 'addServiceController') {
  686. this.set('selectedService', this.get('stepConfigs').filterProperty('selected', true).get('firstObject'));
  687. }
  688. else {
  689. this.set('selectedService', this.get('stepConfigs').filterProperty('showConfig', true).objectAt(0));
  690. }
  691. },
  692. /**
  693. * Load config tags
  694. * @return {$.ajax|null}
  695. * @method getConfigTags
  696. */
  697. getConfigTags: function () {
  698. this.set('isAppliedConfigLoaded', false);
  699. return App.ajax.send({
  700. name: 'config.tags',
  701. sender: this,
  702. success: 'getConfigTagsSuccess'
  703. });
  704. },
  705. /**
  706. * Success callback for config tags request
  707. * Updates <code>serviceConfigTags</code> with tags received from server
  708. * @param {object} data
  709. * @method getConfigTagsSuccess
  710. */
  711. getConfigTagsSuccess: function (data) {
  712. var installedServiceSites = [];
  713. App.StackService.find().filterProperty('isInstalled').forEach(function (service) {
  714. if (!service.get('configTypes')) return;
  715. var configTypes = Object.keys(service.get('configTypes'));
  716. installedServiceSites = installedServiceSites.concat(configTypes);
  717. }, this);
  718. installedServiceSites = installedServiceSites.uniq();
  719. var serviceConfigTags = [];
  720. for (var site in data.Clusters.desired_configs) {
  721. if (data.Clusters.desired_configs.hasOwnProperty(site)) {
  722. if (installedServiceSites.contains(site)) {
  723. serviceConfigTags.push({
  724. siteName: site,
  725. tagName: data.Clusters.desired_configs[site].tag,
  726. newTagName: null
  727. });
  728. }
  729. }
  730. }
  731. this.set('serviceConfigTags', serviceConfigTags);
  732. this.set('isAppliedConfigLoaded', true);
  733. },
  734. /**
  735. * set configs actual values from server
  736. * @param serviceConfigTags
  737. * @param configs
  738. * @method setInstalledServiceConfigs
  739. */
  740. setInstalledServiceConfigs: function (serviceConfigTags, configs, configsByTags) {
  741. var configsMap = {};
  742. var configTypeMap = {};
  743. var configMixin = App.get('config');
  744. var self = this;
  745. configsByTags.forEach(function (configSite) {
  746. $.extend(configsMap, configSite.properties);
  747. for (var name in configSite.properties) {
  748. configTypeMap[name] = configSite.type;
  749. }
  750. });
  751. configs.forEach(function (_config) {
  752. if (!Em.isNone(configsMap[_config.name])) {
  753. // prevent overriding already edited properties
  754. if (_config.defaultValue != configsMap[_config.name])
  755. _config.value = configsMap[_config.name];
  756. _config.defaultValue = configsMap[_config.name];
  757. _config.hasInitialValue = true;
  758. App.config.handleSpecialProperties(_config);
  759. delete configsMap[_config.name];
  760. }
  761. });
  762. self.setServiceDatabaseConfigs(configs);
  763. //add user properties
  764. for (var name in configsMap) {
  765. configs.push(configMixin.addUserProperty({
  766. id: 'site property',
  767. name: name,
  768. serviceName: configMixin.getServiceNameByConfigType(configTypeMap[name]),
  769. value: configsMap[name],
  770. defaultValue: configsMap[name],
  771. filename: (configMixin.get('filenameExceptions').contains(configTypeMap[name])) ? configTypeMap[name] : configTypeMap[name] + '.xml',
  772. category: 'Advanced',
  773. hasInitialValue: true,
  774. isUserProperty: true,
  775. isOverridable: true,
  776. overrides: [],
  777. isRequired: true,
  778. isVisible: true,
  779. showLabel: true
  780. }, false, []));
  781. }
  782. },
  783. /**
  784. * Check if Oozie or Hive use existing database then need
  785. * to restore missed properties
  786. *
  787. * @param {Object[]} configs
  788. **/
  789. setServiceDatabaseConfigs: function(configs) {
  790. var serviceNames = this.get('installedServiceNames').filter(function(serviceName) {
  791. return ['OOZIE', 'HIVE'].contains(serviceName);
  792. });
  793. serviceNames.forEach(function(serviceName) {
  794. var dbTypeConfig = configs.findProperty('name', serviceName.toLowerCase() + '_database');
  795. if (!/existing/gi.test(dbTypeConfig.value)) return;
  796. var dbHostName = serviceName.toLowerCase() + '_hostname';
  797. var database = dbTypeConfig.value.match(/MySQL|PostgreSQL|Oracle|Derby/gi)[0];
  798. var existingDBConfig = configs.findProperty('name', serviceName.toLowerCase() + '_existing_' + database.toLowerCase() + '_host');
  799. if (!existingDBConfig.value)
  800. existingDBConfig.value = existingDBConfig.defaultValue = configs.findProperty('name', dbHostName).value;
  801. }, this);
  802. },
  803. /**
  804. * Add group ids to <code>groupsToDelete</code>
  805. * Also save <code>groupsToDelete</code> to local storage
  806. * @param {Ember.Object[]} groups
  807. * @method setGroupsToDelete
  808. */
  809. setGroupsToDelete: function (groups) {
  810. var groupsToDelete = this.get('groupsToDelete');
  811. groups.forEach(function (group) {
  812. if (group.get('id'))
  813. groupsToDelete.push({
  814. id: group.get('id')
  815. });
  816. });
  817. this.get('wizardController').setDBProperty('groupsToDelete', groupsToDelete);
  818. },
  819. /**
  820. * Update <code>configGroups</code> with selected service configGroups
  821. * Also set default group to first position
  822. * Update <code>selectedConfigGroup</code> with new default group
  823. * @method selectedServiceObserver
  824. */
  825. selectedServiceObserver: function () {
  826. if (App.supports.hostOverridesInstaller && this.get('selectedService') && (this.get('selectedService.serviceName') !== 'MISC')) {
  827. var serviceGroups = this.get('selectedService.configGroups');
  828. serviceGroups.forEach(function (item, index, array) {
  829. if (item.isDefault) {
  830. array.unshift(item);
  831. array.splice(index + 1, 1);
  832. }
  833. });
  834. this.set('configGroups', serviceGroups);
  835. this.set('selectedConfigGroup', serviceGroups.findProperty('isDefault'));
  836. }
  837. }.observes('selectedService.configGroups.@each'),
  838. /**
  839. * load default groups for each service in case of initial load
  840. * @param serviceConfigGroups
  841. * @method loadConfigGroups
  842. */
  843. loadConfigGroups: function (serviceConfigGroups) {
  844. var services = this.get('stepConfigs');
  845. var hosts = this.get('wizardController.allHosts').mapProperty('hostName');
  846. services.forEach(function (service) {
  847. if (service.get('serviceName') === 'MISC') return;
  848. var serviceRawGroups = serviceConfigGroups.filterProperty('service.id', service.serviceName);
  849. if (!serviceRawGroups.length) {
  850. service.set('configGroups', [
  851. App.ConfigGroup.create({
  852. name: service.displayName + " Default",
  853. description: "Default cluster level " + service.serviceName + " configuration",
  854. isDefault: true,
  855. hosts: Em.copy(hosts),
  856. service: Em.Object.create({
  857. id: service.serviceName
  858. }),
  859. serviceName: service.serviceName
  860. })
  861. ]);
  862. }
  863. else {
  864. var defaultGroup = App.ConfigGroup.create(serviceRawGroups.findProperty('isDefault'));
  865. var serviceGroups = service.get('configGroups');
  866. serviceRawGroups.filterProperty('isDefault', false).forEach(function (configGroup) {
  867. var readyGroup = App.ConfigGroup.create(configGroup);
  868. var wrappedProperties = [];
  869. readyGroup.get('properties').forEach(function (property) {
  870. wrappedProperties.pushObject(App.ServiceConfigProperty.create(property));
  871. });
  872. wrappedProperties.setEach('group', readyGroup);
  873. readyGroup.set('properties', wrappedProperties);
  874. readyGroup.set('parentConfigGroup', defaultGroup);
  875. serviceGroups.pushObject(readyGroup);
  876. });
  877. defaultGroup.set('childConfigGroups', serviceGroups);
  878. serviceGroups.pushObject(defaultGroup);
  879. }
  880. });
  881. },
  882. /**
  883. * Click-handler on config-group to make it selected
  884. * @param {object} event
  885. * @method selectConfigGroup
  886. */
  887. selectConfigGroup: function (event) {
  888. this.set('selectedConfigGroup', event.context);
  889. },
  890. /**
  891. * Rebuild list of configs switch of config group:
  892. * on default - display all configs from default group and configs from non-default groups as disabled
  893. * on non-default - display all from default group as disabled and configs from selected non-default group
  894. * @method switchConfigGroupConfigs
  895. */
  896. switchConfigGroupConfigs: function () {
  897. var serviceConfigs = this.get('selectedService.configs'),
  898. selectedGroup = this.get('selectedConfigGroup'),
  899. overrideToAdd = this.get('overrideToAdd'),
  900. overrides = [];
  901. if (!selectedGroup) return;
  902. var displayedConfigGroups = this._getDisplayedConfigGroups();
  903. displayedConfigGroups.forEach(function (group) {
  904. overrides.pushObjects(group.get('properties'));
  905. });
  906. serviceConfigs.forEach(function (config) {
  907. this._setEditableValue(config);
  908. this._setOverrides(config, overrides);
  909. }, this);
  910. }.observes('selectedConfigGroup'),
  911. /**
  912. * Get list of config groups to display
  913. * Returns empty array if no <code>selectedConfigGroup</code>
  914. * @return {Array}
  915. * @method _getDisplayedConfigGroups
  916. */
  917. _getDisplayedConfigGroups: function () {
  918. var selectedGroup = this.get('selectedConfigGroup');
  919. if (!selectedGroup) return [];
  920. return (selectedGroup.get('isDefault')) ?
  921. this.get('selectedService.configGroups').filterProperty('isDefault', false) :
  922. [this.get('selectedConfigGroup')];
  923. },
  924. /**
  925. * Set <code>isEditable</code> property to <code>config</code>
  926. * @param {Ember.Object} config
  927. * @return {Ember.Object} updated config-object
  928. * @method _setEditableValue
  929. */
  930. _setEditableValue: function (config) {
  931. var selectedGroup = this.get('selectedConfigGroup');
  932. if (!selectedGroup) return config;
  933. var isEditable = config.get('isEditable'),
  934. isServiceInstalled = this.get('installedServiceNames').contains(this.get('selectedService.serviceName'));
  935. if (isServiceInstalled) {
  936. isEditable = (!isEditable && !config.get('isReconfigurable')) ? false : selectedGroup.get('isDefault');
  937. }
  938. else {
  939. isEditable = selectedGroup.get('isDefault');
  940. }
  941. config.set('isEditable', isEditable);
  942. return config;
  943. },
  944. /**
  945. * Set <code>overrides</code> property to <code>config</code>
  946. * @param {Ember.Object} config
  947. * @param {Ember.Enumerable} overrides
  948. * @returns {Ember.Object}
  949. * @method _setOverrides
  950. */
  951. _setOverrides: function (config, overrides) {
  952. var selectedGroup = this.get('selectedConfigGroup'),
  953. overrideToAdd = this.get('overrideToAdd'),
  954. configOverrides = overrides.filterProperty('name', config.get('name'));
  955. if (!selectedGroup) return config;
  956. if (overrideToAdd && overrideToAdd.get('name') === config.get('name')) {
  957. configOverrides.push(this.addOverrideProperty(config));
  958. this.set('overrideToAdd', null);
  959. }
  960. configOverrides.setEach('isEditable', !selectedGroup.get('isDefault'));
  961. configOverrides.setEach('parentSCP', config);
  962. config.set('overrides', configOverrides);
  963. return config;
  964. },
  965. /**
  966. * create overriden property and push it into Config group
  967. * @param {App.ServiceConfigProperty} serviceConfigProperty
  968. * @return {App.ServiceConfigProperty}
  969. * @method addOverrideProperty
  970. */
  971. addOverrideProperty: function (serviceConfigProperty) {
  972. var overrides = serviceConfigProperty.get('overrides') || [];
  973. var newSCP = App.ServiceConfigProperty.create(serviceConfigProperty);
  974. var group = this.get('selectedService.configGroups').findProperty('name', this.get('selectedConfigGroup.name'));
  975. newSCP.set('group', group);
  976. newSCP.set('value', '');
  977. newSCP.set('isOriginalSCP', false); // indicated this is overridden value,
  978. newSCP.set('parentSCP', serviceConfigProperty);
  979. newSCP.set('isEditable', true);
  980. group.get('properties').pushObject(newSCP);
  981. overrides.pushObject(newSCP);
  982. return newSCP;
  983. },
  984. /**
  985. * @method manageConfigurationGroup
  986. */
  987. manageConfigurationGroup: function () {
  988. App.router.get('mainServiceInfoConfigsController').manageConfigurationGroups(this);
  989. },
  990. /**
  991. * Make some configs visible depending on active services
  992. * @method activateSpecialConfigs
  993. */
  994. activateSpecialConfigs: function () {
  995. var miscConfigs = this.get('stepConfigs').findProperty('serviceName', 'MISC').configs;
  996. miscConfigs = App.config.miscConfigVisibleProperty(miscConfigs, this.get('selectedServiceNames'));
  997. },
  998. /**
  999. * Check whether hive New MySQL database is on the same host as Ambari server MySQL server
  1000. * @return {$.ajax|null}
  1001. * @method checkMySQLHost
  1002. */
  1003. checkMySQLHost: function () {
  1004. // get ambari database type and hostname
  1005. return App.ajax.send({
  1006. name: 'config.ambari.database.info',
  1007. sender: this,
  1008. success: 'getAmbariDatabaseSuccess'
  1009. });
  1010. },
  1011. /**
  1012. * Success callback for ambari database, get Ambari DB type and DB server hostname, then
  1013. * Check whether hive New MySQL database is on the same host as Ambari server MySQL server
  1014. * @param {object} data
  1015. * @method getAmbariDatabaseSuccess
  1016. */
  1017. getAmbariDatabaseSuccess: function (data) {
  1018. var hiveDBHostname = this.get('stepConfigs').findProperty('serviceName', 'HIVE').configs.findProperty('name', 'hivemetastore_host').value;
  1019. var ambariServiceHostComponents = data.hostComponents;
  1020. if (!!ambariServiceHostComponents.length) {
  1021. var ambariDBInfo = JSON.stringify(ambariServiceHostComponents[0].RootServiceHostComponents.properties);
  1022. this.set('mySQLServerConflict', ambariDBInfo.indexOf('mysql') > 0 && ambariDBInfo.indexOf(hiveDBHostname) > 0);
  1023. } else {
  1024. this.set('mySQLServerConflict', false);
  1025. }
  1026. },
  1027. /**
  1028. * Check if new MySql database was chosen for Hive service
  1029. * and it is not located on the same host as Ambari server
  1030. * that using MySql database too.
  1031. *
  1032. * @method resolveHiveMysqlDatabase
  1033. **/
  1034. resolveHiveMysqlDatabase: function () {
  1035. var hiveService = this.get('content.services').findProperty('serviceName', 'HIVE');
  1036. if (!hiveService || !hiveService.get('isSelected') || hiveService.get('isInstalled')) {
  1037. this.moveNext();
  1038. return;
  1039. }
  1040. var hiveDBType = this.get('stepConfigs').findProperty('serviceName', 'HIVE').configs.findProperty('name', 'hive_database').value;
  1041. if (hiveDBType == 'New MySQL Database') {
  1042. var self = this;
  1043. this.checkMySQLHost().done(function () {
  1044. if (self.get('mySQLServerConflict')) {
  1045. // error popup before you can proceed
  1046. return App.ModalPopup.show({
  1047. header: Em.I18n.t('installer.step7.popup.mySQLWarning.header'),
  1048. bodyClass: Ember.View.extend({
  1049. template: Ember.Handlebars.compile(Em.I18n.t('installer.step7.popup.mySQLWarning.body'))
  1050. }),
  1051. secondary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.gotostep5'),
  1052. primary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.dismiss'),
  1053. onSecondary: function () {
  1054. var parent = this;
  1055. return App.ModalPopup.show({
  1056. header: Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.header'),
  1057. bodyClass: Ember.View.extend({
  1058. template: Ember.Handlebars.compile(Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.body'))
  1059. }),
  1060. onPrimary: function () {
  1061. this.hide();
  1062. parent.hide();
  1063. // go back to step 5: assign masters and disable default navigation warning
  1064. App.router.get('installerController').gotoStep(5, true);
  1065. }
  1066. });
  1067. }
  1068. });
  1069. } else {
  1070. self.moveNext();
  1071. }
  1072. });
  1073. } else {
  1074. this.moveNext();
  1075. }
  1076. },
  1077. checkDatabaseConnectionTest: function () {
  1078. var deferred = $.Deferred();
  1079. if (!App.supports.databaseConnection) {
  1080. deferred.resolve();
  1081. return deferred;
  1082. }
  1083. var configMap = [
  1084. {
  1085. serviceName: 'OOZIE',
  1086. ignored: Em.I18n.t('installer.step7.oozie.database.new')
  1087. },
  1088. {
  1089. serviceName: 'HIVE',
  1090. ignored: Em.I18n.t('installer.step7.hive.database.new')
  1091. }
  1092. ];
  1093. configMap.forEach(function (config) {
  1094. var isConnectionNotTested = false;
  1095. var service = this.get('content.services').findProperty('serviceName', config.serviceName);
  1096. if (service && service.get('isSelected') && !service.get('isInstalled')) {
  1097. var serviceConfigs = this.get('stepConfigs').findProperty('serviceName', config.serviceName).configs;
  1098. var serviceDatabase = serviceConfigs.findProperty('name', config.serviceName.toLowerCase() + '_database').get('value');
  1099. if (serviceDatabase !== config.ignored) {
  1100. var filledProperties = App.db.get('tmp', config.serviceName + '_connection');
  1101. if (!filledProperties || App.isEmptyObject(filledProperties)) {
  1102. isConnectionNotTested = true;
  1103. } else {
  1104. for (var key in filledProperties) {
  1105. if (serviceConfigs.findProperty('name', key).get('value') !== filledProperties[key])
  1106. isConnectionNotTested = true;
  1107. }
  1108. }
  1109. }
  1110. }
  1111. config.isCheckIgnored = isConnectionNotTested;
  1112. }, this);
  1113. var ignoredServices = configMap.filterProperty('isCheckIgnored', true);
  1114. if (ignoredServices.length) {
  1115. var displayedServiceNames = ignoredServices.mapProperty('serviceName').map(function (serviceName) {
  1116. return this.get('content.services').findProperty('serviceName', serviceName).get('displayName');
  1117. }, this);
  1118. this.showDatabaseConnectionWarningPopup(displayedServiceNames, deferred);
  1119. }
  1120. else {
  1121. deferred.resolve();
  1122. }
  1123. return deferred;
  1124. },
  1125. showDatabaseConnectionWarningPopup: function (serviceNames, deferred) {
  1126. return App.ModalPopup.show({
  1127. header: Em.I18n.t('installer.step7.popup.database.connection.header'),
  1128. body: Em.I18n.t('installer.step7.popup.database.connection.body').format(serviceNames.join(', ')),
  1129. secondary: Em.I18n.t('common.cancel'),
  1130. primary: Em.I18n.t('common.proceedAnyway'),
  1131. onPrimary: function () {
  1132. deferred.resolve();
  1133. this._super();
  1134. },
  1135. onSecondary: function () {
  1136. deferred.reject();
  1137. this._super();
  1138. }
  1139. })
  1140. },
  1141. /**
  1142. * Proceed to the next step
  1143. **/
  1144. moveNext: function () {
  1145. App.router.send('next');
  1146. },
  1147. /**
  1148. * Click-handler on Next button
  1149. * @method submit
  1150. */
  1151. submit: function () {
  1152. var _this = this;
  1153. if (!this.get('isSubmitDisabled')) {
  1154. this.checkDatabaseConnectionTest().done(function () {
  1155. _this.resolveHiveMysqlDatabase();
  1156. });
  1157. }
  1158. }
  1159. });