Module: Pvectl::Commands::ResourceLifecycleCommand Abstract
- Included in:
- ContainerLifecycleCommand, VmLifecycleCommand
- Defined in:
- lib/pvectl/commands/resource_lifecycle_command.rb
Overview
This module is abstract.
Include a specialization module (VmLifecycleCommand, ContainerLifecycleCommand) instead of this one directly.
Shared functionality for lifecycle commands across resource types.
Template method pattern: provides common flow (validate, resolve, confirm, execute, output) while specialization modules define resource-specific hooks.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
Hook called when module is included.
Instance Method Summary collapse
-
#execute ⇒ Integer
Executes the lifecycle command.
-
#initialize(resource_type, resource_ids, options, global_options) ⇒ Object
Initializes a lifecycle command.
Class Method Details
.included(base) ⇒ Object
Hook called when module is included.
44 45 46 |
# File 'lib/pvectl/commands/resource_lifecycle_command.rb', line 44 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#execute ⇒ Integer
Executes the lifecycle command.
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/pvectl/commands/resource_lifecycle_command.rb', line 64 def execute return usage_error("Resource type required (#{supported_resources.join(', ')})") unless @resource_type return usage_error("Unsupported resource: #{@resource_type}") unless supported_resources.include?(@resource_type) if @resource_ids.empty? && !@options[:all] && selector_strings.empty? return usage_error("#{resource_id_label}, --all, or -l selector required") end perform_operation end |
#initialize(resource_type, resource_ids, options, global_options) ⇒ Object
Initializes a lifecycle command.
54 55 56 57 58 59 |
# File 'lib/pvectl/commands/resource_lifecycle_command.rb', line 54 def initialize(resource_type, resource_ids, , ) @resource_type = resource_type @resource_ids = Array(resource_ids).compact @options = @global_options = end |