wizard_controller.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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.KerberosWizardController = App.WizardController.extend({
  20. name: 'kerberosWizardController',
  21. totalSteps: 6,
  22. isKerberosWizard: true,
  23. /**
  24. * Used for hiding back button in wizard
  25. */
  26. hideBackButton: true,
  27. content: Em.Object.create({
  28. controllerName: 'kerberosWizardController',
  29. serviceName: 'KERBEROS',
  30. hosts: '',
  31. kerberosOption: null,
  32. cluster: null,
  33. services: null,
  34. advancedServiceConfig: null,
  35. serviceConfigProperties: [],
  36. kerberosDescriptorConfigs: null,
  37. failedTask: null
  38. }),
  39. setCurrentStep: function (currentStep, completed) {
  40. this._super(currentStep, completed);
  41. if (App.testMode) {
  42. return;
  43. }
  44. App.clusterStatus.setClusterStatus({
  45. clusterName: this.get('content.cluster.name'),
  46. clusterState: 'KERBEROS_DEPLOY',
  47. wizardControllerName: 'kerberosWizardController',
  48. localdb: App.db.data
  49. });
  50. },
  51. /**
  52. * return new object extended from clusterStatusTemplate
  53. * @return Object
  54. */
  55. getCluster: function () {
  56. return jQuery.extend({}, this.get('clusterStatusTemplate'), {name: App.router.getClusterName()});
  57. },
  58. /**
  59. * save status of the cluster.
  60. * @param clusterStatus object with status,requestId fields.
  61. */
  62. saveClusterStatus: function (clusterStatus) {
  63. var oldStatus = this.toObject(this.get('content.cluster'));
  64. clusterStatus = jQuery.extend(oldStatus, clusterStatus);
  65. if (clusterStatus.requestId) {
  66. clusterStatus.requestId.forEach(function (requestId) {
  67. if (clusterStatus.oldRequestsId.indexOf(requestId) === -1) {
  68. clusterStatus.oldRequestsId.push(requestId)
  69. }
  70. }, this);
  71. }
  72. this.set('content.cluster', clusterStatus);
  73. this.save('cluster');
  74. },
  75. saveTasksStatuses: function (statuses) {
  76. this.setDBProperty('tasksStatuses',statuses);
  77. this.set('content.tasksStatuses', statuses);
  78. },
  79. saveConfigTag: function (tag) {
  80. App.db.setKerberosWizardConfigTag(tag);
  81. this.set('content.' + [tag.name], tag.value);
  82. },
  83. saveKerberosOption: function (stepController) {
  84. this.setDBProperty('kerberosOption', stepController.get('selectedItem'));
  85. this.set('content.kerberosOption', stepController.get('selectedItem'));
  86. },
  87. loadConfigTag: function (tag) {
  88. var tagVal = App.db.getKerberosWizardConfigTag(tag);
  89. this.set('content.' + tag, tagVal);
  90. },
  91. loadTasksStatuses: function () {
  92. var statuses = this.getDBProperty('tasksStatuses');
  93. this.set('content.tasksStatuses', statuses);
  94. },
  95. /**
  96. * Load serviceConfigProperties to model
  97. */
  98. loadServiceConfigProperties: function () {
  99. var serviceConfigProperties = this.getDBProperty('serviceConfigProperties');
  100. this.set('content.serviceConfigProperties', serviceConfigProperties);
  101. },
  102. /**
  103. * load advanced configs from server
  104. */
  105. loadAdvancedConfigs: function (dependentController) {
  106. var self = this;
  107. var loadAdvancedConfigResult = [];
  108. dependentController.set('isAdvancedConfigLoaded', false);
  109. var serviceName = this.get('content.serviceName');
  110. App.config.loadAdvancedConfig(serviceName, function (properties) {
  111. loadAdvancedConfigResult.pushObjects(properties);
  112. self.set('content.advancedServiceConfig', loadAdvancedConfigResult);
  113. self.setDBProperty('advancedServiceConfig', loadAdvancedConfigResult);
  114. dependentController.set('isAdvancedConfigLoaded', true);
  115. });
  116. },
  117. saveRequestIds: function (requestIds) {
  118. this.setDBProperty('requestIds',requestIds);
  119. this.set('content.requestIds', requestIds);
  120. },
  121. loadKerberosOption: function () {
  122. this.set('content.kerberosOption', this.getDBProperty('kerberosOption'));
  123. },
  124. loadRequestIds: function () {
  125. var requestIds = this.getDBProperty('requestIds');
  126. this.set('content.requestIds', requestIds);
  127. },
  128. saveTasksRequestIds: function (requestIds) {
  129. this.setDBProperty('tasksRequestIds',requestIds);
  130. this.set('content.tasksRequestIds', requestIds);
  131. },
  132. loadTasksRequestIds: function () {
  133. var requestIds = this.getDBProperty('tasksRequestIds');
  134. this.set('content.tasksRequestIds', requestIds);
  135. },
  136. loadMap: {
  137. '1': [
  138. {
  139. type: 'sync',
  140. callback: function () {
  141. this.loadKerberosOption();
  142. }
  143. }
  144. ],
  145. '2': [
  146. {
  147. type: 'sync',
  148. callback: function () {
  149. var kerberosStep2controller = App.router.get('kerberosWizardStep2Controller');
  150. this.loadAdvancedConfigs(kerberosStep2controller);
  151. this.loadServiceConfigProperties();
  152. this.load('hosts');
  153. }
  154. }
  155. ],
  156. '3': [
  157. {
  158. type: 'sync',
  159. callback: function () {
  160. this.loadTasksStatuses();
  161. this.loadTasksRequestIds();
  162. this.loadRequestIds();
  163. }
  164. }
  165. ]
  166. },
  167. /**
  168. * Remove all loaded data.
  169. * Created as copy for App.router.clearAllSteps
  170. */
  171. clearAllSteps: function () {
  172. this.clearInstallOptions();
  173. // clear temporary information stored during the install
  174. this.set('content.cluster', this.getCluster());
  175. },
  176. clearTasksData: function () {
  177. this.saveTasksStatuses(undefined);
  178. this.saveRequestIds(undefined);
  179. this.saveTasksRequestIds(undefined);
  180. },
  181. /**
  182. * Clear all temporary data
  183. */
  184. finish: function () {
  185. // The in-memory variable for currentstep should be reset to 1st step.
  186. this.setCurrentStep('1');
  187. // kerberos wizard namespace in the localStorage should be emptied
  188. this.resetDbNamespace();
  189. App.router.get('updateController').updateAll();
  190. }
  191. });