wizard_controller.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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.RMHighAvailabilityWizardController = App.WizardController.extend({
  20. name: 'rMHighAvailabilityWizardController',
  21. totalSteps: 4,
  22. isFinished: false,
  23. content: Em.Object.create({
  24. controllerName: 'rMHighAvailabilityWizardController'
  25. }),
  26. init: function () {
  27. this._super();
  28. this.clearStep();
  29. },
  30. clearStep: function () {
  31. this.set('isFinished', false);
  32. },
  33. setCurrentStep: function (currentStep, completed) {
  34. this._super(currentStep, completed);
  35. App.clusterStatus.setClusterStatus({
  36. clusterName: this.get('content.cluster.name'),
  37. wizardControllerName: 'rMHighAvailabilityWizardController',
  38. localdb: App.db.data
  39. });
  40. },
  41. /**
  42. * Save hosts for additional and current ResourceManagers to local db and <code>controller.content</code>
  43. * @param rmHosts
  44. */
  45. saveRmHosts: function (rmHosts) {
  46. this.set('content.rmHosts', rmHosts);
  47. this.setDBProperty('rmHosts', rmHosts);
  48. },
  49. /**
  50. * Load hosts for additional and current ResourceManagers from local db to <code>controller.content</code>
  51. */
  52. loadRmHosts: function() {
  53. var rmHosts = this.getDBProperty('rmHosts');
  54. this.set('content.rmHosts', rmHosts);
  55. },
  56. /**
  57. * Save configs to load and apply them on Configure Components step
  58. * @param configs
  59. */
  60. saveConfigs: function (configs) {
  61. this.set('content.configs', configs);
  62. this.setDBProperty('configs', configs);
  63. },
  64. /**
  65. * Load configs to apply them on Configure Components step
  66. */
  67. loadConfigs: function() {
  68. var configs = this.getDBProperty('configs');
  69. this.set('content.configs', configs);
  70. },
  71. saveTasksStatuses: function (tasksStatuses) {
  72. this.set('content.tasksStatuses', tasksStatuses);
  73. this.setDBProperty('tasksStatuses', tasksStatuses);
  74. },
  75. loadTasksStatuses: function() {
  76. var tasksStatuses = this.getDBProperty('tasksStatuses');
  77. this.set('content.tasksStatuses', tasksStatuses);
  78. },
  79. saveTasksRequestIds: function (tasksRequestIds) {
  80. this.set('content.tasksRequestIds', tasksRequestIds);
  81. this.setDBProperty('tasksRequestIds', tasksRequestIds);
  82. },
  83. loadTasksRequestIds: function() {
  84. var tasksRequestIds = this.getDBProperty('tasksRequestIds');
  85. this.set('content.tasksRequestIds', tasksRequestIds);
  86. },
  87. saveRequestIds: function (requestIds) {
  88. this.set('content.requestIds', requestIds);
  89. this.setDBProperty('requestIds', requestIds);
  90. },
  91. loadRequestIds: function() {
  92. var requestIds = this.getDBProperty('requestIds');
  93. this.set('content.requestIds', requestIds);
  94. },
  95. /**
  96. * Load data for all steps until <code>current step</code>
  97. */
  98. loadAllPriorSteps: function () {
  99. var step = this.get('currentStep');
  100. switch (step) {
  101. case '4':
  102. this.loadTasksStatuses();
  103. this.loadTasksRequestIds();
  104. this.loadRequestIds();
  105. this.loadConfigs();
  106. case '3':
  107. case '2':
  108. this.loadRmHosts();
  109. this.loadServicesFromServer();
  110. this.loadMasterComponentHosts();
  111. this.loadConfirmedHosts();
  112. case '1':
  113. this.load('cluster');
  114. }
  115. },
  116. /**
  117. * Remove all loaded data.
  118. * Created as copy for App.router.clearAllSteps
  119. */
  120. clearAllSteps: function () {
  121. this.clearInstallOptions();
  122. // clear temporary information stored during the install
  123. this.set('content.cluster', this.getCluster());
  124. },
  125. /**
  126. * Clear all temporary data
  127. */
  128. finish: function () {
  129. this.resetDbNamespace();
  130. App.router.get('updateController').updateAll();
  131. this.set('isFinished', true);
  132. }
  133. });