summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSandy Walsh <sandy.walsh@rackspace.com>2011-07-06 13:43:48 -0700
committerSandy Walsh <sandy.walsh@rackspace.com>2011-07-06 13:43:48 -0700
commitbd297ae3bc779853cf82f05d0d4da60305416a99 (patch)
tree7e41a51c46aedfd20dbddef4a5d51f8fd8f3ef82
parentf34952f27aa7acdb8bb617346aba281a86e918ae (diff)
changed calling signature to be (instance_id, address)
-rw-r--r--nova/compute/api.py4
-rw-r--r--nova/compute/manager.py6
-rw-r--r--nova/network/api.py6
-rw-r--r--nova/network/manager.py32
4 files changed, 17 insertions, 31 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py
index a07ab4435..e4992bbfa 100644
--- a/nova/compute/api.py
+++ b/nova/compute/api.py
@@ -892,10 +892,10 @@ class API(base.Base):
instance_id, network_id)
@scheduler_api.reroute_compute("remove_fixed_ip")
- def remove_fixed_ip(self, context, instance_id, network_id, ip):
+ def remove_fixed_ip(self, context, instance_id, address):
"""Remove fixed_ip from specified network to given instance."""
self._cast_compute_message('remove_fixed_ip_from_instance', context,
- instance_id, network_id, ip)
+ instance_id, address)
#TODO(tr3buchet): how to run this in the correct zone?
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index ab5499209..b9a3d1a5e 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -844,15 +844,13 @@ class ComputeManager(manager.SchedulerDependentManager):
# TODO(sandy) pep8 until checked ...
@exception.wrap_exception
@checks_instance_lock
- def remove_fixed_ip_from_instance(self, context, instance_id, network_id,
- ip):
+ def remove_fixed_ip_from_instance(self, context, instance_id, address):
"""Calls network_api to remove existing fixed_ip from instance
by injecting the altered network info and resetting
instance networking.
-
"""
self.network_api.remove_fixed_ip_from_instance(context, instance_id,
- network_id, ip)
+ address)
self.inject_network_info(context, instance_id)
self.reset_network(context, instance_id)
diff --git a/nova/network/api.py b/nova/network/api.py
index 54514f482..bcd69d52b 100644
--- a/nova/network/api.py
+++ b/nova/network/api.py
@@ -158,12 +158,10 @@ class API(base.Base):
# TODO(sandy) pep8 until checked
- def remove_fixed_ip_from_instance(self, context, instance_id, network_id,
- ip):
+ def remove_fixed_ip_from_instance(self, context, instance_id, address):
"""Removes a fixed ip from instance from specified network."""
args = {'instance_id': instance_id,
- 'network_id': network_id,
- 'ip': ip}
+ 'address': address}
rpc.cast(context, FLAGS.network_topic,
{'method': 'remove_fixed_ip_from_instance',
'args': args})
diff --git a/nova/network/manager.py b/nova/network/manager.py
index 2ae050b14..4b9fb98f4 100644
--- a/nova/network/manager.py
+++ b/nova/network/manager.py
@@ -482,20 +482,14 @@ class NetworkManager(manager.SchedulerDependentManager):
#TODO(sandy) - PEP8 until this is checked ...
- def remove_fixed_ip_from_instance(self, context, instance_id, network_id,
- ip):
+ def remove_fixed_ip_from_instance(self, context, instance_id, address):
"""Removes a fixed ip from an instance from specified network."""
- networks = [self.db.network_get(context, network_id)]
- # Find the network that contains this IP ...
- network = None
- for n in networks:
- if ip in n:
- network = n
- break
- if not network:
- raise exception.InvalidIP(ip=ip)
-
- self.deallocate_fixed_ips(context, ip)
+ addresses = self.db.fixed_ip_get_by_instance(context, instance_id)
+ for addr in addresses:
+ if addr == address:
+ self.deallocate_fixed_ip(context, address)
+ return
+ raise exception.NoSuchAddress(address=address)
def allocate_fixed_ip(self, context, instance_id, network, **kwargs):
@@ -707,14 +701,10 @@ class FlatManager(NetworkManager):
for network in networks:
self.allocate_fixed_ip(context, instance_id, network)
-
- # TODO(sandy): Switched to multi-IP support
- def deallocate_fixed_ip(self, context, networks, **kwargs):
- """Returns a list of fixed ips to the pool."""
- for network in networks:
- address = network['address']
- super(FlatManager, self).deallocate_fixed_ip(context, address,
- **kwargs)
+ def deallocate_fixed_ip(self, context, address, **kwargs):
+ """Returns a fixed ip to the pool."""
+ super(FlatManager, self).deallocate_fixed_ip(context, address,
+ **kwargs)
self.db.fixed_ip_disassociate(context, address)
def setup_compute_network(self, context, instance_id):