ra_high_availability_routes.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. if (parseInt(currStep) === 4) {
  42. App.showConfirmationPopup(function () {
  43. rAHighAvailabilityWizardController.resetOnClose(rAHighAvailabilityWizardController, 'main.services.index');
  44. }, Em.I18n.t('admin.ra_highAvailability.closePopup'));
  45. } else {
  46. rAHighAvailabilityWizardController.resetOnClose(rAHighAvailabilityWizardController, 'main.services.index');
  47. }
  48. },
  49. didInsertElement: function () {
  50. this._super();
  51. this.fitHeight();
  52. }
  53. });
  54. rAHighAvailabilityWizardController.set('popup', popup);
  55. var currentClusterStatus = App.clusterStatus.get('value');
  56. if (currentClusterStatus) {
  57. switch (currentClusterStatus.clusterState) {
  58. case 'RA_HIGH_AVAILABILITY_DEPLOY' :
  59. rAHighAvailabilityWizardController.setCurrentStep(currentClusterStatus.localdb.RAHighAvailabilityWizard.currentStep);
  60. break;
  61. default:
  62. var currStep = App.router.get('rAHighAvailabilityWizardController.currentStep');
  63. rAHighAvailabilityWizardController.setCurrentStep(currStep);
  64. break;
  65. }
  66. }
  67. App.router.get('wizardWatcherController').setUser(rAHighAvailabilityWizardController.get('name'));
  68. router.transitionTo('step' + rAHighAvailabilityWizardController.get('currentStep'));
  69. });
  70. },
  71. step1: Em.Route.extend({
  72. route: '/step1',
  73. connectOutlets: function (router) {
  74. var controller = router.get('rAHighAvailabilityWizardController');
  75. controller.dataLoading().done(function () {
  76. controller.setCurrentStep('1');
  77. controller.loadAllPriorSteps().done(function(){
  78. controller.connectOutlet('rAHighAvailabilityWizardStep1', controller.get('content'));
  79. });
  80. });
  81. },
  82. next: function (router) {
  83. var controller = router.get('rAHighAvailabilityWizardController');
  84. controller.save('loadBalancerURL');
  85. controller.clearMasterComponentHosts();
  86. router.transitionTo('step2');
  87. }
  88. }),
  89. step2: Em.Route.extend({
  90. route: '/step2',
  91. connectOutlets: function (router) {
  92. var controller = router.get('rAHighAvailabilityWizardController');
  93. controller.dataLoading().done(function () {
  94. controller.setCurrentStep('2');
  95. controller.loadAllPriorSteps().done(function(){
  96. controller.connectOutlet('rAHighAvailabilityWizardStep2', controller.get('content'));
  97. });
  98. });
  99. },
  100. next: function (router) {
  101. var wizardController = router.get('rAHighAvailabilityWizardController');
  102. var stepController = router.get('rAHighAvailabilityWizardStep2Controller');
  103. var currentRA = stepController.get('servicesMasters').filterProperty('component_name', 'RANGER_ADMIN').findProperty('isInstalled', true);
  104. var additionalRAs = stepController.get('servicesMasters').filterProperty('component_name', 'RANGER_ADMIN').filterProperty('isInstalled', false);
  105. var raHosts = {
  106. currentRA: currentRA.get('selectedHost'),
  107. additionalRA: additionalRAs.mapProperty('selectedHost')
  108. };
  109. wizardController.set('content.raHosts', raHosts);
  110. wizardController.save('raHosts');
  111. wizardController.saveMasterComponentHosts(stepController);
  112. router.transitionTo('step3');
  113. },
  114. back: function (router) {
  115. router.transitionTo('step1');
  116. }
  117. }),
  118. step3: Em.Route.extend({
  119. route: '/step3',
  120. connectOutlets: function (router) {
  121. var controller = router.get('rAHighAvailabilityWizardController');
  122. controller.dataLoading().done(function () {
  123. controller.setCurrentStep('3');
  124. controller.loadAllPriorSteps().done(function () {
  125. controller.connectOutlet('rAHighAvailabilityWizardStep3', controller.get('content'));
  126. });
  127. });
  128. },
  129. next: function (router) {
  130. router.transitionTo('step4');
  131. },
  132. back: function (router) {
  133. router.transitionTo('step2');
  134. }
  135. }),
  136. step4: Em.Route.extend({
  137. route: '/step4',
  138. connectOutlets: function (router) {
  139. var controller = router.get('rAHighAvailabilityWizardController');
  140. controller.dataLoading().done(function () {
  141. controller.setCurrentStep('4');
  142. controller.setLowerStepsDisable(4);
  143. controller.loadAllPriorSteps().done(function () {
  144. controller.connectOutlet('rAHighAvailabilityWizardStep4', controller.get('content'));
  145. });
  146. });
  147. },
  148. next: function (router) {
  149. router.get('updateController').set('isWorking', true);
  150. var rAHighAvailabilityWizardController = router.get('rAHighAvailabilityWizardController');
  151. rAHighAvailabilityWizardController.finish();
  152. App.clusterStatus.setClusterStatus({
  153. clusterName: App.router.getClusterName(),
  154. clusterState: 'DEFAULT',
  155. localdb: App.db.data
  156. }, {
  157. alwaysCallback: function () {
  158. rAHighAvailabilityWizardController.get('popup').hide();
  159. router.transitionTo('main.services.index');
  160. Em.run.next(function() {
  161. location.reload();
  162. });
  163. }
  164. });
  165. }
  166. })
  167. });