summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorIlya Alekseyev <ialekseev@griddynamics.com>2011-04-18 21:06:29 +0400
committerIlya Alekseyev <ialekseev@griddynamics.com>2011-04-18 21:06:29 +0400
commit9a0d079cfe28d6d8d4e909f68541efda5ad3a3c5 (patch)
treefd62ca3d58386ba5b43452be8b3067e50f16a252 /nova
parente724baee5a76e38bff151148ab8c295f6fdb53dc (diff)
not performing floating ip operation with auto allocated ips
Diffstat (limited to 'nova')
-rw-r--r--nova/compute/manager.py3
-rw-r--r--nova/db/sqlalchemy/api.py2
-rw-r--r--nova/db/sqlalchemy/models.py1
-rw-r--r--nova/network/api.py6
4 files changed, 11 insertions, 1 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 94fee36a5..829d59170 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -308,7 +308,8 @@ class ComputeManager(manager.SchedulerDependentManager):
network_topic,
{"method": "disassociate_floating_ip",
"args": {"floating_address": address}})
- if FLAGS.auto_assign_floating_ip:
+ if FLAGS.auto_assign_floating_ip \
+ and floating_ip.get('auto_assigned'):
LOG.debug(_("Deallocating floating ip %s"),
floating_ip['address'], context=context)
rpc.cast(context,
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index 28126a517..6b2caf46c 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -461,6 +461,7 @@ def floating_ip_count_by_project(context, project_id):
session = get_session()
return session.query(models.FloatingIp).\
filter_by(project_id=project_id).\
+ filter_by(auto_assigned=False).\
filter_by(deleted=False).\
count()
@@ -560,6 +561,7 @@ def floating_ip_get_all_by_project(context, project_id):
return session.query(models.FloatingIp).\
options(joinedload_all('fixed_ip.instance')).\
filter_by(project_id=project_id).\
+ filter_by(auto_assigned=False).\
filter_by(deleted=False).\
all()
diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py
index f79d0f16c..36a084a1d 100644
--- a/nova/db/sqlalchemy/models.py
+++ b/nova/db/sqlalchemy/models.py
@@ -592,6 +592,7 @@ class FloatingIp(BASE, NovaBase):
'FloatingIp.deleted == False)')
project_id = Column(String(255))
host = Column(String(255)) # , ForeignKey('hosts.id'))
+ auto_assigned = Column(Boolean, default=False, nullable=False)
class ConsolePool(BASE, NovaBase):
diff --git a/nova/network/api.py b/nova/network/api.py
index c56e3062b..c5f76a14e 100644
--- a/nova/network/api.py
+++ b/nova/network/api.py
@@ -53,6 +53,8 @@ class API(base.Base):
def release_floating_ip(self, context, address):
floating_ip = self.db.floating_ip_get_by_address(context, address)
+ if floating_ip.get('auto_assigned'):
+ return
# NOTE(vish): We don't know which network host should get the ip
# when we deallocate, so just send it to any one. This
# will probably need to move into a network supervisor
@@ -66,6 +68,8 @@ class API(base.Base):
if isinstance(fixed_ip, str) or isinstance(fixed_ip, unicode):
fixed_ip = self.db.fixed_ip_get_by_address(context, fixed_ip)
floating_ip = self.db.floating_ip_get_by_address(context, floating_ip)
+ if floating_ip.get('auto_assigned'):
+ return
# Check if the floating ip address is allocated
if floating_ip['project_id'] is None:
raise exception.ApiError(_("Address (%s) is not allocated") %
@@ -92,6 +96,8 @@ class API(base.Base):
def disassociate_floating_ip(self, context, address):
floating_ip = self.db.floating_ip_get_by_address(context, address)
+ if floating_ip.get('auto_assigned'):
+ return
if not floating_ip.get('fixed_ip'):
raise exception.ApiError('Address is not associated.')
# NOTE(vish): Get the topic from the host name of the network of