wizard.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  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.WizardController = Em.Controller.extend({
  20. isStepDisabled: null,
  21. init: function () {
  22. this.set('isStepDisabled', []);
  23. this.clusters = App.Cluster.find();
  24. this.get('isStepDisabled').pushObject(Ember.Object.create({
  25. step: 1,
  26. value: false
  27. }));
  28. for (var i = 2; i <= this.get('totalSteps'); i++) {
  29. this.get('isStepDisabled').pushObject(Ember.Object.create({
  30. step: i,
  31. value: true
  32. }));
  33. }
  34. },
  35. setStepsEnable: function () {
  36. for (var i = 1; i <= this.totalSteps; i++) {
  37. var step = this.get('isStepDisabled').findProperty('step', i);
  38. if (i <= this.get('currentStep')) {
  39. step.set('value', false);
  40. } else {
  41. step.set('value', true);
  42. }
  43. }
  44. }.observes('currentStep'),
  45. setLowerStepsDisable: function (stepNo) {
  46. for (var i = 1; i < stepNo; i++) {
  47. var step = this.get('isStepDisabled').findProperty('step', i);
  48. step.set('value', true);
  49. }
  50. },
  51. /**
  52. * Set current step to new value.
  53. * Method moved from App.router.setInstallerCurrentStep
  54. * @param currentStep
  55. * @param completed
  56. */
  57. currentStep: function () {
  58. return App.get('router').getWizardCurrentStep(this.get('name').substr(0, this.get('name').length - 10));
  59. }.property(),
  60. /**
  61. * Set current step to new value.
  62. * Method moved from App.router.setInstallerCurrentStep
  63. * @param currentStep
  64. * @param completed
  65. */
  66. setCurrentStep: function (currentStep, completed) {
  67. App.db.setWizardCurrentStep(this.get('name').substr(0, this.get('name').length - 10), currentStep, completed);
  68. this.set('currentStep', currentStep);
  69. },
  70. clusters: null,
  71. isStep0: function () {
  72. return this.get('currentStep') == 0;
  73. }.property('currentStep'),
  74. isStep1: function () {
  75. return this.get('currentStep') == 1;
  76. }.property('currentStep'),
  77. isStep2: function () {
  78. return this.get('currentStep') == 2;
  79. }.property('currentStep'),
  80. isStep3: function () {
  81. return this.get('currentStep') == 3;
  82. }.property('currentStep'),
  83. isStep4: function () {
  84. return this.get('currentStep') == 4;
  85. }.property('currentStep'),
  86. isStep5: function () {
  87. return this.get('currentStep') == 5;
  88. }.property('currentStep'),
  89. isStep6: function () {
  90. return this.get('currentStep') == 6;
  91. }.property('currentStep'),
  92. isStep7: function () {
  93. return this.get('currentStep') == 7;
  94. }.property('currentStep'),
  95. isStep8: function () {
  96. return this.get('currentStep') == 8;
  97. }.property('currentStep'),
  98. isStep9: function () {
  99. return this.get('currentStep') == 9;
  100. }.property('currentStep'),
  101. isStep10: function () {
  102. return this.get('currentStep') == 10;
  103. }.property('currentStep'),
  104. gotoStep: function (step) {
  105. if (this.get('isStepDisabled').findProperty('step', step).get('value') !== false) {
  106. return false;
  107. }
  108. // if going back from Step 9 in Install Wizard, delete the checkpoint so that the user is not redirected
  109. // to Step 9
  110. if (this.get('content.controllerName') == 'installerController' && this.get('currentStep') === '9' && step < 9) {
  111. App.clusterStatus.setClusterStatus({
  112. clusterName: this.get('clusterName'),
  113. clusterState: 'CLUSTER_NOT_CREATED_1',
  114. wizardControllerName: 'installerController',
  115. localdb: App.db.data
  116. });
  117. }
  118. if ((this.get('currentStep') - step) > 1) {
  119. App.ModalPopup.show({
  120. header: Em.I18n.t('installer.navigation.warning.header'),
  121. onPrimary: function () {
  122. App.router.send('gotoStep' + step);
  123. this.hide();
  124. },
  125. body: "If you proceed to go back to Step " + step + ", you will lose any changes you have made beyond this step"
  126. });
  127. } else {
  128. App.router.send('gotoStep' + step);
  129. }
  130. return true;
  131. },
  132. gotoStep0: function () {
  133. this.gotoStep(0);
  134. },
  135. gotoStep1: function () {
  136. this.gotoStep(1);
  137. },
  138. gotoStep2: function () {
  139. this.gotoStep(2);
  140. },
  141. gotoStep3: function () {
  142. this.gotoStep(3);
  143. },
  144. gotoStep4: function () {
  145. this.gotoStep(4);
  146. },
  147. gotoStep5: function () {
  148. this.gotoStep(5);
  149. },
  150. gotoStep6: function () {
  151. this.gotoStep(6);
  152. },
  153. gotoStep7: function () {
  154. this.gotoStep(7);
  155. },
  156. gotoStep8: function () {
  157. this.gotoStep(8);
  158. },
  159. gotoStep9: function () {
  160. this.gotoStep(9);
  161. },
  162. gotoStep10: function () {
  163. this.gotoStep(10);
  164. },
  165. /**
  166. * Initialize host status info for step9
  167. */
  168. setInfoForStep9: function () {
  169. var hostInfo = App.db.getHosts();
  170. for (var index in hostInfo) {
  171. hostInfo[index].status = "pending";
  172. hostInfo[index].message = 'Waiting';
  173. hostInfo[index].logTasks = [];
  174. hostInfo[index].tasks = [];
  175. hostInfo[index].progress = '0';
  176. }
  177. App.db.setHosts(hostInfo);
  178. },
  179. /**
  180. * Remove all data for installOptions step
  181. */
  182. clearInstallOptions: function () {
  183. var installOptions = jQuery.extend({}, this.get('installOptionsTemplate'));
  184. this.set('content.installOptions', installOptions);
  185. this.save('installOptions');
  186. this.set('content.hosts', []);
  187. this.save('hosts');
  188. },
  189. toObject: function (object) {
  190. var result = {};
  191. for (var i in object) {
  192. if (object.hasOwnProperty(i)) {
  193. result[i] = object[i];
  194. }
  195. }
  196. return result;
  197. },
  198. /**
  199. * save status of the cluster. This is called from step8 and step9 to persist install and start requestId
  200. * @param clusterStatus object with status, isCompleted, requestId, isInstallError and isStartError field.
  201. */
  202. saveClusterStatus: function (clusterStatus) {
  203. var oldStatus = this.toObject(this.get('content.cluster'));
  204. clusterStatus = jQuery.extend(oldStatus, clusterStatus);
  205. if (clusterStatus.requestId &&
  206. clusterStatus.oldRequestsId.indexOf(clusterStatus.requestId) === -1) {
  207. clusterStatus.oldRequestsId.push(clusterStatus.requestId);
  208. }
  209. this.set('content.cluster', clusterStatus);
  210. this.save('cluster');
  211. },
  212. /**
  213. * Invoke installation of selected services to the server and saves the request id returned by the server.
  214. * @param isRetry
  215. */
  216. installServices: function (isRetry) {
  217. // clear requests since we are installing services
  218. // and we don't want to get tasks for previous install attempts
  219. this.set('content.cluster.oldRequestsId', []);
  220. var clusterName = this.get('content.cluster.name');
  221. var data;
  222. var name;
  223. switch (this.get('content.controllerName')) {
  224. case 'addHostController':
  225. var hostnames = [];
  226. for (var hostname in App.db.getHosts()) {
  227. hostnames.push(hostname);
  228. }
  229. if (isRetry) {
  230. name = 'wizard.install_services.add_host_controller.is_retry';
  231. }
  232. else {
  233. name = 'wizard.install_services.add_host_controller.not_is_retry';
  234. }
  235. data = {
  236. "RequestInfo": {
  237. "context": Em.I18n.t('requestInfo.installComponents'),
  238. "query": "HostRoles/host_name.in(" + hostnames.join(',') + ")"
  239. },
  240. "Body": {
  241. "HostRoles": {"state": "INSTALLED"}
  242. }
  243. };
  244. data = JSON.stringify(data);
  245. break;
  246. case 'installerController':
  247. default:
  248. if (isRetry) {
  249. name = 'wizard.install_services.installer_controller.is_retry';
  250. data = '{"RequestInfo": {"context" :"' + Em.I18n.t('requestInfo.installComponents') + '"}, "Body": {"HostRoles": {"state": "INSTALLED"}}}';
  251. }
  252. else {
  253. name = 'wizard.install_services.installer_controller.not_is_retry';
  254. data = '{"RequestInfo": {"context" :"' + Em.I18n.t('requestInfo.installServices') + '"}, "Body": {"ServiceInfo": {"state": "INSTALLED"}}}';
  255. }
  256. break;
  257. }
  258. App.ajax.send({
  259. name: name,
  260. sender: this,
  261. data: {
  262. data: data,
  263. cluster: clusterName
  264. },
  265. success: 'installServicesSuccessCallback',
  266. error: 'installServicesErrorCallback'
  267. });
  268. },
  269. installServicesSuccessCallback: function (jsonData) {
  270. var installStartTime = new Date().getTime();
  271. console.log("TRACE: In success function for the installService call");
  272. if (jsonData) {
  273. var requestId = jsonData.Requests.id;
  274. console.log('requestId is: ' + requestId);
  275. var clusterStatus = {
  276. status: 'PENDING',
  277. requestId: requestId,
  278. isInstallError: false,
  279. isCompleted: false,
  280. installStartTime: installStartTime
  281. };
  282. this.saveClusterStatus(clusterStatus);
  283. } else {
  284. console.log('ERROR: Error occurred in parsing JSON data');
  285. }
  286. },
  287. installServicesErrorCallback: function (request, ajaxOptions, error) {
  288. console.log("TRACE: In error function for the installService call");
  289. console.log("TRACE: error code status is: " + request.status);
  290. console.log('Error message is: ' + request.responseText);
  291. var clusterStatus = {
  292. status: 'PENDING',
  293. requestId: this.get('content.cluster.requestId'),
  294. isInstallError: true,
  295. isCompleted: false
  296. };
  297. this.saveClusterStatus(clusterStatus);
  298. App.showAlertPopup(Em.I18n.t('common.errorPopup.header'), request.responseText);
  299. },
  300. bootstrapRequestId: null,
  301. /*
  302. Bootstrap selected hosts.
  303. */
  304. launchBootstrap: function (bootStrapData) {
  305. App.ajax.send({
  306. name: 'wizard.launch_bootstrap',
  307. sender: this,
  308. data: {
  309. bootStrapData: bootStrapData
  310. },
  311. success: 'launchBootstrapSuccessCallback',
  312. error: 'launchBootstrapErrorCallback'
  313. });
  314. return this.get('bootstrapRequestId');
  315. },
  316. launchBootstrapSuccessCallback: function (data) {
  317. console.log("TRACE: POST bootstrap succeeded");
  318. this.set('bootstrapRequestId', data.requestId);
  319. },
  320. launchBootstrapErrorCallback: function () {
  321. console.log("ERROR: POST bootstrap failed");
  322. alert('Bootstrap call failed. Please try again.');
  323. },
  324. /**
  325. * Load <code>content.<name></code> variable from localStorage, if wasn't loaded before.
  326. * If you specify <code>reload</code> to true - it will reload it.
  327. * @param name
  328. * @param reload
  329. * @return {Boolean}
  330. */
  331. load: function (name, reload) {
  332. if (this.get('content.' + name) && !reload) {
  333. return false;
  334. }
  335. var result = App.db['get' + name.capitalize()]();
  336. if (!result) {
  337. result = this['get' + name.capitalize()]();
  338. App.db['set' + name.capitalize()](result);
  339. console.log(this.get('name') + ": created " + name, result);
  340. }
  341. this.set('content.' + name, result);
  342. console.log(this.get('name') + ": loaded " + name, result);
  343. },
  344. save: function (name) {
  345. var value = this.toObject(this.get('content.' + name));
  346. App.db['set' + name.capitalize()](value);
  347. console.log(this.get('name') + ": saved " + name, value);
  348. },
  349. clear: function () {
  350. this.set('content', Ember.Object.create({
  351. 'controllerName': this.get('content.controllerName')
  352. }));
  353. this.set('currentStep', 0);
  354. this.clearStorageData();
  355. },
  356. clusterStatusTemplate: {
  357. name: "",
  358. status: "PENDING",
  359. isCompleted: false,
  360. requestId: null,
  361. installStartTime: null,
  362. installTime: null,
  363. isInstallError: false,
  364. isStartError: false,
  365. oldRequestsId: []
  366. },
  367. clearStorageData: function () {
  368. App.db.setService(undefined); //not to use this data at AddService page
  369. App.db.setHosts(undefined);
  370. App.db.setMasterComponentHosts(undefined);
  371. App.db.setSlaveComponentHosts(undefined);
  372. App.db.setCluster(undefined);
  373. App.db.setAllHostNames(undefined);
  374. App.db.setInstallOptions(undefined);
  375. App.db.setAllHostNamesPattern(undefined);
  376. },
  377. installOptionsTemplate: {
  378. hostNames: "", //string
  379. manualInstall: false, //true, false
  380. useSsh: true, //bool
  381. javaHome: App.defaultJavaHome, //string
  382. localRepo: false, //true, false
  383. sshKey: "", //string
  384. bootRequestId: null, //string
  385. sshUser: "root" //string
  386. },
  387. loadedServiceComponents: null,
  388. /**
  389. * Generate serviceComponents as pr the stack definition and save it to localdata
  390. * called form stepController step4WizardController
  391. */
  392. loadServiceComponents: function () {
  393. App.ajax.send({
  394. name: 'wizard.service_components',
  395. sender: this,
  396. data: {
  397. stackUrl: App.get('stack2VersionURL'),
  398. stackVersion: App.get('currentStackVersionNumber')
  399. },
  400. success: 'loadServiceComponentsSuccessCallback',
  401. error: 'loadServiceComponentsErrorCallback'
  402. });
  403. return this.get('loadedServiceComponents');
  404. },
  405. loadServiceComponentsSuccessCallback: function (jsonData) {
  406. var displayOrderConfig = require('data/services');
  407. console.log("TRACE: getService ajax call -> In success function for the getServiceComponents call");
  408. console.log("TRACE: jsonData.services : " + jsonData.items);
  409. // Creating Model
  410. var Service = Ember.Object.extend({
  411. serviceName: null,
  412. displayName: null,
  413. isDisabled: true,
  414. isSelected: true,
  415. isInstalled: false,
  416. description: null,
  417. version: null
  418. });
  419. var data = [];
  420. // loop through all the service components
  421. for (var i = 0; i < displayOrderConfig.length; i++) {
  422. var entry = jsonData.items.findProperty("StackServices.service_name", displayOrderConfig[i].serviceName);
  423. if (entry) {
  424. var myService = Service.create({
  425. serviceName: entry.StackServices.service_name,
  426. displayName: displayOrderConfig[i].displayName,
  427. isDisabled: displayOrderConfig[i].isDisabled,
  428. isSelected: displayOrderConfig[i].isSelected,
  429. canBeSelected: displayOrderConfig[i].canBeSelected,
  430. isInstalled: false,
  431. isHidden: displayOrderConfig[i].isHidden,
  432. description: entry.StackServices.comments,
  433. version: entry.StackServices.service_version
  434. });
  435. data.push(myService);
  436. }
  437. else {
  438. console.warn('Service not found - ', displayOrderConfig[i].serviceName);
  439. }
  440. }
  441. this.set('loadedServiceComponents', data);
  442. console.log('TRACE: service components: ' + JSON.stringify(data));
  443. },
  444. loadServiceComponentsErrorCallback: function (request, ajaxOptions, error) {
  445. console.log("TRACE: STep5 -> In error function for the getServiceComponents call");
  446. console.log("TRACE: STep5 -> error code status is: " + request.status);
  447. console.log('Step8: Error message is: ' + request.responseText);
  448. },
  449. loadServicesFromServer: function () {
  450. var services = App.db.getService();
  451. if (services) {
  452. return;
  453. }
  454. var apiService = this.loadServiceComponents();
  455. this.set('content.services', apiService);
  456. App.db.setService(apiService);
  457. },
  458. registerErrPopup: function (header, message) {
  459. App.ModalPopup.show({
  460. header: header,
  461. secondary: false,
  462. onPrimary: function () {
  463. this.hide();
  464. },
  465. bodyClass: Ember.View.extend({
  466. template: Ember.Handlebars.compile(['<p>{{view.message}}</p>'].join('\n')),
  467. message: message
  468. })
  469. });
  470. },
  471. /**
  472. * Save hosts that the user confirmed to proceed with from step 3
  473. * @param stepController App.WizardStep3Controller
  474. */
  475. saveConfirmedHosts: function (stepController) {
  476. var hostInfo = {};
  477. stepController.get('content.hosts').forEach(function (_host) {
  478. hostInfo[_host.name] = {
  479. name: _host.name,
  480. cpu: _host.cpu,
  481. memory: _host.memory,
  482. disk_info: _host.disk_info,
  483. bootStatus: _host.bootStatus,
  484. isInstalled: false
  485. };
  486. });
  487. console.log('wizardController:saveConfirmedHosts: save hosts ', hostInfo);
  488. App.db.setHosts(hostInfo);
  489. this.set('content.hosts', hostInfo);
  490. },
  491. /**
  492. * Save data after installation to main controller
  493. * @param stepController App.WizardStep9Controller
  494. */
  495. saveInstalledHosts: function (stepController) {
  496. var hosts = stepController.get('hosts');
  497. var hostInfo = App.db.getHosts();
  498. for (var index in hostInfo) {
  499. hostInfo[index].status = "pending";
  500. var host = hosts.findProperty('name', hostInfo[index].name);
  501. if (host) {
  502. hostInfo[index].status = host.status;
  503. hostInfo[index].message = host.message;
  504. hostInfo[index].progress = host.progress;
  505. }
  506. }
  507. this.set('content.hosts', hostInfo);
  508. this.save('hosts');
  509. console.log('wizardController:saveInstalledHosts: save hosts ', hostInfo);
  510. },
  511. /**
  512. * Save slaveHostComponents to main controller
  513. * @param stepController
  514. */
  515. saveSlaveComponentHosts: function (stepController) {
  516. var hosts = stepController.get('hosts');
  517. var headers = stepController.get('headers');
  518. var formattedHosts = Ember.Object.create();
  519. headers.forEach(function (header) {
  520. formattedHosts.set(header.get('name'), []);
  521. });
  522. hosts.forEach(function (host) {
  523. var checkboxes = host.get('checkboxes');
  524. headers.forEach(function (header) {
  525. var cb = checkboxes.findProperty('title', header.get('label'));
  526. if (cb.get('checked')) {
  527. formattedHosts.get(header.get('name')).push({
  528. hostName: host.hostName,
  529. group: 'Default',
  530. isInstalled: cb.get('isInstalled')
  531. });
  532. }
  533. });
  534. });
  535. var slaveComponentHosts = [];
  536. headers.forEach(function (header) {
  537. slaveComponentHosts.push({
  538. componentName: header.get('name'),
  539. displayName: header.get('label').replace(/\s/g, ''),
  540. hosts: formattedHosts.get(header.get('name'))
  541. });
  542. });
  543. App.db.setSlaveComponentHosts(slaveComponentHosts);
  544. console.log('wizardController.slaveComponentHosts: saved hosts', slaveComponentHosts);
  545. this.set('content.slaveComponentHosts', slaveComponentHosts);
  546. },
  547. /**
  548. * Return true if cluster data is loaded and false otherwise.
  549. * This is used for all wizard controllers except for installer wizard.
  550. */
  551. dataLoading: function () {
  552. var dfd = $.Deferred();
  553. this.connectOutlet('loading');
  554. if (App.router.get('clusterController.isLoaded')) {
  555. dfd.resolve();
  556. } else {
  557. var interval = setInterval(function () {
  558. if (App.router.get('clusterController.isLoaded')) {
  559. dfd.resolve();
  560. clearInterval(interval);
  561. }
  562. }, 50);
  563. }
  564. return dfd.promise();
  565. },
  566. /**
  567. * Return true if user data is loaded via App.MainServiceInfoConfigsController
  568. * This function is used in reassign master wizard right now.
  569. */
  570. usersLoading: function () {
  571. var self = this;
  572. var dfd = $.Deferred();
  573. var miscController = App.MainAdminMiscController.create({content: self.get('content')});
  574. miscController.loadUsers();
  575. var interval = setInterval(function () {
  576. if (miscController.get('dataIsLoaded')) {
  577. if (self.get("content.hdfsUser")) {
  578. self.set('content.hdfsUser', miscController.get('content.hdfsUser'));
  579. }
  580. dfd.resolve();
  581. clearInterval(interval);
  582. }
  583. }, 10);
  584. return dfd.promise();
  585. },
  586. /**
  587. * Save cluster status before going to deploy step
  588. * @param name cluster state. Unique for every wizard
  589. */
  590. saveClusterState: function (name) {
  591. App.clusterStatus.setClusterStatus({
  592. clusterName: this.get('content.cluster.name'),
  593. clusterState: name,
  594. wizardControllerName: this.get('content.controllerName'),
  595. localdb: App.db.data
  596. });
  597. },
  598. /**
  599. * load advanced configs from server
  600. */
  601. loadAdvancedConfigs: function () {
  602. var configs = (App.db.getAdvancedServiceConfig()) ? App.db.getAdvancedServiceConfig() : [];
  603. this.get('content.services').filterProperty('isSelected', true).mapProperty('serviceName').forEach(function (_serviceName) {
  604. var serviceComponents = App.config.loadAdvancedConfig(_serviceName);
  605. if (serviceComponents) {
  606. configs = configs.concat(serviceComponents);
  607. }
  608. }, this);
  609. this.set('content.advancedServiceConfig', configs);
  610. App.db.setAdvancedServiceConfig(configs);
  611. },
  612. /**
  613. * Load serviceConfigProperties to model
  614. */
  615. loadServiceConfigProperties: function () {
  616. var serviceConfigProperties = App.db.getServiceConfigProperties();
  617. this.set('content.serviceConfigProperties', serviceConfigProperties);
  618. console.log("AddHostController.loadServiceConfigProperties: loaded config ", serviceConfigProperties);
  619. },
  620. /**
  621. * Save config properties
  622. * @param stepController Step7WizardController
  623. */
  624. saveServiceConfigProperties: function (stepController) {
  625. var serviceConfigProperties = [];
  626. stepController.get('stepConfigs').forEach(function (_content) {
  627. if (_content.serviceName === 'YARN' && !App.supports.capacitySchedulerUi) {
  628. _content.set('configs', App.config.textareaIntoFileConfigs(_content.get('configs'), 'capacity-scheduler.xml'));
  629. }
  630. _content.get('configs').forEach(function (_configProperties) {
  631. var overrides = _configProperties.get('overrides');
  632. var overridesArray = [];
  633. if (overrides != null) {
  634. overrides.forEach(function (override) {
  635. var overrideEntry = {
  636. value: override.get('value'),
  637. hosts: []
  638. };
  639. override.get('selectedHostOptions').forEach(function (host) {
  640. overrideEntry.hosts.push(host);
  641. });
  642. overridesArray.push(overrideEntry);
  643. });
  644. }
  645. overridesArray = (overridesArray.length) ? overridesArray : null;
  646. var configProperty = {
  647. id: _configProperties.get('id'),
  648. name: _configProperties.get('name'),
  649. value: _configProperties.get('value'),
  650. defaultValue: _configProperties.get('defaultValue'),
  651. description: _configProperties.get('description'),
  652. serviceName: _configProperties.get('serviceName'),
  653. domain: _configProperties.get('domain'),
  654. filename: _configProperties.get('filename'),
  655. displayType: _configProperties.get('displayType'),
  656. overrides: overridesArray
  657. };
  658. serviceConfigProperties.push(configProperty);
  659. }, this);
  660. }, this);
  661. App.db.setServiceConfigProperties(serviceConfigProperties);
  662. this.set('content.serviceConfigProperties', serviceConfigProperties);
  663. }
  664. })