class VpsAdmin::CLI::Commands::BaseDownload

Public Class Methods

new(*) click to toggle source
Calls superclass method
# File lib/vpsadmin/cli/commands/base_download.rb, line 3
def initialize(*)
  super

  @api.set_opts(block: false)
end

Protected Instance Methods

find_or_create_dl(opts, do_create = true) click to toggle source
# File lib/vpsadmin/cli/commands/base_download.rb, line 10
def find_or_create_dl(opts, do_create = true)
  @api.snapshot_download.index(snapshot: opts[:snapshot]).each do |r|
    if opts[:from_snapshot] == (r.from_snapshot && r.from_snapshot_id)
      if r.format != opts[:format].to_s
        fail "SnapshotDownload id=#{r.id} is in unusable format '#{r.format}' (needs '#{opts[:format]}')"
      end

      return [r, false]
    end
  end

  if do_create
    [@api.snapshot_download.create(opts), true]

  else
    [nil, true]
  end
end
msg(str) click to toggle source
# File lib/vpsadmin/cli/commands/base_download.rb, line 29
def msg(str)
  puts str unless @opts[:quiet]
end
warn_msg(str) click to toggle source
# File lib/vpsadmin/cli/commands/base_download.rb, line 33
def warn_msg(str)
  warn str unless @opts[:quiet]
end