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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 26, 2008 at 12:47:27PM -0400, "Bryan M. Kearney <bkearney@xxxxxxxxxx>"@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
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/et-mgmt-tools

[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux