Sha256: c473db168891570f3ef033e933bdc9dfbd19b7ad6ff9f537a35d35e660fe4c94

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

module Smartdc::Cli
  class MachineSnapshot < Thor
    include Smartdc::CliHelper

    namespace 'machine snapshot'
    class_option :id, type: :string, aliases: '-m', desc: 'Machine id'

    desc 'list', 'Lists all snapshots taken for a given machine. '
    def list
      id = use_machine(options['id'])
      output Smartdc.machine_snapshots(id), options.merge(table: :horizontal)
    end

    desc 'show [NAME]', 'Gets the state of the named snapshot.'
    def show(name)
      id = use_machine(options['id'])
      output Smartdc.machine_snapshot(id, name), options.merge(table: :vertical)
    end

    desc 'add [NAME]', 'Allows you to take a snapshot of a machine.'
    def add(name)
      id = use_machine(options['id'])
      output Smartdc.create_machine_snapshot(id, {name: name}), options.merge(table: :vertical)
    end

    desc 'destroy [NAME]', 'Deletes the specified snapshot of a machine.'
    def destroy(name)
      id = use_machine(options['id'])
      output Smartdc.destroy_machine_snapshot(id, name), options.merge(message: "Destroy [#{name}] of machine snapshot.")
    end

    desc 'start [NAME]', 'Starts a stopped machine from the referenced snapshot.'
    def start(name)
      id = use_machine(options['id'])
      output Smartdc.start_machine_snapshot(id, name), options.merge(message: "Start [#{name}] of machine snapshot.")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
smartdc-2.0.2 lib/smartdc/cli/machine/snapshot.rb
smartdc-2.0.1 lib/smartdc/cli/machine/snapshot.rb
smartdc-2.0.0 lib/smartdc/cli/machine/snapshot.rb