1
0
mirror of https://github.com/virt-manager/virt-manager.git synced 2025-01-10 01:18:03 +03:00

capabilities: Drop lookup_virtinst_guest

Users should just init Guest() directly, and call
set_capabilities_defaults if they need default arch data
This commit is contained in:
Cole Robinson 2018-09-06 20:28:05 -04:00
parent e61f2b991b
commit a2fa799478
6 changed files with 15 additions and 17 deletions

View File

@ -5,6 +5,7 @@
import unittest
from virtinst import Guest
from virtinst import OSDB
from virtinst import urldetect
@ -25,7 +26,7 @@ class TestOSDB(unittest.TestCase):
def test_recommended_resources(self):
conn = utils.URIs.open_testdefault_cached()
guest = conn.caps.lookup_virtinst_guest()
guest = Guest(conn)
assert not OSDB.lookup_os("generic").get_recommended_resources(guest)
res = OSDB.lookup_os("fedora21").get_recommended_resources(guest)

View File

@ -18,7 +18,7 @@ def _make_guest(conn=None, os_variant=None):
if not conn:
conn = utils.URIs.open_testdriver_cached()
g = conn.caps.lookup_virtinst_guest()
g = virtinst.Guest(conn)
g.type = "kvm"
g.name = "TestGuest"
g.memory = int(200 * 1024)

View File

@ -316,8 +316,15 @@ def set_distro_variant(options, guest, installer):
fail(_("Error validating install location: %s") % str(e))
def do_test_media_detection(conn, url):
guest = conn.caps.lookup_virtinst_guest()
def do_test_media_detection(conn, options):
url = options.test_media_detection
guest = virtinst.Guest(conn)
if options.arch:
guest.os.arch = options.arch
if options.os_type:
guest.os.os_type = options.os_type
guest.set_capabilities_defaults()
installer = virtinst.DistroInstaller(conn)
installer.location = url
print_stdout(installer.detect_distro(guest), do_force=True)
@ -918,7 +925,7 @@ def main(conn=None):
conn = cli.getConnection(options.connect)
if options.test_media_detection:
do_test_media_detection(conn, options.test_media_detection)
do_test_media_detection(conn, options)
return 0
guest, installer = build_guest_instance(conn, options)

View File

@ -233,7 +233,7 @@ def _import_file(conn, input_file):
# Generate the Guest
guest = conn.caps.lookup_virtinst_guest()
guest = virtinst.Guest(conn)
if not name:
name = os.path.basename(input_file)

View File

@ -284,7 +284,7 @@ class vmx_parser(parser_class):
not os.path.exists(disk.path)):
disk.path = None
guest = conn.caps.lookup_virtinst_guest()
guest = virtinst.Guest(conn)
guest.name = name.replace(" ", "_")
guest.description = desc or None
if vcpus:

View File

@ -349,13 +349,3 @@ class Capabilities(XMLBuilder):
gobj.capsinfo = capsinfo
return gobj
def lookup_virtinst_guest(self, *args, **kwargs):
"""
Call guest_lookup and pass the results to build_virtinst_guest.
This is a shortcut for API users that don't need to do anything
with the output from guest_lookup
"""
capsinfo = self.guest_lookup(*args, **kwargs)
return self.build_virtinst_guest(capsinfo)