Commit Graph

5512 Commits

Author SHA1 Message Date
Radostin Stoyanov 5146d66126 python3 compat: python3 strings have no decode() 2018-02-06 18:49:17 -05:00
Radostin Stoyanov 4d9c6141dd Convert the output of range() to list
In Python 2 the range() function returns a list [1].
In Python 3 the range function returns a range type [2] which
represents an immutable sequence of numbers [3].

[1] https://docs.python.org/2.7/library/functions.html#range
[2] https://docs.python.org/3/library/functions.html#func-range
[3] https://docs.python.org/3/library/stdtypes.html#typesseq-range
2018-02-06 18:49:17 -05:00
Radostin Stoyanov 5854b7bb17 Replace "Queue" with "queue"
The Queue module has been renamed to queue in Python 3. [1]

[1] https://docs.python.org/2/library/queue.html
2018-02-06 18:49:17 -05:00
Radostin Stoyanov 08c23477fd Fix re-raising exception
In Python 2 the raise command can take 3 objects as arguments which
are used to specify the exception to be raise as well as detailed
information and traceback [1].

In Python 3 the sintax is changed and now the keyword "from" and
"with_traceback" keyworkds are used to specify this information. [2]

Example which has the same behaviour for both Python 2 and 3:

    try:
        a = 1/0
    except Exception:
        import sys
        err = sys.exc_info()

        try:
                raise Exception("Test")
        except:
                pass

        if sys.version_info[0] == 2:
            exec("raise err[0], err[1], err[2]")
        else:
            raise
2018-02-06 18:49:17 -05:00
Radostin Stoyanov 95c695d774 Convert long to int
- Python 2 only
k = 9223372036854775808L

- Python 2 and 3:
k = 9223372036854775808

See http://python-future.org/compatible_idioms.html#long-integers
2018-02-06 18:49:17 -05:00
Radostin Stoyanov 6de65ab328 urlfetcher: Python 2/3 compatability for 'urllib'
The `urllib2` module has been split across several modules in Python 3
named `urllib.request` and `urllib.error`. [1]

[1] https://docs.python.org/2.7/library/urllib2.html
2018-02-06 18:49:17 -05:00
Radostin Stoyanov 5553cbeb38 Replace ipaddr module with ipaddress
The `ipaddress` is available in Python 3.3+ [1] and backport for
Python 2 is available on PyPI [2].

The main differences between ipaddr and ipaddress are:

- ipaddress *Network classes are equivalent to the ipaddr *Network
  class counterparts with the strict flag set to True.
- ipaddress *Interface classes are equivalent to the ipaddr *Network
  class counterparts with the strict flag set to False.
- The factory functions in ipaddress were renamed to disambiguate them
  from classes.
- A few attributes were renamed to disambiguate their purpose as well.
  (eg. network -> network_address, numhosts -> num_addresses)
- A number of methods and functions which returned containers in ipaddr
  now return iterators. This includes subnets, address_exclude,
  summarize_address_range and collapse_address_list.

Another major difference is that in Python 2 the `ipaddress` module
must use unicode. [3]

[1] https://www.python.org/dev/peps/pep-3144/
[2] https://pypi.python.org/pypi/ipaddress
[3] https://github.com/phihag/ipaddress
2018-02-06 18:49:17 -05:00
Radostin Stoyanov 978fb25ac7 Wrap keys(), values() in a list
In Python 3 dict.values() [1] , dict.keys() [2] and dict.items() [3]
return a view [4] of the dictionary’s values, keys and items.

In Python 2 these functions return a list. [5] [6] [7]

To resolve this we can convert the result of these function to a list.

[1] https://docs.python.org/3/library/stdtypes.html#dict.values
[2] https://docs.python.org/3/library/stdtypes.html#dict.keys
[3] https://docs.python.org/3/library/stdtypes.html#dict.items
[4] https://docs.python.org/3/library/stdtypes.html#dict-views
[5] https://docs.python.org/2/library/stdtypes.html#dict.items
[6] https://docs.python.org/2/library/stdtypes.html#dict.keys
[7] https://docs.python.org/2/library/stdtypes.html#dict.values
2018-02-06 18:49:17 -05:00
Radostin Stoyanov 810ee09292 Replace ConfigParser with configparser
The ConfigParser module has been renamed to configparser in
Python 3. [1] Backport of this changes is also available for
Python 2. [2]

