Commit Graph

59 Commits

Author SHA1 Message Date
Cole Robinson f107e39989 Switch to more traditional logging structure
Init a shared log instance in virtinst/logger.py, and use that
throughout the code base, so we aren't calling directly into
'logging'. This helps protect our logging output from being
cluttered with other library output, as happens with some
'requests' usage
2019-06-17 00:12:31 -04:00
Cole Robinson 088657a2b8 storage: Kill get_default_dir
The last location is in virt-convert, which has weird local directory
creation semantics. Just have it use storage APIs like we do
everywhere else
2019-06-11 17:54:45 -04:00
Cole Robinson 388850f04e virtinst: Rename util to xmlutil
The only functions left in there are largely for xml handling, so
make it explicit
2019-06-07 18:21:24 -04:00
Cole Robinson 2510c299f5 Use shutil.which instead of distutils find_executable
The former is the more standard library method for this
with python3
2019-06-05 16:35:34 -04:00
Cole Robinson 135b97637e guest: Rename memory properties to match XML values
Right now we have:

* memory -> ./currentMemory
* maxmem -> ./memory
* hotplugmaxmem -> ./maxMemory

Which is just a mess to know what we might be really setting behind
the scenes. Rename the properties to match the XML element name, and
adjust all users to the new names. cli options aren't changed though
2019-05-12 17:25:47 -04:00
Cole Robinson 2f89ecf4a9 Remove Author lines from file headers
Similar to what was done in libvirt. See these commits:

600462834f
c99e954973
2019-01-08 11:45:35 -05:00
Cole Robinson a2fa799478 capabilities: Drop lookup_virtinst_guest
Users should just init Guest() directly, and call
set_capabilities_defaults if they need default arch data
2018-09-06 20:28:05 -04:00
Cole Robinson 2ac54ac001 guest: Drop self.installer and start_install wrapper
This changes all the callers to invoke start_install directly on the
Installer object. We still stash the installer instance inside the
guest object in create.py, just for simplicity
2018-09-04 14:55:04 -04:00
Cole Robinson c154bbacd4 guest: Fold add_default_devices into set_defaults
It doesn't have any need anymore to be separate
2018-09-04 14:55:04 -04:00
Cole Robinson 068c8aedd2 installer: Remove ContainerInstaller and ImportInstaller
Fold their non-logic into the base Installer class
2018-09-04 14:55:04 -04:00
Daniel P. Berrangé b1460ba065 Chagne most URIs to use https:// instead of http://
All URLs were checked to see if they supported https://, those which did
were converted.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-30 13:35:39 -04:00
Daniel P. Berrangé 48e32b429d Fix copyright header to specify GPLv2 or later, not GPLv2 only.
The copyright headers in every file were chjanged in this previous commit

  commit b6dcee8eb7
  Author: Cole Robinson <crobinso@redhat.com>
  Date:   Tue Mar 20 15:00:02 2018 -0400

    Use consistent and minimal license header for every file

Where before this they said "

  "either version 2 of the License, or (at your option) any later version."

Now they just say

  "GNU GPLv2"

This fixes it to say "GNU GPLv2 or later" again.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-04 16:51:37 -04:00
Cole Robinson 7b61c45d3b guest: Move all_devices to guest.devices.X
The way we enumerate devices doesn't conform with the way all
other XMLBuilder instances expose child objects. Move more towards
that direction.

This requires some virt-xml and cli.py hacks but we will remove those
in future patches
2018-03-21 11:17:36 -04:00
Cole Robinson b6dcee8eb7 Use consistent and minimal license header for every file 2018-03-21 07:29:40 -04:00
Cole Robinson 1c911ce567 virtinst: Give device classes consistent DeviceX naming
Previous state was inconsistenty and needlessly wordy. Fix up
a few other class namings that have redundant Virtual in the name
2018-03-21 07:29:40 -04:00
Cole Robinson 472a52b170 virtconv: Drop all the chdir hackery
This was just lazy stuff to avoid having to assumble abspaths. Plus
it confuses cprofile
2018-02-22 20:49:07 -05:00
Cole Robinson ab884b620f virtconv: ovf: convert to ElementTree 2018-02-14 09:57:39 -05:00
Cole Robinson 8e7b5ed2d8 Drop __future__ imports, no longer needed 2018-02-08 14:08:23 -05:00
Cole Robinson d2648d81cc virtconv: Don't implicitly depend on dict hash order 2017-10-20 16:13:04 -04:00
Radostin Stoyanov 37ea520773 Replace 'StandardError' with 'Exception'
Python 2 has an exception class called StandardError that has
been removed in Python 3. Use Exception instead. [1]

