Skip to content

Commit

Permalink
Use version from Nova API
Browse files Browse the repository at this point in the history
  • Loading branch information
pdesgarets committed Feb 19, 2020
1 parent 5d136c3 commit 101032b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
10 changes: 2 additions & 8 deletions source/lib/vagrant-openstack-provider/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def get_ip_address(env)
next unless network_detail['OS-EXT-IPS:type'] == 'floating'
if env[:machine].provider_config.ip_version.nil?
return network_detail['addr']
elsif get_ip_version(network_detail['addr']) == env[:machine].provider_config.ip_version
elsif network_detail['version'] == env[:machine].provider_config.ip_version
return network_detail['addr']
end
fallback ||= network_detail['addr']
Expand Down Expand Up @@ -67,15 +67,9 @@ def get_ip_address(env)

private

def get_ip_version(ip)
(ip.include? '.') ? 4 : 6
end

def filter_by_version(net_addresses, wanted_ip_version)
net_addresses.each do |address|
if get_ip_version(address['addr']) == wanted_ip_version
return address['addr']
end
return address['addr'] if address['version'] == wanted_ip_version
end
nil
end
Expand Down
18 changes: 12 additions & 6 deletions source/spec/vagrant-openstack-provider/utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@
'addresses' => {
'net' => [
{
'addr' => '2001:0db8:85a3:0000:0000:8a2e:0370:7334'
'addr' => '2001:0db8:85a3:0000:0000:8a2e:0370:7334',
'version' => 6
},
{
'addr' => '13.13.13.13'
'addr' => '13.13.13.13',
'version' => 4
}
]
}
Expand All @@ -64,10 +66,12 @@
'addresses' => {
'net' => [
{
'addr' => '13.13.13.13'
'addr' => '13.13.13.13',
'version' => 4
},
{
'addr' => '2001:0db8:85a3:0000:0000:8a2e:0370:7334'
'addr' => '2001:0db8:85a3:0000:0000:8a2e:0370:7334',
'version' => 6
}
]
}
Expand All @@ -85,10 +89,12 @@
{
'addresses' => {
'net-1' => [{
'addr' => '2001:0db8:85a3:0000:0000:8a2e:0370:7334'
'addr' => '2001:0db8:85a3:0000:0000:8a2e:0370:7334',
'version' => 6
}],
'net-2' => [{
'addr' => '13.13.13.13'
'addr' => '13.13.13.13',
'version' => 4
}]
}
}
Expand Down

0 comments on commit 101032b

Please sign in to comment.