diff options
| author | Trey Morris <trey.morris@rackspace.com> | 2011-06-23 18:10:30 -0500 |
|---|---|---|
| committer | Trey Morris <trey.morris@rackspace.com> | 2011-06-23 18:10:30 -0500 |
| commit | 5b5cc6f42ef5cca33bbca65ef66e53862cf69f07 (patch) | |
| tree | 2ac8e4694a842d224a077732f460dd711b99f57a /nova/compute | |
| parent | c33fc283c4f75b4de745484b53a818795ad80d96 (diff) | |
| parent | 654350a1cf93e8ecf8d38f07802e0c3ed7039562 (diff) | |
| download | nova-5b5cc6f42ef5cca33bbca65ef66e53862cf69f07.tar.gz nova-5b5cc6f42ef5cca33bbca65ef66e53862cf69f07.tar.xz nova-5b5cc6f42ef5cca33bbca65ef66e53862cf69f07.zip | |
trunk merge
Diffstat (limited to 'nova/compute')
| -rw-r--r-- | nova/compute/api.py | 13 | ||||
| -rw-r--r-- | nova/compute/manager.py | 71 |
2 files changed, 53 insertions, 31 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py index 9f4d4899f..4eff7bac0 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -478,6 +478,16 @@ class API(base.Base): {"method": "refresh_security_group_members", "args": {"security_group_id": group_id}}) + def trigger_provider_fw_rules_refresh(self, context): + """Called when a rule is added to or removed from a security_group""" + + hosts = [x['host'] for (x, idx) + in db.service_get_all_compute_sorted(context)] + for host in hosts: + rpc.cast(context, + self.db.queue_get_for(context, FLAGS.compute_topic, host), + {'method': 'refresh_provider_fw_rules', 'args': {}}) + def update(self, context, instance_id, **kwargs): """Updates the instance in the datastore. @@ -683,7 +693,7 @@ class API(base.Base): raise exception.Error(_("Unable to find host for Instance %s") % instance_id) - def snapshot(self, context, instance_id, name): + def snapshot(self, context, instance_id, name, extra_properties=None): """Snapshot the given instance. :returns: A dict containing image metadata @@ -691,6 +701,7 @@ class API(base.Base): properties = {'instance_id': str(instance_id), 'user_id': str(context.user_id), 'image_state': 'creating'} + properties.update(extra_properties or {}) sent_meta = {'name': name, 'is_public': False, 'status': 'creating', 'properties': properties} recv_meta = self.image_service.create(context, sent_meta) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 8021154eb..102a3c5a7 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -201,6 +201,11 @@ class ComputeManager(manager.SchedulerDependentManager): """ return self.driver.refresh_security_group_members(security_group_id) + @exception.wrap_exception + def refresh_provider_fw_rules(self, context, **_kwargs): + """This call passes straight through to the virtualization driver.""" + return self.driver.refresh_provider_fw_rules() + def _setup_block_device_mapping(self, context, instance_id): """setup volumes for block device mapping""" self.db.instance_set_state(context, @@ -277,39 +282,45 @@ class ComputeManager(manager.SchedulerDependentManager): 'networking') is_vpn = instance['image_ref'] == str(FLAGS.vpn_image_id) - # NOTE(vish): This could be a cast because we don't do anything - # with the address currently, but I'm leaving it as - # a call to ensure that network setup completes. We - # will eventually also need to save the address here. - if not FLAGS.stub_network: - network_info = self.network_api.allocate_for_instance(context, - instance, - vpn=is_vpn) - LOG.debug(_("instance network_info: |%s|"), network_info) - self.network_manager.setup_compute_network(context, instance_id) - else: - # TODO(tr3buchet) not really sure how this should be handled. - # virt requires network_info to be passed in but stub_network - # is enabled. Setting to [] for now will cause virt to skip - # all vif creation and network injection, maybe this is correct - network_info = [] - - block_device_mapping = self._setup_block_device_mapping(context, - instance_id) + try: + # NOTE(vish): This could be a cast because we don't do anything + # with the address currently, but I'm leaving it as + # a call to ensure that network setup completes. We + # will eventually also need to save the address here. + if not FLAGS.stub_network: + network_info = self.network_api.allocate_for_instance(context, + instance, vpn=is_vpn) + LOG.debug(_("instance network_info: |%s|"), network_info) + self.network_manager.setup_compute_network(context, + instance_id) + else: + # TODO(tr3buchet) not really sure how this should be handled. + # virt requires network_info to be passed in but stub_network + # is enabled. Setting to [] for now will cause virt to skip + # all vif creation and network injection, maybe this is correct + network_info = [] - # TODO(vish) check to make sure the availability zone matches - self._update_state(context, instance_id, power_state.BUILDING) + bd_mapping = self._setup_block_device_mapping(context, instance_id) - try: - self.driver.spawn(instance, network_info, block_device_mapping) - except Exception as ex: # pylint: disable=W0702 - msg = _("Instance '%(instance_id)s' failed to spawn. Is " - "virtualization enabled in the BIOS? Details: " - "%(ex)s") % locals() - LOG.exception(msg) + # TODO(vish) check to make sure the availability zone matches + self._update_state(context, instance_id, power_state.BUILDING) - self._update_launched_at(context, instance_id) - self._update_state(context, instance_id) + try: + self.driver.spawn(instance, network_info, bd_mapping) + except Exception as ex: # pylint: disable=W0702 + msg = _("Instance '%(instance_id)s' failed to spawn. Is " + "virtualization enabled in the BIOS? Details: " + "%(ex)s") % locals() + LOG.exception(msg) + + self._update_launched_at(context, instance_id) + self._update_state(context, instance_id) + except exception.InstanceNotFound: + # FIXME(wwolf): We are just ignoring InstanceNotFound + # exceptions here in case the instance was immediately + # deleted before it actually got created. This should + # be fixed once we have no-db-messaging + pass @exception.wrap_exception def run_instance(self, context, instance_id, **kwargs): |
