step7_controller.js 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358
  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. var rangerService = App.StackService.find().findProperty('serviceName', 'RANGER');
  591. if (!rangerService.get('isInstalled') && !rangerService.get('isSelected')) {
  592. App.config.removeRangerConfigs(self.get('stepConfigs'));
  593. }
  594. self.updateDependentConfigs();
  595. self.checkHostOverrideInstaller();
  596. self.activateSpecialConfigs();
  597. self.selectProperService();
  598. self.restoreRecommendedConfigs();
  599. self.clearDependentConfigsByService(App.StackService.find().filterProperty('isSelected').mapProperty('serviceName'));
  600. self.set('isRecommendedLoaded', true);
  601. if (self.get('content.skipConfigStep')) {
  602. App.router.send('next');
  603. }
  604. });
  605. },
  606. /**
  607. * After user navigates back to step7, values for depended configs should be set to values set by user and not to default values
  608. * @method restoreRecommendedConfigs
  609. */
  610. restoreRecommendedConfigs: function () {
  611. var recommendationsConfigs = this.get('recommendationsConfigs') || {};
  612. var serviceConfigProperties = this.get('content.serviceConfigProperties') || [];
  613. var stepConfigs = this.get('stepConfigs');
  614. Em.keys(recommendationsConfigs).forEach(function (file) {
  615. (Em.keys(recommendationsConfigs[file].properties).concat(Em.keys(recommendationsConfigs[file].property_attributes || {}))).forEach(function (configName) {
  616. stepConfigs.forEach(function (stepConfig) {
  617. stepConfig.get('configs').filterProperty('name', configName).forEach(function (configProperty) {
  618. if (Em.get(configProperty, 'filename').contains(file)) {
  619. var scps = serviceConfigProperties.filterProperty('name', configName).filter(function (cp) {
  620. return Em.get(cp, 'filename').contains(file);
  621. });
  622. if (scps.length) {
  623. Em.set(configProperty, 'value', Em.get(scps[0], 'value'));
  624. }
  625. }
  626. });
  627. });
  628. });
  629. });
  630. },
  631. /**
  632. * Mark descriptor properties in configuration object.
  633. *
  634. * @param {Object[]} configs - config properties to change
  635. * @param {App.ServiceConfigProperty[]} descriptor - parsed kerberos descriptor
  636. * @method addKerberosDescriptorConfigs
  637. */
  638. addKerberosDescriptorConfigs: function (configs, descriptor) {
  639. descriptor.forEach(function (item) {
  640. var property = configs.findProperty('name', item.get('name'));
  641. if (property) {
  642. Em.setProperties(property, {
  643. isSecureConfig: true,
  644. displayName: Em.get(item, 'name'),
  645. isUserProperty: false,
  646. isOverridable: false,
  647. category: 'Advanced ' + Em.get(item, 'filename')
  648. });
  649. }
  650. });
  651. },
  652. /**
  653. * Load config groups
  654. * and (if some services are already installed) load config groups for installed services
  655. * @method checkHostOverrideInstaller
  656. */
  657. checkHostOverrideInstaller: function () {
  658. if (this.get('wizardController.name') !== 'kerberosWizardController') {
  659. this.loadConfigGroups(this.get('content.configGroups'));
  660. }
  661. if (this.get('installedServiceNames').length > 0) {
  662. this.loadInstalledServicesConfigGroups(this.get('installedServiceNames'));
  663. }
  664. },
  665. /**
  666. * Set init <code>stepConfigs</code> value
  667. * Set <code>selected</code> for addable services if addServiceController is used
  668. * Remove SNameNode if HA is enabled (and if addServiceController is used)
  669. * @param {Ember.Object[]} configs
  670. * @param {Ember.Object[]} storedConfigs
  671. * @method setStepConfigs
  672. */
  673. setStepConfigs: function (configs, storedConfigs) {
  674. var localDB = {
  675. hosts: this.get('wizardController.content.hosts'),
  676. masterComponentHosts: this.get('wizardController.content.masterComponentHosts'),
  677. slaveComponentHosts: this.get('wizardController.content.slaveComponentHosts')
  678. };
  679. var serviceConfigs = App.config.renderConfigs(configs, storedConfigs, this.get('allSelectedServiceNames'), this.get('installedServiceNames'), localDB);
  680. if (this.get('wizardController.name') === 'addServiceController') {
  681. serviceConfigs.setEach('showConfig', true);
  682. serviceConfigs.setEach('selected', false);
  683. this.get('selectedServiceNames').forEach(function (serviceName) {
  684. if (!serviceConfigs.findProperty('serviceName', serviceName)) return;
  685. serviceConfigs.findProperty('serviceName', serviceName).set('selected', true);
  686. }, this);
  687. this.get('installedServiceNames').forEach(function (serviceName) {
  688. var serviceConfigObj = serviceConfigs.findProperty('serviceName', serviceName);
  689. var isInstallableService = App.StackService.find(serviceName).get('isInstallable');
  690. if (!isInstallableService) serviceConfigObj.set('showConfig', false);
  691. }, this);
  692. // if HA is enabled -> Remove SNameNode, hbase.rootdir should use Name Service ID
  693. if (App.get('isHaEnabled')) {
  694. var c = serviceConfigs.findProperty('serviceName', 'HDFS').configs,
  695. nameServiceId = c.findProperty('name', 'dfs.nameservices'),
  696. removedConfigs = c.filterProperty('category', 'SECONDARY_NAMENODE');
  697. removedConfigs.setEach('isVisible', false);
  698. serviceConfigs.findProperty('serviceName', 'HDFS').configs = c;
  699. if(this.get('selectedServiceNames').contains('HBASE') && nameServiceId){
  700. var hRootDir = serviceConfigs.findProperty('serviceName', 'HBASE').configs.findProperty('name','hbase.rootdir'),
  701. valueToChange = hRootDir.get('value').replace(/\/\/.*:/i, '//' + nameServiceId.get('value') + ':');
  702. hRootDir.setProperties({
  703. 'value': valueToChange,
  704. 'recommendedValue' : valueToChange
  705. });
  706. }
  707. if(this.get('selectedServiceNames').contains('ACCUMULO') && nameServiceId){
  708. var vols = serviceConfigs.findProperty('serviceName', 'ACCUMULO').configs.findProperty('name','instance.volumes'),
  709. valueToChange = vols.get('value').replace(/\/\/.*:[0-9]+/i, '//' + nameServiceId.get('value'));
  710. vols.setProperties({
  711. 'value': valueToChange,
  712. 'recommendedValue' : valueToChange
  713. });
  714. }
  715. }
  716. }
  717. // Remove Notifications from MISC if it isn't Installer Controller
  718. if (this.get('wizardController.name') !== 'installerController') {
  719. var miscService = serviceConfigs.findProperty('serviceName', 'MISC');
  720. if (miscService) {
  721. c = miscService.configs;
  722. removedConfigs = c.filterProperty('category', 'Notifications');
  723. removedConfigs.map(function (config) {
  724. c = c.without(config);
  725. });
  726. miscService.configs = c;
  727. }
  728. }
  729. this.set('stepConfigs', serviceConfigs);
  730. },
  731. /**
  732. * Select first addable service for <code>addServiceWizard</code>
  733. * Select first service at all in other cases
  734. * @method selectProperService
  735. */
  736. selectProperService: function () {
  737. if (this.get('wizardController.name') === 'addServiceController') {
  738. this.set('selectedService', this.get('stepConfigs').filterProperty('selected', true).get('firstObject'));
  739. } else {
  740. this.set('selectedService', this.get('stepConfigs').filterProperty('showConfig', true).objectAt(0));
  741. }
  742. },
  743. /**
  744. * Load config tags
  745. * @return {$.ajax|null}
  746. * @method getConfigTags
  747. */
  748. getConfigTags: function () {
  749. this.set('isAppliedConfigLoaded', false);
  750. return App.ajax.send({
  751. name: 'config.tags',
  752. sender: this,
  753. success: 'getConfigTagsSuccess'
  754. });
  755. },
  756. /**
  757. * Success callback for config tags request
  758. * Updates <code>serviceConfigTags</code> with tags received from server
  759. * @param {object} data
  760. * @method getConfigTagsSuccess
  761. */
  762. getConfigTagsSuccess: function (data) {
  763. var installedServiceSites = [];
  764. App.StackService.find().filterProperty('isInstalled').forEach(function (service) {
  765. if (!service.get('configTypes')) return;
  766. var configTypes = Object.keys(service.get('configTypes'));
  767. installedServiceSites = installedServiceSites.concat(configTypes);
  768. }, this);
  769. installedServiceSites = installedServiceSites.uniq();
  770. var serviceConfigTags = [];
  771. for (var site in data.Clusters.desired_configs) {
  772. if (data.Clusters.desired_configs.hasOwnProperty(site)) {
  773. if (installedServiceSites.contains(site)) {
  774. serviceConfigTags.push({
  775. siteName: site,
  776. tagName: data.Clusters.desired_configs[site].tag,
  777. newTagName: null
  778. });
  779. }
  780. }
  781. }
  782. this.set('serviceConfigTags', serviceConfigTags);
  783. this.set('isAppliedConfigLoaded', true);
  784. },
  785. /**
  786. * set configs actual values from server
  787. * @param serviceConfigTags
  788. * @param configs
  789. * @param configsByTags
  790. * @param installedServiceNames
  791. * @method setInstalledServiceConfigs
  792. */
  793. setInstalledServiceConfigs: function (serviceConfigTags, configs, configsByTags, installedServiceNames) {
  794. var configsMap = {};
  795. var configMixin = App.get('config');
  796. var nonServiceTab = require('data/service_configs');
  797. var self = this;
  798. configsByTags.forEach(function (configSite) {
  799. configsMap[configSite.type] = configSite.properties || {};
  800. });
  801. configs.forEach(function (_config) {
  802. var type = _config.filename ? App.config.getConfigTagFromFileName(_config.filename) : null;
  803. var mappedConfigValue = type && configsMap[type] ? configsMap[type][_config.name] : null;
  804. if (!Em.isNone(mappedConfigValue) && ((installedServiceNames && installedServiceNames.contains(_config.serviceName) || nonServiceTab.someProperty('serviceName', _config.serviceName)))) {
  805. // prevent overriding already edited properties
  806. if (_config.savedValue != mappedConfigValue) {
  807. _config.value = mappedConfigValue;
  808. }
  809. _config.savedValue = mappedConfigValue;
  810. _config.hasInitialValue = true;
  811. App.config.handleSpecialProperties(_config);
  812. delete configsMap[type][_config.name];
  813. }
  814. });
  815. self.setServiceDatabaseConfigs(configs);
  816. //add user properties
  817. Em.keys(configsMap).forEach(function (filename) {
  818. Em.keys(configsMap[filename]).forEach(function (propertyName) {
  819. configs.push(configMixin.addUserProperty({
  820. id: 'site property',
  821. name: propertyName,
  822. serviceName: configMixin.getServiceNameByConfigType(filename),
  823. value: configsMap[filename][propertyName],
  824. savedValue: configsMap[filename][propertyName],
  825. filename: configMixin.get('filenameExceptions').contains(filename) ? filename : filename + '.xml',
  826. category: 'Advanced',
  827. hasInitialValue: true,
  828. isUserProperty: true,
  829. isOverridable: true,
  830. overrides: [],
  831. isRequired: true,
  832. isVisible: true,
  833. showLabel: true
  834. }, false, []));
  835. });
  836. });
  837. },
  838. /**
  839. * Check if Oozie or Hive use existing database then need
  840. * to restore missed properties
  841. *
  842. * @param {Object[]} configs
  843. **/
  844. setServiceDatabaseConfigs: function (configs) {
  845. var serviceNames = this.get('installedServiceNames').filter(function (serviceName) {
  846. return ['OOZIE', 'HIVE'].contains(serviceName);
  847. });
  848. serviceNames.forEach(function (serviceName) {
  849. var propertyPrefix = serviceName.toLowerCase();
  850. var dbTypeConfig = configs.findProperty('name', propertyPrefix + '_database');
  851. if (!/existing/gi.test(dbTypeConfig.value)) return;
  852. var dbHostName = propertyPrefix + '_hostname';
  853. var database = dbTypeConfig.value.match(/MySQL|PostgreSQL|Oracle|Derby|MSSQL/gi)[0];
  854. var dbPrefix = database.toLowerCase();
  855. if (database.toLowerCase() == 'mssql') {
  856. if (/integrated/gi.test(dbTypeConfig.value)) {
  857. dbPrefix = 'mssql_server_2';
  858. } else {
  859. dbPrefix = 'mssql_server';
  860. }
  861. }
  862. var propertyName = propertyPrefix + '_existing_' + dbPrefix + '_host';
  863. var existingDBConfig = configs.findProperty('name', propertyName);
  864. if (!existingDBConfig.value)
  865. existingDBConfig.value = existingDBConfig.savedValue = configs.findProperty('name', dbHostName).value;
  866. }, this);
  867. },
  868. /**
  869. * Add group ids to <code>groupsToDelete</code>
  870. * Also save <code>groupsToDelete</code> to local storage
  871. * @param {Ember.Object[]} groups
  872. * @method setGroupsToDelete
  873. */
  874. setGroupsToDelete: function (groups) {
  875. var groupsToDelete = this.get('groupsToDelete');
  876. groups.forEach(function (group) {
  877. if (group.get('id'))
  878. groupsToDelete.push({
  879. id: group.get('id')
  880. });
  881. });
  882. this.get('wizardController').setDBProperty('groupsToDelete', groupsToDelete);
  883. },
  884. /**
  885. * Update <code>configGroups</code> with selected service configGroups
  886. * Also set default group to first position
  887. * Update <code>selectedConfigGroup</code> with new default group
  888. * @method selectedServiceObserver
  889. */
  890. selectedServiceObserver: function () {
  891. if (this.get('selectedService') && (this.get('selectedService.serviceName') !== 'MISC')) {
  892. var serviceGroups = this.get('selectedService.configGroups');
  893. serviceGroups.forEach(function (item, index, array) {
  894. if (item.isDefault) {
  895. array.unshift(item);
  896. array.splice(index + 1, 1);
  897. }
  898. });
  899. this.set('configGroups', serviceGroups);
  900. this.set('selectedConfigGroup', serviceGroups.findProperty('isDefault'));
  901. }
  902. }.observes('selectedService.configGroups.@each'),
  903. /**
  904. * load default groups for each service in case of initial load
  905. * @param serviceConfigGroups
  906. * @method loadConfigGroups
  907. */
  908. loadConfigGroups: function (serviceConfigGroups) {
  909. var services = this.get('stepConfigs');
  910. var hosts = this.get('wizardController.allHosts').mapProperty('hostName');
  911. services.forEach(function (service) {
  912. if (service.get('serviceName') === 'MISC') return;
  913. var serviceRawGroups = serviceConfigGroups.filterProperty('service.id', service.serviceName);
  914. if (!serviceRawGroups.length) {
  915. service.set('configGroups', [
  916. App.ConfigGroup.create({
  917. name: service.displayName + " Default",
  918. description: "Default cluster level " + service.serviceName + " configuration",
  919. isDefault: true,
  920. hosts: Em.copy(hosts),
  921. service: Em.Object.create({
  922. id: service.serviceName
  923. }),
  924. serviceName: service.serviceName
  925. })
  926. ]);
  927. }
  928. else {
  929. var defaultGroup = App.ConfigGroup.create(serviceRawGroups.findProperty('isDefault'));
  930. var serviceGroups = service.get('configGroups');
  931. serviceRawGroups.filterProperty('isDefault', false).forEach(function (configGroup) {
  932. var readyGroup = App.ConfigGroup.create(configGroup);
  933. var wrappedProperties = [];
  934. readyGroup.get('properties').forEach(function (propertyData) {
  935. var parentSCP = service.configs.filterProperty('filename', propertyData.filename).findProperty('name', propertyData.name);
  936. var overriddenSCP = App.ServiceConfigProperty.create(parentSCP);
  937. overriddenSCP.set('isOriginalSCP', false);
  938. overriddenSCP.set('parentSCP', parentSCP);
  939. overriddenSCP.set('group', readyGroup);
  940. overriddenSCP.setProperties(propertyData);
  941. wrappedProperties.pushObject(App.ServiceConfigProperty.create(overriddenSCP));
  942. });
  943. wrappedProperties.setEach('group', readyGroup);
  944. readyGroup.set('properties', wrappedProperties);
  945. readyGroup.set('parentConfigGroup', defaultGroup);
  946. serviceGroups.pushObject(readyGroup);
  947. });
  948. defaultGroup.set('childConfigGroups', serviceGroups);
  949. serviceGroups.pushObject(defaultGroup);
  950. }
  951. });
  952. },
  953. /**
  954. * Click-handler on config-group to make it selected
  955. * @param {object} event
  956. * @method selectConfigGroup
  957. */
  958. selectConfigGroup: function (event) {
  959. this.set('selectedConfigGroup', event.context);
  960. },
  961. /**
  962. * Rebuild list of configs switch of config group:
  963. * on default - display all configs from default group and configs from non-default groups as disabled
  964. * on non-default - display all from default group as disabled and configs from selected non-default group
  965. * @method switchConfigGroupConfigs
  966. */
  967. switchConfigGroupConfigs: function () {
  968. var serviceConfigs = this.get('selectedService.configs'),
  969. selectedGroup = this.get('selectedConfigGroup'),
  970. overrideToAdd = this.get('overrideToAdd'),
  971. overrides = [];
  972. if (!selectedGroup) return;
  973. var displayedConfigGroups = this._getDisplayedConfigGroups();
  974. displayedConfigGroups.forEach(function (group) {
  975. overrides.pushObjects(group.get('properties'));
  976. });
  977. serviceConfigs.forEach(function (config) {
  978. this._setEditableValue(config);
  979. this._setOverrides(config, overrides);
  980. }, this);
  981. }.observes('selectedConfigGroup'),
  982. /**
  983. * Get list of config groups to display
  984. * Returns empty array if no <code>selectedConfigGroup</code>
  985. * @return {Array}
  986. * @method _getDisplayedConfigGroups
  987. */
  988. _getDisplayedConfigGroups: function () {
  989. var selectedGroup = this.get('selectedConfigGroup');
  990. if (!selectedGroup) return [];
  991. return (selectedGroup.get('isDefault')) ?
  992. this.get('selectedService.configGroups').filterProperty('isDefault', false) :
  993. [this.get('selectedConfigGroup')];
  994. },
  995. /**
  996. * Set <code>isEditable</code> property to <code>config</code>
  997. * @param {Ember.Object} config
  998. * @return {Ember.Object} updated config-object
  999. * @method _setEditableValue
  1000. */
  1001. _setEditableValue: function (config) {
  1002. var selectedGroup = this.get('selectedConfigGroup');
  1003. if (!selectedGroup) return config;
  1004. var isEditable = config.get('isEditable'),
  1005. isServiceInstalled = this.get('installedServiceNames').contains(this.get('selectedService.serviceName'));
  1006. if (isServiceInstalled) {
  1007. isEditable = (!isEditable && !config.get('isReconfigurable')) ? false : selectedGroup.get('isDefault');
  1008. }
  1009. else {
  1010. isEditable = selectedGroup.get('isDefault');
  1011. }
  1012. if (config.get('group')) {
  1013. isEditable = config.get('group.name') == this.get('selectedConfigGroup.name');
  1014. }
  1015. config.set('isEditable', isEditable);
  1016. return config;
  1017. },
  1018. /**
  1019. * Set <code>overrides</code> property to <code>config</code>
  1020. * @param {Ember.Object} config
  1021. * @param {Ember.Enumerable} overrides
  1022. * @returns {Ember.Object}
  1023. * @method _setOverrides
  1024. */
  1025. _setOverrides: function (config, overrides) {
  1026. var selectedGroup = this.get('selectedConfigGroup'),
  1027. overrideToAdd = this.get('overrideToAdd'),
  1028. configOverrides = overrides.filterProperty('name', config.get('name'));
  1029. if (!selectedGroup) return config;
  1030. if (overrideToAdd && overrideToAdd.get('name') === config.get('name')) {
  1031. configOverrides.push(this.addOverrideProperty(config));
  1032. this.set('overrideToAdd', null);
  1033. }
  1034. configOverrides.setEach('isEditable', !selectedGroup.get('isDefault'));
  1035. configOverrides.setEach('parentSCP', config);
  1036. config.set('overrides', configOverrides);
  1037. return config;
  1038. },
  1039. /**
  1040. * create overriden property and push it into Config group
  1041. * @param {App.ServiceConfigProperty} serviceConfigProperty
  1042. * @return {App.ServiceConfigProperty}
  1043. * @method addOverrideProperty
  1044. */
  1045. addOverrideProperty: function (serviceConfigProperty) {
  1046. var overrides = serviceConfigProperty.get('overrides') || [];
  1047. var newSCP = App.ServiceConfigProperty.create(serviceConfigProperty);
  1048. var group = this.get('selectedService.configGroups').findProperty('name', this.get('selectedConfigGroup.name'));
  1049. var valueForOverride = (serviceConfigProperty.get('widget') || serviceConfigProperty.get('displayType') == 'checkbox') ? serviceConfigProperty.get('value') : '';
  1050. newSCP.set('group', group);
  1051. newSCP.set('value', valueForOverride);
  1052. newSCP.set('isOriginalSCP', false); // indicated this is overridden value,
  1053. newSCP.set('parentSCP', serviceConfigProperty);
  1054. newSCP.set('isEditable', true);
  1055. group.get('properties').pushObject(newSCP);
  1056. overrides.pushObject(newSCP);
  1057. newSCP.validate();
  1058. return newSCP;
  1059. },
  1060. /**
  1061. * @method manageConfigurationGroup
  1062. */
  1063. manageConfigurationGroup: function () {
  1064. App.router.get('manageConfigGroupsController').manageConfigurationGroups(this);
  1065. },
  1066. /**
  1067. * Make some configs visible depending on active services
  1068. * @method activateSpecialConfigs
  1069. */
  1070. activateSpecialConfigs: function () {
  1071. if (this.get('addMiscTabToPage')) {
  1072. var serviceToShow = this.get('selectedServiceNames').concat('MISC');
  1073. var miscConfigs = this.get('stepConfigs').findProperty('serviceName', 'MISC').configs;
  1074. if (this.get('wizardController.name') == "addServiceController") {
  1075. miscConfigs.findProperty('name', 'smokeuser').set('value', this.get('content.smokeuser')).set('isEditable', false);
  1076. miscConfigs.findProperty('name', 'user_group').set('value', this.get('content.group')).set('isEditable', false);
  1077. }
  1078. App.config.miscConfigVisibleProperty(miscConfigs, serviceToShow);
  1079. }
  1080. var wizardController = this.get('wizardController');
  1081. if (wizardController.get('name') === "kerberosWizardController") {
  1082. var kerberosConfigs = this.get('stepConfigs').findProperty('serviceName', 'KERBEROS').configs;
  1083. kerberosConfigs.findProperty('name', 'kdc_type').set('value', wizardController.get('content.kerberosOption'));
  1084. }
  1085. },
  1086. /**
  1087. * Check whether hive New MySQL database is on the same host as Ambari server MySQL server
  1088. * @return {$.ajax|null}
  1089. * @method checkMySQLHost
  1090. */
  1091. checkMySQLHost: function () {
  1092. // get ambari database type and hostname
  1093. return App.ajax.send({
  1094. name: 'ambari.service',
  1095. data: {
  1096. fields : "?fields=hostComponents/RootServiceHostComponents/properties/server.jdbc.database_name,hostComponents/RootServiceHostComponents/properties/server.jdbc.url"
  1097. },
  1098. sender: this,
  1099. success: 'getAmbariDatabaseSuccess'
  1100. });
  1101. },
  1102. /**
  1103. * Success callback for ambari database, get Ambari DB type and DB server hostname, then
  1104. * Check whether hive New MySQL database is on the same host as Ambari server MySQL server
  1105. * @param {object} data
  1106. * @method getAmbariDatabaseSuccess
  1107. */
  1108. getAmbariDatabaseSuccess: function (data) {
  1109. var hiveDBHostname = this.get('stepConfigs').findProperty('serviceName', 'HIVE').configs.findProperty('name', 'hive_ambari_host').value;
  1110. var ambariServiceHostComponents = data.hostComponents;
  1111. if (!!ambariServiceHostComponents.length) {
  1112. var ambariDBInfo = JSON.stringify(ambariServiceHostComponents[0].RootServiceHostComponents.properties);
  1113. this.set('mySQLServerConflict', ambariDBInfo.indexOf('mysql') > 0 && ambariDBInfo.indexOf(hiveDBHostname) > 0);
  1114. } else {
  1115. this.set('mySQLServerConflict', false);
  1116. }
  1117. },
  1118. /**
  1119. * Check if new MySql database was chosen for Hive service
  1120. * and it is not located on the same host as Ambari server
  1121. * that using MySql database too.
  1122. *
  1123. * @method resolveHiveMysqlDatabase
  1124. **/
  1125. resolveHiveMysqlDatabase: function () {
  1126. var hiveService = this.get('content.services').findProperty('serviceName', 'HIVE');
  1127. if (!hiveService || !hiveService.get('isSelected') || hiveService.get('isInstalled')) {
  1128. this.moveNext();
  1129. return;
  1130. }
  1131. var hiveDBType = this.get('stepConfigs').findProperty('serviceName', 'HIVE').configs.findProperty('name', 'hive_database').value;
  1132. if (hiveDBType == 'New MySQL Database') {
  1133. var self = this;
  1134. this.checkMySQLHost().done(function () {
  1135. if (self.get('mySQLServerConflict')) {
  1136. // error popup before you can proceed
  1137. return App.ModalPopup.show({
  1138. header: Em.I18n.t('installer.step7.popup.mySQLWarning.header'),
  1139. body:Em.I18n.t('installer.step7.popup.mySQLWarning.body'),
  1140. secondary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.gotostep5'),
  1141. primary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.dismiss'),
  1142. onSecondary: function () {
  1143. var parent = this;
  1144. return App.ModalPopup.show({
  1145. header: Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.header'),
  1146. body: Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.body'),
  1147. onPrimary: function () {
  1148. this.hide();
  1149. parent.hide();
  1150. // go back to step 5: assign masters and disable default navigation warning
  1151. App.router.get('installerController').gotoStep(5, true);
  1152. }
  1153. });
  1154. }
  1155. });
  1156. } else {
  1157. self.moveNext();
  1158. }
  1159. });
  1160. } else {
  1161. this.moveNext();
  1162. }
  1163. },
  1164. checkDatabaseConnectionTest: function () {
  1165. var deferred = $.Deferred();
  1166. var configMap = [
  1167. {
  1168. serviceName: 'OOZIE',
  1169. ignored: [Em.I18n.t('installer.step7.oozie.database.new')]
  1170. },
  1171. {
  1172. serviceName: 'HIVE',
  1173. ignored: [Em.I18n.t('installer.step7.hive.database.new.mysql'), Em.I18n.t('installer.step7.hive.database.new.postgres')]
  1174. }
  1175. ];
  1176. configMap.forEach(function (config) {
  1177. var isConnectionNotTested = false;
  1178. var service = this.get('content.services').findProperty('serviceName', config.serviceName);
  1179. if (service && service.get('isSelected') && !service.get('isInstalled')) {
  1180. var serviceConfigs = this.get('stepConfigs').findProperty('serviceName', config.serviceName).configs;
  1181. var serviceDatabase = serviceConfigs.findProperty('name', config.serviceName.toLowerCase() + '_database').get('value');
  1182. if (!config.ignored.contains(serviceDatabase)) {
  1183. var filledProperties = App.db.get('tmp', config.serviceName + '_connection');
  1184. if (!filledProperties || App.isEmptyObject(filledProperties)) {
  1185. isConnectionNotTested = true;
  1186. } else {
  1187. for (var key in filledProperties) {
  1188. if (serviceConfigs.findProperty('name', key).get('value') !== filledProperties[key])
  1189. isConnectionNotTested = true;
  1190. }
  1191. }
  1192. }
  1193. }
  1194. config.isCheckIgnored = isConnectionNotTested;
  1195. }, this);
  1196. var ignoredServices = configMap.filterProperty('isCheckIgnored', true);
  1197. if (ignoredServices.length) {
  1198. var displayedServiceNames = ignoredServices.mapProperty('serviceName').map(function (serviceName) {
  1199. return this.get('content.services').findProperty('serviceName', serviceName).get('displayName');
  1200. }, this);
  1201. this.showDatabaseConnectionWarningPopup(displayedServiceNames, deferred);
  1202. }
  1203. else {
  1204. deferred.resolve();
  1205. }
  1206. return deferred;
  1207. },
  1208. showDatabaseConnectionWarningPopup: function (serviceNames, deferred) {
  1209. var self = this;
  1210. return App.ModalPopup.show({
  1211. header: Em.I18n.t('installer.step7.popup.database.connection.header'),
  1212. body: Em.I18n.t('installer.step7.popup.database.connection.body').format(serviceNames.join(', ')),
  1213. secondary: Em.I18n.t('common.cancel'),
  1214. primary: Em.I18n.t('common.proceedAnyway'),
  1215. onPrimary: function () {
  1216. deferred.resolve();
  1217. this._super();
  1218. },
  1219. onSecondary: function () {
  1220. self.set('submitButtonClicked', false);
  1221. deferred.reject();
  1222. this._super();
  1223. }
  1224. })
  1225. },
  1226. /**
  1227. * Proceed to the next step
  1228. **/
  1229. moveNext: function () {
  1230. App.router.send('next');
  1231. },
  1232. /**
  1233. * Click-handler on Next button
  1234. * Disable "Submit"-button while server-side processes are running
  1235. * @method submit
  1236. */
  1237. submit: function () {
  1238. if (this.get('isSubmitDisabled')) {
  1239. return;
  1240. }
  1241. var self = this;
  1242. this.set('submitButtonClicked', true);
  1243. this.serverSideValidation().done(function () {
  1244. self.checkDatabaseConnectionTest().done(function () {
  1245. self.resolveHiveMysqlDatabase();
  1246. self.set('submitButtonClicked', false);
  1247. });
  1248. }).fail(function (value) {
  1249. if ("invalid_configs" == value) {
  1250. self.set('submitButtonClicked', false);
  1251. } else {
  1252. // Failed due to validation mechanism failure.
  1253. // Should proceed with other checks
  1254. self.checkDatabaseConnectionTest().done(function () {
  1255. self.resolveHiveMysqlDatabase();
  1256. self.set('submitButtonClicked', false);
  1257. });
  1258. }
  1259. });
  1260. },
  1261. toggleIssuesFilter: function () {
  1262. this.get('filterColumns').findProperty('attributeName', 'hasIssues').toggleProperty('selected');
  1263. }
  1264. });