[et-mgmt-tools] [PATCH] Added a --replace option to virt-image which allows it to replace an existing machine if it is current running or defined

Bryan Kearney bkearney at redhat.com
Fri Jun 27 11:40:08 UTC 2008


Daniel P. Berrange wrote:
> On Thu, Jun 26, 2008 at 12:47:27PM -0400, "Bryan M. Kearney <bkearney at redhat.com>"@redhat.com wrote:
>> +                    if vm.ID() == -1:
>> +                        logging.info("Removing old definition for image %s" %(self.name))
>> +                        vm.undefine()
>> +                    else:
>> +                        logging.info("Destroying image %s" %(self.name))           
>> +                        vm.destroy()
> 
> You don't want this to be an either / or conditional. If the VM exists
> you should *always* attempt to undefine it - a running VM may or may
> not have a config file
> 
> So you want something closer to
> 
>      if vm.ID() != -1:
>         vm.destroy()
> 
>      try:
>         vm.undefine()
>      except:
>         pass
> 
> Daniel

I thought destroy did an undefine. I have made the change, will resend 
the patch.

-- bk




More information about the et-mgmt-tools mailing list