[1] http://python3porting.com/differences.html#standarderror
2017-10-20 13:18:31 -04:00
Radostin Stoyanov 63fce081ed pycodestyle: Use isinstance() for type checking
This is E721 in pycodestyle [1]:
   "do not compare types, use ‘isinstance()’"

The main differece between "type() is" and "isinstance()" is that
isinstance() supports inheritance. [1]

This can be seen in the example below:
    >>> type(True) is int
    False
    >>> isinstance(True, int)
    True

As we can see in python 'bool' a subclass of 'int'.

[1] https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes
[2] https://docs.python.org/2/library/functions.html#isinstance
2017-10-20 11:49:13 -04:00
Radostin Stoyanov b93cc3bbc9 pycodestyle: Do not use bare 'except:'
A bare 'except:' catches all exceptions [1], including SystemExit,
KeyboardInterrupt, and GeneratorExit (which is not an error and should
not normally be caught by user code). In situations where you need to
catch all “normal” errors, you can catch the base class for all normal
exceptions, Exception [2].

[1] https://docs.python.org/2/howto/doanddont.html#except
[2] https://docs.python.org/2/library/exceptions.html#Exception
2017-08-02 13:57:43 -04:00
Cole Robinson 55288c4551 Convert to python3 style print() syntax
Use __future__ imports to keep this working for python2
2017-05-05 14:52:37 -04:00
Cole Robinson 62feeb02a8 Switch to python3 style 'except X as Y' notation
Which also works with python2.7
2017-05-05 14:52:11 -04:00
Cole Robinson f4dfb6de9d Fix recent pylint/pep8 output 2016-04-18 16:42:12 -04:00
Lin Ma f11eb00b9a virt-convert: decompress the .gz files before converting
The OVF specification v1.1.0(page 15) indicates that "Each file
referenced by a File element may be compressed using gzip
(see RFC1952)."

In this case the .gz files should be decompressed first before
converting through qemu-img.

Signed-off-by: Lin Ma <lma@suse.com>
2016-03-09 20:06:16 -05:00
Michal Privoznik 58ac786b6b virt-convert: Don't detect existing paths in test suite
We have this option --dry-run that should run through the
installation process but don't actually touch anything. Just
pretend the installation. And we have a test that uses it
heavily. However, the test is failing:

  Traceback (most recent call last):
    File "/home/zippy/work/virt-manager.git/tests/clitest.py", line 161, in _launch_command
      ret = virtconvert.main(conn=conn)
    File "virt-convert", line 111, in main
      destdir=options.destination, dry=options.dry)
    File "/home/zippy/work/virt-manager.git/virtconv/formats.py", line 314, in convert_disks
      newpath)
  RuntimeError: New path name '/var/lib/libvirt/images/fedora.qcow2' already exists

Problem is, even in test suite we really touch the host paths.
This in general will spit unpredictable results. Resolution
consists of making this specific part of the code fault tolerant
if ran under test suite.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-01-15 11:42:37 -05:00
Lin Ma 21fd079eb1 Replace the unar to more common archivers
Because some of distributions dont provide the unar (universal archiver),
Using more common archivers to replace it.

Signed-off-by: Lin Ma <lma@suse.com>

