Module: Pvectl::Commands::FeatureCommand
- Included in:
- FeatureContainer, FeatureVm
- Defined in:
- lib/pvectl/commands/feature_command.rb
Overview
Shared functionality for the feature query commands (feature vm, feature ct).
Queries whether a Proxmox feature (clone, snapshot, copy) is available for a given VM or container. Availability depends on storage type, snapshot state, and other server-side conditions.
Designed with the hybrid Template Method pattern (MoveDiskCommand / MigrateCommand) — specializations only set RESOURCE_TYPE and SUPPORTED_RESOURCES; the FeatureVm specialization additionally implements .register which wires the GLI command.
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- VALID_FEATURES =
Valid feature names per Proxmox API (both QEMU and LXC endpoints).
%w[clone snapshot copy].freeze
Class Method Summary collapse
-
.included(base) ⇒ Object
Hook called when the module is included.
Instance Method Summary collapse
-
#execute ⇒ Integer
Executes the feature query.
-
#initialize(args, options, global_options) ⇒ Object
Initializes a feature query command.
Class Method Details
.included(base) ⇒ Object
Hook called when the module is included.
43 44 45 |
# File 'lib/pvectl/commands/feature_command.rb', line 43 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#execute ⇒ Integer
Executes the feature query.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/pvectl/commands/feature_command.rb', line 61 def execute return usage_error("#{id_label} is required") if @args.empty? return usage_error("FEATURE is required") if @args.size < 2 id_str = @args[0] feature = @args[1] unless id_str.to_s.match?(/\A\d+\z/) return usage_error("Invalid #{id_label}: #{id_str}") end unless VALID_FEATURES.include?(feature) return usage_error( "Invalid feature: #{feature} (allowed: #{VALID_FEATURES.join(', ')})" ) end perform_operation(id_str.to_i, feature) end |
#initialize(args, options, global_options) ⇒ Object
Initializes a feature query command.
52 53 54 55 56 |
# File 'lib/pvectl/commands/feature_command.rb', line 52 def initialize(args, , ) @args = Array(args).compact @options = @global_options = end |