diff options
| author | Sandy Walsh <sandy.walsh@rackspace.com> | 2011-07-05 13:24:31 -0700 |
|---|---|---|
| committer | Sandy Walsh <sandy.walsh@rackspace.com> | 2011-07-05 13:24:31 -0700 |
| commit | 46690df48392c8967fc4f0ea05b5dba152fa400a (patch) | |
| tree | 09e3446ecd3055ce3069fbc6f5fd329e6823c614 | |
| parent | 6843421be9cdef1fc12d3480889bdcfd96821e1b (diff) | |
| download | nova-46690df48392c8967fc4f0ea05b5dba152fa400a.tar.gz nova-46690df48392c8967fc4f0ea05b5dba152fa400a.tar.xz nova-46690df48392c8967fc4f0ea05b5dba152fa400a.zip | |
copy paste
| -rw-r--r-- | nova/compute/api.py | 10 | ||||
| -rw-r--r-- | nova/compute/manager.py | 14 | ||||
| -rw-r--r-- | nova/network/api.py | 8 | ||||
| -rw-r--r-- | nova/network/manager.py | 7 |
4 files changed, 37 insertions, 2 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py index 28459dc75..a17ab2e1c 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -889,8 +889,14 @@ class API(base.Base): def add_fixed_ip(self, context, instance_id, network_id): """Add fixed_ip from specified network to given instance.""" self._cast_compute_message('add_fixed_ip_to_instance', context, - instance_id, - network_id) + instance_id, network_id) + + @scheduler_api.reroute_compute("remove_fixed_ip") + def remove_fixed_ip(self, context, instance_id, network_id): + """Remove fixed_ip from specified network to given instance.""" + self._cast_compute_message('remove_fixed_ip_from_instance', context, + instance_id, network_id) + #TODO(tr3buchet): how to run this in the correct zone? def add_network_to_project(self, context, project_id): diff --git a/nova/compute/manager.py b/nova/compute/manager.py index bbbddde0a..0f761c939 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -842,6 +842,20 @@ class ComputeManager(manager.SchedulerDependentManager): @exception.wrap_exception @checks_instance_lock + def remove_fixed_ip_from_instance(self, context, instance_id, network_id): + """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) + self.inject_network_info(context, instance_id) + self.reset_network(context, instance_id) + + + @exception.wrap_exception + @checks_instance_lock def pause_instance(self, context, instance_id): """Pause an instance on this host.""" context = context.elevated() diff --git a/nova/network/api.py b/nova/network/api.py index b2b96082b..0a70ff73e 100644 --- a/nova/network/api.py +++ b/nova/network/api.py @@ -156,6 +156,14 @@ class API(base.Base): {'method': 'add_fixed_ip_to_instance', 'args': args}) + def remove_fixed_ip_from_instance(self, context, instance_id, network_id): + """Removes a fixed ip from instance from specified network.""" + args = {'instance_id': instance_id, + 'network_id': network_id} + 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 d42bc8c4e..675101b5a 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -480,6 +480,13 @@ 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): + """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) + def allocate_fixed_ip(self, context, instance_id, network, **kwargs): """Gets a fixed ip from the pool.""" # TODO(vish): when this is called by compute, we can associate compute |
