[Kimchi-devel] [PATCH 2/4] reset VM in backend.

Daniel H Barboza danielhb at linux.vnet.ibm.com
Thu Apr 10 14:02:55 UTC 2014


Reviewed-by: Daniel Barboza <danielhb at linux.vnet.ibm.com>

On 04/10/2014 10:04 AM, shaohef at linux.vnet.ibm.com wrote:
> From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
>
> update mockmodel, model and controller.
>
> Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
> ---
>   src/kimchi/control/vms.py | 1 +
>   src/kimchi/i18n.py        | 1 +
>   src/kimchi/mockmodel.py   | 3 +++
>   src/kimchi/model/vms.py   | 8 ++++++++
>   4 files changed, 13 insertions(+)
>
> diff --git a/src/kimchi/control/vms.py b/src/kimchi/control/vms.py
> index e75b27f..b84df76 100644
> --- a/src/kimchi/control/vms.py
> +++ b/src/kimchi/control/vms.py
> @@ -39,6 +39,7 @@ class VM(Resource):
>               setattr(self, ident, node(model, self.ident))
>           self.start = self.generate_action_handler('start')
>           self.poweroff = self.generate_action_handler('poweroff')
> +        self.reset = self.generate_action_handler('reset')
>           self.connect = self.generate_action_handler('connect')
>
>       @property
> diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
> index 7cf0970..6a31428 100644
> --- a/src/kimchi/i18n.py
> +++ b/src/kimchi/i18n.py
> @@ -78,6 +78,7 @@ messages = {
>       "KCHVM0019E": _("Unable to start virtual machine %(name)s. Details: %(err)s"),
>       "KCHVM0020E": _("Unable to poweroff virtual machine %(name)s. Details: %(err)s"),
>       "KCHVM0021E": _("Unable to delete virtual machine %(name)s. Details: %(err)s"),
> +    "KCHVM0022E": _("Unable to reset virtual machine %(name)s. Details: %(err)s"),
>
>       "KCHVMIF0001E": _("Interface %(iface)s does not exist in virtual machine %(name)s"),
>       "KCHVMIF0002E": _("Network %(network)s specified for virtual machine %(name)s does not exist"),
> diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py
> index 98fb080..1ed6861 100644
> --- a/src/kimchi/mockmodel.py
> +++ b/src/kimchi/mockmodel.py
> @@ -132,6 +132,9 @@ class MockModel(object):
>       def vm_poweroff(self, name):
>           self._get_vm(name).info['state'] = 'shutoff'
>
> +    def vm_reset(self, name):
> +        pass
> +
>       def vm_connect(self, name):
>           pass
>
> diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
> index 8334d9e..38ad180 100644
> --- a/src/kimchi/model/vms.py
> +++ b/src/kimchi/model/vms.py
> @@ -380,6 +380,14 @@ class VMModel(object):
>               raise OperationFailed("KCHVM0020E",
>                                     {'name': name, 'err': e.get_error_message()})
>
> +    def reset(self, name):
> +        dom = self.get_vm(name, self.conn)
> +        try:
> +            dom.reset(flags=0)
> +        except libvirt.libvirtError as e:
> +            raise OperationFailed("KCHVM0022E",
> +                                  {'name': name, 'err': e.get_error_message()})
> +
>       def _vm_get_graphics(self, name):
>           dom = self.get_vm(name, self.conn)
>           xml = dom.XMLDesc(0)




More information about the Kimchi-devel mailing list