diff options
| author | Brian Lamar <brian.lamar@rackspace.com> | 2011-03-31 14:43:15 -0400 |
|---|---|---|
| committer | Brian Lamar <brian.lamar@rackspace.com> | 2011-03-31 14:43:15 -0400 |
| commit | fc5d44d785c61b019ca60fa8dc3d4adbcf189c0c (patch) | |
| tree | 859e322fbb90a925af8def968f1042bb7edfc94f /nova/compute | |
| parent | 46e90b5d28b682b668c441f0550b8c53e16321bb (diff) | |
| parent | 59e8112994e293fa1155b703abcc3e33d7cfc6c7 (diff) | |
Merged with Waldon.
Diffstat (limited to 'nova/compute')
| -rw-r--r-- | nova/compute/api.py | 12 | ||||
| -rw-r--r-- | nova/compute/power_state.py | 21 |
2 files changed, 17 insertions, 16 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py index bb909f925..17bec2545 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -489,17 +489,15 @@ class API(base.Base): def rebuild(self, context, instance_id, image_id, metadata=None): """Rebuild the given instance with the provided metadata.""" + instance = db.api.instance_get(context, instance_id) + if instance["state"] == power_state.BUILDING: + msg = _("Instance already building") + raise exception.BuildInProgress(msg) + metadata = metadata or [] self._check_metadata_quota(context, metadata) self._check_metadata_item_length(context, metadata) - instance_ref = self.db.instance_get(context, instance_id) - if instance_ref.state_description == "rebuilding": - raise exception.NotFound("blah") - else: - LOG.error("SENDING REBUILD MESSAGE, INSTANCE HAD STATE: %s" % - instance_ref.state_description) - self._cast_compute_message('rebuild_instance', context, instance_id, params={"image_id": image_id}) diff --git a/nova/compute/power_state.py b/nova/compute/power_state.py index ef013b2ef..c468fe6b3 100644 --- a/nova/compute/power_state.py +++ b/nova/compute/power_state.py @@ -30,20 +30,23 @@ SHUTOFF = 0x05 CRASHED = 0x06 SUSPENDED = 0x07 FAILED = 0x08 +BUILDING = 0x09 # TODO(justinsb): Power state really needs to be a proper class, # so that we're not locked into the libvirt status codes and can put mapping # logic here rather than spread throughout the code _STATE_MAP = { - NOSTATE: 'pending', - RUNNING: 'running', - BLOCKED: 'blocked', - PAUSED: 'paused', - SHUTDOWN: 'shutdown', - SHUTOFF: 'shutdown', - CRASHED: 'crashed', - SUSPENDED: 'suspended', - FAILED: 'failed to spawn'} + NOSTATE: 'pending', + RUNNING: 'running', + BLOCKED: 'blocked', + PAUSED: 'paused', + SHUTDOWN: 'shutdown', + SHUTOFF: 'shutdown', + CRASHED: 'crashed', + SUSPENDED: 'suspended', + FAILED: 'failed to spawn', + BUILDING: 'building', +} def name(code): |
