step7_controller.js 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. this.set('isLoaded', true);
  47. },
  48. putHostComponentsInMaintenanceMode: function () {
  49. this.set('multiTaskCounter', 0);
  50. var hostComponents = this.get('hostComponents');
  51. var hostName = this.get('content.reassignHosts.target');
  52. for (var i = 0; i < hostComponents.length; i++) {
  53. App.ajax.send({
  54. name: 'common.host.host_component.passive',
  55. sender: this,
  56. data: {
  57. hostName: hostName,
  58. passive_state: "ON",
  59. componentName: hostComponents[i]
  60. },
  61. success: 'onComponentsTasksSuccess',
  62. error: 'onTaskError'
  63. });
  64. }
  65. },
  66. deleteHostComponents: function () {
  67. this.set('multiTaskCounter', 0);
  68. var hostComponents = this.get('hostComponents');
  69. var hostName = this.get('content.reassignHosts.target');
  70. for (var i = 0; i < hostComponents.length; i++) {
  71. App.ajax.send({
  72. name: 'common.delete.host_component',
  73. sender: this,
  74. data: {
  75. hostName: hostName,
  76. componentName: hostComponents[i]
  77. },
  78. success: 'onComponentsTasksSuccess',
  79. error: 'onDeleteHostComponentsError'
  80. });
  81. }
  82. }
  83. });