Skip to content
Browse files

make it all work correctly

  • Loading branch information...
1 parent ad8dbea commit 9726119a4a7964d1af6b2756f96eb77741b400ed @branan branan committed May 1, 2012
Showing with 7 additions and 14 deletions.
  1. +6 −13 lib/puppet/provider/nova_floating/nova_manage.rb
  2. +1 −1 lib/puppet/type/nova_floating.rb
View
19 lib/puppet/provider/nova_floating/nova_manage.rb
@@ -5,22 +5,15 @@
optional_commands :nova_manage => 'nova-manage'
def exists?
- begin
- # Calculate num quads to grab for prefix
- mask=resource[:network].sub(/.*\/([0-9][0-9]?)/, '\1')
- num_quads=32/$mask
- if num_quads == 4
- num_quads=3
- end
- prefix=resource[:network].sub(/(\.[0-9]{1,3}){#{num_quads}}(\/[0-9]{1,2})?$/, '') + "."
- return nova_manage("floating", "list").match(/#{prefix}/)
- rescue
- return false
- end
+ # Calculate num quads to grab for prefix
+ mask=resource[:network].sub(/.*\/([0-9][0-9]?)/, '\1').to_i
+ num_quads = 4 - mask / 8
+ prefix=resource[:network].sub(/(\.[0-9]{1,3}){#{num_quads}}(\/[0-9]{1,2})?$/, '') + "."
+ return nova_manage("floating", "list").match(/#{prefix}/)
end
def create
- nova_manage("floating", "create", resource[:network]) if exists? == false
+ nova_manage("floating", "create", resource[:network])
end
def destroy
View
2 lib/puppet/type/nova_floating.rb
@@ -6,7 +6,7 @@
newparam(:network, :namevar => true) do
desc "Network (ie, 192.168.1.0/24 or 192.168.1.128/25 etc.)"
- newvalues(/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[1-9][0-9]{0,2}\/[0-9]{1,2}$/)
+ newvalues(/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\/[0-9]{1,2}$/)
end
end

0 comments on commit 9726119

Please sign in to comment.
Something went wrong with that request. Please try again.