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:
parent
e61f2b991b
commit
a2fa799478
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from virtinst import Guest
|
||||||
from virtinst import OSDB
|
from virtinst import OSDB
|
||||||
from virtinst import urldetect
|
from virtinst import urldetect
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ class TestOSDB(unittest.TestCase):
|
|||||||
|
|
||||||
def test_recommended_resources(self):
|
def test_recommended_resources(self):
|
||||||
conn = utils.URIs.open_testdefault_cached()
|
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)
|
assert not OSDB.lookup_os("generic").get_recommended_resources(guest)
|
||||||
|
|
||||||
res = OSDB.lookup_os("fedora21").get_recommended_resources(guest)
|
res = OSDB.lookup_os("fedora21").get_recommended_resources(guest)
|
||||||
|
@ -18,7 +18,7 @@ def _make_guest(conn=None, os_variant=None):
|
|||||||
if not conn:
|
if not conn:
|
||||||
conn = utils.URIs.open_testdriver_cached()
|
conn = utils.URIs.open_testdriver_cached()
|
||||||
|
|
||||||
g = conn.caps.lookup_virtinst_guest()
|
g = virtinst.Guest(conn)
|
||||||
g.type = "kvm"
|
g.type = "kvm"
|
||||||
g.name = "TestGuest"
|
g.name = "TestGuest"
|
||||||
g.memory = int(200 * 1024)
|
g.memory = int(200 * 1024)
|
||||||
|
13
virt-install
13
virt-install
@ -316,8 +316,15 @@ def set_distro_variant(options, guest, installer):
|
|||||||
fail(_("Error validating install location: %s") % str(e))
|
fail(_("Error validating install location: %s") % str(e))
|
||||||
|
|
||||||
|
|
||||||
def do_test_media_detection(conn, url):
|
def do_test_media_detection(conn, options):
|
||||||
guest = conn.caps.lookup_virtinst_guest()
|
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 = virtinst.DistroInstaller(conn)
|
||||||
installer.location = url
|
installer.location = url
|
||||||
print_stdout(installer.detect_distro(guest), do_force=True)
|
print_stdout(installer.detect_distro(guest), do_force=True)
|
||||||
@ -918,7 +925,7 @@ def main(conn=None):
|
|||||||
conn = cli.getConnection(options.connect)
|
conn = cli.getConnection(options.connect)
|
||||||
|
|
||||||
if options.test_media_detection:
|
if options.test_media_detection:
|
||||||
do_test_media_detection(conn, options.test_media_detection)
|
do_test_media_detection(conn, options)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
guest, installer = build_guest_instance(conn, options)
|
guest, installer = build_guest_instance(conn, options)
|
||||||
|
@ -233,7 +233,7 @@ def _import_file(conn, input_file):
|
|||||||
|
|
||||||
|
|
||||||
# Generate the Guest
|
# Generate the Guest
|
||||||
guest = conn.caps.lookup_virtinst_guest()
|
guest = virtinst.Guest(conn)
|
||||||
if not name:
|
if not name:
|
||||||
name = os.path.basename(input_file)
|
name = os.path.basename(input_file)
|
||||||
|
|
||||||
|
@ -284,7 +284,7 @@ class vmx_parser(parser_class):
|
|||||||
not os.path.exists(disk.path)):
|
not os.path.exists(disk.path)):
|
||||||
disk.path = None
|
disk.path = None
|
||||||
|
|
||||||
guest = conn.caps.lookup_virtinst_guest()
|
guest = virtinst.Guest(conn)
|
||||||
guest.name = name.replace(" ", "_")
|
guest.name = name.replace(" ", "_")
|
||||||
guest.description = desc or None
|
guest.description = desc or None
|
||||||
if vcpus:
|
if vcpus:
|
||||||
|
@ -349,13 +349,3 @@ class Capabilities(XMLBuilder):
|
|||||||
gobj.capsinfo = capsinfo
|
gobj.capsinfo = capsinfo
|
||||||
|
|
||||||
return gobj
|
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)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user