step7_controller.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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.ReassignMasterWizardStep7Controller = App.ReassignMasterWizardStep4Controller.extend({
  20. name: 'reassignMasterWizardStep7Controller',
  21. isReassign: true,
  22. commands: ['putHostComponentsInMaintenanceMode', 'deleteHostComponents', 'cleanMySqlServer', 'configureMySqlServer', 'startServices'],
  23. clusterDeployState: 'REASSIGN_MASTER_INSTALLING',
  24. multiTaskCounter: 0,
  25. initializeTasks: function () {
  26. var commands = this.get('commands');
  27. var hostComponentsNames = this.getHostComponentsNames();
  28. for (var i = 0; i < commands.length; i++) {
  29. var TaskLabel = i === 3 ? this.get('serviceName') : hostComponentsNames; //For Reconfigure task, show serviceName
  30. var title = Em.I18n.t('services.reassign.step4.tasks.' + commands[i] + '.title').format(TaskLabel);
  31. this.get('tasks').pushObject(Ember.Object.create({
  32. title: title,
  33. status: 'PENDING',
  34. id: i,
  35. command: commands[i],
  36. showRetry: false,
  37. showRollback: false,
  38. name: title,
  39. displayName: title,
  40. progress: 0,
  41. isRunning: false,
  42. hosts: []
  43. }));
  44. }
  45. this.removeUnneededTasks();
  46. },
  47. putHostComponentsInMaintenanceMode: function () {
  48. this.set('multiTaskCounter', 0);
  49. var hostComponents = this.get('hostComponents');
  50. var hostName = this.get('content.reassignHosts.target');
  51. for (var i = 0; i < hostComponents.length; i++) {
  52. App.ajax.send({
  53. name: 'common.host.host_component.passive',
  54. sender: this,
  55. data: {
  56. hostName: hostName,
  57. passive_state: "ON",
  58. componentName: hostComponents[i]
  59. },
  60. success: 'onComponentsTasksSuccess',
  61. error: 'onTaskError'
  62. });
  63. }
  64. },
  65. deleteHostComponents: function () {
  66. this.set('multiTaskCounter', 0);
  67. var hostComponents = this.get('hostComponents');
  68. var hostName = this.get('content.reassignHosts.target');
  69. for (var i = 0; i < hostComponents.length; i++) {
  70. App.ajax.send({
  71. name: 'common.delete.host_component',
  72. sender: this,
  73. data: {
  74. hostName: hostName,
  75. componentName: hostComponents[i]
  76. },
  77. success: 'onComponentsTasksSuccess',
  78. error: 'onDeleteHostComponentsError'
  79. });
  80. }
  81. }
  82. });