step6_controller.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. App.ReassignMasterWizardStep6Controller = App.HighAvailabilityProgressPageController.extend({
  20. isReassign: true,
  21. commands: ['deleteHostComponents', 'startServices'],
  22. clusterDeployState: 'REASSIGN_MASTER_INSTALLING',
  23. initializeTasks: function () {
  24. var commands = this.get('commands');
  25. var currentStep = App.router.get('reassignMasterController.currentStep');
  26. for (var i = 0; i < commands.length; i++) {
  27. var title = Em.I18n.t('services.reassign.step6.task' + i + '.title').format(App.format.role(this.get('content.reassign.component_name')),
  28. App.Service.find().findProperty('serviceName', this.get('content.reassign.service_id')).get('displayName'));
  29. this.get('tasks').pushObject(Ember.Object.create({
  30. title: title,
  31. status: 'PENDING',
  32. id: i,
  33. command: commands[i],
  34. showRetry: false,
  35. showRollback: false,
  36. name: title,
  37. displayName: title,
  38. progress: 0,
  39. isRunning: false,
  40. hosts: []
  41. }));
  42. }
  43. },
  44. hideRollbackButton: function () {
  45. var failedTask = this.get('tasks').findProperty('showRollback');
  46. if (failedTask) {
  47. failedTask.set('showRollback', false)
  48. }
  49. }.observes('tasks.@each.showRollback'),
  50. startServices: function () {
  51. var serviceName = this.get('content.reassign.service_id');
  52. App.ajax.send({
  53. name: 'reassign.start_components',
  54. sender: this,
  55. data: {
  56. serviceName: serviceName,
  57. displayName: App.Service.find().findProperty('serviceName', serviceName).get('displayName')
  58. },
  59. success: 'startPolling',
  60. error: 'onTaskError'
  61. });
  62. },
  63. deleteHostComponents: function () {
  64. var hostName = this.get('content.reassignHosts.source');
  65. App.ajax.send({
  66. name: 'reassign.remove_component',
  67. sender: this,
  68. data: {
  69. hostName: hostName,
  70. componentName: this.get('content.reassign.component_name')
  71. },
  72. success: 'onTaskCompleted',
  73. error: 'onTaskError'
  74. });
  75. }
  76. })