Commit Graph

77 Commits

Author SHA1 Message Date
Cole Robinson 8fe0a208db Move virt-* code into their modules
This layout is closer to what most python modules have nowadays.
It also simplifies testing and static analysis setup.

Keep virt-* wrappers locally, for ease of running these commands
from a git checkout.

Adjust the wrapper binaries we install on via packaging to be
pure python, which makes things like running gdb easier.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-01-26 18:27:20 -05:00
Pavel Hrdina 29f9f5f2d7 virt-xml: fix defined_xml_is_unchanged
Commit <53f075ab76e1c372474ae0d88f202e487d9f213f> added a warning if the
VM XML is not changed after removing default devices but the code was
incorrect.  We have to compare strings instead of string vs Guest object
and also the condition was inverted.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2019-12-03 13:04:37 +01:00
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 53f075ab76 virt-xml: Warn if libvirt discards our defined changes
This can happen if we try to remove a default device, like
 a ps2 mouse on x86, but it can happen for many other reasons as well

https://bugzilla.redhat.com/show_bug.cgi?id=1405263
2019-06-16 17:08:59 -04:00
Cole Robinson f7854d0a84 virt-xml: Use VIR_DOMAIN_XML_SECURE
Otherwise we will lose data when editing VMs
2019-06-16 16:48:50 -04:00
Cole Robinson 52c6094c65 virt-xml: Denest and comment code flow a bit
Add lots of early exits to remove implicit fall through
behavior that I find hard to follow
2019-06-16 16:47:05 -04:00
Cole Robinson 0221471e4f virt-xml: If no XML diff is generated, explicitly warn 2019-06-16 16:37:48 -04:00
Cole Robinson 524002da02 virt-xml: Abide domain name for --build-xml
https://bugzilla.redhat.com/show_bug.cgi?id=1648939
2019-06-14 21:37:50 -04:00
Cole Robinson f6b87bd6d6 virt-xml: Remove virt_xml_setup hack
Not sure why this was originally required, but I can't think how
to even trigger this occasion nowadays
2019-06-14 12:38:51 -04:00
Cole Robinson bd7d213cf8 virt-xml: Add more test coverage 2019-06-14 12:37:35 -04:00
Cole Robinson 17ac0d017c virt-install: Drop --os-variant suboption parsing
Not sure I want to go down that route if we can avoid it. Instead
just fold the full_id support into the existing option handling.
Streamline the OSVariantData usage throughout the cli tools
2019-06-13 21:25:05 -04:00
Cole Robinson 8c8fec6cb1 cli: Rename parse_option_strings update= to editing=
Makes it more clear what the distinction is. Set this in the parser
class so the cli infrastructure can access it
2019-06-13 17:37:26 -04:00
Cole Robinson cc366fff7d cli: Add more code coverage 2019-06-11 17:51:25 -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 bc4573a14b Fix codespell errors 2019-05-16 14:43:31 -04:00
Cole Robinson 2a30a5f0bf cli: make parse() guest argument optional
Because the non-guest parsers don't need it.
2019-05-12 17:22:13 -04:00
Cole Robinson 3bd7c7c55b cli: Clarify guest_propname and list_propname
There's conflicting 'propname' naming now, so rename some usage
to match
2019-05-10 14:02:44 -04:00
Cole Robinson 7afbb90b4d virt-xml: Handle VM names that look like id/uuid (bz 1679025)
Previously we assume they are id/uuid, so if it's actually the VM
name then the command fails. Now we always check for a name first,

https://bugzilla.redhat.com/show_bug.cgi?id=1679025
2019-03-21 13:45:58 -04:00
Marc Hartmayer 90b1a3ab7d virt-xml: Add support for starting the domain
Add support for starting the domain. By default, first the domain is
defined and then started. If the `--start` is used in combination with
`--no-define` a transient domain is created without persisting the
changes in the persistent domain definition.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
2019-03-06 13:15:38 -05:00
Marc Hartmayer 29f9f2ac9c virt-xml: Add --no-define argument
Add `--no-define` argument. It's mutually exclusive to the `--define`
argument and later on it allows the user to start a domain
transiently.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
2019-03-06 13:15:38 -05:00
Cole Robinson 4a2ff83b51 cli: Parameterize --os-variant
For now it just takes a single name= parameter that maps to
the current behavior
2019-02-07 16:27:01 -05:00
Cole Robinson a9eecd591c cli: Rename options.distro_variant to options.os_variant
We don't really use the 'distro' naming any more, and the
command line option is called os_variant, so stick with that
2019-02-07 15:48:40 -05:00
Lin Ma bbe4866127 cli: Add function cli_flag_name and use it
It can convert the underscore to minus for cli_arg_name in help
output or error message.

