<div dir="ltr">+1, good idea!<br></div><div class="gmail_extra"><br><div class="gmail_quote">2014-11-04 15:15 GMT+08:00 Eli Qiao <span dir="ltr"><<a href="mailto:taget@linux.vnet.ibm.com" target="_blank">taget@linux.vnet.ibm.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  

    
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    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><span class="HOEnZb"><font color="#888888">
    <br>
    <pre cols="72">-- 
Thanks,
Eli (Li Yong) Qiao</pre>
    <div>
      <div title="点击翻译"></div>
    </div>
  </font></span></div>

<br>_______________________________________________<br>
OpenStack-dev mailing list<br>
<a href="mailto:OpenStack-dev@lists.openstack.org">OpenStack-dev@lists.openstack.org</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br></blockquote></div><br></div>