(crobinso: adjust test suite)
2016-01-10 18:23:29 -05:00
Pavel Hrdina c7049eb120 pep8 W503: line break before binary operator
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-07-14 13:01:20 -04:00
Pavel Hrdina 0fbe8e7a1f translation: fix wrong usage of _() function
All the strings have to be at first translated and then we can fill the
formated and translated string.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2015-06-05 16:33:51 -04:00
Cole Robinson 45e6cd4cac Remove redundant 'default dir' functions 2015-05-02 19:48:04 -04:00
Cole Robinson 97259c4d9b capabilities: Store results of guest_lookup together
Simplifies API users lives to not have to remember whether caps guest
or caps domain contains a particular value.
2015-04-03 17:37:08 -04:00
Cole Robinson e3de3d8b69 virt-convert: Fix pointing to relative config file 2014-09-20 18:29:20 -04:00
Cole Robinson eb7612356e virtinst: Switch to relative imports, fix cyclic import warnings 2014-09-12 16:28:38 -04:00
Chen Hanxiao 75d43f6a37 fix some missed binary prefixes for units
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2014-06-17 09:33:14 +08:00
Cole Robinson 506791157e Fix some pylint 2014-05-31 17:37:19 -04:00
Cole Robinson eca6cd9471 virt-convert: Don't print 'convert' output with --print-xml 2014-05-31 16:41:30 -04:00
Cole Robinson ceab99cf7b virtconv: Don't create default pool when in dry mode
We will still need to create pools to probe source storage if doing
--print-xml.
2014-05-31 16:30:00 -04:00
Cole Robinson 876c721d8e virt-convert: Fix use of relative OVF file 2014-05-31 16:05:29 -04:00
Cole Robinson 196ff823b3 Fix warnings with latest pep8 2014-05-02 10:20:59 -04:00
Chen Hanxiao 98a27fc7fd formats: make sure 'unar' is existed
Commit 0b4a72fd77
need unar command to do something.

But if we haven't installed it, the error message
told us nothing valuable as:
"OSError: [Errno 2] No such file or directory"

This patch will impove the error message.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2014-03-06 09:22:03 +08:00
Cole Robinson 0b4a72fd77 virt-convert: Reimplement it
We totally break CLI compat here, but the previous tool wasn't sustainable.
Instead, repurpose the tool as strictly converting external formats
like ovf/vmx to native libvirt XML, and launch the guest.

So we drop vmx/virt-image output, and virt-image input, and a slew of
command line options. I don't think anyone was depending on this in a
scripted fashion, so in practice I don't think anyone will care.

Add much more comprehensive unit tests while we are at it.
2014-02-07 21:16:09 -05:00
Giuseppe Scrivano 2a040ccd17 mass update: remove double spaces from comments
Updated by this script:

find -name '*.py' -exec sed -i "s|^\(#.*[^.?\!]\)  \(.*[^#]\)$|\1 \2|g" \{\} \;

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2013-10-28 17:22:31 +01:00
Giuseppe Scrivano 0df75c7603 headers: update "Red Hat, Inc." copyright for the year 2013
Ensure that any file touched by a @redhat.com author in 2013 has an
updated copyright header.

The files were updated using the build-aux/update-copyright gnulib
script and manually added where the copyright line wasn't present.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2013-10-28 17:22:26 +01:00
Cole Robinson a6d92c7001 Drop a lot of usage of utility XML functions 2013-09-22 17:34:53 -04:00
Cole Robinson c426d5a16f Guest: Drop os_type, just use single os_variant
Internally the distinction hasn't been valuable for a long time,
so simplify the API here.
2013-08-11 12:39:36 -04:00
Cole Robinson 1d0695abd2 virtconv: Drop reference to OS_TYPES 2013-08-11 12:39:28 -04:00
Cole Robinson 01629d3f2c virtinst: Combine ImageInstaller and ImageParser code
They aren't touched much these days, so unify the files for clarity.
2013-08-08 21:00:37 -04:00
Cole Robinson 0d5fe93048 Centralize XML helpers in virtinst/util.py 2013-07-12 13:10:23 -04:00
Cole Robinson 94f8d4cfa9 VirtualConnection: cache capabilities XML
This means we can drop passing around the pre-parsed caps info everywhere.
2013-07-06 14:12:13 -04:00