Ensure nova_manage detects existing networks

Previously, there was a bug in the exists? method of
the nova_network provider where it could not detect
if a network already existed. This is b/c it
appended an extra /\d\d on the network id.

This commit corrects the logic so that existing
networks can be correctly detected.
This commit is contained in:
Dan Bode 2012-01-24 22:04:22 -08:00
parent bcca7bedc4
commit bfd1fa5da8
1 changed files with 4 additions and 1 deletions

View File

@ -6,7 +6,10 @@ Puppet::Type.type(:nova_network).provide(:nova_manage) do
def exists?
begin
nova_manage("network", "list").match(/^#{resource[:network]}\/[0-9]{1,2} /)
network_list = nova_manage("network", "list")
return network_list.split("\n")[1..-1].detect do |n|
n =~ /^(\S+)\s+(#{resource[:network]})/
end
rescue
return false
end