Update network types

This commit resolves similar issues with both the
nova_floating type as well as the nova_network type
where they could not detect if networks already existed.
This commit is contained in:
Dan Bode 2012-04-10 21:25:35 -07:00
parent d45ac457c2
commit 067fdb49c7
2 changed files with 5 additions and 2 deletions

View File

@ -6,8 +6,10 @@ Puppet::Type.type(:nova_floating).provide(:nova_manage) do
def exists?
begin
# TODO this assumes that the CIDR is 24
# this may be good for an approximation, but it needs to be fixed eventually
prefix=resource[:network].sub(/(^[0-9]*\.[0-9]*\.[0-9]*\.).*/, '\1')
return false if not nova_manage("floating", "list").match(/#{prefix}/)
return nova_manage("floating", "list").match(/#{prefix}/)
rescue
return false
end

View File

@ -27,7 +27,8 @@ Puppet::Type.type(:nova_network).provide(:nova_manage) do
begin
network_list = nova_manage("network", "list")
return network_list.split("\n")[1..-1].detect do |n|
n =~ /^(\S+)\s+(#{resource[:network]})/
# TODO - this does not take the CIDR into accont. Does it matter?
n =~ /^(\S+)\s+(#{resource[:network].split('/').first})/
end
rescue
return false