diff --git a/lib/vagrant-openstack-plugin/action/create_server.rb b/lib/vagrant-openstack-plugin/action/create_server.rb index ebba3c8..229fc40 100644 --- a/lib/vagrant-openstack-plugin/action/create_server.rb +++ b/lib/vagrant-openstack-plugin/action/create_server.rb @@ -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) } diff --git a/lib/vagrant-openstack-plugin/config.rb b/lib/vagrant-openstack-plugin/config.rb index f37c75f..22ae5cc 100644 --- a/lib/vagrant-openstack-plugin/config.rb +++ b/lib/vagrant-openstack-plugin/config.rb @@ -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. # @@ -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 @@ -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 @@ -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 diff --git a/locales/en.yml b/locales/en.yml index 8dcd349..0cce9fd 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -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: |-