diff --git a/README.md b/README.md index d26bda3..ca2e461 100644 --- a/README.md +++ b/README.md @@ -58,10 +58,10 @@ Vagrant.configure("2") do |config| config.vm.provider :openstack do |os| os.username = "YOUR USERNAME" # e.g. "#{ENV['OS_USERNAME']}" - os.api_key = "YOUR API KEY" # e.g. "#{ENV['OS_PASSWORD']}" + os.api_key = "YOUR API KEY" # e.g. "#{ENV['OS_PASSWORD']}" os.flavor = /m1.tiny/ # Regex or String os.image = /Ubuntu/ # Regex or String - os.endpoint = "KEYSTONE AUTH URL" # e.g. "#{ENV['OS_AUTH_URL']}/tokens" + os.endpoint = "KEYSTONE AUTH URL" # e.g. "#{ENV['OS_AUTH_URL']}/tokens" os.keypair_name = "YOUR KEYPAIR NAME" # as stored in Nova os.ssh_username = "SSH USERNAME" # login for the VM @@ -132,6 +132,7 @@ This provider exposes quite a few provider-specific configuration options: must be created. * `security_groups` - List of security groups to be applied to the machine. * `tenant` - Tenant name. You only need to specify this if your OpenStack user has access to multiple tenants. +* `region` - Region Name. Specify the region you want the instance to be launched in for multi-region environments. These can be set like typical provider-specific configuration: diff --git a/lib/vagrant-openstack-plugin/action/connect_openstack.rb b/lib/vagrant-openstack-plugin/action/connect_openstack.rb index 0dc584f..57d187f 100644 --- a/lib/vagrant-openstack-plugin/action/connect_openstack.rb +++ b/lib/vagrant-openstack-plugin/action/connect_openstack.rb @@ -20,6 +20,7 @@ def call(env) endpoint = config.endpoint username = config.username tenant = config.tenant + region = config.region @logger.info("Connecting to OpenStack...") env[:openstack_compute] = Fog::Compute.new({ @@ -27,7 +28,8 @@ def call(env) :openstack_username => username, :openstack_api_key => api_key, :openstack_auth_url => endpoint, - :openstack_tenant => tenant + :openstack_tenant => tenant, + :openstack_region => region }) if config.network diff --git a/lib/vagrant-openstack-plugin/config.rb b/lib/vagrant-openstack-plugin/config.rb index 74508a6..56eaf56 100644 --- a/lib/vagrant-openstack-plugin/config.rb +++ b/lib/vagrant-openstack-plugin/config.rb @@ -31,12 +31,12 @@ class Config < Vagrant.plugin("2", :config) # # @return [String] attr_accessor :username - + # The name of the keypair to use. # # @return [String] attr_accessor :keypair_name - + # Network configurations for the instance # # @return [String] @@ -80,11 +80,17 @@ class Config < Vagrant.plugin("2", :config) # # @return [String] attr_accessor :user_data - + # The floating IP address from the IP pool which will be assigned to the instance. # # @return [String] attr_accessor :floating_ip + + # The region to specify when the OpenStack cloud has multiple regions + # + # @return [String] + attr_accessor :region + def initialize @api_key = UNSET_VALUE @endpoint = UNSET_VALUE @@ -103,6 +109,7 @@ def initialize @tenant = UNSET_VALUE @user_data = UNSET_VALUE @floating_ip = UNSET_VALUE + @region = UNSET_VALUE end def finalize! @@ -130,6 +137,8 @@ def finalize! @tenant = nil if @tenant == UNSET_VALUE @user_data = "" if @user_data == UNSET_VALUE @floating_ip = nil if @floating_ip == UNSET_VALUE + + @region = nil if @region == UNSET_VALUE end def validate(machine) @@ -137,7 +146,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 - + { "OpenStack Provider" => errors } end end