step4.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  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('isSuccess', 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')) {
  217. value = this.checkServiceForConfigValue(value, _config.dependedServiceName);
  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, serviceNames) {
  242. serviceNames.forEach(function (_serviceName) {
  243. if (!App.Service.find().mapProperty('serviceName').contains(_serviceName.name)) {
  244. value = value.replace(_serviceName.replace, '');
  245. }
  246. }, this);
  247. return value;
  248. },
  249. /**
  250. * Set all site property that are derived from other puppet-variable
  251. */
  252. getGlobConfigValue: function (templateName, expression, name) {
  253. var express = expression.match(/<(.*?)>/g);
  254. var value = expression;
  255. if (express == null) {
  256. return expression;
  257. }
  258. express.forEach(function (_express) {
  259. //console.log("The value of template is: " + _express);
  260. var index = parseInt(_express.match(/\[([\d]*)(?=\])/)[1]);
  261. var globValue = this.get('globalProperties').findProperty('name', templateName[index]);
  262. if (globValue) {
  263. console.log('The template value of templateName ' + '[' + index + ']' + ': ' + templateName[index] + ' is: ' + globValue);
  264. 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
  265. value = value.replace(_express, globValue.value);
  266. }
  267. } else {
  268. /*
  269. console.log("ERROR: The variable name is: " + templateName[index]);
  270. console.log("ERROR: mapped config from secureMapping file has no corresponding variable in " +
  271. "content.serviceConfigProperties. Two possible reasons for the error could be: 1) The service is not selected. " +
  272. "and/OR 2) The service_config metadata file has no corresponding global var for the site property variable");
  273. */
  274. value = null;
  275. }
  276. }, this);
  277. return value;
  278. },
  279. /**
  280. * Set all site property that are derived from other site-properties
  281. */
  282. setConfigValue: function (uiConfig, config) {
  283. if (config.value == null) {
  284. return;
  285. }
  286. var fkValue = config.name.match(/<(foreignKey.*?)>/g);
  287. if (fkValue) {
  288. fkValue.forEach(function (_fkValue) {
  289. var index = parseInt(_fkValue.match(/\[([\d]*)(?=\])/)[1]);
  290. var globalValue;
  291. if (uiConfig.someProperty('name', config.foreignKey[index])) {
  292. globalValue = uiConfig.findProperty('name', config.foreignKey[index]).value;
  293. config._name = config.name.replace(_fkValue, globalValue);
  294. } else if (this.get('globalProperties').someProperty('name', config.foreignKey[index])) {
  295. globalValue = this.get('globalProperties').findProperty('name', config.foreignKey[index]).value;
  296. config._name = config.name.replace(_fkValue, globalValue);
  297. }
  298. }, this);
  299. }
  300. //For properties in the configMapping file having foreignKey and templateName properties.
  301. var templateValue = config.value.match(/<(templateName.*?)>/g);
  302. if (templateValue) {
  303. templateValue.forEach(function (_value) {
  304. var index = parseInt(_value.match(/\[([\d]*)(?=\])/)[1]);
  305. var globValue = this.get('globalProperties').findProperty('name', config.templateName[index]);
  306. if (globValue) {
  307. config.value = config.value.replace(_value, globValue.value);
  308. } else {
  309. config.value = null;
  310. }
  311. }, this);
  312. }
  313. },
  314. prepareSecureConfigs: function () {
  315. this.loadGlobals();
  316. var storedConfigs = this.get('content.serviceConfigProperties').filterProperty('id', 'site property');
  317. var uiConfigs = this.loadUiSideConfigs();
  318. this.set('configs', storedConfigs.concat(uiConfigs));
  319. },
  320. loadGlobals: function () {
  321. var globals = this.get('content.serviceConfigProperties').filterProperty('id', 'puppet var');
  322. this.set('globalProperties', globals);
  323. this.loadStaticGlobal(); //Hack for properties which are declared in config_properties.js and not able to retrieve values declared in secure_properties.js
  324. this.loadUsersToGlobal();
  325. this.loadHostNamesToGlobal();
  326. this.loadPrimaryNamesToGlobals();
  327. },
  328. loadUsersToGlobal: function () {
  329. if (!this.get('serviceUsers').length) {
  330. this.loadUsersFromServer();
  331. }
  332. App.router.get('mainAdminSecurityController.serviceUsers').forEach(function (_user) {
  333. this.get('globalProperties').pushObject(_user);
  334. }, this);
  335. },
  336. loadHostNamesToGlobal: function () {
  337. var oozieHostComponent = App.Service.find('OOZIE').get('hostComponents').findProperty('componentName', 'OOZIE_SERVER');
  338. if (this.get('isOozieSelected') && oozieHostComponent) {
  339. var oozieHostName = oozieHostComponent.get('host.hostName');
  340. this.get('globalProperties').pushObject({
  341. id: 'puppet var',
  342. name: 'oozieserver_host',
  343. value: oozieHostName
  344. });
  345. }
  346. var hiveHostComponent = App.Service.find('HIVE').get('hostComponents').findProperty('componentName', 'HIVE_METASTORE');
  347. if (this.get('isHiveSelected') && hiveHostComponent) {
  348. var hiveHostName = hiveHostComponent.get('host.hostName');
  349. this.get('globalProperties').pushObject({
  350. id: 'puppet var',
  351. name: 'hivemetastore_host',
  352. value: hiveHostName
  353. });
  354. }
  355. var webHcatComponent = App.Service.find('WEBHCAT').get('hostComponents').findProperty('componentName', 'WEBHCAT_SERVER');
  356. if (this.isWebHcatSelected() && webHcatComponent) {
  357. var webHcatHostName = webHcatComponent.get('host.hostName');
  358. this.get('globalProperties').pushObject({
  359. id: 'puppet var',
  360. name: 'webhcat_server',
  361. value: webHcatHostName
  362. });
  363. }
  364. },
  365. loadStaticGlobal: function () {
  366. var globalProperties = this.get('globalProperties');
  367. this.get('globalProperties').forEach(function (_property) {
  368. switch (_property.name) {
  369. case 'security_enabled':
  370. _property.value = 'true';
  371. break;
  372. case 'dfs_datanode_address':
  373. _property.value = '1019';
  374. break;
  375. case 'dfs_datanode_http_address':
  376. _property.value = '1022';
  377. break;
  378. }
  379. }, this);
  380. },
  381. loadPrimaryNamesToGlobals: function () {
  382. var principalProperties = this.getPrincipalNames();
  383. principalProperties.forEach(function (_principalProperty) {
  384. var name = _principalProperty.name.replace('principal', 'primary');
  385. var value = _principalProperty.value.split('/')[0];
  386. this.get('globalProperties').pushObject({name: name, value: value});
  387. }, this);
  388. },
  389. getPrincipalNames: function () {
  390. var principalNames = [];
  391. var allPrincipalNames = [];
  392. this.get('globalProperties').forEach(function (_globalProperty) {
  393. if (/principal_name?$/.test(_globalProperty.name)) {
  394. principalNames.pushObject(_globalProperty);
  395. }
  396. }, this);
  397. this.get('secureProperties').forEach(function (_secureProperty) {
  398. if (/principal_name?$/.test(_secureProperty.name)) {
  399. var principalName = principalNames.findProperty('name', _secureProperty.name);
  400. if (!principalName) {
  401. _secureProperty.value = _secureProperty.defaultValue;
  402. principalNames.pushObject(_secureProperty);
  403. }
  404. }
  405. }, this);
  406. return principalNames;
  407. },
  408. loadUsersFromServer: function () {
  409. if (App.testMode) {
  410. var serviceUsers = this.get('serviceUsers');
  411. serviceUsers.pushObject({id: 'puppet var', name: 'hdfs_user', value: 'hdfs'});
  412. serviceUsers.pushObject({id: 'puppet var', name: 'mapred_user', value: 'mapred'});
  413. serviceUsers.pushObject({id: 'puppet var', name: 'hbase_user', value: 'hbase'});
  414. serviceUsers.pushObject({id: 'puppet var', name: 'hive_user', value: 'hive'});
  415. } else {
  416. App.router.get('mainAdminSecurityController').setSecurityStatus();
  417. }
  418. },
  419. loadClusterConfigs: function () {
  420. var self = this;
  421. var url = App.apiPrefix + '/clusters/' + App.router.getClusterName();
  422. App.ajax.send({
  423. name: 'admin.security.add.cluster_configs',
  424. sender: this,
  425. success: 'loadClusterConfigsSuccessCallback',
  426. error: 'loadClusterConfigsErrorCallback'
  427. });
  428. },
  429. loadClusterConfigsSuccessCallback: function (data) {
  430. var self = this;
  431. //prepare tags to fetch all configuration for a service
  432. this.get('content.services').forEach(function (_secureService) {
  433. self.setServiceTagNames(_secureService, data.Clusters.desired_configs);
  434. });
  435. this.getAllConfigurations();
  436. },
  437. loadClusterConfigsErrorCallback: function (request, ajaxOptions, error) {
  438. var stage3 = this.get('stages').findProperty('stage', 'stage3');
  439. if (stage3) {
  440. stage3.set('isSuccess', false);
  441. stage3.set('isError', true);
  442. }
  443. console.log("TRACE: error code status is: " + request.status);
  444. },
  445. /**
  446. * set tagnames for configuration of the *-site.xml
  447. */
  448. setServiceTagNames: function (secureService, configs) {
  449. //var serviceConfigTags = this.get('serviceConfigTags');
  450. for (var index in configs) {
  451. if (secureService.sites && secureService.sites.contains(index)) {
  452. var serviceConfigObj = {
  453. siteName: index,
  454. tagName: configs[index].tag,
  455. newTagName: null,
  456. configs: {}
  457. };
  458. console.log("The value of serviceConfigTags[index]: " + configs[index]);
  459. this.get('serviceConfigTags').pushObject(serviceConfigObj);
  460. }
  461. }
  462. return serviceConfigObj;
  463. },
  464. applyConfigurationsToCluster: function () {
  465. this.set('noOfWaitingAjaxCalls', this.get('serviceConfigTags').length);
  466. this.get('serviceConfigTags').forEach(function (_serviceConfig) {
  467. this.applyConfigurationToCluster({type: _serviceConfig.siteName, tag: _serviceConfig.newTagName, properties: _serviceConfig.configs});
  468. }, this);
  469. },
  470. applyConfigurationToCluster: function (data) {
  471. var clusterData = {
  472. Clusters: {
  473. desired_config: data
  474. }
  475. };
  476. App.ajax.send({
  477. name: 'admin.security.apply_configuration',
  478. sender: this,
  479. data: {
  480. clusterData: clusterData
  481. },
  482. success: 'applyConfigurationToClusterSuccessCallback',
  483. error: 'applyConfigurationToClusterErrorCallback'
  484. });
  485. },
  486. applyConfigurationToClusterSuccessCallback: function (data) {
  487. this.set('noOfWaitingAjaxCalls', this.get('noOfWaitingAjaxCalls') - 1);
  488. if (this.get('noOfWaitingAjaxCalls') == 0) {
  489. var currentStage = this.get('stages').findProperty('stage', 'stage3');
  490. currentStage.set('isSuccess', true);
  491. currentStage.set('isError', false);
  492. }
  493. },
  494. applyConfigurationToClusterErrorCallback: function (request, ajaxOptions, error) {
  495. var stage3 = this.get('stages').findProperty('stage', 'stage3');
  496. if (stage3) {
  497. stage3.set('isSuccess', false);
  498. stage3.set('isError', true);
  499. }
  500. },
  501. /**
  502. * gets site config properties from server and sets it for every configuration
  503. * @param serviceConfigTags
  504. */
  505. getAllConfigurations: function () {
  506. var urlParams = [];
  507. this.get('serviceConfigTags').forEach(function (_tag) {
  508. urlParams.push('(type=' + _tag.siteName + '&tag=' + _tag.tagName + ')');
  509. }, this);
  510. if (urlParams.length > 0) {
  511. App.ajax.send({
  512. name: 'admin.security.all_configurations',
  513. sender: this,
  514. data: {
  515. urlParams: urlParams.join('|')
  516. },
  517. success: 'getAllConfigurationsSuccessCallback',
  518. error: 'getAllConfigurationsErrorCallback'
  519. });
  520. }
  521. },
  522. getAllConfigurationsSuccessCallback: function (data) {
  523. console.log("TRACE: In success function for the GET getServiceConfigsFromServer call");
  524. var stage3 = this.get('stages').findProperty('stage', 'stage3');
  525. this.get('serviceConfigTags').forEach(function (_tag) {
  526. if (!data.items.someProperty('type', _tag.siteName)) {
  527. console.log("Error: Metadata for secure services (secure_configs.js) is having config tags that are not being retrieved from server");
  528. if (stage3) {
  529. stage3.set('isSuccess', false);
  530. stage3.set('isError', true);
  531. }
  532. }
  533. _tag.configs = data.items.findProperty('type', _tag.siteName).properties;
  534. }, this);
  535. if (this.addSecureConfigs()) {
  536. this.applyConfigurationsToCluster();
  537. }
  538. },
  539. getAllConfigurationsErrorCallback: function (request, ajaxOptions, error) {
  540. var stage3 = this.get('stages').findProperty('stage', 'stage3');
  541. if (stage3) {
  542. stage3.set('isSuccess', false);
  543. stage3.set('isError', true);
  544. }
  545. console.log("TRACE: In error function for the getServiceConfigsFromServer call");
  546. console.log("TRACE: error code status is: " + request.status);
  547. },
  548. addSecureConfigs: function () {
  549. try {
  550. this.get('serviceConfigTags').forEach(function (_serviceConfigTags) {
  551. _serviceConfigTags.newTagName = 'version' + (new Date).getTime();
  552. if (_serviceConfigTags.siteName === 'global') {
  553. var realmName = this.get('globalProperties').findProperty('name', 'kerberos_domain');
  554. if (this.get('isNagiosSelected')) {
  555. var nagiosPrincipalName = this.get('globalProperties').findProperty('name', 'nagios_principal_name');
  556. nagiosPrincipalName.value = nagiosPrincipalName.value + '@' + realmName.value;
  557. }
  558. if (this.get('isZkSelected')) {
  559. var zkPrincipalName = this.get('globalProperties').findProperty('name', 'zookeeper_principal_name');
  560. zkPrincipalName.value = zkPrincipalName.value + '@' + realmName.value;
  561. }
  562. this.get('globalProperties').forEach(function (_globalProperty) {
  563. if (!/_hosts?$/.test(_globalProperty.name)) {
  564. _serviceConfigTags.configs[_globalProperty.name] = _globalProperty.value;
  565. }
  566. }, this);
  567. }
  568. else {
  569. this.get('configs').filterProperty('id', 'site property').filterProperty('filename', _serviceConfigTags.siteName + '.xml').forEach(function (_config) {
  570. _serviceConfigTags.configs[_config.name] = _config.value;
  571. }, this);
  572. }
  573. }, this);
  574. } catch (err) {
  575. var stage3 = this.get('stages').findProperty('stage', 'stage3');
  576. if (stage3) {
  577. stage3.set('isSuccess', false);
  578. stage3.set('isError', true);
  579. }
  580. if (err) {
  581. console.log("Error: Error occurred while applying secure configs to the server. Error message: " + err);
  582. }
  583. this.onJsError();
  584. return false;
  585. }
  586. return true;
  587. },
  588. onJsError: function () {
  589. App.ModalPopup.show({
  590. header: Em.I18n.t('common.error'),
  591. secondary: false,
  592. onPrimary: function () {
  593. this.hide();
  594. },
  595. bodyClass: Ember.View.extend({
  596. template: Ember.Handlebars.compile('<p>{{t admin.security.apply.configuration.error}}</p>')
  597. })
  598. });
  599. },
  600. saveStagesOnRequestId: function () {
  601. this.saveStages();
  602. }.observes('stages.@each.requestId'),
  603. saveStagesOnCompleted: function () {
  604. this.saveStages();
  605. }.observes('stages.@each.isCompleted'),
  606. saveStages: function () {
  607. var stages = [];
  608. if (this.get('stages').length === this.totalSteps) {
  609. this.get('stages').forEach(function (_stage) {
  610. var stage = {
  611. name: _stage.get('name'),
  612. stage: _stage.get('stage'),
  613. label: _stage.get('label'),
  614. isPolling: _stage.get('isPolling'),
  615. isStarted: _stage.get('isStarted'),
  616. requestId: _stage.get('requestId'),
  617. isSuccess: _stage.get('isSuccess'),
  618. isError: _stage.get('isError'),
  619. url: _stage.get('url'),
  620. polledData: _stage.get('polledData'),
  621. data: _stage.get('data')
  622. };
  623. stages.pushObject(stage);
  624. }, this);
  625. App.db.setSecurityDeployStages(stages);
  626. if (!App.testMode) {
  627. App.clusterStatus.setClusterStatus({
  628. clusterName: this.get('clusterName'),
  629. clusterState: 'ADD_SECURITY_STEP_4',
  630. wizardControllerName: App.router.get('addSecurityController.name'),
  631. localdb: App.db.data.AddSecurity
  632. });
  633. }
  634. }
  635. }
  636. });