Skip to content

Commit

Permalink
Introduced 'address_id' config, which has a higher order of precedenc…
Browse files Browse the repository at this point in the history
…e than 'network'.
  • Loading branch information
jkburges committed May 3, 2013
1 parent 40044c4 commit 92ba812
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Vagrant.configure("2") do |config|
os.metadata = {"key" => "value"} # Optional
os.network = "YOUR NETWORK_NAME" # Optional
os.address_id = "YOUR ADDRESS ID" # Optional (overrides above, if both set).
os.security_groups = ['ssh', 'http'] # Optional
os.tenant = "YOUR TENANT_NAME" # Optional
Expand Down Expand Up @@ -119,6 +120,8 @@ This provider exposes quite a few provider-specific configuration options:
* `network` - A name or id that will be used to fetch network configuration
data when configuring the instance. NOTE: This is not compliant with the
vagrant network configurations.
* `address_id` - A specific address identifier to use when connecting to the
instance. Overrides `network` above if both are set.
* `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.

Expand Down
2 changes: 2 additions & 0 deletions lib/vagrant-openstack-plugin/action/read_ssh_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def read_ssh_info(openstack, machine)

if config.network
host = server.addresses[config.network].last['addr'] rescue nil
elsif config.address_id
host = server.addresses[config.address_id].last['addr'] rescue nil
else
host = server.addresses['public'].last['addr'] rescue nil
end
Expand Down
7 changes: 7 additions & 0 deletions lib/vagrant-openstack-plugin/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ class Config < Vagrant.plugin("2", :config)
# @return [String]
attr_accessor :network

# A specific address identifier to use when connecting.
# Overrides `network` above if both are set.
#
attr_accessor :address_id

# List of strings representing the security groups to apply.
# e.g. ['ssh', 'http']
#
Expand Down Expand Up @@ -80,6 +85,7 @@ def initialize
@username = UNSET_VALUE
@keypair_name = UNSET_VALUE
@network = UNSET_VALUE
@address_id = UNSET_VALUE
@security_groups = UNSET_VALUE
@ssh_username = UNSET_VALUE
@tenant = UNSET_VALUE
Expand All @@ -95,6 +101,7 @@ def finalize!
@metadata = nil if @metadata == UNSET_VALUE
@username = nil if @username == UNSET_VALUE
@network = nil if @network == UNSET_VALUE
@address_id = nil if @address_id == UNSET_VALUE

# Keypair defaults to nil
@keypair_name = nil if @keypair_name == UNSET_VALUE
Expand Down

0 comments on commit 92ba812

Please sign in to comment.