[Kimchi-devel] [PATCH 2/3] Update some VM state conditions

Aline Manera alinefm at linux.vnet.ibm.com
Fri Jan 23 14:05:46 UTC 2015


On 22/01/2015 12:52, Crístian Viana wrote:
> Some functions assume that a VM can only be in two states: shutoff and
> running. However, that's not always the case (e.g. not being running
> doesn't mean it's shutoff).
>
> Update some functions so the VM state conditions are more accurate.
>
> Signed-off-by: Crístian Viana <vianac at linux.vnet.ibm.com>
> ---
>   src/kimchi/model/vms.py | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
> index 42cf3e9..5128d1e 100644
> --- a/src/kimchi/model/vms.py
> +++ b/src/kimchi/model/vms.py
> @@ -683,7 +683,7 @@ class VMModel(object):
>           try:
>               if 'name' in params:
>                   state = DOM_STATE_MAP[dom.info()[0]]
> -                if state == 'running':
> +                if state != u'shutoff':

DOM_STATE_MAP returns a string instead of unicode.

>                       msg_args = {'name': dom.name(), 'new_name': params['name']}
>                       raise InvalidParameter("KCHVM0003E", msg_args)
>   
> @@ -788,7 +788,7 @@ class VMModel(object):
>           paths = self._vm_get_disk_paths(dom)
>           info = self.lookup(name)
>   
> -        if info['state'] == 'running':
> +        if info['state'] != u'shutoff':
>               self.poweroff(name)
>   
>           # delete existing snapshots before deleting VM




More information about the Kimchi-devel mailing list