step7_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.KerberosWizardStep7Controller = App.KerberosProgressPageController.extend({
  19. name: 'kerberosWizardStep7Controller',
  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 kerberizeRequest = {
  36. name: 'KERBERIZE_CLUSTER',
  37. ajaxName: 'admin.kerberize.cluster',
  38. ajaxData: {
  39. data: {
  40. Clusters: {
  41. security_type: "KERBEROS"
  42. }
  43. }
  44. }
  45. };
  46. if (isRetry) {
  47. // on retry send force update
  48. this.set('request', {
  49. name: 'KERBERIZE_CLUSTER',
  50. ajaxName: 'admin.kerberize.cluster.force'
  51. });
  52. this.clearStage();
  53. this.loadStep();
  54. } else {
  55. this.set('request', kerberizeRequest);
  56. }
  57. },
  58. /**
  59. * Send request to unkerberisze cluster
  60. * @returns {$.ajax}
  61. */
  62. unkerberizeCluster: function () {
  63. return App.ajax.send({
  64. name: 'admin.unkerberize.cluster',
  65. sender: this,
  66. success: 'goToNextStep',
  67. error: 'goToNextStep'
  68. });
  69. },
  70. goToNextStep: function() {
  71. this.clearStage();
  72. App.router.transitionTo('step7');
  73. },
  74. postKerberosDescriptor: function (kerberosDescriptor) {
  75. return App.ajax.send({
  76. name: 'admin.kerberos.cluster.artifact.create',
  77. sender: this,
  78. data: {
  79. artifactName: 'kerberos_descriptor',
  80. data: {
  81. artifact_data: kerberosDescriptor
  82. }
  83. }
  84. });
  85. },
  86. /**
  87. * Send request to update kerberos descriptor
  88. * @param kerberosDescriptor
  89. * @returns {$.ajax|*}
  90. */
  91. putKerberosDescriptor: function (kerberosDescriptor) {
  92. return App.ajax.send({
  93. name: 'admin.kerberos.cluster.artifact.update',
  94. sender: this,
  95. data: {
  96. artifactName: 'kerberos_descriptor',
  97. data: {
  98. artifact_data: kerberosDescriptor
  99. }
  100. },
  101. success: 'unkerberizeCluster',
  102. error: 'unkerberizeCluster'
  103. });
  104. },
  105. retry: function () {
  106. this.set('showRetry', false);
  107. this.removeObserver('tasks.@each.status', this, 'onTaskStatusChange');
  108. this.set('status', 'IN_PROGRESS');
  109. this.get('tasks').setEach('status', 'PENDING');
  110. this.setRequest(true);
  111. },
  112. /**
  113. * Enable or disable previous steps according to tasks statuses
  114. */
  115. enableDisablePreviousSteps: function () {
  116. var wizardController = App.router.get(this.get('content.controllerName'));
  117. if (this.get('tasks').someProperty('status', 'FAILED')) {
  118. wizardController.enableStep(4);
  119. this.set('isBackButtonDisabled', false);
  120. } else {
  121. wizardController.setLowerStepsDisable(6);
  122. this.set('isBackButtonDisabled', true);
  123. }
  124. }.observes('tasks.@each.status')
  125. });