diff options
| author | Sandy Walsh <sandy.walsh@rackspace.com> | 2011-07-06 08:14:58 -0700 |
|---|---|---|
| committer | Sandy Walsh <sandy.walsh@rackspace.com> | 2011-07-06 08:14:58 -0700 |
| commit | f34952f27aa7acdb8bb617346aba281a86e918ae (patch) | |
| tree | ea97c41525d1502d474c19335a0606e9ea196d44 | |
| parent | 46690df48392c8967fc4f0ea05b5dba152fa400a (diff) | |
| download | nova-f34952f27aa7acdb8bb617346aba281a86e918ae.tar.gz nova-f34952f27aa7acdb8bb617346aba281a86e918ae.tar.xz nova-f34952f27aa7acdb8bb617346aba281a86e918ae.zip | |
slightly more fleshed out call path
| -rw-r--r-- | nova/compute/api.py | 4 | ||||
| -rw-r--r-- | nova/compute/manager.py | 7 | ||||
| -rw-r--r-- | nova/network/api.py | 9 | ||||
| -rw-r--r-- | nova/network/manager.py | 31 |
4 files changed, 37 insertions, 14 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py index a17ab2e1c..a07ab4435 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): + def remove_fixed_ip(self, context, instance_id, network_id, ip): """Remove fixed_ip from specified network to given instance.""" self._cast_compute_message('remove_fixed_ip_from_instance', context, - instance_id, network_id) + instance_id, network_id, ip) #TODO(tr3buchet): how to run this in the correct zone? diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 0f761c939..ab5499209 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -840,16 +840,19 @@ class ComputeManager(manager.SchedulerDependentManager): self.inject_network_info(context, instance_id) self.reset_network(context, instance_id) + + # TODO(sandy) pep8 until checked ... @exception.wrap_exception @checks_instance_lock - def remove_fixed_ip_from_instance(self, context, instance_id, network_id): + def remove_fixed_ip_from_instance(self, context, instance_id, network_id, + ip): """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) + network_id, ip) 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 0a70ff73e..54514f482 100644 --- a/nova/network/api.py +++ b/nova/network/api.py @@ -156,14 +156,19 @@ class API(base.Base): {'method': 'add_fixed_ip_to_instance', 'args': args}) - def remove_fixed_ip_from_instance(self, context, instance_id, network_id): + + # TODO(sandy) pep8 until checked + def remove_fixed_ip_from_instance(self, context, instance_id, network_id, + ip): """Removes a fixed ip from instance from specified network.""" args = {'instance_id': instance_id, - 'network_id': network_id} + 'network_id': network_id, + 'ip': ip} rpc.cast(context, FLAGS.network_topic, {'method': 'remove_fixed_ip_from_instance', 'args': args}) + def add_network_to_project(self, context, project_id): """Force adds another network to a project.""" rpc.cast(context, FLAGS.network_topic, diff --git a/nova/network/manager.py b/nova/network/manager.py index 675101b5a..2ae050b14 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -480,12 +480,23 @@ class NetworkManager(manager.SchedulerDependentManager): networks = [self.db.network_get(context, network_id)] self._allocate_fixed_ips(context, instance_id, networks) - def remove_fixed_ip_from_instance(self, context, instance_id, network_id): + + #TODO(sandy) - PEP8 until this is checked ... + def remove_fixed_ip_from_instance(self, context, instance_id, network_id, + ip): """Removes a fixed ip from an instance from specified network.""" networks = [self.db.network_get(context, network_id)] - # TODO(sandy): Do the right thing here ... - x = 1+1 # pep8 to catch this. - self._allocate_fixed_ips(context, instance_id, networks) + # 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) + def allocate_fixed_ip(self, context, instance_id, network, **kwargs): """Gets a fixed ip from the pool.""" @@ -696,10 +707,14 @@ class FlatManager(NetworkManager): for network in networks: self.allocate_fixed_ip(context, instance_id, network) - def deallocate_fixed_ip(self, context, address, **kwargs): - """Returns a fixed ip to the pool.""" - super(FlatManager, self).deallocate_fixed_ip(context, address, - **kwargs) + + # 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) self.db.fixed_ip_disassociate(context, address) def setup_compute_network(self, context, instance_id): |