[1] https://docs.python.org/2/library/configparser.html
[2] https://pypi.python.org/pypi/configparser/3.2.0r3
2018-02-06 18:49:17 -05:00
Cole Robinson 40c678783e Prep for release 1.5.0 2018-02-06 18:03:49 -05:00
Cole Robinson 5141e73416 man: Fix libvirt doc reference for startup_policy
Reported-by: Digimer <lists@alteeve.ca>
2018-02-06 10:24:32 -05:00
Wim ten Have 708516c39e virtinst: add vcpupin support
Add vcpupin support to virt-install so that it can create guest
domains with statically allocated vcpu pinning towards a given cpuset.

Syntax: to pin vcpu=0 to cpuset="1,3" and vcpu=1 to cpuset=2

  --cputune vcpupin0.vcpu=0,vcpupin0.cpuset=1,3,vcpupin1.vcpu=1,vcpupin1.cpuset=2

generates below XML description for the guest domain.

  <cputune>
    <vcpupin vcpu="0" cpuset="1,3"/>
    <vcpupin vcpu="1" cpuset="2"/>
  </cputune>

Signed-off-by: Wim ten Have <wim.ten.have@oracle.com>
Signed-off-by: Menno Lageman <menno.lageman@oracle.com>
2018-02-06 10:21:56 -05:00
Rauno Väli 582c1d3ded devicedisk: copy all rbd pool host and auth for volume
(crobinso: add test suite coverage, fix some pylint)
2018-01-30 11:30:22 -05:00
Menno Lageman ae5239358a virtinst: Add NUMA distance support
Now that libvirt has support for administration of distances between NUMA cells
it would be nice to be able to set those with virt-install directly instead of
having to 'virsh edit' the domain XML manually after installation.

For example

--cpu cell0.memory=1234,cell0.cpus=0-3,cell1.memory=5678,cell1.cpus=4-7,\
      cell0.distances.sibling0.id=0,cell0.distances.sibling0.value=10,\
      cell0.distances.sibling1.id=1,cell0.distances.sibling1.value=21,\
      cell1.distances.sibling0.id=0,cell1.distances.sibling0.value=21,\
      cell1.distances.sibling1.id=1,cell1.distances.sibling1.value=10

would generate the following XML:

     <cpu>
       <numa>
         <cell cpus="0-3" memory="1234">
           <distances>
             <sibling id="0" value="10"/>
             <sibling id="1" value="21"/>
           </distances>
         </cell>
         <cell cpus="4-7" memory="5678">
           <distances>
             <sibling id="0" value="21"/>
             <sibling id="1" value="10"/>
           </distances>
         </cell>
       </numa>
     </cpu>

Signed-off-by: Menno Lageman <menno.lageman@oracle.com>

(crobinso: rework cli format, drop some validation, drop man changes)
2018-01-30 11:19:54 -05:00
Cole Robinson cb6fc20210 cli: Drop python2ism with OSError 2018-01-27 16:27:41 -05:00
Cole Robinson bcdf7c8922 tests: inject: Fix some pylint 2018-01-27 16:27:41 -05:00
Cole Robinson 2fc2eed938 Drop more cmp() usage for python3 2018-01-27 16:27:41 -05:00
Cole Robinson 5e70cee128 tests: urls: Fix pylint 2018-01-27 16:12:11 -05:00
Cole Robinson ec8ee78d18 addhardware: Only add virtio-scsi if no other scsi controllers present 2018-01-27 16:07:26 -05:00
Radostin Stoyanov 6712261510 Python 2/3 division compatability
In Python 2 the classic devision of integers returns an integer
but in Python 3 it might return float.

Example:
- Python 2:          - Python 3:
    >>> 9 / 4            >>> 9 / 4
    2                    2.25
    >>> 9 // 4           >>> 9 // 4
    2                    2
    >>> 9 / 4.0          >>> 9 / 4.0
    2.25                 2.25
    >>> 9 // 4.0         >>> 9 // 4.0
    2.0                  2.0

