Sha256: 5eb5c9014d40d4c483944162b2f2ab2b835100e45720700336fbde87e6418e0d

Contents?: true

Size: 1004 Bytes

Versions: 8

Compression:

Stored size: 1004 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/base')


module KnifeJoyent
  class JoyentSnapshotList < Chef::Knife

    include KnifeJoyent::Base

    banner "knife joyent snapshot list <server_id>"

    def run

      unless name_args.size == 1
        show_usage
        exit 1
      end

      server = name_args.first

      snapshots = [
        ui.color('ID', :bold),
        ui.color('State', :bold),
        ui.color('Created', :bold),
      ]

      self.connection.snapshots.all(server).each do |s|
        snapshots << ui.color(s.name, :bold)
        snapshots << case s.state
        when "queued" then
          ui.color(s.state, :yellow)
        when "success" then
          ui.color(s.state, :green)
        else
          ui.color(s.state, :red)
        end
        snapshots << s.created.to_s
      end

      puts ui.list(snapshots, :uneven_columns_across, 3)
    rescue Fog::Compute::Joyent::Errors::NotFound
      puts ui.error("Server #{server} not found.")
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
knife-joyent-0.0.10 lib/chef/knife/joyent_snapshot_list.rb
knife-joyent-0.0.9 lib/chef/knife/joyent_snapshot_list.rb
knife-joyent-0.0.7 lib/chef/knife/joyent_snapshot_list.rb
knife-joyent-0.0.6 lib/chef/knife/joyent_snapshot_list.rb
knife-joyent-0.0.5 lib/chef/knife/joyent_snapshot_list.rb
knife-joyent-0.0.4 lib/chef/knife/joyent_snapshot_list.rb
knife-joyent-0.0.3 lib/chef/knife/joyent_snapshot_list.rb
knife-joyent-0.0.2 lib/knife-joyent/joyent_snapshot_list.rb