hello all:
in current _init_instance function in compute manager,
there's flood 'and' 'or' logic, to check the vm_state and task_state
when initialize a instance during service list,
this lead hard to read and hard to maintain, so I propose a new way to
handle this.

we can create a vm_state_table, by look up the table we can find the
action we need to do for the instance,
from this table , you can clearly see what vm_state and task_state
should take the action.

for example:
{vm_states list :{task_states list: action}},

each entry stands for an action,
and we walk though the tuple
so the table should be like this:

vm_state_table = (
{vm_states.SOFT_DELETE :{'ALL': ACTION_NONE}},
{vm_states.ERROR: {('NOT_IN',[task_states.RESIZE_MIGRATING,
task_states.DELETING]): ACTION_NONE}},
{vm_states.DELETED: {'ALL': _complete_partial_deletion}},
{vm_states.BUILDING: {'ALL': ACTION_ERROR}},
{'ALL': {('IN',[task_states.SCHEDULING,
task_states.BLOCK_DEVICE_MAPPING,
task_states.NETWORKING,
task_states.SPAWNING)]: ACTION_ERROR}},
{('IN',[vm_states.ACTIVE, vm_states.STOPPED]: {('IN',
[task_states.REBUILDING,
task_states.REBUILD_BLOCK_DEVICE_MAPPING,
task_states.REBUILD_SPAWNING]): ACTION_ERROR}},
{('NOT_IN',[vm_states.ERROR]): {('IN', [task_states.IMAGE_SNAPSHOT_PENDING,
task_states.IMAGE_PENDING_UPLOAD,
task_states.IMAGE_UPLOADING,
task_states.IMAGE_SNAPSHOT]): _post_interrupted_snapshot_cleanup}}
)

what do you think, do we need a bp for this?

-- 
Thanks,
Eli (Li Yong) Qiao

_______________________________________________
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

Reply via email to