Re: [virt-tools-list] [virt-manager PATCH] virtManager: disable 'Clone' in VMActionMenu if VM can't be cloned

2016-10-06 Thread Chen Hanxiao

At 2016-09-30 22:03:49, "Cole Robinson"  wrote:
>On 09/20/2016 11:59 PM, Chen Hanxiao wrote:
>> From: Chen Hanxiao 
>> 
>> We can't clone a VM in some scenarios,
>> such as a VM is active.
>> 
>> This patch will disable 'Clone' label in VMActionMenu
>> if we can't clone a VM,
>> as same as we did for 'Clone' button in clone ui page.
>> 
>> Signed-off-by: Chen Hanxiao 
>> ---
>>  virtManager/domain.py | 4 
>>  virtManager/vmmenu.py | 2 +-
>>  2 files changed, 5 insertions(+), 1 deletion(-)
>> 
>> diff --git a/virtManager/domain.py b/virtManager/domain.py
>> index a707f25..582de64 100644
>> --- a/virtManager/domain.py
>> +++ b/virtManager/domain.py
>> @@ -1655,6 +1655,10 @@ class vmmDomain(vmmLibvirtObject):
>>  return self.status() in [libvirt.VIR_DOMAIN_PAUSED]
>>  def is_paused(self):
>>  return self.status() in [libvirt.VIR_DOMAIN_PAUSED]
>> +def is_clonable(self):
>> +return self.status() in [libvirt.VIR_DOMAIN_SHUTOFF,
>> + libvirt.VIR_DOMAIN_PAUSED,
>> + libvirt.VIR_DOMAIN_PMSUSPENDED]
>>  
>>  def run_status(self):
>>  return self.pretty_run_status(self.status(), 
>> self.has_managed_save())
>> diff --git a/virtManager/vmmenu.py b/virtManager/vmmenu.py
>> index a1ae375..bb23360 100644
>> --- a/virtManager/vmmenu.py
>> +++ b/virtManager/vmmenu.py
>> @@ -128,7 +128,7 @@ class VMActionMenu(_VMMenu):
>>  "suspend": bool(vm and vm.is_stoppable()),
>>  "resume": bool(vm and vm.is_paused()),
>>  "migrate": bool(vm and vm.is_stoppable()),
>> -"clone": True,
>> +"clone": bool(vm and vm.is_clonable()),
>>  }
>>  vismap = {
>>  "suspend": bool(vm and not vm.is_paused()),
>> 
>
>Technically we can clone an active VM, if it doesn't have any disks, but
>that's sufficiently rare that I don't think it's worth supporting in the UI.
>So ACK
>

Pushed, Thanks.

Regards,
- Chen

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


Re: [virt-tools-list] [virt-manager PATCH] virtManager: disable 'Clone' in VMActionMenu if VM can't be cloned

2016-09-30 Thread Cole Robinson
On 09/20/2016 11:59 PM, Chen Hanxiao wrote:
> From: Chen Hanxiao 
> 
> We can't clone a VM in some scenarios,
> such as a VM is active.
> 
> This patch will disable 'Clone' label in VMActionMenu
> if we can't clone a VM,
> as same as we did for 'Clone' button in clone ui page.
> 
> Signed-off-by: Chen Hanxiao 
> ---
>  virtManager/domain.py | 4 
>  virtManager/vmmenu.py | 2 +-
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/virtManager/domain.py b/virtManager/domain.py
> index a707f25..582de64 100644
> --- a/virtManager/domain.py
> +++ b/virtManager/domain.py
> @@ -1655,6 +1655,10 @@ class vmmDomain(vmmLibvirtObject):
>  return self.status() in [libvirt.VIR_DOMAIN_PAUSED]
>  def is_paused(self):
>  return self.status() in [libvirt.VIR_DOMAIN_PAUSED]
> +def is_clonable(self):
> +return self.status() in [libvirt.VIR_DOMAIN_SHUTOFF,
> + libvirt.VIR_DOMAIN_PAUSED,
> + libvirt.VIR_DOMAIN_PMSUSPENDED]
>  
>  def run_status(self):
>  return self.pretty_run_status(self.status(), self.has_managed_save())
> diff --git a/virtManager/vmmenu.py b/virtManager/vmmenu.py
> index a1ae375..bb23360 100644
> --- a/virtManager/vmmenu.py
> +++ b/virtManager/vmmenu.py
> @@ -128,7 +128,7 @@ class VMActionMenu(_VMMenu):
>  "suspend": bool(vm and vm.is_stoppable()),
>  "resume": bool(vm and vm.is_paused()),
>  "migrate": bool(vm and vm.is_stoppable()),
> -"clone": True,
> +"clone": bool(vm and vm.is_clonable()),
>  }
>  vismap = {
>  "suspend": bool(vm and not vm.is_paused()),
> 

Technically we can clone an active VM, if it doesn't have any disks, but
that's sufficiently rare that I don't think it's worth supporting in the UI.
So ACK

- Cole

___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list


[virt-tools-list] [virt-manager PATCH] virtManager: disable 'Clone' in VMActionMenu if VM can't be cloned

2016-09-20 Thread Chen Hanxiao
From: Chen Hanxiao 

We can't clone a VM in some scenarios,
such as a VM is active.

This patch will disable 'Clone' label in VMActionMenu
if we can't clone a VM,
as same as we did for 'Clone' button in clone ui page.

Signed-off-by: Chen Hanxiao 
---
 virtManager/domain.py | 4 
 virtManager/vmmenu.py | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/virtManager/domain.py b/virtManager/domain.py
index a707f25..582de64 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -1655,6 +1655,10 @@ class vmmDomain(vmmLibvirtObject):
 return self.status() in [libvirt.VIR_DOMAIN_PAUSED]
 def is_paused(self):
 return self.status() in [libvirt.VIR_DOMAIN_PAUSED]
+def is_clonable(self):
+return self.status() in [libvirt.VIR_DOMAIN_SHUTOFF,
+ libvirt.VIR_DOMAIN_PAUSED,
+ libvirt.VIR_DOMAIN_PMSUSPENDED]
 
 def run_status(self):
 return self.pretty_run_status(self.status(), self.has_managed_save())
diff --git a/virtManager/vmmenu.py b/virtManager/vmmenu.py
index a1ae375..bb23360 100644
--- a/virtManager/vmmenu.py
+++ b/virtManager/vmmenu.py
@@ -128,7 +128,7 @@ class VMActionMenu(_VMMenu):
 "suspend": bool(vm and vm.is_stoppable()),
 "resume": bool(vm and vm.is_paused()),
 "migrate": bool(vm and vm.is_stoppable()),
-"clone": True,
+"clone": bool(vm and vm.is_clonable()),
 }
 vismap = {
 "suspend": bool(vm and not vm.is_paused()),
-- 
1.8.3.1


___
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list