step7_controller.js 44 KB

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