ra_high_availability_routes.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. module.exports = App.WizardRoute.extend({
  20. route: '/highAvailability/RangerAdmin/enable',
  21. enter: function (router) {
  22. var rAHighAvailabilityWizardController = router.get('rAHighAvailabilityWizardController');
  23. rAHighAvailabilityWizardController.dataLoading().done(function () {
  24. //Set RANGER as current service
  25. App.router.set('mainServiceItemController.content', App.Service.find().findProperty('serviceName', 'RANGER'));
  26. });
  27. Em.run.next(function () {
  28. App.router.get('updateController').set('isWorking', false);
  29. var popup = App.ModalPopup.show({
  30. classNames: ['full-width-modal'],
  31. header: Em.I18n.t('admin.ra_highAvailability.wizard.header'),
  32. bodyClass: App.RAHighAvailabilityWizardView.extend({
  33. controller: rAHighAvailabilityWizardController
  34. }),
  35. primary: Em.I18n.t('form.cancel'),
  36. showFooter: false,
  37. secondary: null,
  38. onClose: function () {
  39. var rAHighAvailabilityWizardController = router.get('rAHighAvailabilityWizardController'),
  40. currStep = rAHighAvailabilityWizardController.get('currentStep'),
  41. self = this;
  42. if (parseInt(currStep) === 4) {
  43. App.showConfirmationPopup(function () {
  44. router.get('updateController').set('isWorking', true);
  45. rAHighAvailabilityWizardController.finish();
  46. App.clusterStatus.setClusterStatus({
  47. clusterName: App.router.getClusterName(),
  48. clusterState: 'DEFAULT',
  49. localdb: App.db.data
  50. }, {
  51. alwaysCallback: function () {
  52. self.hide();
  53. router.transitionTo('main.services.index');
  54. Em.run.next(function() {
  55. location.reload();
  56. });
  57. }
  58. });
  59. }, Em.I18n.t('admin.ra_highAvailability.closePopup'));
  60. } else {
  61. router.get('updateController').set('isWorking', true);
  62. rAHighAvailabilityWizardController.finish();
  63. App.router.get('wizardWatcherController').resetUser();
  64. App.clusterStatus.setClusterStatus({
  65. clusterName: App.router.getClusterName(),
  66. clusterState: 'DEFAULT',
  67. localdb: App.db.data
  68. }, {
  69. alwaysCallback: function () {
  70. self.hide();
  71. router.transitionTo('main.services.index');
  72. Em.run.next(function() {
  73. location.reload();
  74. });
  75. }
  76. });
  77. }
  78. },
  79. didInsertElement: function () {
  80. this.fitHeight();
  81. }
  82. });
  83. rAHighAvailabilityWizardController.set('popup', popup);
  84. var currentClusterStatus = App.clusterStatus.get('value');
  85. if (currentClusterStatus) {
  86. switch (currentClusterStatus.clusterState) {
  87. case 'RA_HIGH_AVAILABILITY_DEPLOY' :
  88. rAHighAvailabilityWizardController.setCurrentStep(currentClusterStatus.localdb.RAHighAvailabilityWizard.currentStep);
  89. break;
  90. default:
  91. var currStep = App.router.get('rAHighAvailabilityWizardController.currentStep');
  92. rAHighAvailabilityWizardController.setCurrentStep(currStep);
  93. break;
  94. }
  95. }
  96. App.router.get('wizardWatcherController').setUser(rAHighAvailabilityWizardController.get('name'));
  97. router.transitionTo('step' + rAHighAvailabilityWizardController.get('currentStep'));
  98. });
  99. },
  100. step1: Em.Route.extend({
  101. route: '/step1',
  102. connectOutlets: function (router) {
  103. var controller = router.get('rAHighAvailabilityWizardController');
  104. controller.dataLoading().done(function () {
  105. controller.setCurrentStep('1');
  106. controller.loadAllPriorSteps().done(function(){
  107. controller.connectOutlet('rAHighAvailabilityWizardStep1', controller.get('content'));
  108. });
  109. });
  110. },
  111. next: function (router) {
  112. var controller = router.get('rAHighAvailabilityWizardController');
  113. controller.save('loadBalancerURL');
  114. controller.clearMasterComponentHosts();
  115. router.transitionTo('step2');
  116. }
  117. }),
  118. step2: Em.Route.extend({
  119. route: '/step2',
  120. connectOutlets: function (router) {
  121. var controller = router.get('rAHighAvailabilityWizardController');
  122. controller.dataLoading().done(function () {
  123. controller.setCurrentStep('2');
  124. controller.loadAllPriorSteps().done(function(){
  125. controller.connectOutlet('rAHighAvailabilityWizardStep2', controller.get('content'));
  126. });
  127. });
  128. },
  129. next: function (router) {
  130. var wizardController = router.get('rAHighAvailabilityWizardController');
  131. var stepController = router.get('rAHighAvailabilityWizardStep2Controller');
  132. var currentRA = stepController.get('servicesMasters').filterProperty('component_name', 'RANGER_ADMIN').findProperty('isInstalled', true);
  133. var additionalRAs = stepController.get('servicesMasters').filterProperty('component_name', 'RANGER_ADMIN').filterProperty('isInstalled', false);
  134. var raHosts = {
  135. currentRA: currentRA.get('selectedHost'),
  136. additionalRA: additionalRAs.mapProperty('selectedHost')
  137. };
  138. wizardController.set('content.raHosts', raHosts);
  139. wizardController.save('raHosts');
  140. wizardController.saveMasterComponentHosts(stepController);
  141. router.transitionTo('step3');
  142. },
  143. back: function (router) {
  144. router.transitionTo('step1');
  145. }
  146. }),
  147. step3: Em.Route.extend({
  148. route: '/step3',
  149. connectOutlets: function (router) {
  150. var controller = router.get('rAHighAvailabilityWizardController');
  151. controller.dataLoading().done(function () {
  152. controller.setCurrentStep('3');
  153. controller.loadAllPriorSteps().done(function () {
  154. controller.connectOutlet('rAHighAvailabilityWizardStep3', controller.get('content'));
  155. });
  156. });
  157. },
  158. next: function (router) {
  159. router.transitionTo('step4');
  160. },
  161. back: function (router) {
  162. router.transitionTo('step2');
  163. }
  164. }),
  165. step4: Em.Route.extend({
  166. route: '/step4',
  167. connectOutlets: function (router) {
  168. var controller = router.get('rAHighAvailabilityWizardController');
  169. controller.dataLoading().done(function () {
  170. controller.setCurrentStep('4');
  171. controller.setLowerStepsDisable(4);
  172. controller.loadAllPriorSteps().done(function () {
  173. controller.connectOutlet('rAHighAvailabilityWizardStep4', controller.get('content'));
  174. });
  175. });
  176. },
  177. next: function (router) {
  178. router.get('updateController').set('isWorking', true);
  179. var rAHighAvailabilityWizardController = router.get('rAHighAvailabilityWizardController');
  180. rAHighAvailabilityWizardController.finish();
  181. App.clusterStatus.setClusterStatus({
  182. clusterName: App.router.getClusterName(),
  183. clusterState: 'DEFAULT',
  184. localdb: App.db.data
  185. }, {
  186. alwaysCallback: function () {
  187. rAHighAvailabilityWizardController.get('popup').hide();
  188. router.transitionTo('main.services.index');
  189. Em.run.next(function() {
  190. location.reload();
  191. });
  192. }
  193. });
  194. }
  195. })
  196. });