step4.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  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. App.MainAdminSecurityAddStep4Controller = Em.Controller.extend({
  20. name: 'mainAdminSecurityAddStep4Controller',
  21. secureMapping: require('data/secure_mapping'),
  22. secureProperties: require('data/secure_properties').configProperties,
  23. stages: [],
  24. configs: [],
  25. noOfWaitingAjaxCalls: 0,
  26. secureServices: [],
  27. serviceConfigTags: [],
  28. globalProperties: [],
  29. totalSteps: 3,
  30. isSubmitDisabled: true,
  31. isBackBtnDisabled: function () {
  32. return !this.get('stages').someProperty('isError', true);
  33. }.property('stages.@each.isCompleted'),
  34. isOozieSelected: function () {
  35. return this.get('content.services').someProperty('serviceName', 'OOZIE');
  36. }.property('content.services'),
  37. isHiveSelected: function () {
  38. return this.get('content.services').someProperty('serviceName', 'HIVE');
  39. }.property('content.services'),
  40. isNagiosSelected: function () {
  41. return this.get('content.services').someProperty('serviceName', 'NAGIOS');
  42. }.property('content.services'),
  43. isZkSelected: function () {
  44. return this.get('content.services').someProperty('serviceName', 'ZOOKEEPER');
  45. }.property('content.services'),
  46. isWebHcatSelected: function () {
  47. var installedServices = App.Service.find().mapProperty('serviceName');
  48. return installedServices.contains('WEBHCAT');
  49. },
  50. serviceUsersBinding: 'App.router.mainAdminSecurityController.serviceUsers',
  51. hasHostPopup: true,
  52. services: [],
  53. serviceTimestamp: null,
  54. isSecurityApplied: function () {
  55. return this.get('stages').someProperty('stage', 'stage3') && this.get('stages').findProperty('stage', 'stage3').get('isSuccess');
  56. }.property('stages.@each.isCompleted'),
  57. clearStep: function () {
  58. this.get('stages').clear();
  59. this.set('isSubmitDisabled', true);
  60. this.set('isBackBtnDisabled', true);
  61. this.get('serviceConfigTags').clear();
  62. },
  63. retry: function () {
  64. var failedStage = this.get('stages').findProperty('isError', true);
  65. if (failedStage) {
  66. failedStage.set('isStarted', false);
  67. failedStage.set('isError', false);
  68. this.startStage(failedStage);
  69. }
  70. },
  71. loadStep: function () {
  72. this.set('secureMapping', require('data/secure_mapping').slice(0));
  73. this.clearStep();
  74. var stages = App.db.getSecurityDeployStages();
  75. this.prepareSecureConfigs();
  76. if (stages && stages.length > 0) {
  77. stages.forEach(function (_stage, index) {
  78. stages[index] = App.Poll.create(_stage);
  79. }, this);
  80. if (stages.someProperty('isError', true)) {
  81. this.get('stages').pushObjects(stages);
  82. this.addObserver('stages.@each.isSuccess', this.onCompleteStage);
  83. return;
  84. } else if (stages.filterProperty('isStarted', true).someProperty('isCompleted', false)) {
  85. var runningStage = stages.filterProperty('isStarted', true).findProperty('isCompleted', false);
  86. runningStage.set('isStarted', false);
  87. this.get('stages').pushObjects(stages);
  88. } else {
  89. this.get('stages').pushObjects(stages);
  90. }
  91. } else {
  92. this.loadStages();
  93. this.addInfoToStages();
  94. var runningOperations = App.router.get('backgroundOperationsController.services').filterProperty('isRunning');
  95. var stopAllOperation = runningOperations.findProperty('name', 'Stop All Services');
  96. var stopStage = this.get('stages').findProperty('name', 'STOP_SERVICES');
  97. if (stopStage.get('name') === 'STOP_SERVICES' && stopAllOperation) {
  98. stopStage.set('requestId', stopAllOperation.get('id'));
  99. }
  100. }
  101. this.addObserver('stages.@each.isSuccess', this.onCompleteStage);
  102. this.moveToNextStage();
  103. },
  104. enableSubmit: function () {
  105. var addSecurityController = App.router.get('addSecurityController');
  106. if (this.get('stages').someProperty('isError', true) || this.get('stages').everyProperty('isSuccess', true)) {
  107. this.set('isSubmitDisabled', false);
  108. if (this.get('stages').someProperty('isError', true)) {
  109. addSecurityController.setStepsEnable();
  110. }
  111. } else {
  112. this.set('isSubmitDisabled', true);
  113. addSecurityController.setLowerStepsDisable(4);
  114. }
  115. }.observes('stages.@each.isCompleted'),
  116. updateServices: function () {
  117. this.services.clear();
  118. var services = this.get("services");
  119. this.get("stages").forEach(function (stage) {
  120. var newService = Ember.Object.create({
  121. name: stage.label,
  122. hosts: []
  123. });
  124. if (stage && stage.get("polledData")) {
  125. var hostNames = stage.get("polledData").mapProperty('Tasks.host_name').uniq();
  126. hostNames.forEach(function (name) {
  127. newService.hosts.push({
  128. name: name,
  129. publicName: name,
  130. logTasks: stage.polledData.filterProperty("Tasks.host_name", name)
  131. });
  132. });
  133. services.push(newService);
  134. }
  135. });
  136. this.set('serviceTimestamp', new Date().getTime());
  137. }.observes('stages.@each.polledData'),
  138. loadStages: function () {
  139. this.get('stages').pushObjects([
  140. App.Poll.create({stage: 'stage2', label: Em.I18n.translations['admin.addSecurity.apply.stage2'], isPolling: true, name: 'STOP_SERVICES'}),
  141. App.Poll.create({stage: 'stage3', label: Em.I18n.translations['admin.addSecurity.apply.stage3'], isPolling: false, name: 'APPLY_CONFIGURATIONS'}),
  142. App.Poll.create({stage: 'stage4', label: Em.I18n.translations['admin.addSecurity.apply.stage4'], isPolling: true, name: 'START_SERVICES'})
  143. ]);
  144. },
  145. startStage: function (currentStage) {
  146. if (this.get('stages').length === this.totalSteps) {
  147. if (!currentStage) {
  148. var startedStages = this.get('stages').filterProperty('isStarted', true);
  149. currentStage = startedStages.findProperty('isCompleted', false);
  150. }
  151. if (currentStage && currentStage.get('isPolling') === true) {
  152. currentStage.set('isStarted', true);
  153. currentStage.start();
  154. } else if (currentStage && currentStage.get('stage') === 'stage3') {
  155. currentStage.set('isStarted', true);
  156. if (App.testMode) {
  157. currentStage.set('isError', false);
  158. currentStage.set('isCompleted', true);
  159. } else {
  160. this.loadClusterConfigs();
  161. }
  162. }
  163. }
  164. },
  165. onCompleteStage: function () {
  166. if (this.get('stages').length === this.totalSteps) {
  167. var index = this.get('stages').filterProperty('isSuccess', true).length;
  168. if (index > 0) {
  169. var lastCompletedStageResult = this.get('stages').objectAt(index - 1).get('isSuccess');
  170. if (lastCompletedStageResult) {
  171. var nextStage = this.get('stages').objectAt(index);
  172. this.moveToNextStage(nextStage);
  173. }
  174. }
  175. }
  176. },
  177. moveToNextStage: function (nextStage) {
  178. if (!nextStage) {
  179. nextStage = this.get('stages').findProperty('isStarted', false);
  180. }
  181. if (nextStage) {
  182. this.startStage(nextStage);
  183. }
  184. },
  185. addInfoToStages: function () {
  186. this.addInfoToStage2();
  187. this.addInfoToStage4();
  188. },
  189. addInfoToStage1: function () {
  190. var stage1 = this.get('stages').findProperty('stage', 'stage1');
  191. if (App.testMode) {
  192. stage1.set('isSuccess', true);
  193. stage1.set('isStarted', true);
  194. stage1.set('isCompleted', true);
  195. }
  196. },
  197. addInfoToStage2: function () {
  198. var stage2 = this.get('stages').findProperty('stage', 'stage2');
  199. var url = (App.testMode) ? '/data/wizard/deploy/2_hosts/poll_1.json' : App.apiPrefix + '/clusters/' + App.router.getClusterName() + '/services';
  200. var data = '{"RequestInfo": {"context" :"' + Em.I18n.t('requestInfo.stopAllServices') + '"}, "Body": {"ServiceInfo": {"state": "INSTALLED"}}}';
  201. stage2.set('url', url);
  202. stage2.set('data', data);
  203. },
  204. addInfoToStage4: function () {
  205. var stage4 = this.get('stages').findProperty('stage', 'stage4');
  206. var url = (App.testMode) ? '/data/wizard/deploy/2_hosts/poll_1.json' : App.apiPrefix + '/clusters/' + App.router.getClusterName() + '/services?params/run_smoke_test=true';
  207. var data = '{"RequestInfo": {"context": "' + Em.I18n.t('requestInfo.startAllServices') + '"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}';
  208. stage4.set('url', url);
  209. stage4.set('data', data);
  210. },
  211. loadUiSideConfigs: function () {
  212. var uiConfig = [];
  213. var configs = this.get('secureMapping').filterProperty('foreignKey', null);
  214. configs.forEach(function (_config) {
  215. var value = _config.value;
  216. if (_config.hasOwnProperty('dependedServiceName') && _config.hasOwnProperty('replace')) {
  217. value = this.checkServiceForConfigValue(value, _config.dependedServiceName, _config.replace);
  218. }
  219. value = this.getGlobConfigValue(_config.templateName, value, _config.name);
  220. uiConfig.pushObject({
  221. "id": "site property",
  222. "name": _config.name,
  223. "value": value,
  224. "filename": _config.filename
  225. });
  226. }, this);
  227. var dependentConfig = this.get('secureMapping').filterProperty('foreignKey');
  228. dependentConfig.forEach(function (_config) {
  229. if (App.Service.find().mapProperty('serviceName').contains(_config.serviceName)) {
  230. this.setConfigValue(uiConfig, _config);
  231. uiConfig.pushObject({
  232. "id": "site property",
  233. "name": _config._name || _config.name,
  234. "value": _config.value,
  235. "filename": _config.filename
  236. });
  237. }
  238. }, this);
  239. return uiConfig;
  240. },
  241. checkServiceForConfigValue: function (value, serviceName, replace) {
  242. if (!App.Service.find().mapProperty('serviceName').contains(serviceName)) {
  243. value = value.replace(replace, '');
  244. }
  245. return value;
  246. },
  247. /**
  248. * Set all site property that are derived from other puppet-variable
  249. */
  250. getGlobConfigValue: function (templateName, expression, name) {
  251. var express = expression.match(/<(.*?)>/g);
  252. var value = expression;
  253. if (express == null) {
  254. return expression;
  255. }
  256. express.forEach(function (_express) {
  257. //console.log("The value of template is: " + _express);
  258. var index = parseInt(_express.match(/\[([\d]*)(?=\])/)[1]);
  259. var globValue = this.get('globalProperties').findProperty('name', templateName[index]);
  260. if (globValue) {
  261. console.log('The template value of templateName ' + '[' + index + ']' + ': ' + templateName[index] + ' is: ' + globValue);
  262. if (value !== null) { // if the property depends on more than one template name like <templateName[0]>/<templateName[1]> then don't proceed to the next if the prior is null or not found in the global configs
  263. value = value.replace(_express, globValue.value);
  264. }
  265. } else {
  266. /*
  267. console.log("ERROR: The variable name is: " + templateName[index]);
  268. console.log("ERROR: mapped config from secureMapping file has no corresponding variable in " +
  269. "content.serviceConfigProperties. Two possible reasons for the error could be: 1) The service is not selected. " +
  270. "and/OR 2) The service_config metadata file has no corresponding global var for the site property variable");
  271. */
  272. value = null;
  273. }
  274. }, this);
  275. return value;
  276. },
  277. /**
  278. * Set all site property that are derived from other site-properties
  279. */
  280. setConfigValue: function (uiConfig, config) {
  281. if (config.value == null) {
  282. return;
  283. }
  284. var fkValue = config.name.match(/<(foreignKey.*?)>/g);
  285. if (fkValue) {
  286. fkValue.forEach(function (_fkValue) {
  287. var index = parseInt(_fkValue.match(/\[([\d]*)(?=\])/)[1]);
  288. var globalValue;
  289. if (uiConfig.someProperty('name', config.foreignKey[index])) {
  290. globalValue = uiConfig.findProperty('name', config.foreignKey[index]).value;
  291. config._name = config.name.replace(_fkValue, globalValue);
  292. } else if (this.get('globalProperties').someProperty('name', config.foreignKey[index])) {
  293. globalValue = this.get('globalProperties').findProperty('name', config.foreignKey[index]).value;
  294. config._name = config.name.replace(_fkValue, globalValue);
  295. }
  296. }, this);
  297. }
  298. //For properties in the configMapping file having foreignKey and templateName properties.
  299. var templateValue = config.value.match(/<(templateName.*?)>/g);
  300. if (templateValue) {
  301. templateValue.forEach(function (_value) {
  302. var index = parseInt(_value.match(/\[([\d]*)(?=\])/)[1]);
  303. var globValue = this.get('globalProperties').findProperty('name', config.templateName[index]);
  304. if (globValue) {
  305. config.value = config.value.replace(_value, globValue.value);
  306. } else {
  307. config.value = null;
  308. }
  309. }, this);
  310. }
  311. },
  312. prepareSecureConfigs: function () {
  313. this.loadGlobals();
  314. var storedConfigs = this.get('content.serviceConfigProperties').filterProperty('id', 'site property');
  315. var uiConfigs = this.loadUiSideConfigs();
  316. this.set('configs', storedConfigs.concat(uiConfigs));
  317. },
  318. loadGlobals: function () {
  319. var globals = this.get('content.serviceConfigProperties').filterProperty('id', 'puppet var');
  320. this.set('globalProperties', globals);
  321. this.loadStaticGlobal(); //Hack for properties which are declared in config_properties.js and not able to retrieve values declared in secure_properties.js
  322. this.loadUsersToGlobal();
  323. this.loadHostNamesToGlobal();
  324. this.loadPrimaryNamesToGlobals();
  325. },
  326. loadUsersToGlobal: function () {
  327. if (!this.get('serviceUsers').length) {
  328. this.loadUsersFromServer();
  329. }
  330. App.router.get('mainAdminSecurityController.serviceUsers').forEach(function (_user) {
  331. this.get('globalProperties').pushObject(_user);
  332. }, this);
  333. },
  334. loadHostNamesToGlobal: function () {
  335. var oozieHostComponent = App.Service.find('OOZIE').get('hostComponents').findProperty('componentName', 'OOZIE_SERVER');
  336. if (this.get('isOozieSelected') && oozieHostComponent) {
  337. var oozieHostName = oozieHostComponent.get('host.hostName');
  338. this.get('globalProperties').pushObject({
  339. id: 'puppet var',
  340. name: 'oozieserver_host',
  341. value: oozieHostName
  342. });
  343. }
  344. var hiveHostComponent = App.Service.find('HIVE').get('hostComponents').findProperty('componentName', 'HIVE_METASTORE');
  345. if (this.get('isHiveSelected') && hiveHostComponent) {
  346. var hiveHostName = hiveHostComponent.get('host.hostName');
  347. this.get('globalProperties').pushObject({
  348. id: 'puppet var',
  349. name: 'hivemetastore_host',
  350. value: hiveHostName
  351. });
  352. }
  353. var webHcatComponent = App.Service.find('WEBHCAT').get('hostComponents').findProperty('componentName', 'WEBHCAT_SERVER');
  354. if (this.isWebHcatSelected() && webHcatComponent) {
  355. var webHcatHostName = webHcatComponent.get('host.hostName');
  356. this.get('globalProperties').pushObject({
  357. id: 'puppet var',
  358. name: 'webhcat_server',
  359. value: webHcatHostName
  360. });
  361. }
  362. },
  363. loadStaticGlobal: function () {
  364. var globalProperties = this.get('globalProperties');
  365. this.get('globalProperties').forEach(function (_property) {
  366. switch (_property.name) {
  367. case 'security_enabled':
  368. _property.value = 'true';
  369. break;
  370. case 'dfs_datanode_address':
  371. _property.value = '1019';
  372. break;
  373. case 'dfs_datanode_http_address':
  374. _property.value = '1022';
  375. break;
  376. }
  377. }, this);
  378. },
  379. loadPrimaryNamesToGlobals: function () {
  380. var principalProperties = this.getPrincipalNames();
  381. principalProperties.forEach(function (_principalProperty) {
  382. var name = _principalProperty.name.replace('principal', 'primary');
  383. var value = _principalProperty.value.split('/')[0];
  384. this.get('globalProperties').pushObject({name: name, value: value});
  385. }, this);
  386. },
  387. getPrincipalNames: function () {
  388. var principalNames = [];
  389. var allPrincipalNames = [];
  390. this.get('globalProperties').forEach(function (_globalProperty) {
  391. if (/principal_name?$/.test(_globalProperty.name)) {
  392. principalNames.pushObject(_globalProperty);
  393. }
  394. }, this);
  395. this.get('secureProperties').forEach(function (_secureProperty) {
  396. if (/principal_name?$/.test(_secureProperty.name)) {
  397. var principalName = principalNames.findProperty('name', _secureProperty.name);
  398. if (!principalName) {
  399. _secureProperty.value = _secureProperty.defaultValue;
  400. principalNames.pushObject(_secureProperty);
  401. }
  402. }
  403. }, this);
  404. return principalNames;
  405. },
  406. loadUsersFromServer: function () {
  407. if (App.testMode) {
  408. var serviceUsers = this.get('serviceUsers');
  409. serviceUsers.pushObject({id: 'puppet var', name: 'hdfs_user', value: 'hdfs'});
  410. serviceUsers.pushObject({id: 'puppet var', name: 'mapred_user', value: 'mapred'});
  411. serviceUsers.pushObject({id: 'puppet var', name: 'hbase_user', value: 'hbase'});
  412. serviceUsers.pushObject({id: 'puppet var', name: 'hive_user', value: 'hive'});
  413. } else {
  414. App.router.get('mainAdminSecurityController').setSecurityStatus();
  415. }
  416. },
  417. loadClusterConfigs: function () {
  418. var self = this;
  419. var url = App.apiPrefix + '/clusters/' + App.router.getClusterName();
  420. App.ajax.send({
  421. name: 'admin.security.add.cluster_configs',
  422. sender: this,
  423. success: 'loadClusterConfigsSuccessCallback',
  424. error: 'loadClusterConfigsErrorCallback'
  425. });
  426. },
  427. loadClusterConfigsSuccessCallback: function (data) {
  428. var self = this;
  429. //prepare tags to fetch all configuration for a service
  430. this.get('content.services').forEach(function (_secureService) {
  431. self.setServiceTagNames(_secureService, data.Clusters.desired_configs);
  432. });
  433. this.getAllConfigurations();
  434. },
  435. loadClusterConfigsErrorCallback: function (request, ajaxOptions, error) {
  436. var stage3 = this.get('stages').findProperty('stage', 'stage3');
  437. if (stage3) {
  438. stage3.set('isSuccess', false);
  439. stage3.set('isError', true);
  440. }
  441. console.log("TRACE: error code status is: " + request.status);
  442. },
  443. /**
  444. * set tagnames for configuration of the *-site.xml
  445. */
  446. setServiceTagNames: function (secureService, configs) {
  447. //var serviceConfigTags = this.get('serviceConfigTags');
  448. for (var index in configs) {
  449. if (secureService.sites && secureService.sites.contains(index)) {
  450. var serviceConfigObj = {
  451. siteName: index,
  452. tagName: configs[index].tag,
  453. newTagName: null,
  454. configs: {}
  455. };
  456. console.log("The value of serviceConfigTags[index]: " + configs[index]);
  457. this.get('serviceConfigTags').pushObject(serviceConfigObj);
  458. }
  459. }
  460. return serviceConfigObj;
  461. },
  462. applyConfigurationsToCluster: function () {
  463. this.set('noOfWaitingAjaxCalls', this.get('serviceConfigTags').length);
  464. this.get('serviceConfigTags').forEach(function (_serviceConfig) {
  465. this.applyConfigurationToCluster({type: _serviceConfig.siteName, tag: _serviceConfig.newTagName, properties: _serviceConfig.configs});
  466. }, this);
  467. },
  468. applyConfigurationToCluster: function (data) {
  469. var clusterData = {
  470. Clusters: {
  471. desired_config: data
  472. }
  473. };
  474. App.ajax.send({
  475. name: 'admin.security.apply_configuration',
  476. sender: this,
  477. data: {
  478. clusterData: clusterData
  479. },
  480. success: 'applyConfigurationToClusterSuccessCallback',
  481. error: 'applyConfigurationToClusterErrorCallback'
  482. });
  483. },
  484. applyConfigurationToClusterSuccessCallback: function (data) {
  485. this.set('noOfWaitingAjaxCalls', this.get('noOfWaitingAjaxCalls') - 1);
  486. if (this.get('noOfWaitingAjaxCalls') == 0) {
  487. var currentStage = this.get('stages').findProperty('stage', 'stage3');
  488. currentStage.set('isSuccess', true);
  489. currentStage.set('isError', false);
  490. }
  491. },
  492. applyConfigurationToClusterErrorCallback: function (request, ajaxOptions, error) {
  493. var stage3 = this.get('stages').findProperty('stage', 'stage3');
  494. if (stage3) {
  495. stage3.set('isSuccess', false);
  496. stage3.set('isError', true);
  497. }
  498. },
  499. /**
  500. * gets site config properties from server and sets it for every configuration
  501. * @param serviceConfigTags
  502. */
  503. getAllConfigurations: function () {
  504. var urlParams = [];
  505. this.get('serviceConfigTags').forEach(function (_tag) {
  506. urlParams.push('(type=' + _tag.siteName + '&tag=' + _tag.tagName + ')');
  507. }, this);
  508. if (urlParams.length > 0) {
  509. App.ajax.send({
  510. name: 'admin.security.all_configurations',
  511. sender: this,
  512. data: {
  513. urlParams: urlParams.join('|')
  514. },
  515. success: 'getAllConfigurationsSuccessCallback',
  516. error: 'getAllConfigurationsErrorCallback'
  517. });
  518. }
  519. },
  520. getAllConfigurationsSuccessCallback: function (data) {
  521. console.log("TRACE: In success function for the GET getServiceConfigsFromServer call");
  522. var stage3 = this.get('stages').findProperty('stage', 'stage3');
  523. this.get('serviceConfigTags').forEach(function (_tag) {
  524. if (!data.items.someProperty('type', _tag.siteName)) {
  525. console.log("Error: Metadata for secure services (secure_configs.js) is having config tags that are not being retrieved from server");
  526. if (stage3) {
  527. stage3.set('isSuccess', false);
  528. stage3.set('isError', true);
  529. }
  530. }
  531. _tag.configs = data.items.findProperty('type', _tag.siteName).properties;
  532. }, this);
  533. this.addSecureConfigs();
  534. this.applyConfigurationsToCluster();
  535. },
  536. getAllConfigurationsErrorCallback: function (request, ajaxOptions, error) {
  537. var stage3 = this.get('stages').findProperty('stage', 'stage3');
  538. if (stage3) {
  539. stage3.set('isSuccess', false);
  540. stage3.set('isError', true);
  541. }
  542. console.log("TRACE: In error function for the getServiceConfigsFromServer call");
  543. console.log("TRACE: error code status is: " + request.status);
  544. },
  545. addSecureConfigs: function () {
  546. this.get('serviceConfigTags').forEach(function (_serviceConfigTags) {
  547. _serviceConfigTags.newTagName = 'version' + (new Date).getTime();
  548. if (_serviceConfigTags.siteName === 'global') {
  549. var realmName = this.get('globalProperties').findProperty('name', 'kerberos_domain');
  550. if (this.get('isNagiosSelected')) {
  551. var nagiosPrincipalName = this.get('globalProperties').findProperty('name', 'nagios_principal_name');
  552. nagiosPrincipalName.value = nagiosPrincipalName.value + '@' + realmName.value;
  553. }
  554. if (this.get('isZkSelected')) {
  555. var zkPrincipalName = this.get('globalProperties').findProperty('name', 'zookeeper_principal_name');
  556. zkPrincipalName.value = zkPrincipalName.value + '@' + realmName.value;
  557. }
  558. this.get('globalProperties').forEach(function (_globalProperty) {
  559. if (!/_hosts?$/.test(_globalProperty.name)) {
  560. _serviceConfigTags.configs[_globalProperty.name] = _globalProperty.value;
  561. }
  562. }, this);
  563. }
  564. else {
  565. this.get('configs').filterProperty('id', 'site property').filterProperty('filename', _serviceConfigTags.siteName + '.xml').forEach(function (_config) {
  566. _serviceConfigTags.configs[_config.name] = _config.value;
  567. }, this);
  568. }
  569. }, this);
  570. },
  571. saveStagesOnRequestId: function () {
  572. this.saveStages();
  573. }.observes('stages.@each.requestId'),
  574. saveStagesOnCompleted: function () {
  575. this.saveStages();
  576. }.observes('stages.@each.isCompleted'),
  577. saveStages: function () {
  578. var stages = [];
  579. if (this.get('stages').length === this.totalSteps) {
  580. this.get('stages').forEach(function (_stage) {
  581. var stage = {
  582. name: _stage.get('name'),
  583. stage: _stage.get('stage'),
  584. label: _stage.get('label'),
  585. isPolling: _stage.get('isPolling'),
  586. isStarted: _stage.get('isStarted'),
  587. requestId: _stage.get('requestId'),
  588. isSuccess: _stage.get('isSuccess'),
  589. isError: _stage.get('isError'),
  590. url: _stage.get('url'),
  591. polledData: _stage.get('polledData'),
  592. data: _stage.get('data')
  593. };
  594. stages.pushObject(stage);
  595. }, this);
  596. App.db.setSecurityDeployStages(stages);
  597. if (!App.testMode) {
  598. App.clusterStatus.setClusterStatus({
  599. clusterName: this.get('clusterName'),
  600. clusterState: 'ADD_SECURITY_STEP_3',
  601. wizardControllerName: App.router.get('addSecurityController.name'),
  602. localdb: App.db.data.AddSecurity
  603. });
  604. }
  605. }
  606. }
  607. });