step3_controller.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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.KerberosWizardStep3Controller = App.KerberosProgressPageController.extend({
  19. name: 'kerberosWizardStep3Controller',
  20. clusterDeployState: 'KERBEROS_DEPLOY',
  21. serviceName: 'KERBEROS',
  22. componentName: 'KERBEROS_CLIENT',
  23. ignore: undefined,
  24. commands: ['installKerberos', 'testKerberos'],
  25. loadStep: function () {
  26. this._super();
  27. this.enableDisablePreviousSteps();
  28. },
  29. installKerberos: function() {
  30. var self = this;
  31. this.getKerberosClientState().done(function(data) {
  32. if (data.ServiceComponentInfo.state === 'INIT') {
  33. App.ajax.send({
  34. name: 'common.services.update',
  35. sender: self,
  36. data: {
  37. context: Em.I18n.t('requestInfo.kerberosService'),
  38. ServiceInfo: {"state": "INSTALLED"},
  39. urlParams: "ServiceInfo/state=INSTALLED&ServiceInfo/service_name=KERBEROS"
  40. },
  41. success: 'startPolling',
  42. error: 'onTaskError'
  43. });
  44. } else {
  45. var hostNames = App.get('allHostNames');
  46. self.updateComponent('KERBEROS_CLIENT', hostNames, "KERBEROS", "Install");
  47. }
  48. });
  49. },
  50. getKerberosClientState: function() {
  51. return App.ajax.send({
  52. name: 'common.service_component.info',
  53. sender: this,
  54. data: {
  55. serviceName: this.serviceName,
  56. componentName: this.componentName,
  57. urlParams: "fields=ServiceComponentInfo/state"
  58. }
  59. });
  60. },
  61. testKerberos: function() {
  62. var self = this;
  63. App.ajax.send({
  64. 'name': 'service.item.smoke',
  65. 'sender': this,
  66. 'success': 'startPolling',
  67. 'error': 'onTestKerberosError',
  68. 'kdcCancelHandler': function() {
  69. App.router.get(self.get('content.controllerName')).setStepsEnable();
  70. self.get('tasks').objectAt(self.get('currentTaskId')).set('status', 'FAILED');
  71. },
  72. 'data': {
  73. 'serviceName': this.serviceName,
  74. 'displayName': App.format.role(this.serviceName),
  75. 'actionName': this.serviceName + '_SERVICE_CHECK',
  76. 'operationLevel': {
  77. "level": "CLUSTER",
  78. "cluster_name": App.get('clusterName')
  79. }
  80. }
  81. });
  82. },
  83. onTestKerberosError: function (jqXHR, ajaxOptions, error, opt) {
  84. App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.type, jqXHR.status);
  85. this.onTaskError(jqXHR, ajaxOptions, error, opt);
  86. },
  87. /**
  88. * Enable or disable previous steps according to tasks statuses
  89. */
  90. enableDisablePreviousSteps: function () {
  91. var wizardController = App.router.get(this.get('content.controllerName'));
  92. if (this.get('tasks').someProperty('status', 'FAILED')) {
  93. wizardController.setStepsEnable();
  94. } else {
  95. wizardController.setLowerStepsDisable(3);
  96. }
  97. }.observes('tasks.@each.status'),
  98. /**
  99. * Show or hide warning to ignore errors and continue with the install
  100. */
  101. showIgnore: Em.computed.someBy('tasks', 'showRetry', true),
  102. /**
  103. * Enable or disable next button if ignore checkbox ticked
  104. */
  105. ignoreAndProceed: function() {
  106. if (this.get('showIgnore')) {
  107. this.set('isSubmitDisabled', !this.get('ignore'));
  108. }
  109. }.observes('ignore','showIgnore')
  110. });