summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrey Morris <trey.morris@rackspace.com>2011-06-10 16:55:27 -0500
committerTrey Morris <trey.morris@rackspace.com>2011-06-10 16:55:27 -0500
commit878468db557b4498528d57804a1808388d7993ec (patch)
treea580f0884e465e6e687f77330ccf4b4f66692055
parenta442e9d3fb00b9a39b39586f1d3752b4f96dee8a (diff)
floating ips can now move around the network hosts
-rwxr-xr-xbin/nova-manage12
-rw-r--r--nova/db/sqlalchemy/api.py4
-rw-r--r--nova/network/manager.py2
3 files changed, 11 insertions, 7 deletions
diff --git a/bin/nova-manage b/bin/nova-manage
index 187db0c86..16b0cd1dd 100755
--- a/bin/nova-manage
+++ b/bin/nova-manage
@@ -518,13 +518,12 @@ class FixedIpCommands(object):
class FloatingIpCommands(object):
"""Class for managing floating ip."""
- def create(self, host, range):
- """Creates floating ips for host by range
- arguments: host ip_range"""
+ def create(self, range):
+ """Creates floating ips for zone by range
+ arguments: ip_range"""
for address in IPy.IP(range):
db.floating_ip_create(context.get_admin_context(),
- {'address': str(address),
- 'host': host})
+ {'address': str(address)})
def delete(self, ip_range):
"""Deletes floating ips by range
@@ -535,7 +534,8 @@ class FloatingIpCommands(object):
def list(self, host=None):
"""Lists all floating ips (optionally by host)
- arguments: [host]"""
+ arguments: [host]
+ Note: if host is given, only active floating IPs are returned"""
ctxt = context.get_admin_context()
if host is None:
floating_ips = db.floating_ip_get_all(ctxt)
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index e2996ba87..076f7ba67 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -433,7 +433,7 @@ def certificate_update(context, certificate_id, values):
@require_context
-def floating_ip_allocate_address(context, project_id):
+def floating_ip_allocate_address(context, host, project_id):
authorize_project_context(context, project_id)
session = get_session()
with session.begin():
@@ -448,6 +448,7 @@ def floating_ip_allocate_address(context, project_id):
if not floating_ip_ref:
raise db.NoMoreAddresses()
floating_ip_ref['project_id'] = project_id
+ floating_ip_ref['host'] = host
session.add(floating_ip_ref)
return floating_ip_ref['address']
@@ -496,6 +497,7 @@ def floating_ip_deallocate(context, address):
address,
session=session)
floating_ip_ref['project_id'] = None
+ floating_ip_ref['host'] = None
floating_ip_ref['auto_assigned'] = False
floating_ip_ref.save(session=session)
diff --git a/nova/network/manager.py b/nova/network/manager.py
index 889cfa59c..ea37989ce 100644
--- a/nova/network/manager.py
+++ b/nova/network/manager.py
@@ -232,6 +232,7 @@ class FloatingIP(object):
def allocate_floating_ip(self, context, project_id):
"""Gets an floating ip from the pool."""
+ # NOTE(tr3buchet): all networks hosts in zone now use the same pool
LOG.debug("QUOTA: %s" % quota.allowed_floating_ips(context, 1))
if quota.allowed_floating_ips(context, 1) < 1:
LOG.warn(_('Quota exceeeded for %s, tried to allocate '
@@ -241,6 +242,7 @@ class FloatingIP(object):
'allocate any more addresses'))
# TODO(vish): add floating ips through manage command
return self.db.floating_ip_allocate_address(context,
+ self.host
project_id)
def associate_floating_ip(self, context, floating_address, fixed_address):