Module: Pvectl::Commands::DeleteCommand

Includes:
IrreversibleCommand
Included in:
DeleteContainer, DeleteVm
Defined in:
lib/pvectl/commands/delete_command.rb,
sig/pvectl/commands/delete_command.rbs

Overview

Delete-specific functionality built on IrreversibleCommand.

Adds delete-specific behavior:

  • Confirmation message mentioning disk destruction
  • --keep-disks and --purge options in service_options
  • Delegates to Services::ResourceDelete

Examples:

Including in a command class

class DeleteVm
  include DeleteCommand
  RESOURCE_TYPE = :vm
  SUPPORTED_RESOURCES = %w[vm].freeze
end

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Methods included from IrreversibleCommand

#build_repository

Class Method Details

.included(base) ⇒ void

This method returns an undefined value.

Hook called when module is included.

Parameters:

  • base (Class)

    the class including this module



25
26
27
# File 'lib/pvectl/commands/delete_command.rb', line 25

def self.included(base)
  base.extend(IrreversibleCommand::ClassMethods)
end

Instance Method Details

#apply_selectorsArray[untyped]

Parameters:

  • resources (Array[untyped])

Returns:

  • (Array[untyped])


28
# File 'sig/pvectl/commands/delete_command.rbs', line 28

def apply_selectors: (Array[untyped] resources) -> Array[untyped]

#confirm_operation(resources) ⇒ Boolean

Confirms delete operation — always required (uses --yes flag, not --force).

Parameters:

  • resources (Array)

    Resources to delete

Returns:

  • (Boolean)

    true if operation should proceed



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/pvectl/commands/delete_command.rb', line 65

def confirm_operation(resources)
  return true if @options[:yes]

  $stdout.puts confirm_message(resources)
  $stdout.puts ""
  $stdout.puts irreversibility_warning
  $stdout.print "Proceed? [y/N]: "

  response = $stdin.gets&.strip&.downcase
  %w[y yes].include?(response)
end

#determine_exit_codeInteger

Parameters:

  • results (Array[untyped])

Returns:

  • (Integer)


38
# File 'sig/pvectl/commands/delete_command.rbs', line 38

def determine_exit_code: (Array[untyped] results) -> Integer

#executeInteger

Returns:

  • (Integer)


12
# File 'sig/pvectl/commands/delete_command.rbs', line 12

def execute: () -> Integer

#initializeDeleteCommand

Returns a new instance of DeleteCommand.

Parameters:

  • resource_type (String, nil)
  • resource_ids (Array[String], String, nil)
  • options (Hash[Symbol, untyped])
  • global_options (Hash[Symbol, untyped])

Returns:



10
# File 'sig/pvectl/commands/delete_command.rbs', line 10

def initialize: (String? resource_type, Array[String] | String | nil resource_ids, Hash[Symbol, untyped] options, Hash[Symbol, untyped] global_options) -> void

#load_configvoid

This method returns an undefined value.



32
# File 'sig/pvectl/commands/delete_command.rbs', line 32

def load_config: () -> void

#no_resources_foundInteger

Returns:

  • (Integer)


42
# File 'sig/pvectl/commands/delete_command.rbs', line 42

def no_resources_found: () -> Integer

#output_resultsvoid

This method returns an undefined value.

Parameters:

  • results (Array[untyped])


36
# File 'sig/pvectl/commands/delete_command.rbs', line 36

def output_results: (Array[untyped] results) -> void

#perform_operationInteger

Returns:

  • (Integer)


22
# File 'sig/pvectl/commands/delete_command.rbs', line 22

def perform_operation: () -> Integer

#resolve_resourcesArray[untyped]

Parameters:

  • connection (Object)

Returns:

  • (Array[untyped])


24
# File 'sig/pvectl/commands/delete_command.rbs', line 24

def resolve_resources: (untyped connection) -> Array[untyped]

#resource_type_symbolSymbol

Returns:

  • (Symbol)


16
# File 'sig/pvectl/commands/delete_command.rbs', line 16

def resource_type_symbol: () -> Symbol

#selector_stringsArray[String]

Returns:

  • (Array[String])


26
# File 'sig/pvectl/commands/delete_command.rbs', line 26

def selector_strings: () -> Array[String]

#service_optionsHash

Builds service options with delete-specific flags.

Returns:

  • (Hash)

    service options



111
112
113
114
115
116
# File 'lib/pvectl/commands/delete_command.rb', line 111

def service_options
  opts = super
  opts[:keep_disks] = true if @options[:"keep-disks"]
  opts[:purge] = true if @options[:purge]
  opts
end

#supported_resource?Boolean

Returns:

  • (Boolean)


20
# File 'sig/pvectl/commands/delete_command.rbs', line 20

def supported_resource?: () -> bool

#supported_typesArray[String]

Returns:

  • (Array[String])


18
# File 'sig/pvectl/commands/delete_command.rbs', line 18

def supported_types: () -> Array[String]

#usage_errorInteger

Parameters:

  • message (String)

Returns:

  • (Integer)


40
# File 'sig/pvectl/commands/delete_command.rbs', line 40

def usage_error: (String message) -> Integer