Radostin Stoyanov
5146d66126
python3 compat: python3 strings have no decode()
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
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
a9e3e50046
xmlbuilder: Improve __repr__ a bit
...
To show child class name as well
2017-03-08 13:59:11 -05:00
Cole Robinson
22b6becd5d
guest: Add support for qemu cli passthrough
...
This is for xml like:
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0 '>
...
</devices>
<qemu:commandline>
<qemu:arg value='-newarg'/>
<qemu:env name='QEMU_ENV' value='VAL'/>
</qemu:commandline>
</domain>
Requires some extensions to the xmlbuilder infrastructure
2017-03-06 22:15:46 -05:00
Cole Robinson
8424d7fa7c
xmlbuilder: Pass around top level xpath context
...
Rather than instantiate it for every object. Gives about a 10% speed up
to to the test suite.
Clean up how we pass around this info a bit
2017-03-06 22:15:46 -05:00
Marc-André Lureau
1f0d1d3f7d
xmlbuilder: add a __repr__ for XMLBuilder object
...
To help with debugging.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com >
2017-02-23 19:42:00 -05:00
Cole Robinson
eb2a56f700
util: Move xml_indent to XMLBuilder
2016-08-24 15:56:13 -04:00
Cole Robinson
b08647c2f2
xmlbuilder: Handle setting conditional xpaths correctly
...
So if xml=<foo> and xpath=./bar[@baz='foo'] and val=XXX, xmlbuilder
previously would generate XML
<foo>
<bar>XXX</bar>
</foo>
But now generates the expected
<foo>
<bar baz='foo'/>XXX</bar>
</foo>
No users yet, but they are incoming
2016-07-18 14:46:50 -04:00
Cole Robinson
835ddc5f77
xmlbuilder: More comments for _build_xpath_node
2016-07-18 14:46:50 -04:00
Cole Robinson
a931a1a6ad
xmlbuilder: Opencode single addnode= usage
2016-07-18 14:46:50 -04:00
Cole Robinson
559e813b96
xmlbuilder: Clarify the node 'pretty' helper function
2016-07-18 14:46:50 -04:00
Cole Robinson
d8a0a78805
xmlbuilder: Update XMLProperty docs
2016-07-18 14:46:50 -04:00
Cole Robinson
55327c81b7
xmlbuilder: Support clear()ing an object in place
...
This gives friendly XML output via virt-xml for clearxml=yes +
extra options: the XML block is editted in place, rather than removed
and with the newchanges appended
2016-05-20 14:51:31 -04:00
Cole Robinson
333103adbf
xmlbuilder: minor cleanup
2016-05-20 14:51:31 -04:00
Cole Robinson
f4dfb6de9d
Fix recent pylint/pep8 output
2016-04-18 16:42:12 -04:00
Cole Robinson
d449fb6fd5
xmlbuilder: Kill make_xpath_cb
...
There's no users left, and it's better to come up with a solution at
the caller anyways
2015-09-05 17:20:43 -04:00
Cole Robinson
7786c4b35b
xmlbuilder: Make clear() work for child objects
...
So we can call clear() on a Guest owned VirtualDisk, and it actually
does the correct thing. This allows us to enable clearxml= cli option
for most devices.
2015-09-05 13:16:35 -04:00
Cole Robinson
4d87d2f27b
cli: Make child lookup not specific to guest devices
...
<seclabel> is not singleton nowadays, so we need to extend our
infrastructure to handle non-device child properties. This is part of
that
2015-09-04 16:16:25 -04:00
Cole Robinson
acfb988945
xmlbuilder: Make _add_child and _remove_child public
...
We have a lot of functions that are just wrappers around these, so
make it public for future use.
2015-09-04 15:47:43 -04:00
Cole Robinson
070664b9e7
tests: Enable property checking for all objects
...
And loosen restrictions a bit so any read/write will trigger the
tracking.
2015-04-22 16:26:03 -04:00
Cole Robinson
e125aa69d8
nodedev: Handle busted 'system' XML
...
Libvirt can generated invalid XML for the system nodedev device:
https://bugzilla.redhat.com/show_bug.cgi?id=1184131
This hits at least two people, so catch this specific case, but the
real fix is libvirt not outputing busted XML.
2015-03-26 18:04:23 -04:00
Cole Robinson
0e67ffba2e
xmlbuilder: Remove now unused clear_attrs infrastructure
2014-12-04 15:29:12 -05:00
Cole Robinson
86417d42ca
osxml: Ensure kernel/initrd/dtb are absolute paths
2014-09-23 14:32:01 -04:00
Cole Robinson
052220cfc8
virtinst: Add DomainCapabilities parser
2014-09-17 18:29:24 -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
a398d245cb
Clean up pylint integration
...
- Drop no longer needed disable= bits
- Use string names for all skipped pylint messages
2014-04-02 19:00:24 -04:00
Cole Robinson
0b94c83beb
xmlbuilder: Actually import logging
2014-02-25 14:56:54 -05:00
Cole Robinson
87c2ff1a14
xmlbuilder: Log broken XML if we can't parse it
...
Related to https://bugzilla.redhat.com/show_bug.cgi?id=1066564
2014-02-25 12:45:15 -05:00
Cole Robinson
d76aab264e
tests: Only use one env variable to notify we are running tests
2014-02-10 14:47:20 -05:00
Cole Robinson
dde460e399
xmlbuilder: Fix adding devices with child properties
...
And test it
2014-01-27 19:55:37 -05:00
Cole Robinson
9f5a842a3a
xmlbuilder: Make clear() remove unknown XML properties
2014-01-25 17:20:30 -05:00
Cole Robinson
16c8c31cbd
xmlbuilder: Remove unneeded argument to _remove_xpath_node
2014-01-25 17:20:30 -05:00
Cole Robinson
5edf4de058
xmlbuilder: Only pass xml context to _remove_xpath_node
...
Was confusing otherwise, and can give us a speedup.
2014-01-25 17:20:29 -05:00
Cole Robinson
5c762a9851
simplify remove_ node args
2014-01-25 17:20:29 -05:00
Cole Robinson
329ebe0746
xmlbuilder: Remove some unneeded redirection
2014-01-25 17:20:29 -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
Cole Robinson
3f532fe263
VirtualDisk: Handle the blktap default
...
And cache the blktap lookup once for the localhost
2013-10-06 13:17:35 -04:00
Cole Robinson
9ec845af03
xmlbuilder: Unify make_xpath callbacks
2013-09-24 09:25:05 -04:00
Cole Robinson
b690557a53
Convert NodeDevice to XMLBuilder
2013-09-23 08:25:20 -04:00
Cole Robinson
1c0475feff
xmlbuilder: Make prop cache work with subclasses
2013-09-23 07:38:22 -04:00
Cole Robinson
cadf5ba770
xmlbuilder: Cache class property maps
...
Shaves about 20 seconds off the test suite
2013-09-20 11:30:33 -04:00
Cole Robinson
85e81df01a
xmlbuilder: Serialize child objects even if they aren't in PROP_ORDER
...
This was just a bug
2013-09-20 11:17:11 -04:00
Cole Robinson
a23f1794d0
guest stuff
2013-09-20 10:55:48 -04:00
Cole Robinson
aff0ddb259
Use XMLBuilder for Storage object handling
...
Simplify the API a bunch while we are at it, add tests, etc.
2013-09-20 10:00:08 -04:00
Cole Robinson
3db5cb5f06
Use XMLBuilder for Interface XML
...
So we unify parsing and building the XML.
Since we already do this for vmmDomain, take the opportunity to move
the shared infrastructure into vmmLibvirtObject
2013-09-19 16:56:38 -04:00
Cole Robinson
cb06f7eb3d
xmlbuilder: Ensure top level XML objects always end with a newline
2013-09-19 13:48:28 -04:00
Cole Robinson
1aaf41b201
xmlbuilder: A couple optimizations
...
This brings the test suite back to pre-refactor speeds
2013-09-19 13:31:33 -04:00