Commit Graph

5678 Commits

Author SHA1 Message Date
Cole Robinson dae8642bb1 xmlbuilder: centralize adding child new child prop instances
Currently the domain CPU class has a child property like:

  siblings = XMLChildProperty(_CPUCellSibling)

If a user wants to add a new sibling, we add a convenience function:

    def add_sibling(self):
        obj = _CPUCellSibling(self.conn)
        self.add_child(obj)
        return obj

Rather than require every child property to define a similar matching
helper function, this adds infrastructure in xmlbuilder to do this
generically for every child property. Now callers can do

    obj = guest.cpu.siblings.add_new()
2018-02-08 14:03:47 -05:00
Cole Robinson 8819176ad4 xmlbuilder: Drop unused node_top_xpath 2018-02-07 15:45:38 -05:00
Cole Robinson 598be36862 xmlbuilder: drop is_build monkey patching
It's not needed
2018-02-07 15:38:30 -05:00
Cole Robinson 48037fcf6f spec: Remove obsolete icon/desktop cache commands
Handled in Fedora for a while now
2018-02-06 19:02:53 -05:00
Cole Robinson 3cb33d381c Update docs to use new setup.py invocation 2018-02-06 19:02:53 -05:00
Cole Robinson b42e37be1f Fix last bits of python3 pylint 2018-02-06 19:02:53 -05:00
Cole Robinson de791136c1 setup: Use pylint-3 2018-02-06 19:02:53 -05:00
Cole Robinson 03971cef11 spec: Update for python3
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2018-02-06 19:02:53 -05:00
Cole Robinson ddba9c1702 Switch to python3 in script shebang
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2018-02-06 18:56:15 -05:00
Cole Robinson e47b34c05a Fix initrdinject and urltests with py3
A few random issues scattered about
2018-02-06 18:56:15 -05:00
Cole Robinson b8e2952a9c connect: Fix urllib usage on py3 2018-02-06 18:56:15 -05:00
Cole Robinson 3086c7fda9 Drop python3 compat imports
We are going completely python3
2018-02-06 18:56:15 -05:00
Cole Robinson e90d728380 urlfetcher: Open local files as binary
Needed for proper functioning on python3
2018-02-06 18:49:17 -05:00
Radostin Stoyanov 15bd408570 Replace raw_input() with input()
raw_input() was renamed to input() in Python 3

See https://www.python.org/dev/peps/pep-3111/
2018-02-06 18:49:17 -05:00
Radostin Stoyanov e3d35b2fb9 tests: cli: Handle UnicodeError when logging 2018-02-06 18:49:17 -05:00
Radostin Stoyanov 81d68e6100 Use StringIO instad of BytesIO in Py 3
The print function in Python will convert printed arguments to text
strings [1] and thus print() cannot be used with binary mode file
objects.

In Python 2 the write() method of BytesIO() takes as input *bytes* object
which refers to *str* in Python 3. [2] The write() method of StringIO()
takes *unicode* object. [3] Therefore, StringIO() object cannot be used with
the print() function.

In Python 3 the write() method of BytesIO() takes a *bytes* object (not
*str*). [4] Therefore, the BytesIO() obj cannot be used with print().
However, the write() method of StringIO() in Python 3 takes a *str* as
input.[5]

Example of the issue:

    from __future__ import print_function
    import io

    a = io.BytesIO()
    b = io.StringIO()

    print("test", file=a)  <- Fails for Python 3
    print("test", file=b)  <- Fails for Python 2

    a.write('%s\n' % "test")  <- Fails for Python 3
    b.write('%s\n' % "test")  <- Fails for Python 2

[1] https://docs.python.org/3.5/library/functions.html#print
[2] https://docs.python.org/2/library/io.html#io.BufferedWriter.write
[3] https://docs.python.org/2/library/io.html#io.TextIOBase.write
[4] https://docs.python.org/3/library/io.html#io.BufferedWriter.write
[5] https://docs.python.org/3/library/io.html#io.TextIOBase.write
2018-02-06 18:49:17 -05:00
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