Class: Pvectl::Commands::DeleteBackup

Inherits:
Object
  • Object
show all
Defined in:
lib/pvectl/commands/delete_backup.rb

Overview

Handler for the ‘pvectl delete backup` command.

Deletes a backup identified by its full volume ID (volid). Requires –yes flag for confirmation.

Examples:

Delete a backup

pvectl delete backup local:backup/vzdump-qemu-100-2024_01_15.vma.zst --yes

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource_type, args, options, global_options) ⇒ DeleteBackup

Initializes a delete backup command.

Parameters:

  • resource_type (String, nil)

    resource type (backup)

  • args (Array<String>, String, nil)

    backup volid

  • options (Hash)

    command options

  • global_options (Hash)

    global CLI options



31
32
33
34
35
36
37
# File 'lib/pvectl/commands/delete_backup.rb', line 31

def initialize(resource_type, args, options, global_options)
  @resource_type = resource_type
  @args = Array(args).compact
  @options = options
  @global_options = global_options
  @volid = @args.first
end

Class Method Details

.execute(resource_type, args, options, global_options) ⇒ Integer

Executes the delete backup command.

Parameters:

  • resource_type (String, nil)

    resource type (backup)

  • args (Array<String>, String, nil)

    backup volid

  • options (Hash)

    command options

  • global_options (Hash)

    global CLI options

Returns:

  • (Integer)

    exit code



21
22
23
# File 'lib/pvectl/commands/delete_backup.rb', line 21

def self.execute(resource_type, args, options, global_options)
  new(resource_type, args, options, global_options).execute
end

Instance Method Details

#executeInteger

Executes the delete backup command.

Returns:

  • (Integer)

    exit code



42
43
44
45
46
47
48
# File 'lib/pvectl/commands/delete_backup.rb', line 42

def execute
  return usage_error("Resource type required (backup)") unless @resource_type == "backup"
  return usage_error("Backup volid is required") if @volid.nil? || @volid.empty?
  return usage_error("Confirmation required: use --yes to confirm deletion") unless @options[:yes]

  perform_operation
end