[openstack-dev] [nova][compute] propose to use a table to deal with the vm_state when _init_instance in compute

Chen CH Ji jichenjc at cn.ibm.com
Tue Nov 4 07:19:46 UTC 2014


+1,

a good idea, it will make it more clear.
from implementation perspective we need to pay attention that some status
will pass through and some will just return

Best Regards!

Kevin (Chen) Ji 纪 晨

Engineer, zVM Development, CSTL
Notes: Chen CH Ji/China/IBM at IBMCN   Internet: jichenjc at cn.ibm.com
Phone: +86-10-82454158
Address: 3/F Ring Building, ZhongGuanCun Software Park, Haidian District,
Beijing 100193, PRC



From:	Eli Qiao <taget at linux.vnet.ibm.com>
To:	"OpenStack Development Mailing List (not for usage questions)"
            <openstack-dev at lists.openstack.org>
Date:	11/04/2014 03:13 PM
Subject:	[openstack-dev] [nova][compute] propose to use a table to deal
            with the vm_state when _init_instance in compute



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 at lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20141104/adb8b355/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20141104/adb8b355/attachment-0001.gif>


More information about the OpenStack-dev mailing list