diff options
| author | Yun Mao <yunmao@gmail.com> | 2012-06-05 14:55:34 -0400 |
|---|---|---|
| committer | Yun Mao <yunmao@gmail.com> | 2012-06-21 15:34:53 -0400 |
| commit | 129b87e17d3333aeaa9e855a70dea51e6581ea63 (patch) | |
| tree | 052999c17d4402237e57218dd8e708d6a1723836 /nova/api | |
| parent | 1ecf8311f817cf1c5b3b6f0efe7c022da1950187 (diff) | |
| download | nova-129b87e17d3333aeaa9e855a70dea51e6581ea63.tar.gz nova-129b87e17d3333aeaa9e855a70dea51e6581ea63.tar.xz nova-129b87e17d3333aeaa9e855a70dea51e6581ea63.zip | |
vm state and task state management
partially implements bp task-management
fixes bug 997867
also see http://wiki.openstack.org/VMState
Refactored the following API/state:
* rebuild
* migrate
* resize
* start
* stop
* delete
* soft delete
* rework sync_power_state in compute/manager.
fix broken tests, add transition diagram in dot
Change-Id: I3c5a97508a6dad7175fba12828bd3fa6ef1e50ee
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/ec2/cloud.py | 25 | ||||
| -rw-r--r-- | nova/api/ec2/inst_state.py | 2 | ||||
| -rw-r--r-- | nova/api/openstack/common.py | 27 | ||||
| -rw-r--r-- | nova/api/openstack/compute/contrib/floating_ips.py | 2 |
4 files changed, 25 insertions, 31 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index cfbb0894f..ac569652d 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -71,26 +71,22 @@ _STATE_DESCRIPTION_MAP = { None: inst_state.PENDING, vm_states.ACTIVE: inst_state.RUNNING, vm_states.BUILDING: inst_state.PENDING, - vm_states.REBUILDING: inst_state.PENDING, vm_states.DELETED: inst_state.TERMINATED, - vm_states.SOFT_DELETE: inst_state.TERMINATED, + vm_states.SOFT_DELETED: inst_state.TERMINATED, vm_states.STOPPED: inst_state.STOPPED, - vm_states.SHUTOFF: inst_state.SHUTOFF, - vm_states.MIGRATING: inst_state.MIGRATE, - vm_states.RESIZING: inst_state.RESIZE, vm_states.PAUSED: inst_state.PAUSE, vm_states.SUSPENDED: inst_state.SUSPEND, vm_states.RESCUED: inst_state.RESCUE, + vm_states.RESIZED: inst_state.RESIZE, } -def _state_description(vm_state, shutdown_terminate): +def _state_description(vm_state, _shutdown_terminate): """Map the vm state to the server status string""" - if (vm_state == vm_states.SHUTOFF and - not shutdown_terminate): - name = inst_state.STOPPED - else: - name = _STATE_DESCRIPTION_MAP.get(vm_state, vm_state) + # Note(maoy): We do not provide EC2 compatibility + # in shutdown_terminate flag behavior. So we ignore + # it here. + name = _STATE_DESCRIPTION_MAP.get(vm_state, vm_state) return {'code': inst_state.name_to_code(name), 'name': name} @@ -1138,7 +1134,7 @@ class CloudController(object): except exception.NoFloatingIpInterface: msg = _('l3driver call to add floating ip failed.') raise exception.EC2APIError(msg) - except: + except Exception: msg = _('Error, unable to associate floating ip.') raise exception.EC2APIError(msg) @@ -1453,11 +1449,10 @@ class CloudController(object): vm_state = instance['vm_state'] # if the instance is in subtle state, refuse to proceed. - if vm_state not in (vm_states.ACTIVE, vm_states.SHUTOFF, - vm_states.STOPPED): + if vm_state not in (vm_states.ACTIVE, vm_states.STOPPED): raise exception.InstanceNotRunning(instance_id=ec2_instance_id) - if vm_state in (vm_states.ACTIVE, vm_states.SHUTOFF): + if vm_state == vm_states.ACTIVE: restart_instance = True self.compute_api.stop(context, instance) diff --git a/nova/api/ec2/inst_state.py b/nova/api/ec2/inst_state.py index 68d18c8ad..1451bbfba 100644 --- a/nova/api/ec2/inst_state.py +++ b/nova/api/ec2/inst_state.py @@ -30,7 +30,6 @@ STOPPING = 'stopping' STOPPED = 'stopped' # non-ec2 value -SHUTOFF = 'shutoff' MIGRATE = 'migrate' RESIZE = 'resize' PAUSE = 'pause' @@ -47,7 +46,6 @@ _NAME_TO_CODE = { STOPPED: STOPPED_CODE, # approximation - SHUTOFF: TERMINATED_CODE, MIGRATE: RUNNING_CODE, RESIZE: RUNNING_CODE, PAUSE: STOPPED_CODE, diff --git a/nova/api/openstack/common.py b/nova/api/openstack/common.py index 93b5a36ab..eacd9b8cb 100644 --- a/nova/api/openstack/common.py +++ b/nova/api/openstack/common.py @@ -48,25 +48,26 @@ _STATE_MAP = { task_states.REBOOTING: 'REBOOT', task_states.REBOOTING_HARD: 'HARD_REBOOT', task_states.UPDATING_PASSWORD: 'PASSWORD', - task_states.RESIZE_VERIFY: 'VERIFY_RESIZE', + task_states.REBUILDING: 'REBUILD', + task_states.REBUILD_BLOCK_DEVICE_MAPPING: 'REBUILD', + task_states.REBUILD_SPAWNING: 'REBUILD', + task_states.MIGRATING: 'MIGRATING', + task_states.RESIZE_PREP: 'RESIZE', + task_states.RESIZE_MIGRATING: 'RESIZE', + task_states.RESIZE_MIGRATED: 'RESIZE', + task_states.RESIZE_FINISH: 'RESIZE', }, vm_states.BUILDING: { 'default': 'BUILD', }, - vm_states.REBUILDING: { - 'default': 'REBUILD', - }, vm_states.STOPPED: { 'default': 'STOPPED', }, - vm_states.SHUTOFF: { - 'default': 'SHUTOFF', - }, - vm_states.MIGRATING: { - 'default': 'MIGRATING', - }, - vm_states.RESIZING: { - 'default': 'RESIZE', + vm_states.RESIZED: { + 'default': 'VERIFY_RESIZE', + # Note(maoy): the OS API spec 1.1 doesn't have CONFIRMING_RESIZE + # state so we comment that out for future reference only. + #task_states.RESIZE_CONFIRMING: 'CONFIRMING_RESIZE', task_states.RESIZE_REVERTING: 'REVERT_RESIZE', }, vm_states.PAUSED: { @@ -84,7 +85,7 @@ _STATE_MAP = { vm_states.DELETED: { 'default': 'DELETED', }, - vm_states.SOFT_DELETE: { + vm_states.SOFT_DELETED: { 'default': 'DELETED', }, } diff --git a/nova/api/openstack/compute/contrib/floating_ips.py b/nova/api/openstack/compute/contrib/floating_ips.py index a3dac71ae..f4dfe2ecd 100644 --- a/nova/api/openstack/compute/contrib/floating_ips.py +++ b/nova/api/openstack/compute/contrib/floating_ips.py @@ -253,7 +253,7 @@ class FloatingIPActionController(wsgi.Controller): except exception.NoFloatingIpInterface: msg = _('l3driver call to add floating ip failed') raise webob.exc.HTTPBadRequest(explanation=msg) - except: + except Exception: msg = _('Error. Unable to associate floating ip') raise webob.exc.HTTPBadRequest(explanation=msg) |
