<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=GB2312">
<link href="chrome://translator/skin/floatingPanel.css"
type="text/css" rel="stylesheet">
</head>
<body 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>
<br>
<pre class="moz-signature" cols="72">--
Thanks,
Eli (Li Yong) Qiao</pre>
<div style="bottom: auto; left: 301px; right: auto; top: 395px;
display: none;" class="translator-theme-default"
id="translator-floating-panel">
<div title="µã»÷·Òë" id="translator-floating-panel-button"></div>
</div>
</body>
</html>