Skip to content

Commit

Permalink
Merge pull request mitchellh#3 from reachlocal/add_metadata_support
Browse files Browse the repository at this point in the history
Added the ability to pass metadata keypairs to instances
  • Loading branch information
tkadauke committed Apr 26, 2013
2 parents 33a1f98 + b3b81c1 commit 5877e5d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/vagrant-openstack-plugin/action/create_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def call(env)
:image_ref => image.id,
:name => server_name,
:key_name => config.keypair_name,
:metadata => config.metadata,
:user_data_encoded => Base64.encode64(config.user_data)
}

Expand Down
8 changes: 8 additions & 0 deletions lib/vagrant-openstack-plugin/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ class Config < Vagrant.plugin("2", :config)
# @return [String]
attr_accessor :ssh_username

# A Hash of metadata that will be sent to the instance for configuration
#
# @return [Hash]
attr_accessor :metadata

# User data to be sent to the newly created OpenStack instance. Use this
# e.g. to inject a script at boot time.
#
Expand All @@ -60,6 +65,7 @@ def initialize
@flavor = UNSET_VALUE
@image = UNSET_VALUE
@server_name = UNSET_VALUE
@metatdata = UNSET_VALUE
@username = UNSET_VALUE
@keypair_name = UNSET_VALUE
@network = UNSET_VALUE
Expand All @@ -73,6 +79,7 @@ def finalize!
@flavor = /m1.tiny/ if @flavor == UNSET_VALUE
@image = /cirros/ if @image == UNSET_VALUE
@server_name = nil if @server_name == UNSET_VALUE
@metadata = {} if @metadata == UNSET_VALUE
@username = nil if @username == UNSET_VALUE
@network = nil if @network == UNSET_VALUE

Expand All @@ -91,6 +98,7 @@ def validate(machine)

errors << I18n.t("vagrant_openstack.config.api_key_required") if !@api_key
errors << I18n.t("vagrant_openstack.config.username_required") if !@username
errors << I18n.t("vagrant_openstack.config.metadata_must_be_hash") if !@metadata.is_a?(Hash)

{ "OpenStack Provider" => errors }
end
Expand Down
2 changes: 2 additions & 0 deletions locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ en:
An API key is required.
username_required: |-
A username is required.
metadata_must_be_hash: |-
Metadata must be a hash.
errors:
create_bad_state: |-
Expand Down

0 comments on commit 5877e5d

Please sign in to comment.