Sha256: ac3296b9e2f2e2a53936613ae801fadc5abafb8069c030ab637f797c7715abe6

Contents?: true

Size: 868 Bytes

Versions: 8

Compression:

Stored size: 868 Bytes

Contents

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

module KnifeJoyent
  class JoyentTagCreate < Chef::Knife

    include KnifeJoyent::Base

    banner "knife joyent tag create <server_id> <tag> <value>"

    def run
      server = name_args[0]
      tagkey = name_args[1]
      tagvalue = name_args[2]

      unless server || tagkey || tagvalue
        show_usage
        exit 1
      end

      tags = [
        ui.color('Name', :bold),
        ui.color('Value', :bold),
      ]

      self.connection.servers.get(server).add_tags({tagkey => tagvalue}).each do |k, v|
        tags << k
        tags << v
      end

      puts ui.color("Updated tags for #{server}", :cyan)
      puts ui.list(tags, :uneven_columns_across, 2)
      exit 0
    rescue Excon::Errors::NotFound => e
      puts ui.error("Server #{server} not found")
      exit 1
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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