Class: Pvectl::Services::VmLifecycle
- Inherits:
-
Object
- Object
- Pvectl::Services::VmLifecycle
- Defined in:
- lib/pvectl/services/vm_lifecycle.rb
Overview
Orchestrates VM lifecycle operations.
Handles execution of start/stop/shutdown/restart/reset/suspend/resume operations with sync/async modes, error handling, and result collection.
Constant Summary collapse
- SYNC_OPERATIONS =
%i[start stop reset resume].freeze
- ASYNC_OPERATIONS =
%i[shutdown restart suspend].freeze
- ALL_OPERATIONS =
(SYNC_OPERATIONS + ASYNC_OPERATIONS).freeze
- DEFAULT_TIMEOUT =
60
Instance Method Summary collapse
-
#execute(operation, vms) ⇒ Array<Models::OperationResult>
Executes a lifecycle operation on a list of VMs.
-
#initialize(vm_repository, task_repository, options = {}) ⇒ VmLifecycle
constructor
Creates a new VmLifecycle service.
Constructor Details
#initialize(vm_repository, task_repository, options = {}) ⇒ VmLifecycle
Creates a new VmLifecycle service.
27 28 29 30 31 |
# File 'lib/pvectl/services/vm_lifecycle.rb', line 27 def initialize(vm_repository, task_repository, = {}) @vm_repository = vm_repository @task_repository = task_repository @options = end |
Instance Method Details
#execute(operation, vms) ⇒ Array<Models::OperationResult>
Executes a lifecycle operation on a list of VMs.
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/pvectl/services/vm_lifecycle.rb', line 38 def execute(operation, vms) validate_operation!(operation) results = [] vms.each do |vm| result = execute_single(operation, vm) results << result break if @options[:fail_fast] && result.failed? end results end |