step7_controller.js 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351
  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. if (serviceConfig.get('serviceName') === 'HDFS') {
  369. App.config.OnNnHAHideSnn(serviceConfig);
  370. }
  371. service.set('selectedConfigGroup', this.get('preSelectedConfigGroup'));
  372. this.loadComponentConfigs(service.get('configs'), serviceConfig, service);
  373. service.set('configs', serviceConfig.get('configs'));
  374. },
  375. /**
  376. * Set <code>isEditable</code>-property to <code>serviceConfigProperty</code>
  377. * Based on user's permissions and selected config group
  378. * @param {Ember.Object} serviceConfigProperty
  379. * @param {bool} defaultGroupSelected
  380. * @returns {Ember.Object} Updated config-object
  381. * @method _updateIsEditableFlagForConfig
  382. */
  383. _updateIsEditableFlagForConfig: function (serviceConfigProperty, defaultGroupSelected) {
  384. if (App.isAccessible('ADMIN')) {
  385. if (defaultGroupSelected && !this.get('isHostsConfigsPage') && !Em.get(serviceConfigProperty, 'group')) {
  386. serviceConfigProperty.set('isEditable', serviceConfigProperty.get('isReconfigurable'));
  387. } else if (Em.get(serviceConfigProperty, 'group') && Em.get(serviceConfigProperty, 'group.name') == this.get('selectedConfigGroup.name')) {
  388. serviceConfigProperty.set('isEditable', true);
  389. } else {
  390. serviceConfigProperty.set('isEditable', false);
  391. }
  392. }
  393. else {
  394. serviceConfigProperty.set('isEditable', false);
  395. }
  396. return serviceConfigProperty;
  397. },
  398. /**
  399. * Set <code>overrides</code>-property to <code>serviceConfigProperty<code>
  400. * @param {Ember.Object} serviceConfigProperty
  401. * @param {Ember.Object} component
  402. * @return {Ember.Object} Updated config-object
  403. * @method _updateOverridesForConfig
  404. */
  405. _updateOverridesForConfig: function (serviceConfigProperty, component) {
  406. var overrides = serviceConfigProperty.get('overrides');
  407. if (Em.isNone(overrides)) {
  408. serviceConfigProperty.set('overrides', Em.A([]));
  409. return serviceConfigProperty;
  410. }
  411. serviceConfigProperty.set('overrides', null);
  412. var defaultGroupSelected = component.get('selectedConfigGroup.isDefault');
  413. // Wrap each override to App.ServiceConfigProperty
  414. overrides.forEach(function (override) {
  415. var newSCP = App.ServiceConfigProperty.create(serviceConfigProperty);
  416. newSCP.set('value', override.value);
  417. newSCP.set('isOriginalSCP', false); // indicated this is overridden value,
  418. newSCP.set('parentSCP', serviceConfigProperty);
  419. if (defaultGroupSelected) {
  420. var group = component.get('configGroups').findProperty('name', override.group.get('name'));
  421. // prevent cycle in proto object, clean link
  422. if (group.get('properties').length == 0) {
  423. group.set('properties', Em.A([]));
  424. }
  425. group.get('properties').push(newSCP);
  426. newSCP.set('group', override.group);
  427. newSCP.set('isEditable', false);
  428. }
  429. var parentOverridesArray = serviceConfigProperty.get('overrides');
  430. if (Em.isNone(parentOverridesArray)) {
  431. parentOverridesArray = Em.A([]);
  432. serviceConfigProperty.set('overrides', parentOverridesArray);
  433. }
  434. serviceConfigProperty.get('overrides').pushObject(newSCP);
  435. newSCP.validate();
  436. }, this);
  437. return serviceConfigProperty;
  438. },
  439. /**
  440. * Set configs with overrides, recommended defaults to component
  441. * @param {Ember.Object[]} configs
  442. * @param {Ember.Object} componentConfig
  443. * @param {Ember.Object} component
  444. * @method loadComponentConfigs
  445. */
  446. loadComponentConfigs: function (configs, componentConfig, component) {
  447. var defaultGroupSelected = component.get('selectedConfigGroup.isDefault');
  448. configs.forEach(function (serviceConfigProperty) {
  449. if (!serviceConfigProperty) return;
  450. if (Em.isNone(serviceConfigProperty.get('isOverridable'))) {
  451. serviceConfigProperty.set('isOverridable', true);
  452. }
  453. this._updateOverridesForConfig(serviceConfigProperty, component);
  454. this._updateIsEditableFlagForConfig(serviceConfigProperty, defaultGroupSelected);
  455. componentConfig.get('configs').pushObject(serviceConfigProperty);
  456. serviceConfigProperty.validate();
  457. }, this);
  458. component.get('configGroups').filterProperty('isDefault', false).forEach(function (configGroup) {
  459. configGroup.set('hash', this.get('wizardController').getConfigGroupHash(configGroup));
  460. }, this);
  461. var overrideToAdd = this.get('overrideToAdd');
  462. if (overrideToAdd) {
  463. overrideToAdd = componentConfig.get('configs').findProperty('name', overrideToAdd.name);
  464. if (overrideToAdd) {
  465. this.addOverrideProperty(overrideToAdd);
  466. component.set('overrideToAdd', null);
  467. }
  468. }
  469. },
  470. /**
  471. * Resolve dependency between configs.
  472. * @param serviceName {String}
  473. * @param configs {Ember.Enumerable}
  474. */
  475. resolveServiceDependencyConfigs: function (serviceName, configs) {
  476. switch (serviceName) {
  477. case 'STORM':
  478. this.resolveStormConfigs(configs);
  479. break;
  480. case 'YARN':
  481. this.resolveYarnConfigs(configs);
  482. break;
  483. }
  484. },
  485. /**
  486. * Update some Storm configs
  487. * If Ganglia is selected to install or already installed, Ganglia host should be added to configs
  488. * @param {Ember.Enumerable} configs
  489. * @method resolveStormConfigs
  490. */
  491. resolveStormConfigs: function (configs) {
  492. var dependentConfigs, gangliaServerHost, gangliaHostId, hosts;
  493. dependentConfigs = ['nimbus.childopts', 'supervisor.childopts', 'worker.childopts'];
  494. // if Ganglia selected or installed, set ganglia host to configs
  495. if (this.get('installedServiceNames').contains('STORM') && this.get('installedServiceNames').contains('GANGLIA')) return;
  496. if (this.get('allSelectedServiceNames').contains('GANGLIA') || this.get('installedServiceNames').contains('GANGLIA')) {
  497. if (this.get('wizardController.name') === 'addServiceController') {
  498. gangliaServerHost = this.get('wizardController').getDBProperty('masterComponentHosts').findProperty('component', 'GANGLIA_SERVER').hostName;
  499. } else {
  500. hosts = this.get('wizardController').getDBProperty('hosts');
  501. gangliaHostId = this.get('wizardController').getDBProperty('masterComponentHosts').findProperty('component', 'GANGLIA_SERVER').host_id;
  502. for (var hostName in hosts) {
  503. if (hosts[hostName].id == gangliaHostId) gangliaServerHost = hosts[hostName].name;
  504. }
  505. }
  506. dependentConfigs.forEach(function (configName) {
  507. var config = configs.findProperty('name', configName);
  508. if (!Em.isNone(config.value)) {
  509. var replaceStr = config.value.match(/.jar=host[^,]+/)[0];
  510. var replaceWith = replaceStr.slice(0, replaceStr.lastIndexOf('=') - replaceStr.length + 1) + gangliaServerHost;
  511. config.value = config.recommendedValue = config.value.replace(replaceStr, replaceWith);
  512. }
  513. }, this);
  514. }
  515. },
  516. /**
  517. * Update some Storm configs
  518. * If SLIDER is selected to install or already installed,
  519. * some Yarn properties must be changed
  520. * @param {Ember.Enumerable} configs
  521. * @method resolveYarnConfigs
  522. */
  523. resolveYarnConfigs: function (configs) {
  524. var cfgToChange = configs.findProperty('name', 'hadoop.registry.rm.enabled');
  525. if (cfgToChange) {
  526. var res = this.get('allSelectedServiceNames').contains('SLIDER');
  527. if (Em.get(cfgToChange, 'value') !== res) {
  528. Em.set(cfgToChange, 'recommendedValue', res);
  529. Em.set(cfgToChange, 'value', res);
  530. }
  531. }
  532. },
  533. /**
  534. * On load function
  535. * @method loadStep
  536. */
  537. loadStep: function () {
  538. console.log("TRACE: Loading step7: Configure Services");
  539. if (!this.get('isConfigsLoaded')) {
  540. return;
  541. }
  542. this.clearStep();
  543. var self = this;
  544. //STEP 1: Load advanced configs
  545. var advancedConfigs = this.get('content.advancedServiceConfig');
  546. //STEP 2: Load on-site configs by service from local DB
  547. var storedConfigs = this.get('content.serviceConfigProperties');
  548. //STEP 3: Merge pre-defined configs with loaded on-site configs
  549. var configs = App.config.mergePreDefinedWithStored(
  550. storedConfigs,
  551. advancedConfigs,
  552. this.get('selectedServiceNames').concat(this.get('installedServiceNames'))
  553. );
  554. App.config.setPreDefinedServiceConfigs(this.get('addMiscTabToPage'));
  555. //STEP 4: Add advanced configs
  556. App.config.addAdvancedConfigs(configs, advancedConfigs);
  557. this.set('groupsToDelete', this.get('wizardController').getDBProperty('groupsToDelete') || []);
  558. if (this.get('wizardController.name') === 'addServiceController') {
  559. App.router.get('configurationController').getConfigsByTags(this.get('serviceConfigTags')).done(function (loadedConfigs) {
  560. self.setInstalledServiceConfigs(self.get('serviceConfigTags'), configs, loadedConfigs, self.get('installedServiceNames'));
  561. self.applyServicesConfigs(configs, storedConfigs);
  562. });
  563. } else {
  564. this.applyServicesConfigs(configs, storedConfigs);
  565. }
  566. },
  567. applyServicesConfigs: function (configs, storedConfigs) {
  568. if (this.get('allSelectedServiceNames').contains('YARN')) {
  569. configs = App.config.fileConfigsIntoTextarea(configs, 'capacity-scheduler.xml', []);
  570. }
  571. var dependedServices = ["STORM", "YARN"];
  572. dependedServices.forEach(function (serviceName) {
  573. if (this.get('allSelectedServiceNames').contains(serviceName)) {
  574. this.resolveServiceDependencyConfigs(serviceName, configs);
  575. }
  576. }, this);
  577. //STEP 6: Distribute configs by service and wrap each one in App.ServiceConfigProperty (configs -> serviceConfigs)
  578. var self = this;
  579. if (self.get('securityEnabled') && self.get('wizardController.name') == 'addServiceController') {
  580. self.addKerberosDescriptorConfigs(configs, self.get('wizardController.kerberosDescriptorConfigs') || []);
  581. }
  582. self.setStepConfigs(configs, storedConfigs);
  583. this.loadServerSideConfigsRecommendations().always(function () {
  584. // format descriptor configs
  585. var serviceConfigProperties = (self.get('content.serviceConfigProperties') || []).mapProperty('name');
  586. var recommendedToDelete = self.get('_dependentConfigValues').filterProperty('toDelete');
  587. recommendedToDelete.forEach(function (c) {
  588. var name = Em.get(c, 'propertyName');
  589. if (serviceConfigProperties.contains(name)) {
  590. Em.set(self.get('_dependentConfigValues').findProperty('propertyName', name), 'toDelete', false);
  591. }
  592. });
  593. self.updateDependentConfigs();
  594. self.checkHostOverrideInstaller();
  595. self.activateSpecialConfigs();
  596. self.selectProperService();
  597. self.restoreRecommendedConfigs();
  598. self.clearDependentConfigsByService(App.StackService.find().filterProperty('isSelected').mapProperty('serviceName'));
  599. self.set('isRecommendedLoaded', true);
  600. if (self.get('content.skipConfigStep')) {
  601. App.router.send('next');
  602. }
  603. });
  604. },
  605. /**
  606. * After user navigates back to step7, values for depended configs should be set to values set by user and not to default values
  607. * @method restoreRecommendedConfigs
  608. */
  609. restoreRecommendedConfigs: function () {
  610. var recommendationsConfigs = this.get('recommendationsConfigs') || {};
  611. var serviceConfigProperties = this.get('content.serviceConfigProperties') || [];
  612. var stepConfigs = this.get('stepConfigs');
  613. Em.keys(recommendationsConfigs).forEach(function (file) {
  614. (Em.keys(recommendationsConfigs[file].properties).concat(Em.keys(recommendationsConfigs[file].property_attributes || {}))).forEach(function (configName) {
  615. stepConfigs.forEach(function (stepConfig) {
  616. stepConfig.get('configs').filterProperty('name', configName).forEach(function (configProperty) {
  617. if (Em.get(configProperty, 'filename').contains(file)) {
  618. var scps = serviceConfigProperties.filterProperty('name', configName).filter(function (cp) {
  619. return Em.get(cp, 'filename').contains(file);
  620. });
  621. if (scps.length) {
  622. Em.set(configProperty, 'value', Em.get(scps[0], 'value'));
  623. }
  624. }
  625. });
  626. });
  627. });
  628. });
  629. },
  630. /**
  631. * Mark descriptor properties in configuration object.
  632. *
  633. * @param {Object[]} configs - config properties to change
  634. * @param {App.ServiceConfigProperty[]} descriptor - parsed kerberos descriptor
  635. * @method addKerberosDescriptorConfigs
  636. */
  637. addKerberosDescriptorConfigs: function (configs, descriptor) {
  638. descriptor.forEach(function (item) {
  639. var property = configs.findProperty('name', item.get('name'));
  640. if (property) {
  641. Em.setProperties(property, {
  642. isSecureConfig: true,
  643. displayName: Em.get(item, 'name'),
  644. isUserProperty: false,
  645. isOverridable: false,
  646. category: 'Advanced ' + Em.get(item, 'filename')
  647. });
  648. }
  649. });
  650. },
  651. /**
  652. * Load config groups
  653. * and (if some services are already installed) load config groups for installed services
  654. * @method checkHostOverrideInstaller
  655. */
  656. checkHostOverrideInstaller: function () {
  657. if (this.get('wizardController.name') !== 'kerberosWizardController') {
  658. this.loadConfigGroups(this.get('content.configGroups'));
  659. }
  660. if (this.get('installedServiceNames').length > 0) {
  661. this.loadInstalledServicesConfigGroups(this.get('installedServiceNames'));
  662. }
  663. },
  664. /**
  665. * Set init <code>stepConfigs</code> value
  666. * Set <code>selected</code> for addable services if addServiceController is used
  667. * Remove SNameNode if HA is enabled (and if addServiceController is used)
  668. * @param {Ember.Object[]} configs
  669. * @param {Ember.Object[]} storedConfigs
  670. * @method setStepConfigs
  671. */
  672. setStepConfigs: function (configs, storedConfigs) {
  673. var localDB = {
  674. hosts: this.get('wizardController.content.hosts'),
  675. masterComponentHosts: this.get('wizardController.content.masterComponentHosts'),
  676. slaveComponentHosts: this.get('wizardController.content.slaveComponentHosts')
  677. };
  678. var serviceConfigs = App.config.renderConfigs(configs, storedConfigs, this.get('allSelectedServiceNames'), this.get('installedServiceNames'), localDB);
  679. if (this.get('wizardController.name') === 'addServiceController') {
  680. serviceConfigs.setEach('showConfig', true);
  681. serviceConfigs.setEach('selected', false);
  682. this.get('selectedServiceNames').forEach(function (serviceName) {
  683. if (!serviceConfigs.findProperty('serviceName', serviceName)) return;
  684. serviceConfigs.findProperty('serviceName', serviceName).set('selected', true);
  685. }, this);
  686. this.get('installedServiceNames').forEach(function (serviceName) {
  687. var serviceConfigObj = serviceConfigs.findProperty('serviceName', serviceName);
  688. var isInstallableService = App.StackService.find(serviceName).get('isInstallable');
  689. if (!isInstallableService) serviceConfigObj.set('showConfig', false);
  690. }, this);
  691. // if HA is enabled -> Remove SNameNode, hbase.rootdir should use Name Service ID
  692. if (App.get('isHaEnabled')) {
  693. var c = serviceConfigs.findProperty('serviceName', 'HDFS').configs,
  694. nameServiceId = c.findProperty('name', 'dfs.nameservices'),
  695. removedConfigs = c.filterProperty('category', 'SECONDARY_NAMENODE');
  696. removedConfigs.map(function (config) {
  697. c = c.without(config);
  698. });
  699. serviceConfigs.findProperty('serviceName', 'HDFS').configs = c;
  700. if(this.get('selectedServiceNames').contains('HBASE') && nameServiceId){
  701. var hRootDir = serviceConfigs.findProperty('serviceName', 'HBASE').configs.findProperty('name','hbase.rootdir'),
  702. valueToChange = hRootDir.get('value').replace(/\/\/.*:/i, '//' + nameServiceId.get('value') + ':');
  703. hRootDir.setProperties({
  704. 'value': valueToChange,
  705. 'recommendedValue' : valueToChange
  706. });
  707. }
  708. }
  709. }
  710. // Remove Notifications from MISC if it isn't Installer Controller
  711. if (this.get('wizardController.name') !== 'installerController') {
  712. var miscService = serviceConfigs.findProperty('serviceName', 'MISC');
  713. if (miscService) {
  714. c = miscService.configs;
  715. removedConfigs = c.filterProperty('category', 'Notifications');
  716. removedConfigs.map(function (config) {
  717. c = c.without(config);
  718. });
  719. miscService.configs = c;
  720. }
  721. }
  722. this.set('stepConfigs', serviceConfigs);
  723. },
  724. /**
  725. * Select first addable service for <code>addServiceWizard</code>
  726. * Select first service at all in other cases
  727. * @method selectProperService
  728. */
  729. selectProperService: function () {
  730. if (this.get('wizardController.name') === 'addServiceController') {
  731. this.set('selectedService', this.get('stepConfigs').filterProperty('selected', true).get('firstObject'));
  732. } else {
  733. this.set('selectedService', this.get('stepConfigs').filterProperty('showConfig', true).objectAt(0));
  734. }
  735. },
  736. /**
  737. * Load config tags
  738. * @return {$.ajax|null}
  739. * @method getConfigTags
  740. */
  741. getConfigTags: function () {
  742. this.set('isAppliedConfigLoaded', false);
  743. return App.ajax.send({
  744. name: 'config.tags',
  745. sender: this,
  746. success: 'getConfigTagsSuccess'
  747. });
  748. },
  749. /**
  750. * Success callback for config tags request
  751. * Updates <code>serviceConfigTags</code> with tags received from server
  752. * @param {object} data
  753. * @method getConfigTagsSuccess
  754. */
  755. getConfigTagsSuccess: function (data) {
  756. var installedServiceSites = [];
  757. App.StackService.find().filterProperty('isInstalled').forEach(function (service) {
  758. if (!service.get('configTypes')) return;
  759. var configTypes = Object.keys(service.get('configTypes'));
  760. installedServiceSites = installedServiceSites.concat(configTypes);
  761. }, this);
  762. installedServiceSites = installedServiceSites.uniq();
  763. var serviceConfigTags = [];
  764. for (var site in data.Clusters.desired_configs) {
  765. if (data.Clusters.desired_configs.hasOwnProperty(site)) {
  766. if (installedServiceSites.contains(site)) {
  767. serviceConfigTags.push({
  768. siteName: site,
  769. tagName: data.Clusters.desired_configs[site].tag,
  770. newTagName: null
  771. });
  772. }
  773. }
  774. }
  775. this.set('serviceConfigTags', serviceConfigTags);
  776. this.set('isAppliedConfigLoaded', true);
  777. },
  778. /**
  779. * set configs actual values from server
  780. * @param serviceConfigTags
  781. * @param configs
  782. * @param configsByTags
  783. * @param installedServiceNames
  784. * @method setInstalledServiceConfigs
  785. */
  786. setInstalledServiceConfigs: function (serviceConfigTags, configs, configsByTags, installedServiceNames) {
  787. var configsMap = {};
  788. var configMixin = App.get('config');
  789. var nonServiceTab = require('data/service_configs');
  790. var self = this;
  791. configsByTags.forEach(function (configSite) {
  792. configsMap[configSite.type] = configSite.properties || {};
  793. });
  794. configs.forEach(function (_config) {
  795. var type = _config.filename ? App.config.getConfigTagFromFileName(_config.filename) : null;
  796. var mappedConfigValue = type && configsMap[type] ? configsMap[type][_config.name] : null;
  797. if (!Em.isNone(mappedConfigValue) && ((installedServiceNames && installedServiceNames.contains(_config.serviceName) || nonServiceTab.someProperty('serviceName', _config.serviceName)))) {
  798. // prevent overriding already edited properties
  799. if (_config.savedValue != mappedConfigValue) {
  800. _config.value = mappedConfigValue;
  801. }
  802. _config.savedValue = mappedConfigValue;
  803. _config.hasInitialValue = true;
  804. App.config.handleSpecialProperties(_config);
  805. delete configsMap[type][_config.name];
  806. }
  807. });
  808. self.setServiceDatabaseConfigs(configs);
  809. //add user properties
  810. Em.keys(configsMap).forEach(function (filename) {
  811. Em.keys(configsMap[filename]).forEach(function (propertyName) {
  812. configs.push(configMixin.addUserProperty({
  813. id: 'site property',
  814. name: propertyName,
  815. serviceName: configMixin.getServiceNameByConfigType(filename),
  816. value: configsMap[filename][propertyName],
  817. savedValue: configsMap[filename][propertyName],
  818. filename: configMixin.get('filenameExceptions').contains(filename) ? filename : filename + '.xml',
  819. category: 'Advanced',
  820. hasInitialValue: true,
  821. isUserProperty: true,
  822. isOverridable: true,
  823. overrides: [],
  824. isRequired: true,
  825. isVisible: true,
  826. showLabel: true
  827. }, false, []));
  828. });
  829. });
  830. },
  831. /**
  832. * Check if Oozie or Hive use existing database then need
  833. * to restore missed properties
  834. *
  835. * @param {Object[]} configs
  836. **/
  837. setServiceDatabaseConfigs: function (configs) {
  838. var serviceNames = this.get('installedServiceNames').filter(function (serviceName) {
  839. return ['OOZIE', 'HIVE'].contains(serviceName);
  840. });
  841. serviceNames.forEach(function (serviceName) {
  842. var propertyPrefix = serviceName.toLowerCase();
  843. var dbTypeConfig = configs.findProperty('name', propertyPrefix + '_database');
  844. if (!/existing/gi.test(dbTypeConfig.value)) return;
  845. var dbHostName = propertyPrefix + '_hostname';
  846. var database = dbTypeConfig.value.match(/MySQL|PostgreSQL|Oracle|Derby|MSSQL/gi)[0];
  847. var dbPrefix = database.toLowerCase();
  848. if (database.toLowerCase() == 'mssql') {
  849. if (/integrated/gi.test(dbTypeConfig.value)) {
  850. dbPrefix = 'mssql_server_2';
  851. } else {
  852. dbPrefix = 'mssql_server';
  853. }
  854. }
  855. var propertyName = propertyPrefix + '_existing_' + dbPrefix + '_host';
  856. var existingDBConfig = configs.findProperty('name', propertyName);
  857. if (!existingDBConfig.value)
  858. existingDBConfig.value = existingDBConfig.savedValue = configs.findProperty('name', dbHostName).value;
  859. }, this);
  860. },
  861. /**
  862. * Add group ids to <code>groupsToDelete</code>
  863. * Also save <code>groupsToDelete</code> to local storage
  864. * @param {Ember.Object[]} groups
  865. * @method setGroupsToDelete
  866. */
  867. setGroupsToDelete: function (groups) {
  868. var groupsToDelete = this.get('groupsToDelete');
  869. groups.forEach(function (group) {
  870. if (group.get('id'))
  871. groupsToDelete.push({
  872. id: group.get('id')
  873. });
  874. });
  875. this.get('wizardController').setDBProperty('groupsToDelete', groupsToDelete);
  876. },
  877. /**
  878. * Update <code>configGroups</code> with selected service configGroups
  879. * Also set default group to first position
  880. * Update <code>selectedConfigGroup</code> with new default group
  881. * @method selectedServiceObserver
  882. */
  883. selectedServiceObserver: function () {
  884. if (this.get('selectedService') && (this.get('selectedService.serviceName') !== 'MISC')) {
  885. var serviceGroups = this.get('selectedService.configGroups');
  886. serviceGroups.forEach(function (item, index, array) {
  887. if (item.isDefault) {
  888. array.unshift(item);
  889. array.splice(index + 1, 1);
  890. }
  891. });
  892. this.set('configGroups', serviceGroups);
  893. this.set('selectedConfigGroup', serviceGroups.findProperty('isDefault'));
  894. }
  895. }.observes('selectedService.configGroups.@each'),
  896. /**
  897. * load default groups for each service in case of initial load
  898. * @param serviceConfigGroups
  899. * @method loadConfigGroups
  900. */
  901. loadConfigGroups: function (serviceConfigGroups) {
  902. var services = this.get('stepConfigs');
  903. var hosts = this.get('wizardController.allHosts').mapProperty('hostName');
  904. services.forEach(function (service) {
  905. if (service.get('serviceName') === 'MISC') return;
  906. var serviceRawGroups = serviceConfigGroups.filterProperty('service.id', service.serviceName);
  907. if (!serviceRawGroups.length) {
  908. service.set('configGroups', [
  909. App.ConfigGroup.create({
  910. name: service.displayName + " Default",
  911. description: "Default cluster level " + service.serviceName + " configuration",
  912. isDefault: true,
  913. hosts: Em.copy(hosts),
  914. service: Em.Object.create({
  915. id: service.serviceName
  916. }),
  917. serviceName: service.serviceName
  918. })
  919. ]);
  920. }
  921. else {
  922. var defaultGroup = App.ConfigGroup.create(serviceRawGroups.findProperty('isDefault'));
  923. var serviceGroups = service.get('configGroups');
  924. serviceRawGroups.filterProperty('isDefault', false).forEach(function (configGroup) {
  925. var readyGroup = App.ConfigGroup.create(configGroup);
  926. var wrappedProperties = [];
  927. readyGroup.get('properties').forEach(function (propertyData) {
  928. var parentSCP = service.configs.filterProperty('filename', propertyData.filename).findProperty('name', propertyData.name);
  929. var overriddenSCP = App.ServiceConfigProperty.create(parentSCP);
  930. overriddenSCP.set('isOriginalSCP', false);
  931. overriddenSCP.set('parentSCP', parentSCP);
  932. overriddenSCP.set('group', readyGroup);
  933. overriddenSCP.setProperties(propertyData);
  934. wrappedProperties.pushObject(App.ServiceConfigProperty.create(overriddenSCP));
  935. });
  936. wrappedProperties.setEach('group', readyGroup);
  937. readyGroup.set('properties', wrappedProperties);
  938. readyGroup.set('parentConfigGroup', defaultGroup);
  939. serviceGroups.pushObject(readyGroup);
  940. });
  941. defaultGroup.set('childConfigGroups', serviceGroups);
  942. serviceGroups.pushObject(defaultGroup);
  943. }
  944. });
  945. },
  946. /**
  947. * Click-handler on config-group to make it selected
  948. * @param {object} event
  949. * @method selectConfigGroup
  950. */
  951. selectConfigGroup: function (event) {
  952. this.set('selectedConfigGroup', event.context);
  953. },
  954. /**
  955. * Rebuild list of configs switch of config group:
  956. * on default - display all configs from default group and configs from non-default groups as disabled
  957. * on non-default - display all from default group as disabled and configs from selected non-default group
  958. * @method switchConfigGroupConfigs
  959. */
  960. switchConfigGroupConfigs: function () {
  961. var serviceConfigs = this.get('selectedService.configs'),
  962. selectedGroup = this.get('selectedConfigGroup'),
  963. overrideToAdd = this.get('overrideToAdd'),
  964. overrides = [];
  965. if (!selectedGroup) return;
  966. var displayedConfigGroups = this._getDisplayedConfigGroups();
  967. displayedConfigGroups.forEach(function (group) {
  968. overrides.pushObjects(group.get('properties'));
  969. });
  970. serviceConfigs.forEach(function (config) {
  971. this._setEditableValue(config);
  972. this._setOverrides(config, overrides);
  973. }, this);
  974. }.observes('selectedConfigGroup'),
  975. /**
  976. * Get list of config groups to display
  977. * Returns empty array if no <code>selectedConfigGroup</code>
  978. * @return {Array}
  979. * @method _getDisplayedConfigGroups
  980. */
  981. _getDisplayedConfigGroups: function () {
  982. var selectedGroup = this.get('selectedConfigGroup');
  983. if (!selectedGroup) return [];
  984. return (selectedGroup.get('isDefault')) ?
  985. this.get('selectedService.configGroups').filterProperty('isDefault', false) :
  986. [this.get('selectedConfigGroup')];
  987. },
  988. /**
  989. * Set <code>isEditable</code> property to <code>config</code>
  990. * @param {Ember.Object} config
  991. * @return {Ember.Object} updated config-object
  992. * @method _setEditableValue
  993. */
  994. _setEditableValue: function (config) {
  995. var selectedGroup = this.get('selectedConfigGroup');
  996. if (!selectedGroup) return config;
  997. var isEditable = config.get('isEditable'),
  998. isServiceInstalled = this.get('installedServiceNames').contains(this.get('selectedService.serviceName'));
  999. if (isServiceInstalled) {
  1000. isEditable = (!isEditable && !config.get('isReconfigurable')) ? false : selectedGroup.get('isDefault');
  1001. }
  1002. else {
  1003. isEditable = selectedGroup.get('isDefault');
  1004. }
  1005. if (config.get('group')) {
  1006. isEditable = config.get('group.name') == this.get('selectedConfigGroup.name');
  1007. }
  1008. config.set('isEditable', isEditable);
  1009. return config;
  1010. },
  1011. /**
  1012. * Set <code>overrides</code> property to <code>config</code>
  1013. * @param {Ember.Object} config
  1014. * @param {Ember.Enumerable} overrides
  1015. * @returns {Ember.Object}
  1016. * @method _setOverrides
  1017. */
  1018. _setOverrides: function (config, overrides) {
  1019. var selectedGroup = this.get('selectedConfigGroup'),
  1020. overrideToAdd = this.get('overrideToAdd'),
  1021. configOverrides = overrides.filterProperty('name', config.get('name'));
  1022. if (!selectedGroup) return config;
  1023. if (overrideToAdd && overrideToAdd.get('name') === config.get('name')) {
  1024. configOverrides.push(this.addOverrideProperty(config));
  1025. this.set('overrideToAdd', null);
  1026. }
  1027. configOverrides.setEach('isEditable', !selectedGroup.get('isDefault'));
  1028. configOverrides.setEach('parentSCP', config);
  1029. config.set('overrides', configOverrides);
  1030. return config;
  1031. },
  1032. /**
  1033. * create overriden property and push it into Config group
  1034. * @param {App.ServiceConfigProperty} serviceConfigProperty
  1035. * @return {App.ServiceConfigProperty}
  1036. * @method addOverrideProperty
  1037. */
  1038. addOverrideProperty: function (serviceConfigProperty) {
  1039. var overrides = serviceConfigProperty.get('overrides') || [];
  1040. var newSCP = App.ServiceConfigProperty.create(serviceConfigProperty);
  1041. var group = this.get('selectedService.configGroups').findProperty('name', this.get('selectedConfigGroup.name'));
  1042. var valueForOverride = (serviceConfigProperty.get('widget') || serviceConfigProperty.get('displayType') == 'checkbox') ? serviceConfigProperty.get('value') : '';
  1043. newSCP.set('group', group);
  1044. newSCP.set('value', valueForOverride);
  1045. newSCP.set('isOriginalSCP', false); // indicated this is overridden value,
  1046. newSCP.set('parentSCP', serviceConfigProperty);
  1047. newSCP.set('isEditable', true);
  1048. group.get('properties').pushObject(newSCP);
  1049. overrides.pushObject(newSCP);
  1050. newSCP.validate();
  1051. return newSCP;
  1052. },
  1053. /**
  1054. * @method manageConfigurationGroup
  1055. */
  1056. manageConfigurationGroup: function () {
  1057. App.router.get('manageConfigGroupsController').manageConfigurationGroups(this);
  1058. },
  1059. /**
  1060. * Make some configs visible depending on active services
  1061. * @method activateSpecialConfigs
  1062. */
  1063. activateSpecialConfigs: function () {
  1064. if (this.get('addMiscTabToPage')) {
  1065. var serviceToShow = this.get('selectedServiceNames').concat('MISC');
  1066. var miscConfigs = this.get('stepConfigs').findProperty('serviceName', 'MISC').configs;
  1067. if (this.get('wizardController.name') == "addServiceController") {
  1068. miscConfigs.findProperty('name', 'smokeuser').set('value', this.get('content.smokeuser')).set('isEditable', false);
  1069. miscConfigs.findProperty('name', 'user_group').set('value', this.get('content.group')).set('isEditable', false);
  1070. }
  1071. App.config.miscConfigVisibleProperty(miscConfigs, serviceToShow);
  1072. }
  1073. var wizardController = this.get('wizardController');
  1074. if (wizardController.get('name') === "kerberosWizardController") {
  1075. var kerberosConfigs = this.get('stepConfigs').findProperty('serviceName', 'KERBEROS').configs;
  1076. kerberosConfigs.findProperty('name', 'kdc_type').set('value', wizardController.get('content.kerberosOption'));
  1077. }
  1078. },
  1079. /**
  1080. * Check whether hive New MySQL database is on the same host as Ambari server MySQL server
  1081. * @return {$.ajax|null}
  1082. * @method checkMySQLHost
  1083. */
  1084. checkMySQLHost: function () {
  1085. // get ambari database type and hostname
  1086. return App.ajax.send({
  1087. name: 'ambari.service',
  1088. data: {
  1089. fields : "?fields=hostComponents/RootServiceHostComponents/properties/server.jdbc.database_name,hostComponents/RootServiceHostComponents/properties/server.jdbc.url"
  1090. },
  1091. sender: this,
  1092. success: 'getAmbariDatabaseSuccess'
  1093. });
  1094. },
  1095. /**
  1096. * Success callback for ambari database, get Ambari DB type and DB server hostname, then
  1097. * Check whether hive New MySQL database is on the same host as Ambari server MySQL server
  1098. * @param {object} data
  1099. * @method getAmbariDatabaseSuccess
  1100. */
  1101. getAmbariDatabaseSuccess: function (data) {
  1102. var hiveDBHostname = this.get('stepConfigs').findProperty('serviceName', 'HIVE').configs.findProperty('name', 'hive_ambari_host').value;
  1103. var ambariServiceHostComponents = data.hostComponents;
  1104. if (!!ambariServiceHostComponents.length) {
  1105. var ambariDBInfo = JSON.stringify(ambariServiceHostComponents[0].RootServiceHostComponents.properties);
  1106. this.set('mySQLServerConflict', ambariDBInfo.indexOf('mysql') > 0 && ambariDBInfo.indexOf(hiveDBHostname) > 0);
  1107. } else {
  1108. this.set('mySQLServerConflict', false);
  1109. }
  1110. },
  1111. /**
  1112. * Check if new MySql database was chosen for Hive service
  1113. * and it is not located on the same host as Ambari server
  1114. * that using MySql database too.
  1115. *
  1116. * @method resolveHiveMysqlDatabase
  1117. **/
  1118. resolveHiveMysqlDatabase: function () {
  1119. var hiveService = this.get('content.services').findProperty('serviceName', 'HIVE');
  1120. if (!hiveService || !hiveService.get('isSelected') || hiveService.get('isInstalled')) {
  1121. this.moveNext();
  1122. return;
  1123. }
  1124. var hiveDBType = this.get('stepConfigs').findProperty('serviceName', 'HIVE').configs.findProperty('name', 'hive_database').value;
  1125. if (hiveDBType == 'New MySQL Database') {
  1126. var self = this;
  1127. this.checkMySQLHost().done(function () {
  1128. if (self.get('mySQLServerConflict')) {
  1129. // error popup before you can proceed
  1130. return App.ModalPopup.show({
  1131. header: Em.I18n.t('installer.step7.popup.mySQLWarning.header'),
  1132. body:Em.I18n.t('installer.step7.popup.mySQLWarning.body'),
  1133. secondary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.gotostep5'),
  1134. primary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.dismiss'),
  1135. onSecondary: function () {
  1136. var parent = this;
  1137. return App.ModalPopup.show({
  1138. header: Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.header'),
  1139. body: Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.body'),
  1140. onPrimary: function () {
  1141. this.hide();
  1142. parent.hide();
  1143. // go back to step 5: assign masters and disable default navigation warning
  1144. App.router.get('installerController').gotoStep(5, true);
  1145. }
  1146. });
  1147. }
  1148. });
  1149. } else {
  1150. self.moveNext();
  1151. }
  1152. });
  1153. } else {
  1154. this.moveNext();
  1155. }
  1156. },
  1157. checkDatabaseConnectionTest: function () {
  1158. var deferred = $.Deferred();
  1159. var configMap = [
  1160. {
  1161. serviceName: 'OOZIE',
  1162. ignored: [Em.I18n.t('installer.step7.oozie.database.new')]
  1163. },
  1164. {
  1165. serviceName: 'HIVE',
  1166. ignored: [Em.I18n.t('installer.step7.hive.database.new.mysql'), Em.I18n.t('installer.step7.hive.database.new.postgres')]
  1167. }
  1168. ];
  1169. configMap.forEach(function (config) {
  1170. var isConnectionNotTested = false;
  1171. var service = this.get('content.services').findProperty('serviceName', config.serviceName);
  1172. if (service && service.get('isSelected') && !service.get('isInstalled')) {
  1173. var serviceConfigs = this.get('stepConfigs').findProperty('serviceName', config.serviceName).configs;
  1174. var serviceDatabase = serviceConfigs.findProperty('name', config.serviceName.toLowerCase() + '_database').get('value');
  1175. if (!config.ignored.contains(serviceDatabase)) {
  1176. var filledProperties = App.db.get('tmp', config.serviceName + '_connection');
  1177. if (!filledProperties || App.isEmptyObject(filledProperties)) {
  1178. isConnectionNotTested = true;
  1179. } else {
  1180. for (var key in filledProperties) {
  1181. if (serviceConfigs.findProperty('name', key).get('value') !== filledProperties[key])
  1182. isConnectionNotTested = true;
  1183. }
  1184. }
  1185. }
  1186. }
  1187. config.isCheckIgnored = isConnectionNotTested;
  1188. }, this);
  1189. var ignoredServices = configMap.filterProperty('isCheckIgnored', true);
  1190. if (ignoredServices.length) {
  1191. var displayedServiceNames = ignoredServices.mapProperty('serviceName').map(function (serviceName) {
  1192. return this.get('content.services').findProperty('serviceName', serviceName).get('displayName');
  1193. }, this);
  1194. this.showDatabaseConnectionWarningPopup(displayedServiceNames, deferred);
  1195. }
  1196. else {
  1197. deferred.resolve();
  1198. }
  1199. return deferred;
  1200. },
  1201. showDatabaseConnectionWarningPopup: function (serviceNames, deferred) {
  1202. var self = this;
  1203. return App.ModalPopup.show({
  1204. header: Em.I18n.t('installer.step7.popup.database.connection.header'),
  1205. body: Em.I18n.t('installer.step7.popup.database.connection.body').format(serviceNames.join(', ')),
  1206. secondary: Em.I18n.t('common.cancel'),
  1207. primary: Em.I18n.t('common.proceedAnyway'),
  1208. onPrimary: function () {
  1209. deferred.resolve();
  1210. this._super();
  1211. },
  1212. onSecondary: function () {
  1213. self.set('submitButtonClicked', false);
  1214. deferred.reject();
  1215. this._super();
  1216. }
  1217. })
  1218. },
  1219. /**
  1220. * Proceed to the next step
  1221. **/
  1222. moveNext: function () {
  1223. App.router.send('next');
  1224. },
  1225. /**
  1226. * Click-handler on Next button
  1227. * Disable "Submit"-button while server-side processes are running
  1228. * @method submit
  1229. */
  1230. submit: function () {
  1231. if (this.get('isSubmitDisabled')) {
  1232. return;
  1233. }
  1234. var self = this;
  1235. this.set('submitButtonClicked', true);
  1236. this.serverSideValidation().done(function () {
  1237. self.checkDatabaseConnectionTest().done(function () {
  1238. self.resolveHiveMysqlDatabase();
  1239. self.set('submitButtonClicked', false);
  1240. });
  1241. }).fail(function (value) {
  1242. if ("invalid_configs" == value) {
  1243. self.set('submitButtonClicked', false);
  1244. } else {
  1245. // Failed due to validation mechanism failure.
  1246. // Should proceed with other checks
  1247. self.checkDatabaseConnectionTest().done(function () {
  1248. self.resolveHiveMysqlDatabase();
  1249. self.set('submitButtonClicked', false);
  1250. });
  1251. }
  1252. });
  1253. },
  1254. toggleIssuesFilter: function () {
  1255. this.get('filterColumns').findProperty('attributeName', 'hasIssues').toggleProperty('selected');
  1256. }
  1257. });