step7_controller.js 3.1 KB

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