step7_controller.js 51 KB

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