Sha256: 24f91bfb10f2ae29b1e9a6b97e584097535eba33ea851bc62a38073811109a3c

Contents?: true

Size: 1.04 KB

Versions: 13

Compression:

Stored size: 1.04 KB

Contents

require 'chef/knife/joyent_base'

class Chef
  class Knife
    class JoyentServerMetadataUpdate < Knife

      include Knife::JoyentBase

      banner 'knife joyent server metadata update <server_id> -m <json>'

      option :metadata,
        :short => "-m JSON",
        :long => "--metadata JSON",
        :description => "Metadata to be applied to server",
        :proc => Proc.new { |m| JSON.parse(m) },
        :default => {}

      def run
        if config[:metadata].empty?
          show_usage
          exit 1
        end

        unless name_args.size === 1
          show_usage
          exit 1
        end

        id = name_args.first

        server = self.connection.servers.get(id)
        unless server
          puts ui.error("Server with id: #{id} not found")
          exit 1
        end

        if server.update_metadata(config[:metadata])
          puts ui.color("Updated metadata on #{id}", :cyan)
          exit 0
        else
          puts ui.error("Metadata update failed")
          exit 1
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
knife-joyent-0.4.0 lib/chef/knife/joyent_server_metadata_update.rb
knife-joyent-0.3.6 lib/chef/knife/joyent_server_metadata_update.rb
knife-joyent-0.3.5 lib/chef/knife/joyent_server_metadata_update.rb
knife-joyent-0.3.4 lib/chef/knife/joyent_server_metadata_update.rb
knife-joyent-0.3.3 lib/chef/knife/joyent_server_metadata_update.rb
knife-joyent-0.3.2 lib/chef/knife/joyent_server_metadata_update.rb
knife-joyent-0.3.1 lib/chef/knife/joyent_server_metadata_update.rb
knife-joyent-0.3.0 lib/chef/knife/joyent_server_metadata_update.rb
knife-joyent-0.2.2 lib/chef/knife/joyent_server_metadata_update.rb
knife-joyent-0.2.1 lib/chef/knife/joyent_server_metadata_update.rb
knife-joyent-0.2.0 lib/chef/knife/joyent_server_metadata_update.rb
knife-joyent-0.1.4 lib/chef/knife/joyent_server_metadata_update.rb
knife-joyent-0.1.3 lib/chef/knife/joyent_server_metadata_update.rb