Sha256: a333043703b76ca41742729f8c9670ee6b59c92d4a36b559434c1ea27fe6d35f

Contents?: true

Size: 1006 Bytes

Versions: 2

Compression:

Stored size: 1006 Bytes

Contents

module KnifeJoyent
  class JoyentServerCreate < Chef::Knife

    include KnifeJoyent::Base

    banner 'knife joyent server create (options)'

    option :name,
      :long => '--name <name>',
      :description => 'name for this machine'

    option :package,
      :long => '--flavor <name>',
      :description => 'specify flavor/package for the server'

    option :dataset,
      :short => '--image <id>',
      :description => 'specify image for the server'

    def run
      if s = self.connection.servers.create(:dataset => config[:dataset],
                                            :package => config[:package],
                                            :name => config[:name])
        puts ui.color("Created machine: #{s.id}", :cyan)
        exit 0
      end
    rescue => e
      if e.response && e.response.body.kind_of?(String)
        error = MultiJson.decode(e.response.body)
        puts ui.error(error['message'])
        exit 1
      else
        raise
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
knife-joyent-0.0.6 lib/chef/knife/joyent_server_create.rb
knife-joyent-0.0.5 lib/chef/knife/joyent_server_create.rb