<html><body bgcolor="#FFFFFF">
<p><font size="2" face="sans-serif">+1,</font><br>
<br>
<font size="2" face="sans-serif">a good idea, it will make it more clear. </font><br>
<font size="2" face="sans-serif">from implementation perspective we need to pay attention that some status will pass through and some will just return </font><br>
<br>
<font size="2" face="sans-serif">Best Regards! <br>
<br>
Kevin (Chen) Ji ¼Í ³¿<br>
<br>
Engineer, zVM Development, CSTL<br>
Notes: Chen CH Ji/China/IBM@IBMCN   Internet: jichenjc@cn.ibm.com<br>
Phone: +86-10-82454158<br>
Address: 3/F Ring Building, ZhongGuanCun Software Park, Haidian District, Beijing 100193, PRC </font><br>
<br>
<img width="16" height="16" src="cid:1__=C7BBF715DFB479698f9e8a93df938@cn.ibm.com" border="0" alt="Inactive hide details for Eli Qiao ---11/04/2014 03:13:26 PM---hello all: in current _init_instance function in compute manager"><font size="2" color="#424282" face="sans-serif">Eli Qiao ---11/04/2014 03:13:26 PM---hello all: in current _init_instance function in compute manager,</font><br>
<br>
<font size="1" color="#5F5F5F" face="sans-serif">From:      </font><font size="1" face="sans-serif">Eli Qiao <taget@linux.vnet.ibm.com></font><br>
<font size="1" color="#5F5F5F" face="sans-serif">To:        </font><font size="1" face="sans-serif">"OpenStack Development Mailing List (not for usage questions)" <openstack-dev@lists.openstack.org></font><br>
<font size="1" color="#5F5F5F" face="sans-serif">Date:      </font><font size="1" face="sans-serif">11/04/2014 03:13 PM</font><br>
<font size="1" color="#5F5F5F" face="sans-serif">Subject:   </font><font size="1" face="sans-serif">[openstack-dev] [nova][compute] propose to use a table to deal with the vm_state when _init_instance in compute</font><br>
<hr width="100%" size="2" align="left" noshade style="color:#8091A5; "><br>
<br>
<br>
<font size="3" face="sans-serif">hello all:<br>
in current _init_instance function in compute manager, <br>
there's flood 'and' 'or' logic, to check the vm_state and task_state when initialize a instance during service list,<br>
this lead hard to read and hard to maintain, so I propose a new way to handle this.<br>
<br>
we can create a vm_state_table, by look up the table  we can find the action we need to do for the instance,<br>
from this table , you can clearly see what vm_state and task_state should take the action.<br>
<br>
for example:<br>
{vm_states list :{task_states list: action}},<br>
<br>
each entry stands for an action,<br>
and we walk though the tuple<br>
so the table should be like this:<br>
<br>
vm_state_table = (<br>
    {vm_states.SOFT_DELETE :{'ALL': ACTION_NONE}},<br>
    {vm_states.ERROR:  {('NOT_IN',[task_states.RESIZE_MIGRATING,<br>
                                                      task_states.DELETING]): ACTION_NONE}},<br>
    {vm_states.DELETED: {'ALL': _complete_partial_deletion}},<br>
    {vm_states.BUILDING: {'ALL': ACTION_ERROR}},<br>
    {'ALL': {('IN',[task_states.SCHEDULING,<br>
                        task_states.BLOCK_DEVICE_MAPPING,<br>
                        task_states.NETWORKING,<br>
                        task_states.SPAWNING)]: ACTION_ERROR}},<br>
    {('IN',[vm_states.ACTIVE, vm_states.STOPPED]: {('IN', [task_states.REBUILDING,<br>
                                                                                         task_states.REBUILD_BLOCK_DEVICE_MAPPING,<br>
                                                                                         task_states.REBUILD_SPAWNING]): ACTION_ERROR}},<br>
    {('NOT_IN',[vm_states.ERROR]): {('IN', [task_states.IMAGE_SNAPSHOT_PENDING,<br>
                                                                task_states.IMAGE_PENDING_UPLOAD,<br>
                                                                task_states.IMAGE_UPLOADING,<br>
                                                                task_states.IMAGE_SNAPSHOT]): _post_interrupted_snapshot_cleanup}}<br>
)<br>
<br>
what do you think, do we need a bp for this? <br>
</font><br>
<tt><font size="3">-- <br>
Thanks,<br>
Eli (Li Yong) Qiao</font></tt><tt><font size="2">_______________________________________________<br>
OpenStack-dev mailing list<br>
OpenStack-dev@lists.openstack.org<br>
</font></tt><tt><font size="2"><a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a></font></tt><tt><font size="2"><br>
</font></tt><br>
</body></html>