Module: Pvectl::Commands::MigrateCommand
- Included in:
- MigrateContainer, MigrateVm
- Defined in:
- lib/pvectl/commands/migrate_command.rb
Overview
Shared functionality for migrate commands (migrate vm, migrate container).
This module extracts common code used by MigrateVm and MigrateContainer. Pattern: identical to DeleteCommand module but with migrate-specific behavior:
-
Requires –target flag (no default)
-
Validates –restart only for containers
-
Async is default (no –async flag), –wait for sync
-
partition_by_target logic is in Service layer
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- NODE_NAME_FORMAT =
Valid Proxmox node name format: lowercase alphanumeric, starting with letter, hyphens allowed.
/\A[a-z][a-z0-9-]*\z/
Class Method Summary collapse
-
.included(base) ⇒ Object
Hook called when module is included.
Instance Method Summary collapse
-
#execute ⇒ Integer
Executes the migrate command.
-
#initialize(args, options, global_options) ⇒ Object
Initializes a migrate command.
Class Method Details
.included(base) ⇒ Object
Hook called when module is included.
41 42 43 |
# File 'lib/pvectl/commands/migrate_command.rb', line 41 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#execute ⇒ Integer
Executes the migrate command.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/pvectl/commands/migrate_command.rb', line 59 def execute target = @options[:target] return usage_error("--target is required") if target.nil? || target.empty? unless target.match?(NODE_NAME_FORMAT) return usage_error("Invalid target node name: #{target}") end return usage_error("--restart is only supported for containers") if restart_not_allowed? if @resource_ids.empty? && !@options[:all] && selector_strings.empty? return usage_error("VMID, --all, or -l selector required") end perform_operation end |
#initialize(args, options, global_options) ⇒ Object
Initializes a migrate command.
50 51 52 53 54 |
# File 'lib/pvectl/commands/migrate_command.rb', line 50 def initialize(args, , ) @resource_ids = Array(args).compact @options = @global_options = end |