Sha256: 204b738e668da45d7220ae40a9f7c2051a66e2a5cdc0ffed1cfc44063253f335

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

require 'chef/knife/joyent_base'

class Chef
  class Knife
    class JoyentSnapshotList < Knife

      include Knife::JoyentBase

      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.to_s, :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
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
knife-joyent-0.4.0 lib/chef/knife/joyent_snapshot_list.rb
knife-joyent-0.3.6 lib/chef/knife/joyent_snapshot_list.rb
knife-joyent-0.3.5 lib/chef/knife/joyent_snapshot_list.rb
knife-joyent-0.3.4 lib/chef/knife/joyent_snapshot_list.rb
knife-joyent-0.3.3 lib/chef/knife/joyent_snapshot_list.rb