Skip to content

Commit

Permalink
Merge pull request #287 from aglarendil/fuel-3.0.1
Browse files Browse the repository at this point in the history
Fix floating ip creation
  • Loading branch information
Vladimir Kuklin committed Jun 19, 2013
2 parents 81f83e1 + cab51c0 commit 81442cd
Showing 1 changed file with 17 additions and 5 deletions.
Expand Up @@ -4,20 +4,32 @@

optional_commands :nova_manage => 'nova-manage'

@@cache_floating_list = nil
def exists?
# 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}/)
if resource[:network].match(/\//)
# Calculate num quads to grab for prefix
mask=resource[:network].sub(/.*\/([0-9][0-9]?)/, '\1').to_i
num_quads = 4 - mask / 8
prefix=Regexp.escape(resource[:network].sub(/(\.[0-9]{1,3}){#{num_quads}}(\/[0-9]{1,2})?$/, '') + ".")
else
prefix = Regexp.new('[[:space:]]' + resource[:network] + '[[:space:]]')
end
@@cache_floating_list ||= nova_manage("floating", "list")
return @@cache_floating_list.match(prefix)
end

def create
nova_manage("floating", "create", resource[:network])
if resource[:network].match(/\//)
@@cache_floating_list = nil
else
@@cache_floating_list += " #{resource} "
end
end

def destroy
nova_manage("floating", "delete", resource[:network])
@@cache_floating_list = nil
end

def parse
Expand Down

0 comments on commit 81442cd

Please sign in to comment.