For more info see: https://www.python.org/dev/peps/pep-0238/
2018-01-27 15:30:17 -05:00
Cole Robinson e9b4d35dd0 tests: inject: Small updates
Fix output, better debugging, update URL list
2018-01-27 15:28:19 -05:00
Cole Robinson 1f23d60725 tests: urls: Tweak output and logging a bit 2018-01-27 15:28:12 -05:00
Cole Robinson d66a438ae3 cli: Share find_inst_cb logic
All users follow a similar pattern, so generalize it
2018-01-26 14:09:06 -05:00
Cole Robinson 526d62a0e0 tests: Add 'magicuri' helper
Command line helper for generatin virtinst MagicURI-style URIs, like
we use in the test suite.
2018-01-21 15:08:16 -05:00
Cole Robinson f7c50ebe07 uitests: Add a test for command line errors 2018-01-21 14:42:44 -05:00
Cole Robinson 4a4207189f uitests: Add a live hotplug and media change test 2018-01-21 14:42:44 -05:00
Cole Robinson ab36d429d6 console: Add a basic spice GL + usbredir test 2018-01-21 14:42:44 -05:00
Cole Robinson 808f9975aa uitests: xml: drop hardcoded emulator path 2018-01-21 14:42:44 -05:00
Cole Robinson a10fda6b5c uitests: console: Add live lxc serial test 2018-01-21 14:42:44 -05:00
Cole Robinson d774d01e1c uitests: Add live console tests
Using transient VMs connecting to real qemu:///system. uitests are
already system invasive so I think this is okay
2018-01-21 14:42:44 -05:00
Cole Robinson 2fdf0c7ebe uitests: prefs: Move helper functions to util 2018-01-21 14:42:44 -05:00
Cole Robinson 2bfd2f28c1 uitests: More details config tweaking 2018-01-21 14:42:44 -05:00
Cole Robinson 94e4e8bf5a details: Tweak sound hwlist entry to be consistent with others
Dropping the colon
2018-01-21 14:42:44 -05:00
Cole Robinson c68cd7bb00 uitests: Add details editing tests 2018-01-21 14:42:44 -05:00
Cole Robinson d3137419d0 uitests: Add manager related tests 2018-01-21 10:02:08 -05:00
Cole Robinson c87bb3937d uitests: Add dbus remote cli test 2018-01-21 10:02:08 -05:00
Cole Robinson 3ccb947ce3 uitests: Add choosecd dialog tests 2018-01-21 10:02:08 -05:00
Cole Robinson a6c3fca7a7 uitests: Basic migration tests 2018-01-21 10:02:08 -05:00
Cole Robinson a9ba930936 uitests: newvm: Add a customize->addhardware test 2018-01-21 10:02:08 -05:00
Cole Robinson f1468cf1c7 uitests: addhardware error dialog tests 2018-01-21 10:02:08 -05:00
Cole Robinson 114cfb3479 uitests: addhardware controller tests 2018-01-21 10:02:08 -05:00
Cole Robinson e4c6c64653 addhardware: Don't allow adding floppy controller
It's either built in, or not available
2018-01-21 10:02:08 -05:00
Cole Robinson dc3c0b29f7 uitests: addhardware storage/disk testing 2018-01-21 10:02:08 -05:00
Cole Robinson c620e7405c uitests: addhardware: add network tests 2018-01-21 10:02:08 -05:00
Cole Robinson 72f006ae8b utils: Have find 'name' match labeller text too
Simplifies API callers
2018-01-21 10:02:05 -05:00
Cole Robinson d3b6df8e9a uitests: s/find_pattern/find/g 2018-01-19 11:05:23 -05:00
Cole Robinson 9232a51d55 uitests: Add a bunch of addhardware testing 2018-01-19 11:04:44 -05:00
Cole Robinson 402b42b14a watchdog: Add proper label for 'dump' action 2018-01-19 10:28:29 -05:00
Cole Robinson be03382e25 uitests: Add snapshot tests 2018-01-18 16:56:07 -05:00
Cole Robinson 2f12823cb5 snapshots: Maintain selection after refresh 2018-01-18 16:55:57 -05:00