step6_controller.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. App.KerberosWizardStep6Controller = App.KerberosProgressPageController.extend({
  19. name: 'kerberosWizardStep6Controller',
  20. clusterDeployState: 'KERBEROS_DEPLOY',
  21. isSingleRequestPage: true,
  22. request: {},
  23. commands: [],
  24. contextForPollingRequest: Em.I18n.t('requestInfo.kerberizeCluster'),
  25. /**
  26. * Define whether show Back button
  27. * @type {Boolean}
  28. */
  29. isBackButtonDisabled: true,
  30. /**
  31. * Start cluster kerberization. On retry just unkerberize and kerbrize cluster.
  32. * @param {bool} isRetry
  33. */
  34. setRequest: function (isRetry) {
  35. var self = this;
  36. var kerberizeRequest = {
  37. name: 'KERBERIZE_CLUSTER',
  38. ajaxName: 'admin.kerberize.cluster',
  39. ajaxData: {
  40. data: {
  41. Clusters: {
  42. security_type: "KERBEROS"
  43. }
  44. }
  45. }
  46. };
  47. if (isRetry) {
  48. // on retry we have to unkerberize cluster
  49. this.unkerberizeCluster().always(function() {
  50. // clear current request object before start of kerberize process
  51. self.set('request', kerberizeRequest);
  52. self.clearStage();
  53. self.loadStep();
  54. });
  55. } else {
  56. this.set('request', kerberizeRequest);
  57. }
  58. },
  59. /**
  60. * Send request to unkerberisze cluster
  61. * @returns {$.ajax}
  62. */
  63. unkerberizeCluster: function () {
  64. return App.ajax.send({
  65. name: 'admin.unkerberize.cluster',
  66. sender: this,
  67. success: 'goToNextStep',
  68. error: 'goToNextStep'
  69. });
  70. },
  71. goToNextStep: function() {
  72. this.clearStage();
  73. App.router.transitionTo('step6');
  74. },
  75. postKerberosDescriptor: function (kerberosDescriptor) {
  76. return App.ajax.send({
  77. name: 'admin.kerberos.cluster.artifact.create',
  78. sender: this,
  79. data: {
  80. artifactName: 'kerberos_descriptor',
  81. data: {
  82. artifact_data: kerberosDescriptor
  83. }
  84. }
  85. });
  86. },
  87. /**
  88. * Send request to update kerberos descriptor
  89. * @param kerberosDescriptor
  90. * @returns {$.ajax|*}
  91. */
  92. putKerberosDescriptor: function (kerberosDescriptor) {
  93. return App.ajax.send({
  94. name: 'admin.kerberos.cluster.artifact.update',
  95. sender: this,
  96. data: {
  97. artifactName: 'kerberos_descriptor',
  98. data: {
  99. artifact_data: kerberosDescriptor
  100. }
  101. },
  102. success: 'unkerberizeCluster',
  103. error: 'unkerberizeCluster'
  104. });
  105. },
  106. retry: function () {
  107. this.set('showRetry', false);
  108. this.get('tasks').setEach('status', 'PENDING');
  109. App.router.send('retry');
  110. },
  111. /**
  112. * Enable or disable previous steps according to tasks statuses
  113. */
  114. enableDisablePreviousSteps: function () {
  115. var wizardController = App.router.get(this.get('content.controllerName'));
  116. if (this.get('tasks').someProperty('status', 'FAILED')) {
  117. wizardController.enableStep(4);
  118. this.set('isBackButtonDisabled', false);
  119. } else {
  120. wizardController.setLowerStepsDisable(6);
  121. this.set('isBackButtonDisabled', true);
  122. }
  123. }.observes('tasks.@each.status')
  124. });