Signed-off-by: Lin Ma <lma@suse.com>
2019-01-14 10:40:54 -05:00
Cole Robinson 6c28f53590 cli; Share --os-variant option registering
And improve the help message for both users
2019-01-08 12:44:53 -05: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
Lin Ma 4b09a26578 virt-xml: Add auto complete support for the general options
Signed-off-by: Lin Ma <lma@suse.com>
2018-12-18 11:20:35 -05:00
Andrea Bolognani d2d103a334 virt-xml: Start using --os-variant
The option only works with --add-device for the time being,
so we prevent its use in all other cases.

It would be nice to have it work with --build-xml too, but
in that case the user would have to provide some extra
information that in the case of --add-device we can figure
out from the existing guest, and it's not entirely clear
whether that would even be that useful, so for now we're
not considering that case at all.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-11-13 12:15:50 +01:00
Andrea Bolognani ade53764fc virt-xml: Accept --os-variant option
We're not doing anything with it yet, but having the
parser accept it means we can write tests and see how
their output changes once we wire it up in earnest.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-11-13 12:08:46 +01:00
Cole Robinson bd35f4711c devices: disk: Rename setup() to build_storage()
It's more explicit. Plus drop the supposedly generic setup()
entry point, storage is handled specially everywhere so it's
not a generic interface
2018-09-04 14:55:04 -04:00
Cole Robinson 882e9d1dee virt-xml: Call set_defaults on created XML objects 2018-09-04 14:55:04 -04:00
Cole Robinson ea413be214 xmlbuilder: Rename get_xml_config -> get_xml
The config part is redundant. Should have done this a long time ago
2018-08-31 16:52:02 -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
David H. Gutteridge 4a58a689db virt-xml: Warn when --update is inapplicable 2018-04-03 12:34:55 -04:00
Cole Robinson 46ec093a28 virt-xml: Make it more clear when changes take effect
shutdown could be interpreted as a soft reboot, which won't
apply the changes
2018-03-25 19:22:28 -04:00
Cole Robinson 8d0b1f80f1 cli: Have parser classes reference property names, not xmlbuilders
propertys already give us ways to access the backing class, and
switching to this method lets us drop some infrastructure in
xmlbuilder
2018-03-21 11:17:36 -04:00
Cole Robinson 3b88bfb1ee cli: Drop clear_attr property
It slightly complicates the generic machinery, and the one usage we
can handle directly
2018-03-21 11:17:36 -04:00
Cole Robinson f69b823fad devices: Switch to normal _XML_PROP_ORDER
Drop the register_device stuff, rename virtual_device_type
2018-03-21 11:17:36 -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 8c3388697c virt-xml: Remove redundant XML roundtripping
Based on how we do diff reporting it doesn't accomplish anything anyways
2018-02-22 18:48:31 -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 8b4befae60 virtinst: Drop UUID validation
It's redundant as libvirt will give us these checks already, and we
aren't even testing it
2017-12-14 12:45:01 -05:00
Chen Hanxiao 7f1b4cee82 pycodestyle: fix all E125 warnings
Fix all E125:
     Continuation line with same indent as next logical line

   Also remove ignore options of E125

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
2017-10-21 23:26:16 +08:00
Cole Robinson 4e7a6ad728 tests: pylint: Silence/fix a bunch of new warnings 2017-06-16 12:54:56 -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 38c10f70f8 virt-xml: Only print message if changes are applied 2017-03-06 22:15:46 -05:00
David H. Gutteridge 9a451e6faa Remove minor redundancy in action_remove_device()
There's no need to call util.listify() twice.
2017-02-16 13:31:32 -05:00
Cole Robinson 118bf85cba Apparently -tt doesn't work with #!/usr/bin/env ... 2016-06-17 16:38:57 -04:00
Cole Robinson 47dd38eb3e Use #!/usr/bin/env for python scripts
This is recommended for upstream, but not for downstream, like Fedora.
So change /usr/bin/env to /usr/bin/python2 at RPM install time to
match the ideal Fedora config.

https://fedoraproject.org/wiki/Features/SystemPythonExecutablesUseSystemPython
https://bugzilla.redhat.com/show_bug.cgi?id=1303282
2016-06-17 12:56:14 -04:00
Cole Robinson 984b368725 cli: Rework VirtCLIParser instantiation
Only initialize VirtCLIParser at actual parse time. The data that's
passed to __init__ is the particular data for that parse task, like
the option string, and the Guest object we are editing.

As a result we can drop the whole parsermap handling, since the
parserlist is immutable.

There's a bunch of other reworks mixed in like dropping the
VirtOptionString abstraction...
2016-06-14 10:51:50 -04:00