Revive pep8 and clean up the code
autopep8 is pretty cool :)
This commit is contained in:
parent
fcc680cae1
commit
0d243983d0
26
setup.py
26
setup.py
|
@ -140,7 +140,7 @@ class my_build_icons(build_icons):
|
|||
for size in glob.glob(os.path.join(self.icon_dir, "*")):
|
||||
for category in glob.glob(os.path.join(size, "*")):
|
||||
icons = []
|
||||
for icon in glob.glob(os.path.join(category,"*")):
|
||||
for icon in glob.glob(os.path.join(category, "*")):
|
||||
if not os.path.islink(icon):
|
||||
icons.append(icon)
|
||||
if not icons:
|
||||
|
@ -418,17 +418,23 @@ class CheckPylint(Command):
|
|||
cmd += " ".join(files)
|
||||
os.system(cmd + " --rcfile tests/pylint.cfg")
|
||||
|
||||
print "running pep8"
|
||||
cmd = "pep8 "
|
||||
cmd += "--exclude scriptimports "
|
||||
cmd += " ".join(files)
|
||||
os.system(cmd + " --config tests/pep8.cfg")
|
||||
|
||||
|
||||
setup(
|
||||
name = "virt-manager",
|
||||
version = cliconfig.__version__,
|
||||
author = "Cole Robinson",
|
||||
author_email = "virt-tools-list@redhat.com",
|
||||
url = "http://virt-manager.org",
|
||||
license = "GPLv2+",
|
||||
name="virt-manager",
|
||||
version=cliconfig.__version__,
|
||||
author="Cole Robinson",
|
||||
author_email="virt-tools-list@redhat.com",
|
||||
url="http://virt-manager.org",
|
||||
license="GPLv2+",
|
||||
|
||||
# These wrappers are generated in our custom build command
|
||||
scripts = ([
|
||||
scripts=([
|
||||
"build/virt-manager",
|
||||
"build/virt-clone",
|
||||
"build/virt-install",
|
||||
|
@ -436,7 +442,7 @@ setup(
|
|||
"build/virt-convert"] +
|
||||
(cliconfig.with_tui and ["build/virt-manager-tui"] or [])),
|
||||
|
||||
data_files = [
|
||||
data_files=[
|
||||
("share/virt-manager/", [
|
||||
"virt-manager",
|
||||
"virt-install",
|
||||
|
@ -466,7 +472,7 @@ setup(
|
|||
glob.glob("virtconv/parsers/*.py")),
|
||||
] + tui_files,
|
||||
|
||||
cmdclass = {
|
||||
cmdclass={
|
||||
'build': my_build,
|
||||
'build_i18n': my_build_i18n,
|
||||
'build_icons': my_build_icons,
|
||||
|
|
|
@ -18,6 +18,7 @@ import os.path
|
|||
import unittest
|
||||
import virtinst.CapabilitiesParser as capabilities
|
||||
|
||||
|
||||
def build_host_feature_dict(feature_list):
|
||||
fdict = {}
|
||||
for f in feature_list:
|
||||
|
@ -25,6 +26,7 @@ def build_host_feature_dict(feature_list):
|
|||
|
||||
return fdict
|
||||
|
||||
|
||||
class TestCapabilities(unittest.TestCase):
|
||||
|
||||
def _compareGuest(self, (arch, os_type, domains, features), guest):
|
||||
|
@ -62,74 +64,74 @@ class TestCapabilities(unittest.TestCase):
|
|||
self._compareGuest(guests[idx], caps.guests[idx])
|
||||
|
||||
def testCapabilities1(self):
|
||||
host = ( 'x86_64', {'vmx': capabilities.FEATURE_ON})
|
||||
host = ('x86_64', {'vmx': capabilities.FEATURE_ON})
|
||||
|
||||
guests = [
|
||||
( 'x86_64', 'xen',
|
||||
[['xen', None, []]], {} ),
|
||||
( 'i686', 'xen',
|
||||
[['xen', None, []]], { 'pae': capabilities.FEATURE_ON } ),
|
||||
( 'i686', 'hvm',
|
||||
[['xen', "/usr/lib64/xen/bin/qemu-dm", ['pc', 'isapc']]], { 'pae': capabilities.FEATURE_ON | capabilities.FEATURE_OFF } ),
|
||||
( 'x86_64', 'hvm',
|
||||
[['xen', "/usr/lib64/xen/bin/qemu-dm", ['pc', 'isapc']]], {} )
|
||||
]
|
||||
('x86_64', 'xen',
|
||||
[['xen', None, []]], {}),
|
||||
('i686', 'xen',
|
||||
[['xen', None, []]], {'pae': capabilities.FEATURE_ON}),
|
||||
('i686', 'hvm',
|
||||
[['xen', "/usr/lib64/xen/bin/qemu-dm", ['pc', 'isapc']]], {'pae': capabilities.FEATURE_ON | capabilities.FEATURE_OFF}),
|
||||
('x86_64', 'hvm',
|
||||
[['xen', "/usr/lib64/xen/bin/qemu-dm", ['pc', 'isapc']]], {})
|
||||
]
|
||||
|
||||
self._testCapabilities("capabilities-xen.xml", host, guests)
|
||||
|
||||
def testCapabilities2(self):
|
||||
host = ( 'x86_64', {})
|
||||
host = ('x86_64', {})
|
||||
secmodel = ('selinux', '0')
|
||||
|
||||
guests = [
|
||||
( 'x86_64', 'hvm',
|
||||
[['qemu', '/usr/bin/qemu-system-x86_64', ['pc', 'isapc']]], {} ),
|
||||
( 'i686', 'hvm',
|
||||
[['qemu', '/usr/bin/qemu', ['pc', 'isapc']]], {} ),
|
||||
( 'mips', 'hvm',
|
||||
[['qemu', '/usr/bin/qemu-system-mips', ['mips']]], {} ),
|
||||
( 'mipsel', 'hvm',
|
||||
[['qemu', '/usr/bin/qemu-system-mipsel', ['mips']]], {} ),
|
||||
( 'sparc', 'hvm',
|
||||
[['qemu', '/usr/bin/qemu-system-sparc', ['sun4m']]], {} ),
|
||||
( 'ppc', 'hvm',
|
||||
('x86_64', 'hvm',
|
||||
[['qemu', '/usr/bin/qemu-system-x86_64', ['pc', 'isapc']]], {}),
|
||||
('i686', 'hvm',
|
||||
[['qemu', '/usr/bin/qemu', ['pc', 'isapc']]], {}),
|
||||
('mips', 'hvm',
|
||||
[['qemu', '/usr/bin/qemu-system-mips', ['mips']]], {}),
|
||||
('mipsel', 'hvm',
|
||||
[['qemu', '/usr/bin/qemu-system-mipsel', ['mips']]], {}),
|
||||
('sparc', 'hvm',
|
||||
[['qemu', '/usr/bin/qemu-system-sparc', ['sun4m']]], {}),
|
||||
('ppc', 'hvm',
|
||||
[['qemu', '/usr/bin/qemu-system-ppc',
|
||||
['g3bw', 'mac99', 'prep']]], {} ),
|
||||
]
|
||||
['g3bw', 'mac99', 'prep']]], {}),
|
||||
]
|
||||
|
||||
self._testCapabilities("capabilities-qemu.xml", host, guests, secmodel)
|
||||
|
||||
def testCapabilities3(self):
|
||||
host = ( 'i686', {})
|
||||
host = ('i686', {})
|
||||
|
||||
guests = [
|
||||
( 'i686', 'hvm',
|
||||
('i686', 'hvm',
|
||||
[['qemu', '/usr/bin/qemu', ['pc', 'isapc']],
|
||||
['kvm', '/usr/bin/qemu-kvm', ['pc', 'isapc']]], {} ),
|
||||
( 'x86_64', 'hvm',
|
||||
[['qemu', '/usr/bin/qemu-system-x86_64', ['pc', 'isapc']]], {} ),
|
||||
( 'mips', 'hvm',
|
||||
[['qemu', '/usr/bin/qemu-system-mips', ['mips']]], {} ),
|
||||
( 'mipsel', 'hvm',
|
||||
[['qemu', '/usr/bin/qemu-system-mipsel', ['mips']]], {} ),
|
||||
( 'sparc', 'hvm',
|
||||
[['qemu', '/usr/bin/qemu-system-sparc', ['sun4m']]], {} ),
|
||||
( 'ppc', 'hvm',
|
||||
['kvm', '/usr/bin/qemu-kvm', ['pc', 'isapc']]], {}),
|
||||
('x86_64', 'hvm',
|
||||
[['qemu', '/usr/bin/qemu-system-x86_64', ['pc', 'isapc']]], {}),
|
||||
('mips', 'hvm',
|
||||
[['qemu', '/usr/bin/qemu-system-mips', ['mips']]], {}),
|
||||
('mipsel', 'hvm',
|
||||
[['qemu', '/usr/bin/qemu-system-mipsel', ['mips']]], {}),
|
||||
('sparc', 'hvm',
|
||||
[['qemu', '/usr/bin/qemu-system-sparc', ['sun4m']]], {}),
|
||||
('ppc', 'hvm',
|
||||
[['qemu', '/usr/bin/qemu-system-ppc',
|
||||
['g3bw', 'mac99', 'prep']]], {} ),
|
||||
]
|
||||
['g3bw', 'mac99', 'prep']]], {}),
|
||||
]
|
||||
|
||||
self._testCapabilities("capabilities-kvm.xml", host, guests)
|
||||
|
||||
def testCapabilities4(self):
|
||||
host = ( 'i686',
|
||||
{ 'pae': capabilities.FEATURE_ON | capabilities.FEATURE_OFF })
|
||||
host = ('i686',
|
||||
{'pae': capabilities.FEATURE_ON | capabilities.FEATURE_OFF})
|
||||
|
||||
guests = [
|
||||
( 'i686', 'linux',
|
||||
('i686', 'linux',
|
||||
[['test', None, []]],
|
||||
{ 'pae': capabilities.FEATURE_ON | capabilities.FEATURE_OFF } ),
|
||||
]
|
||||
{'pae': capabilities.FEATURE_ON | capabilities.FEATURE_OFF}),
|
||||
]
|
||||
|
||||
self._testCapabilities("capabilities-test.xml", host, guests)
|
||||
|
||||
|
@ -137,7 +139,7 @@ class TestCapabilities(unittest.TestCase):
|
|||
guests = [
|
||||
("x86_64", "exe", [["lxc", "/usr/libexec/libvirt_lxc", []]], {}),
|
||||
("i686", "exe", [["lxc", "/usr/libexec/libvirt_lxc", []]], {}),
|
||||
]
|
||||
]
|
||||
|
||||
self._testCapabilities("capabilities-lxc.xml",
|
||||
(None, None), guests)
|
||||
|
|
170
tests/clitest.py
170
tests/clitest.py
|
@ -137,20 +137,20 @@ test_files = {
|
|||
# Format:
|
||||
#
|
||||
# "appname" {
|
||||
# "categoryfoo" : { Some descriptive test catagory name (e.g. storage)
|
||||
# "categoryfoo" : {Some descriptive test catagory name (e.g. storage)
|
||||
#
|
||||
# "args" : Args to be applied to all invocations in category
|
||||
#
|
||||
# "valid" : { # Argument strings that should succeed
|
||||
# "valid" : {# Argument strings that should succeed
|
||||
# "--option --string --number1" # Some option string to test. The
|
||||
# resulting cmdstr would be:
|
||||
# $ appname globalargs categoryfoo_args --option --string --number1
|
||||
# }
|
||||
# }
|
||||
#
|
||||
# "invalid" : { # Argument strings that should fail
|
||||
# "invalid" : {# Argument strings that should fail
|
||||
# "--opt1 --opt2",
|
||||
# }
|
||||
# } # End categoryfoo
|
||||
# }
|
||||
# } # End categoryfoo
|
||||
#
|
||||
#}
|
||||
|
||||
|
@ -253,7 +253,7 @@ args_dict = {
|
|||
"--disk /dev/hda",
|
||||
# Building 'default' pool
|
||||
"--disk pool=default,size=.00001",
|
||||
],
|
||||
],
|
||||
|
||||
"invalid": [
|
||||
# Nonexisting file, size too big
|
||||
|
@ -288,8 +288,8 @@ args_dict = {
|
|||
"--disk %(DIR)s,device=cdrom",
|
||||
# Unknown driver name and type options (as of 1.0.0)
|
||||
"--disk %(EXISTIMG1)s,driver_name=foobar,driver_type=foobaz",
|
||||
]
|
||||
}, # category "storage"
|
||||
]
|
||||
}, # category "storage"
|
||||
|
||||
"install" : {
|
||||
"args": "--nographics --noautoconsole --nodisks",
|
||||
|
@ -331,7 +331,7 @@ args_dict = {
|
|||
"--hvm --pxe --boot cdrom,fd,hd,network,menu=off",
|
||||
# Boot w/o other install option
|
||||
"--hvm --boot network,hd,menu=on",
|
||||
],
|
||||
],
|
||||
|
||||
"invalid": [
|
||||
# Bogus virt-type
|
||||
|
@ -352,8 +352,8 @@ args_dict = {
|
|||
"--hvm --cdrom %(EXISTIMG1)s --extra-args console=ttyS0",
|
||||
# initrd-inject with manual kernel/initrd
|
||||
"--hvm --boot kernel=%(TREEDIR)s/pxeboot/vmlinuz,initrd=%(TREEDIR)s/pxeboot/initrd.img --initrd-inject virt-install",
|
||||
],
|
||||
}, # category "install"
|
||||
],
|
||||
}, # category "install"
|
||||
|
||||
"graphics": {
|
||||
"args": "--noautoconsole --nodisks --pxe",
|
||||
|
@ -379,7 +379,7 @@ args_dict = {
|
|||
"--vnc --keymap local",
|
||||
# --keymap none
|
||||
"--vnc --keymap none",
|
||||
],
|
||||
],
|
||||
|
||||
"invalid": [
|
||||
# Invalid keymap
|
||||
|
@ -394,9 +394,9 @@ args_dict = {
|
|||
"--graphics vnc,foobar=baz",
|
||||
# mixing old and new
|
||||
"--graphics vnc --vnclisten 1.2.3.4",
|
||||
],
|
||||
],
|
||||
|
||||
}, # category "graphics"
|
||||
}, # category "graphics"
|
||||
|
||||
"smartcard": {
|
||||
"args": "--noautoconsole --nodisks --pxe",
|
||||
|
@ -411,7 +411,7 @@ args_dict = {
|
|||
# --smartcard mode with type
|
||||
# XXX Requires implementing more opts
|
||||
#"--smartcard passthrough,type=tcp",
|
||||
],
|
||||
],
|
||||
|
||||
"invalid": [
|
||||
# Missing argument
|
||||
|
@ -422,9 +422,9 @@ args_dict = {
|
|||
"--smartcard passthrough,type=foo",
|
||||
# --smartcard bogus
|
||||
"--smartcard host,foobar=baz",
|
||||
],
|
||||
],
|
||||
|
||||
}, # category "smartcard"
|
||||
}, # category "smartcard"
|
||||
|
||||
"char" : {
|
||||
"args": "--hvm --nographics --noautoconsole --nodisks --pxe",
|
||||
|
@ -452,7 +452,7 @@ args_dict = {
|
|||
"--console pty,target_type=virtio",
|
||||
# --console xen
|
||||
"--console pty,target_type=xen",
|
||||
],
|
||||
],
|
||||
"invalid" : [
|
||||
# Bogus device type
|
||||
"--parallel foobah",
|
||||
|
@ -466,9 +466,9 @@ args_dict = {
|
|||
"--channel pty,target_type=guestfwd",
|
||||
# --console unknown type
|
||||
"--console pty,target_type=abcd",
|
||||
],
|
||||
],
|
||||
|
||||
}, # category 'char'
|
||||
}, # category 'char'
|
||||
|
||||
"cpuram" : {
|
||||
"args" : "--hvm --nographics --noautoconsole --nodisks --pxe",
|
||||
|
@ -498,7 +498,7 @@ args_dict = {
|
|||
"--cpu foobar,+x2apic,+x2apicagain,-distest,forbid=foo,forbid=bar,disable=distest2,optional=opttest,require=reqtest,match=strict,vendor=meee",
|
||||
# Simple --numatune
|
||||
"--numatune 1,2,3,5-7,^6",
|
||||
],
|
||||
],
|
||||
|
||||
"invalid" : [
|
||||
# Bogus cpuset
|
||||
|
@ -517,9 +517,9 @@ args_dict = {
|
|||
"--cpu host",
|
||||
# Non-escaped numatune
|
||||
"--numatune 1-3,4,mode=strict",
|
||||
],
|
||||
],
|
||||
|
||||
}, # category 'cpuram'
|
||||
}, # category 'cpuram'
|
||||
|
||||
"misc": {
|
||||
"args": "--nographics --noautoconsole",
|
||||
|
@ -571,7 +571,7 @@ args_dict = {
|
|||
"--hvm --nodisks --pxe --memballoon virtio",
|
||||
# --memballoon disabled
|
||||
"--hvm --nodisks --pxe --memballoon none",
|
||||
],
|
||||
],
|
||||
|
||||
"invalid": [
|
||||
# Positional arguments error
|
||||
|
@ -592,7 +592,7 @@ args_dict = {
|
|||
"--hvm --nodisks --pxe --print-xml",
|
||||
# Busted --memballoon
|
||||
"--hvm --nodisks --pxe --memballoon foobar",
|
||||
],
|
||||
],
|
||||
|
||||
"compare": [
|
||||
# No arguments
|
||||
|
@ -624,9 +624,9 @@ args_dict = {
|
|||
("--connect %(DEFAULTURI)s --hvm --nodisks --pxe --cpuset auto "
|
||||
"--vcpus 2",
|
||||
"cpuset-auto"),
|
||||
],
|
||||
],
|
||||
|
||||
}, # category "misc"
|
||||
}, # category "misc"
|
||||
|
||||
"network": {
|
||||
"args": "--pxe --nographics --noautoconsole --nodisks",
|
||||
|
@ -652,7 +652,7 @@ args_dict = {
|
|||
"--network=user,model=e1000",
|
||||
# several networks
|
||||
"--network=network:default,model=e1000 --network=user,model=virtio,mac=22:22:33:44:55:AF",
|
||||
],
|
||||
],
|
||||
"invalid": [
|
||||
# Nonexistent network
|
||||
"--network=FOO",
|
||||
|
@ -662,9 +662,9 @@ args_dict = {
|
|||
"--network user --bridge foo0",
|
||||
# Colliding macaddr
|
||||
"--mac 22:22:33:12:34:AB",
|
||||
],
|
||||
],
|
||||
|
||||
}, # category "network"
|
||||
}, # category "network"
|
||||
|
||||
"controller": {
|
||||
"args": "--noautoconsole --nodisks --pxe",
|
||||
|
@ -674,7 +674,7 @@ args_dict = {
|
|||
"--controller usb,model=ich9-ehci1,address=0:0:4.7,index=0",
|
||||
"--controller usb,model=ich9-ehci1,address=0:0:4.7,index=1,master=0",
|
||||
"--controller usb2",
|
||||
],
|
||||
],
|
||||
|
||||
"invalid": [
|
||||
# Missing argument
|
||||
|
@ -685,9 +685,9 @@ args_dict = {
|
|||
"--controller usb,model=ich9-ehci1,address=0:0:4.7,index=bar,master=foo",
|
||||
# --bogus
|
||||
"--controller host,foobar=baz",
|
||||
],
|
||||
],
|
||||
|
||||
}, # category "controller"
|
||||
}, # category "controller"
|
||||
|
||||
"hostdev" : {
|
||||
"args": "--noautoconsole --nographics --nodisks --pxe",
|
||||
|
@ -697,7 +697,7 @@ args_dict = {
|
|||
"--host-device usb_device_781_5151_2004453082054CA1BEEE",
|
||||
# Many hostdev parsing types
|
||||
"--host-device 001.003 --host-device 15:0.1 --host-device 2:15:0.2 --host-device 0:15:0.3 --host-device 0x0781:0x5151 --host-device 1d6b:2",
|
||||
],
|
||||
],
|
||||
|
||||
"invalid" : [
|
||||
# Unsupported hostdev type
|
||||
|
@ -706,8 +706,8 @@ args_dict = {
|
|||
"--host-device foobarhostdev",
|
||||
# Parseable hostdev, but unknown digits
|
||||
"--host-device 300:400",
|
||||
],
|
||||
}, # category "hostdev"
|
||||
],
|
||||
}, # category "hostdev"
|
||||
|
||||
"redirdev" : {
|
||||
"args": "--noautoconsole --nographics --nodisks --pxe",
|
||||
|
@ -717,7 +717,7 @@ args_dict = {
|
|||
"--redirdev usb,type=tcp,server=localhost:4000",
|
||||
# Different host server
|
||||
"--redirdev usb,type=tcp,server=127.0.0.1:4002",
|
||||
],
|
||||
],
|
||||
|
||||
"invalid" : [
|
||||
# Missing argument
|
||||
|
@ -734,8 +734,8 @@ args_dict = {
|
|||
"--redirdev usb,type=tcp,server=localhost:",
|
||||
# Missing host
|
||||
"--redirdev usb,type=tcp,server=:399",
|
||||
],
|
||||
}, # category "redirdev"
|
||||
],
|
||||
}, # category "redirdev"
|
||||
|
||||
"remote" : {
|
||||
"args": "--connect %(REMOTEURI)s --nographics --noautoconsole",
|
||||
|
@ -751,15 +751,15 @@ args_dict = {
|
|||
"--pxe --disk vol=%(POOL)s/%(VOL)s",
|
||||
# Creating storage on managed pool
|
||||
"--pxe --disk pool=%(POOL)s,size=.04",
|
||||
],
|
||||
],
|
||||
"invalid": [
|
||||
# Use of --location
|
||||
"--nodisks --location /tmp",
|
||||
# Trying to use unmanaged storage
|
||||
"--file %(EXISTIMG1)s --pxe",
|
||||
],
|
||||
],
|
||||
|
||||
}, # category "remote"
|
||||
}, # category "remote"
|
||||
|
||||
|
||||
"kvm" : {
|
||||
|
@ -770,7 +770,7 @@ args_dict = {
|
|||
"--cdrom %(EXISTIMG2)s --file %(EXISTIMG1)s --os-variant win2k3 --wait 0 --sound",
|
||||
# F14 Directory tree URL install with extra-args
|
||||
"--os-variant fedora14 --file %(EXISTIMG1)s --location %(TREEDIR)s --extra-args console=ttyS0 --sound"
|
||||
],
|
||||
],
|
||||
|
||||
"invalid" : [
|
||||
# Unknown machine type
|
||||
|
@ -779,7 +779,7 @@ args_dict = {
|
|||
"--nodisks --boot network --arch mips --virt-type kvm",
|
||||
# Invalid arch/virt combo
|
||||
"--nodisks --boot network --paravirt --arch mips",
|
||||
],
|
||||
],
|
||||
|
||||
"compare" : [
|
||||
# F14 Directory tree URL install with extra-args
|
||||
|
@ -803,9 +803,9 @@ args_dict = {
|
|||
# exotic arch + machine type
|
||||
("--os-variant fedora14 --nodisks --boot fd --graphics sdl --arch sparc --machine SS-20",
|
||||
"qemu-sparc"),
|
||||
],
|
||||
],
|
||||
|
||||
}, # category "kvm"
|
||||
}, # category "kvm"
|
||||
|
||||
"xen" : {
|
||||
"args": "--connect %(XENURI)s --noautoconsole",
|
||||
|
@ -817,10 +817,10 @@ args_dict = {
|
|||
"--nodisks --boot hd --paravirt",
|
||||
# 32 on 64 xen
|
||||
"--nodisks --boot hd --paravirt --arch i686",
|
||||
],
|
||||
],
|
||||
|
||||
"invalid" : [
|
||||
],
|
||||
],
|
||||
|
||||
"compare" : [
|
||||
# Xen default
|
||||
|
@ -836,7 +836,7 @@ args_dict = {
|
|||
("--connect %(XENIA64URI)s --disk %(EXISTIMG1)s --location %(TREEDIR)s --paravirt", "xen-ia64-pv"),
|
||||
# ia64 hvm
|
||||
("--connect %(XENIA64URI)s --disk %(EXISTIMG1)s --location %(TREEDIR)s --hvm", "xen-ia64-hvm"),
|
||||
],
|
||||
],
|
||||
|
||||
},
|
||||
|
||||
|
@ -850,11 +850,11 @@ args_dict = {
|
|||
("", "default"),
|
||||
("--filesystem /source,/", "fs-default"),
|
||||
("--init /usr/bin/httpd", "manual-init"),
|
||||
],
|
||||
],
|
||||
|
||||
}, # lxc
|
||||
}, # lxc
|
||||
|
||||
}, # virt-install
|
||||
}, # virt-install
|
||||
|
||||
|
||||
|
||||
|
@ -888,7 +888,7 @@ args_dict = {
|
|||
"--original-xml %(CLONE_NOEXIST_XML)s --file %(EXISTIMG1)s --preserve",
|
||||
# Overwriting existing VM
|
||||
"-o test -n test-many-devices --replace",
|
||||
],
|
||||
],
|
||||
|
||||
"invalid": [
|
||||
# Positional arguments error
|
||||
|
@ -913,8 +913,8 @@ args_dict = {
|
|||
"--original-xml %(CLONE_DISK_XML)s --file %(ROIMG)s --file %(ROIMG)s --force",
|
||||
# XML w/ managed storage, specify RO non existent
|
||||
"--original-xml %(CLONE_DISK_XML)s --file %(ROIMG)s --file %(ROIMGNOEXIST)s --force",
|
||||
]
|
||||
}, # category "general"
|
||||
]
|
||||
}, # category "general"
|
||||
|
||||
"misc" : {
|
||||
"args": "",
|
||||
|
@ -928,21 +928,21 @@ args_dict = {
|
|||
"--original-xml %(CLONE_STORAGE_XML)s --auto-clone",
|
||||
# Auto flag, actual VM, skip state check
|
||||
"-o test-for-clone --auto-clone --clone-running",
|
||||
],
|
||||
],
|
||||
|
||||
"invalid" : [
|
||||
# Just the auto flag
|
||||
"--auto-clone"
|
||||
# Auto flag, actual VM, without state skip
|
||||
"-o test-for-clone --auto-clone",
|
||||
],
|
||||
],
|
||||
|
||||
"compare" : [
|
||||
("--connect %(KVMURI)s -o test-for-clone --auto-clone --clone-running", "clone-auto1"),
|
||||
("-o test-clone-simple --name newvm --auto-clone --clone-running",
|
||||
"clone-auto2"),
|
||||
],
|
||||
}, # category "misc"
|
||||
],
|
||||
}, # category "misc"
|
||||
|
||||
"remote" : {
|
||||
"args": "--connect %(REMOTEURI)s",
|
||||
|
@ -952,15 +952,15 @@ args_dict = {
|
|||
"-o test --auto-clone",
|
||||
# Auto flag w/ managed storage,
|
||||
"--original-xml %(CLONE_STORAGE_XML)s --auto-clone",
|
||||
],
|
||||
],
|
||||
"invalid": [
|
||||
# Auto flag w/ storage,
|
||||
"--original-xml %(CLONE_DISK_XML)s --auto-clone",
|
||||
],
|
||||
}, # categort "remote"
|
||||
],
|
||||
}, # categort "remote"
|
||||
|
||||
|
||||
}, # app 'virt-clone'
|
||||
}, # app 'virt-clone'
|
||||
|
||||
|
||||
|
||||
|
@ -982,13 +982,13 @@ args_dict = {
|
|||
"--name foobar --ram 64 --os-variant winxp",
|
||||
# OS variant 'none'
|
||||
"--name foobar --ram 64 --os-variant none",
|
||||
],
|
||||
],
|
||||
|
||||
"invalid": [
|
||||
# Out of bounds index
|
||||
"--boot 10",
|
||||
],
|
||||
}, # category 'general'
|
||||
],
|
||||
}, # category 'general'
|
||||
|
||||
"graphics" : {
|
||||
"args" : "--name test-image --boot 0 %(IMAGE_XML)s",
|
||||
|
@ -998,10 +998,10 @@ args_dict = {
|
|||
"--sdl",
|
||||
# VNC w/ lots of options
|
||||
"--vnc --keymap ja --vncport 5950 --vnclisten 1.2.3.4",
|
||||
],
|
||||
],
|
||||
|
||||
"invalid": [],
|
||||
},
|
||||
},
|
||||
|
||||
"misc": {
|
||||
"args" : "",
|
||||
|
@ -1009,13 +1009,13 @@ args_dict = {
|
|||
"valid" : [
|
||||
# Colliding VM name w/ --replace
|
||||
"--name test --replace %(IMAGE_XML)s",
|
||||
],
|
||||
],
|
||||
"invalid" : [
|
||||
# No name specified, and no prompt flag
|
||||
"%(IMAGE_XML)s",
|
||||
# Colliding VM name without --replace
|
||||
"--name test %(IMAGE_XML)s",
|
||||
],
|
||||
],
|
||||
|
||||
"compare" : [
|
||||
("--name foobar --ram 64 --os-variant winxp --boot 0 %(IMAGE_XML)s",
|
||||
|
@ -1026,9 +1026,9 @@ args_dict = {
|
|||
("--name foobar --ram 64 --boot 0 "
|
||||
"%(IMAGE_NOGFX_XML)s",
|
||||
"image-nogfx"),
|
||||
]
|
||||
]
|
||||
|
||||
}, # category 'misc'
|
||||
}, # category 'misc'
|
||||
|
||||
"network": {
|
||||
"args": "--name test-image --boot 0 --nographics %(IMAGE_XML)s",
|
||||
|
@ -1044,18 +1044,18 @@ args_dict = {
|
|||
"--network=user,model=e1000",
|
||||
# several networks
|
||||
"--network=network:default,model=e1000 --network=user,model=virtio",
|
||||
],
|
||||
],
|
||||
"invalid": [
|
||||
# Nonexistent network
|
||||
"--network=FOO",
|
||||
# Invalid mac
|
||||
"--network=network:default --mac 1234",
|
||||
],
|
||||
],
|
||||
|
||||
}, # category "network"
|
||||
}, # category "network"
|
||||
|
||||
|
||||
}, # app 'virt-image'
|
||||
}, # app 'virt-image'
|
||||
|
||||
|
||||
"virt-convert" : {
|
||||
|
@ -1079,25 +1079,27 @@ args_dict = {
|
|||
"%(VMX_IMG1)s -o vmx -D none %(VIRTCONV_OUT)s",
|
||||
# virt-image with exotic formats specified
|
||||
"%(VC_IMG2)s -o vmx -D vmdk %(VIRTCONV_OUT)s"
|
||||
],
|
||||
],
|
||||
|
||||
"invalid": [
|
||||
# virt-image to virt-image with invalid format
|
||||
"%(VC_IMG1)s -o virt-image -D foobarfmt %(VIRTCONV_OUT)s",
|
||||
# virt-image to ovf (has no output formatter)
|
||||
"%(VC_IMG1)s -o ovf %(VIRTCONV_OUT)s",
|
||||
],
|
||||
],
|
||||
|
||||
"compare": [
|
||||
# virt-image to default (virt-image) w/ no convert
|
||||
("%(VC_IMG1)s %(VIRTCONV_OUT)s", "convert-default"),
|
||||
],
|
||||
}, # category 'misc'
|
||||
],
|
||||
}, # category 'misc'
|
||||
|
||||
}, # app 'virt-convert'
|
||||
}, # app 'virt-convert'
|
||||
}
|
||||
|
||||
_conns = {}
|
||||
|
||||
|
||||
def open_conn(uri):
|
||||
#if uri not in _conns:
|
||||
# _conns[uri] = virtinst.cli.getConnection(uri)
|
||||
|
@ -1108,6 +1110,7 @@ def open_conn(uri):
|
|||
# Test class helpers #
|
||||
######################
|
||||
|
||||
|
||||
class Command(object):
|
||||
"""
|
||||
Instance of a single cli command to test
|
||||
|
@ -1380,6 +1383,7 @@ newidx = 0
|
|||
curtest = 0
|
||||
old_bridge = virtinst.util.default_bridge
|
||||
|
||||
|
||||
def setup():
|
||||
"""
|
||||
Create initial test files/dirs
|
||||
|
@ -1406,6 +1410,7 @@ def cleanup():
|
|||
|
||||
virtinst.util.default_bridge = old_bridge
|
||||
|
||||
|
||||
class CLITests(unittest.TestCase):
|
||||
def __init__(self, *args, **kwargs):
|
||||
unittest.TestCase.__init__(self, *args, **kwargs)
|
||||
|
@ -1422,6 +1427,7 @@ class CLITests(unittest.TestCase):
|
|||
if curtest == newidx:
|
||||
cleanup()
|
||||
|
||||
|
||||
def maketest(cmd):
|
||||
def cmdtemplate(self, c):
|
||||
err = c.run()
|
||||
|
|
|
@ -38,13 +38,13 @@ POOL1 = "/default-pool"
|
|||
POOL2 = "/cross-pool"
|
||||
DISKPOOL = "/disk-pool"
|
||||
|
||||
local_files = [ FILE1, FILE2]
|
||||
local_files = [FILE1, FILE2]
|
||||
|
||||
clonexml_dir = os.path.join(os.getcwd(), "tests/clone-xml")
|
||||
clone_files = []
|
||||
|
||||
for tmpf in os.listdir(clonexml_dir):
|
||||
black_list = [ "managed-storage", "cross-pool", "force", "skip",
|
||||
black_list = ["managed-storage", "cross-pool", "force", "skip",
|
||||
"fullpool"]
|
||||
if tmpf.endswith("-out.xml"):
|
||||
tmpf = tmpf[0:(len(tmpf) - len("-out.xml"))]
|
||||
|
@ -53,6 +53,7 @@ for tmpf in os.listdir(clonexml_dir):
|
|||
|
||||
conn = utils.open_testdriver()
|
||||
|
||||
|
||||
class TestClone(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
@ -92,7 +93,7 @@ class TestClone(unittest.TestCase):
|
|||
cloneobj.clone_mac = "22:23:45:67:89:00"
|
||||
cloneobj.clone_mac = "22:23:45:67:89:01"
|
||||
|
||||
if disks != None:
|
||||
if disks is not None:
|
||||
for disk in disks:
|
||||
cloneobj.clone_devices = disk
|
||||
else:
|
||||
|
@ -149,7 +150,7 @@ class TestClone(unittest.TestCase):
|
|||
def testRemoteNoStorage(self):
|
||||
"""Test remote clone where VM has no storage that needs cloning"""
|
||||
useconn = utils.open_test_remote()
|
||||
for base in [ "nostorage", "noclone-storage" ] :
|
||||
for base in ["nostorage", "noclone-storage"] :
|
||||
self._clone_helper(base, disks=[], useconn=useconn)
|
||||
|
||||
def testRemoteWithStorage(self):
|
||||
|
@ -158,7 +159,7 @@ class TestClone(unittest.TestCase):
|
|||
since libvirt has no storage clone api.
|
||||
"""
|
||||
useconn = utils.open_test_remote()
|
||||
for base in [ "general-cfg" ] :
|
||||
for base in ["general-cfg"] :
|
||||
try:
|
||||
self._clone_helper(base,
|
||||
disks=["%s/1.img" % POOL1,
|
||||
|
|
|
@ -33,6 +33,7 @@ eth_iface2 = conn.interfaceLookupByName("eth1")
|
|||
eth_iface3 = conn.interfaceLookupByName("eth2")
|
||||
br_iface = conn.interfaceLookupByName("brempty")
|
||||
|
||||
|
||||
class TestInterfaces(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
|
|
@ -36,6 +36,7 @@ unknown_xml = """
|
|||
</device>
|
||||
"""
|
||||
|
||||
|
||||
class TestNodeDev(unittest.TestCase):
|
||||
|
||||
def _nodeDevFromName(self, devname):
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
[pep8]
|
||||
|
||||
format = pylint
|
||||
|
||||
# E12*: # Continuation line indents
|
||||
# E203: # Space before : in dictionary defs
|
||||
# E221: # Multiple spaces before operator
|
||||
# (warngs about column aligning assigments)
|
||||
# E241: # Space after , column alignment nono
|
||||
# E301: # 1 blank line between methods
|
||||
# E303: # Too many blank lines
|
||||
# E501: # Line too long
|
||||
|
||||
ignore=E121,E122,E123,E124,E125,E126,E127,E128,E203,E221,E241,E301,E303,E501
|
|
@ -28,6 +28,7 @@ import libvirt
|
|||
|
||||
basepath = os.path.join(os.getcwd(), "tests", "storage-xml")
|
||||
|
||||
|
||||
def generate_uuid_from_string(msg):
|
||||
|
||||
res = msg.split("-", 1)
|
||||
|
@ -44,6 +45,7 @@ def generate_uuid_from_string(msg):
|
|||
|
||||
return numstr
|
||||
|
||||
|
||||
def _findFreePoolName(conn, namebase):
|
||||
|
||||
i = 0
|
||||
|
@ -55,6 +57,7 @@ def _findFreePoolName(conn, namebase):
|
|||
except:
|
||||
return poolname
|
||||
|
||||
|
||||
def createPool(conn, ptype, poolname=None, fmt=None, target_path=None,
|
||||
source_path=None, source_name=None, uuid=None, iqn=None):
|
||||
poolclass = StoragePool.get_pool_class(ptype)
|
||||
|
@ -82,6 +85,7 @@ def createPool(conn, ptype, poolname=None, fmt=None, target_path=None,
|
|||
|
||||
return poolCompare(pool_inst)
|
||||
|
||||
|
||||
def poolCompare(pool_inst):
|
||||
filename = os.path.join(basepath, pool_inst.name + ".xml")
|
||||
out_expect = pool_inst.get_xml_config()
|
||||
|
@ -92,10 +96,11 @@ def poolCompare(pool_inst):
|
|||
|
||||
return pool_inst.install(build=True, meter=None, create=True)
|
||||
|
||||
|
||||
def createVol(poolobj, volname=None, input_vol=None, clone_vol=None):
|
||||
volclass = StorageVolume.get_volume_for_pool(pool_object=poolobj)
|
||||
|
||||
if volname == None:
|
||||
if volname is None:
|
||||
volname = poolobj.name() + "-vol"
|
||||
|
||||
alloc = 5 * 1024 * 1024 * 1024
|
||||
|
@ -125,6 +130,7 @@ def createVol(poolobj, volname=None, input_vol=None, clone_vol=None):
|
|||
|
||||
return vol_inst.install(meter=False)
|
||||
|
||||
|
||||
class TestStorage(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
@ -166,7 +172,7 @@ class TestStorage(unittest.TestCase):
|
|||
|
||||
# Test creating with many devices
|
||||
createPool(self.conn, StoragePool.TYPE_LOGICAL, "pool-logical-manydev",
|
||||
source_path=[ "/tmp/path1", "/tmp/path2", "/tmp/path3" ],
|
||||
source_path=["/tmp/path1", "/tmp/path2", "/tmp/path3"],
|
||||
target_path=None)
|
||||
|
||||
def testDiskPool(self):
|
||||
|
|
|
@ -22,6 +22,7 @@ from tests import utils
|
|||
|
||||
conn = utils.open_testdriver()
|
||||
|
||||
|
||||
class TestSupport(unittest.TestCase):
|
||||
|
||||
def testSupportCollide(self):
|
||||
|
|
|
@ -69,6 +69,8 @@ NOBOOTISO_FILTER = ".*opensuse12.*|.*opensuse11.*|.*opensuse10.3.*|.*opensuse10.
|
|||
EXPECT_XEN_FAIL = ".*opensuse10.2.*|.*opensuse10.0.*"
|
||||
|
||||
# Return the expected Distro class for the passed distro label
|
||||
|
||||
|
||||
def distroClass(distname):
|
||||
if re.match(r".*fedora.*", distname):
|
||||
return FedoraDistro
|
||||
|
@ -93,90 +95,90 @@ urls = {
|
|||
"fedora15" : {
|
||||
'x86_64': FEDORA_BASEURL % ("15", "x86_64"),
|
||||
'distro': ("linux", "fedora15")
|
||||
},
|
||||
},
|
||||
"fedora16" : {
|
||||
'x86_64': FEDORA_BASEURL % ("16", "x86_64"),
|
||||
'distro': ("linux", "fedora16")
|
||||
},
|
||||
},
|
||||
|
||||
# SUSE Distros
|
||||
"opensuse10.0" : {
|
||||
'i386' : "http://ftp.hosteurope.de/mirror/ftp.opensuse.org/discontinued/10.0/",
|
||||
'x86_64': "http://ftp.hosteurope.de/mirror/ftp.opensuse.org/discontinued/10.0/",
|
||||
},
|
||||
},
|
||||
"opensuse10.2" : {
|
||||
'x86_64': OLD_OPENSUSE_BASEURL % ("10.2")
|
||||
},
|
||||
},
|
||||
"opensuse10.3" : {
|
||||
'x86_64': OLD_OPENSUSE_BASEURL % ("10.3")
|
||||
},
|
||||
},
|
||||
"opensuse11.4" : {
|
||||
'i386' : OPENSUSE_BASEURL % ("11.4"),
|
||||
'x86_64': OPENSUSE_BASEURL % ("11.4")
|
||||
},
|
||||
},
|
||||
"opensuse12.1" : {
|
||||
'i386' : OPENSUSE_BASEURL % ("12.1"),
|
||||
'x86_64': OPENSUSE_BASEURL % ("12.1")
|
||||
},
|
||||
},
|
||||
|
||||
# Debian Distros
|
||||
"debian-lenny-64" : {
|
||||
"noxen": True,
|
||||
'x86_64': DEBIAN_BASEURL % ("lenny", "amd64"),
|
||||
'distro': ("linux", None)
|
||||
},
|
||||
},
|
||||
"debian-squeeze" : {
|
||||
'i386' : DEBIAN_BASEURL % ("squeeze", "i386"),
|
||||
'x86_64': DEBIAN_BASEURL % ("squeeze", "amd64"),
|
||||
'distro': ("linux", None)
|
||||
},
|
||||
},
|
||||
"debian-wheezy" : {
|
||||
'x86_64': DEBIAN_BASEURL % ("wheezy", "amd64"),
|
||||
'distro': ("linux", None)
|
||||
},
|
||||
},
|
||||
"debian-sid" : {
|
||||
'x86_64': DEBIAN_BASEURL % ("sid", "amd64"),
|
||||
'distro': ("linux", None)
|
||||
},
|
||||
},
|
||||
"debian-daily" : {
|
||||
'i386' : "http://d-i.debian.org/daily-images/amd64/",
|
||||
'distro': ("linux", None)
|
||||
},
|
||||
},
|
||||
|
||||
# CentOS Distros
|
||||
"centos-5-latest" : {
|
||||
'i386' : CURCENTOS_BASEURL % ("5", "i386"),
|
||||
'x86_64' : CURCENTOS_BASEURL % ("5", "x86_64"), # No .treeinfo
|
||||
'distro': ("linux", "rhel5.4")
|
||||
},
|
||||
},
|
||||
"centos-4.9" : {
|
||||
'i386' : CURCENTOS_BASEURL % ("4.9", "i386"),
|
||||
'x86_64' : CURCENTOS_BASEURL % ("4.9", "x86_64"),
|
||||
'distro': ("linux", None)
|
||||
},
|
||||
},
|
||||
"centos-5.0" : {
|
||||
'x86_64' : OLDCENTOS_BASEURL % ("5.0", "x86_64"),
|
||||
'distro': ("linux", None)
|
||||
},
|
||||
},
|
||||
"centos-4.0" : {
|
||||
"noxen": True,
|
||||
'x86_64' : OLDCENTOS_BASEURL % ("4.0", "x86_64"),
|
||||
'distro': ("linux", None)
|
||||
},
|
||||
},
|
||||
|
||||
# Scientific Linux
|
||||
"scientific-5.4" : {
|
||||
'x86_64': SCIENTIFIC_BASEURL % ("54", "x86_64"),
|
||||
'distro': ("linux", "rhel5.4")
|
||||
},
|
||||
},
|
||||
"scientific-5.2" : {
|
||||
'x86_64': SCIENTIFIC_BASEURL % ("52", "x86_64"),
|
||||
'distro': ("linux", "rhel5")
|
||||
},
|
||||
},
|
||||
"scientific-5.0" : {
|
||||
'x86_64': SCIENTIFIC_BASEURL % ("50", "x86_64"),
|
||||
'distro': ("linux", None)
|
||||
},
|
||||
},
|
||||
|
||||
# Ubuntu
|
||||
"ubuntu-hardy" : {
|
||||
|
@ -184,27 +186,27 @@ urls = {
|
|||
'i386': UBUNTU_BASEURL % ("hardy", "i386"),
|
||||
'x86_64': UBUNTU_BASEURL % ("hardy", "amd64"),
|
||||
'distro': ("linux", None)
|
||||
},
|
||||
},
|
||||
"ubuntu-maverick" : {
|
||||
'i386': UBUNTU_BASEURL % ("maverick", "i386"),
|
||||
'x86_64': UBUNTU_BASEURL % ("maverick", "amd64"),
|
||||
'distro': ("linux", None)
|
||||
},
|
||||
},
|
||||
"ubuntu-natty" : {
|
||||
'i386': UBUNTU_BASEURL % ("natty", "i386"),
|
||||
'x86_64': UBUNTU_BASEURL % ("natty", "amd64"),
|
||||
'distro': ("linux", None)
|
||||
},
|
||||
},
|
||||
"ubuntu-oneiric" : {
|
||||
'i386': UBUNTU_BASEURL % ("oneiric", "i386"),
|
||||
'x86_64': UBUNTU_BASEURL % ("oneiric", "amd64"),
|
||||
'distro': ("linux", None)
|
||||
},
|
||||
},
|
||||
"ubuntu-precise" : {
|
||||
'i386': UBUNTU_BASEURL % ("precise", "i386"),
|
||||
'x86_64': UBUNTU_BASEURL % ("precise", "amd64"),
|
||||
'distro': ("linux", None)
|
||||
},
|
||||
},
|
||||
|
||||
# Mandriva
|
||||
"mandriva-2009.1" : {
|
||||
|
@ -212,13 +214,13 @@ urls = {
|
|||
'i586': MANDRIVA_BASEURL % ("2009.1", "i586"),
|
||||
'x86_64': MANDRIVA_BASEURL % ("2009.1", "x86_64"),
|
||||
'distro': ("linux", None)
|
||||
},
|
||||
},
|
||||
"mandriva-2010.2" : {
|
||||
"noxen": True,
|
||||
'i586': MANDRIVA_BASEURL % ("2010.2", "i586"),
|
||||
'x86_64': MANDRIVA_BASEURL % ("2010.2", "x86_64"),
|
||||
'distro': ("linux", None)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
@ -226,6 +228,7 @@ testconn = libvirt.open("test:///default")
|
|||
testguest = virtinst.Guest(conn=testconn,
|
||||
installer=virtinst.DistroInstaller())
|
||||
|
||||
|
||||
class TestURLFetch(unittest.TestCase):
|
||||
|
||||
|
||||
|
@ -336,7 +339,7 @@ class TestURLFetch(unittest.TestCase):
|
|||
boot = hvmstore.acquireBootDisk(testguest, fetcher, self.meter)
|
||||
logging.debug("acquireBootDisk: %s", str(boot))
|
||||
|
||||
if boot != True:
|
||||
if boot is not True:
|
||||
raise RuntimeError("Didn't fetch any boot iso.")
|
||||
except Exception, e:
|
||||
logging.exception("%s-%s: bootdisk fetching: %s",
|
||||
|
|
|
@ -44,10 +44,12 @@ _plainkvm = "%s,qemu" % _fakeuri
|
|||
_plainxen = "%s,xen" % _fakeuri
|
||||
_kvmuri = "%s,caps=%s" % (_plainkvm, _kvmcaps)
|
||||
|
||||
|
||||
def get_debug():
|
||||
return ("DEBUG_TESTS" in os.environ and
|
||||
os.environ["DEBUG_TESTS"] == "1")
|
||||
|
||||
|
||||
def _make_uri(base, connver=None, libver=None):
|
||||
if connver:
|
||||
base += ",connver=%s" % connver
|
||||
|
@ -55,33 +57,51 @@ def _make_uri(base, connver=None, libver=None):
|
|||
base += ",libver=%s" % libver
|
||||
return base
|
||||
|
||||
|
||||
def open_testdriver():
|
||||
return virtinst.cli.getConnection(_testuri)
|
||||
|
||||
|
||||
def open_testkvmdriver():
|
||||
return virtinst.cli.getConnection(_kvmuri)
|
||||
|
||||
|
||||
def open_plainkvm(connver=None, libver=None):
|
||||
return virtinst.cli.getConnection(_make_uri(_plainkvm, connver, libver))
|
||||
|
||||
|
||||
def open_plainxen(connver=None, libver=None):
|
||||
return virtinst.cli.getConnection(_make_uri(_plainxen, connver, libver))
|
||||
|
||||
|
||||
def open_test_remote():
|
||||
return virtinst.cli.getConnection(_remoteuri)
|
||||
|
||||
_default_conn = open_testdriver()
|
||||
_conn = None
|
||||
|
||||
|
||||
def set_conn(newconn):
|
||||
global _conn
|
||||
_conn = newconn
|
||||
|
||||
|
||||
def reset_conn():
|
||||
set_conn(_default_conn)
|
||||
|
||||
|
||||
def get_conn():
|
||||
return _conn
|
||||
reset_conn()
|
||||
|
||||
# Register libvirt handler
|
||||
|
||||
|
||||
def libvirt_callback(ignore, err):
|
||||
logging.warn("libvirt errmsg: %s", err[2])
|
||||
libvirt.registerErrorHandler(f=libvirt_callback, ctx=None)
|
||||
|
||||
|
||||
def sanitize_xml_for_define(xml):
|
||||
# Libvirt throws errors since we are defining domain
|
||||
# type='xen', when test driver can only handle type='test'
|
||||
|
@ -100,6 +120,7 @@ def sanitize_xml_for_define(xml):
|
|||
|
||||
return xml
|
||||
|
||||
|
||||
def test_create(testconn, xml):
|
||||
xml = sanitize_xml_for_define(xml)
|
||||
|
||||
|
@ -122,6 +143,7 @@ def test_create(testconn, xml):
|
|||
except:
|
||||
pass
|
||||
|
||||
|
||||
def read_file(filename):
|
||||
"""Helper function to read a files contents and return them"""
|
||||
f = open(filename, "r")
|
||||
|
@ -130,6 +152,7 @@ def read_file(filename):
|
|||
|
||||
return out
|
||||
|
||||
|
||||
def diff_compare(actual_out, filename=None, expect_out=None):
|
||||
"""Compare passed string output to contents of filename"""
|
||||
if not expect_out:
|
||||
|
@ -162,6 +185,7 @@ def get_basic_paravirt_guest(installer=None):
|
|||
g.installer._scratchdir = scratch
|
||||
return g
|
||||
|
||||
|
||||
def get_basic_fullyvirt_guest(typ="xen", installer=None):
|
||||
g = virtinst.Guest(conn=_conn, type=typ)
|
||||
g.name = "TestGuest"
|
||||
|
@ -181,24 +205,29 @@ def get_basic_fullyvirt_guest(typ="xen", installer=None):
|
|||
g.installer._scratchdir = scratch
|
||||
return g
|
||||
|
||||
|
||||
def make_import_installer(os_type="hvm"):
|
||||
inst = virtinst.ImportInstaller(type="xen", os_type=os_type, conn=_conn)
|
||||
return inst
|
||||
|
||||
|
||||
def make_distro_installer(location="/default-pool/default-vol", gtype="xen"):
|
||||
inst = virtinst.DistroInstaller(type=gtype, os_type="hvm", conn=_conn,
|
||||
location=location)
|
||||
return inst
|
||||
|
||||
|
||||
def make_live_installer(location="/dev/loop0", gtype="xen"):
|
||||
inst = virtinst.LiveCDInstaller(type=gtype, os_type="hvm",
|
||||
conn=_conn, location=location)
|
||||
return inst
|
||||
|
||||
|
||||
def make_pxe_installer(gtype="xen"):
|
||||
inst = virtinst.PXEInstaller(type=gtype, os_type="hvm", conn=_conn)
|
||||
return inst
|
||||
|
||||
|
||||
def build_win_kvm(path=None):
|
||||
g = get_basic_fullyvirt_guest("kvm")
|
||||
g.os_type = "windows"
|
||||
|
@ -211,19 +240,23 @@ def build_win_kvm(path=None):
|
|||
|
||||
return g
|
||||
|
||||
|
||||
def get_floppy(path=None):
|
||||
if not path:
|
||||
path = "/default-pool/testvol1.img"
|
||||
return VirtualDisk(path, conn=_conn, device=VirtualDisk.DEVICE_FLOPPY)
|
||||
|
||||
|
||||
def get_filedisk(path=None):
|
||||
if not path:
|
||||
path = "/tmp/test.img"
|
||||
return VirtualDisk(path, size=.0001, conn=_conn)
|
||||
|
||||
|
||||
def get_blkdisk(path="/dev/loop0"):
|
||||
return VirtualDisk(path, conn=_conn)
|
||||
|
||||
|
||||
def get_virtual_network():
|
||||
dev = virtinst.VirtualNetworkInterface(conn=_conn)
|
||||
dev.macaddr = "22:22:33:44:55:66"
|
||||
|
|
|
@ -26,11 +26,11 @@ import traceback
|
|||
import os
|
||||
|
||||
# Template for adding arguments to test
|
||||
# { 'label' : { \
|
||||
# 'VAR' : { \
|
||||
# {'label' : {\
|
||||
# 'VAR' : {\
|
||||
# 'invalid' : [param],
|
||||
# 'valid' : [param]},
|
||||
# '__init__' : { \
|
||||
# '__init__' : {\
|
||||
# 'invalid' : [{'initparam':val}],
|
||||
# 'valid' : [{'initparam':val}]}
|
||||
#
|
||||
|
@ -66,33 +66,33 @@ args = {
|
|||
'name' : {
|
||||
'invalid' : ['123456789', 'im_invalid!', '', 0,
|
||||
'verylongnameverylongnameverylongnamevery'
|
||||
'longnameveryvery', "test" # In use,
|
||||
],
|
||||
'valid' : ['Valid_name.01'] },
|
||||
'longnameveryvery', "test",
|
||||
],
|
||||
'valid' : ['Valid_name.01']},
|
||||
'memory' : {
|
||||
'invalid' : [-1, 0, ''],
|
||||
'valid' : [200, 2000] },
|
||||
'valid' : [200, 2000]},
|
||||
'maxmemory' : {
|
||||
'invalid' : [-1, 0, ''],
|
||||
'valid' : [200, 2000], },
|
||||
'uuid' : {
|
||||
'invalid' : [ '', 0, '1234567812345678123456781234567x'],
|
||||
'invalid' : ['', 0, '1234567812345678123456781234567x'],
|
||||
'valid' : ['12345678123456781234567812345678',
|
||||
'12345678-1234-1234-ABCD-ABCDEF123456']},
|
||||
'vcpus' : {
|
||||
'invalid' : [-1, 0, 1000, ''],
|
||||
'valid' : [ 1, 32 ] },
|
||||
'valid' : [1, 32]},
|
||||
'type' : {
|
||||
'invalid' : [],
|
||||
'valid' : ['sometype'] },
|
||||
'valid' : ['sometype']},
|
||||
'cdrom' : {
|
||||
'invalid' : ['', 0, '/somepath'],
|
||||
'valid' : ['/dev/loop0']
|
||||
},
|
||||
},
|
||||
'arch' : {
|
||||
'invalid' : [],
|
||||
'valid' : ["i386", 'i686', 'x86_64'],
|
||||
},
|
||||
},
|
||||
'os_type' : {
|
||||
'invalid' : ['notpresent', 0, ''],
|
||||
'valid' : ['other', 'windows', 'unix', 'linux']},
|
||||
|
@ -103,103 +103,102 @@ args = {
|
|||
|
||||
|
||||
'disk' : {
|
||||
'init_conns' : [ testconn, None ],
|
||||
'init_conns' : [testconn, None],
|
||||
'__init__' : {
|
||||
|
||||
'invalid' : [
|
||||
{'path' : 0},
|
||||
{ 'path' : '/root' },
|
||||
{ 'path' : 'valid', 'size' : None },
|
||||
{ 'path' : "valid", 'size' : 'invalid' },
|
||||
{ 'path' : 'valid', 'size' : -1},
|
||||
{ 'path' : None },
|
||||
{ 'path' : "noexist1", 'size' : 900000, 'sparse' : False },
|
||||
{ 'path' : "noexist2", 'type' : VirtualDisk.DEVICE_CDROM},
|
||||
{ 'volName' : ("default-pool", "default-vol")},
|
||||
{ 'conn' : testconn, 'volName' : ("pool-noexist", "default-vol")},
|
||||
{ 'conn' : testconn, 'volName' : ("default-pool", "vol-noexist")},
|
||||
{ 'conn' : testconn, 'volName' : ( 1234, "vol-noexist")},
|
||||
{ 'path' : 'valid', 'size' : 1, 'driverCache' : 'invalid' },
|
||||
{ 'conn' : testconn, "path" : "/full-pool/newvol.img", "size" : 1,
|
||||
'sparse' : False },
|
||||
{'path' : '/root'},
|
||||
{'path' : 'valid', 'size' : None},
|
||||
{'path' : "valid", 'size' : 'invalid'},
|
||||
{'path' : 'valid', 'size' : -1},
|
||||
{'path' : None},
|
||||
{'path' : "noexist1", 'size' : 900000, 'sparse' : False},
|
||||
{'path' : "noexist2", 'type' : VirtualDisk.DEVICE_CDROM},
|
||||
{'volName' : ("default-pool", "default-vol")},
|
||||
{'conn' : testconn, 'volName' : ("pool-noexist", "default-vol")},
|
||||
{'conn' : testconn, 'volName' : ("default-pool", "vol-noexist")},
|
||||
{'conn' : testconn, 'volName' : (1234, "vol-noexist")},
|
||||
{'path' : 'valid', 'size' : 1, 'driverCache' : 'invalid'},
|
||||
{'conn' : testconn, "path" : "/full-pool/newvol.img", "size" : 1,
|
||||
'sparse' : False},
|
||||
# Inactive pool w/ volume
|
||||
{ 'conn' : testconn, "path" : "/inactive-pool/inactive-vol"},
|
||||
],
|
||||
{'conn' : testconn, "path" : "/inactive-pool/inactive-vol"},
|
||||
],
|
||||
|
||||
'valid' : [
|
||||
{ 'path' : '/dev/loop0' },
|
||||
{ 'path' : 'nonexist', 'size' : 1 },
|
||||
{ 'path' :'/dev/null'},
|
||||
{ 'path' : None, 'device' : VirtualDisk.DEVICE_CDROM},
|
||||
{ 'path' : None, 'device' : VirtualDisk.DEVICE_FLOPPY},
|
||||
{ 'conn' : testconn, 'volName' : ("default-pool", "default-vol")},
|
||||
{ 'conn' : testconn, 'path' : "/default-pool/default-vol" },
|
||||
{ 'conn' : testconn, 'path' : "/default-pool/vol-noexist", 'size' : 1 },
|
||||
{ 'conn' : testconn, 'volInstall': volinst},
|
||||
{ 'path' : 'nonexist', 'size' : 1, 'driverCache' : 'writethrough' },
|
||||
{'path' : '/dev/loop0'},
|
||||
{'path' : 'nonexist', 'size' : 1},
|
||||
{'path' : '/dev/null'},
|
||||
{'path' : None, 'device' : VirtualDisk.DEVICE_CDROM},
|
||||
{'path' : None, 'device' : VirtualDisk.DEVICE_FLOPPY},
|
||||
{'conn' : testconn, 'volName' : ("default-pool", "default-vol")},
|
||||
{'conn' : testconn, 'path' : "/default-pool/default-vol"},
|
||||
{'conn' : testconn, 'path' : "/default-pool/vol-noexist", 'size' : 1},
|
||||
{'conn' : testconn, 'volInstall': volinst},
|
||||
{'path' : 'nonexist', 'size' : 1, 'driverCache' : 'writethrough'},
|
||||
# Full pool, but we are nonsparse
|
||||
{ 'conn' : testconn, "path" : "/full-pool/newvol.img", "size" : 1 },
|
||||
]
|
||||
},
|
||||
{'conn' : testconn, "path" : "/full-pool/newvol.img", "size" : 1},
|
||||
]
|
||||
},
|
||||
|
||||
'shareable' : {
|
||||
'invalid': [ None, 1234 ],
|
||||
'valid': [ True, False ]
|
||||
},
|
||||
'invalid': [None, 1234],
|
||||
'valid': [True, False]
|
||||
},
|
||||
},
|
||||
|
||||
'installer' : {
|
||||
'init_conns' : [ testconn, None ],
|
||||
'init_conns' : [testconn, None],
|
||||
'extraargs' : {
|
||||
'invalid' : [],
|
||||
'valid' : ['someargs']},
|
||||
'arch' : {
|
||||
'invalid' : [],
|
||||
'valid' : ['i686', 'i386', 'x86_64'],
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
'distroinstaller' : {
|
||||
'init_conns' : [ testconn, None ],
|
||||
'init_conns' : [testconn, None],
|
||||
'location' : {
|
||||
'invalid' : ['nogood', 'http:/nogood', [], None,
|
||||
("pool-noexist", "default-vol"),
|
||||
("default-pool", "vol-noexist"),
|
||||
],
|
||||
],
|
||||
'valid' : ['/dev/null', 'http://web', 'ftp://ftp', 'nfs:nfsserv',
|
||||
'/tmp', # For installing from local dir tree
|
||||
("default-pool", "default-vol"),
|
||||
]}
|
||||
'/tmp', ("default-pool", "default-vol"),
|
||||
]}
|
||||
},
|
||||
|
||||
'livecdinstaller' : {
|
||||
'init_conns' : [ testconn, None ],
|
||||
'init_conns' : [testconn, None],
|
||||
'location' : {
|
||||
'invalid' : ['path-noexist',
|
||||
("pool-noexist", "default-vol"),
|
||||
("default-pool", "vol-noexist"),
|
||||
],
|
||||
],
|
||||
'valid' : ['/dev/null', ("default-pool", "default-vol"),
|
||||
]}
|
||||
]}
|
||||
},
|
||||
|
||||
'imageinstaller' : {
|
||||
'__init__' : {
|
||||
'invalid' : \
|
||||
'invalid' :
|
||||
[{'image' : virtimage, 'capabilities': testcaps, 'boot_index': 5},
|
||||
{'image' : virtimage, 'capabilities': "foo"}],
|
||||
'valid' : \
|
||||
'valid' :
|
||||
[{'image' : virtimage, 'capabilities': testcaps, 'boot_index': 1},
|
||||
{'image' : virtimage },
|
||||
{'image' : virtimage},
|
||||
{'image' : virtimage, 'capabilities': testcaps, 'conn': None}],
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
'network' : {
|
||||
'init_conns' : [ testconn, None ],
|
||||
'init_conns' : [testconn, None],
|
||||
'__init__' : {
|
||||
'invalid' : [ {'macaddr':0}, {'macaddr':''}, {'macaddr':'$%XD'},
|
||||
{'type':'network'} ],
|
||||
'invalid' : [{'macaddr' : 0}, {'macaddr' : ''}, {'macaddr' : '$%XD'},
|
||||
{'type' : 'network'}],
|
||||
'valid' : []}
|
||||
},
|
||||
|
||||
|
@ -207,53 +206,52 @@ args = {
|
|||
'original_guest' : {
|
||||
'invalid' : ['idontexist'],
|
||||
'valid' : ['test']},
|
||||
'clone_name': { 'invalid' : [0, 'test' # Already in use
|
||||
],
|
||||
'clone_name': {'invalid' : [0, 'test'],
|
||||
'valid' : ['some.valid-name_9']},
|
||||
'clone_uuid': { 'invalid' : [0],
|
||||
'clone_uuid': {'invalid' : [0],
|
||||
'valid' : ['12345678123456781234567812345678']},
|
||||
'clone_mac' : { 'invalid' : ['badformat'],
|
||||
'clone_mac' : {'invalid' : ['badformat'],
|
||||
'valid' : ['AA:BB:CC:DD:EE:FF']},
|
||||
'clone_bs' : { 'invalid' : [], 'valid' : ['valid']},
|
||||
'clone_bs' : {'invalid' : [], 'valid' : ['valid']},
|
||||
},
|
||||
|
||||
'inputdev' : {
|
||||
'init_conns' : [ testconn ],
|
||||
'init_conns' : [testconn],
|
||||
'type' : {
|
||||
'valid' : [ "mouse", "tablet"],
|
||||
'invalid' : [ "foobar", 1234]},
|
||||
'valid' : ["mouse", "tablet"],
|
||||
'invalid' : ["foobar", 1234]},
|
||||
'bus' : {
|
||||
'valid' : [ "ps2", "xen", "usb"],
|
||||
'invalid' : [ "foobar", 1234]},
|
||||
'valid' : ["ps2", "xen", "usb"],
|
||||
'invalid' : ["foobar", 1234]},
|
||||
},
|
||||
|
||||
'chardev' : {
|
||||
'init_conns' : [ testconn ],
|
||||
'init_conns' : [testconn],
|
||||
'source_path': {
|
||||
'invalid' : [],
|
||||
'valid' : [ "/some/path" ]},
|
||||
'valid' : ["/some/path"]},
|
||||
'source_mode': {
|
||||
'invalid' : [ None ],
|
||||
'valid' : virtinst.VirtualCharDevice.char_modes },
|
||||
'invalid' : [None],
|
||||
'valid' : virtinst.VirtualCharDevice.char_modes},
|
||||
'source_host': {
|
||||
'invalid' : [],
|
||||
'valid' : [ "some.source.host" ]},
|
||||
'valid' : ["some.source.host"]},
|
||||
'source_port': {
|
||||
'invalid' : [ "foobar"],
|
||||
'valid' : [ 1234 ]},
|
||||
'invalid' : ["foobar"],
|
||||
'valid' : [1234]},
|
||||
'connect_host': {
|
||||
'invalid' : [],
|
||||
'valid' : [ "some.connect.com" ]},
|
||||
'valid' : ["some.connect.com"]},
|
||||
'connect_port': {
|
||||
'invalid' : [ "foobar"],
|
||||
'valid' : [ 1234 ]},
|
||||
'invalid' : ["foobar"],
|
||||
'valid' : [1234]},
|
||||
'protocol': {
|
||||
'invalid' : [ None ],
|
||||
'valid' : virtinst.VirtualCharDevice.char_protocols },
|
||||
'invalid' : [None],
|
||||
'valid' : virtinst.VirtualCharDevice.char_protocols},
|
||||
},
|
||||
|
||||
'interface' : {
|
||||
'init_conns' : [ testconn ],
|
||||
'init_conns' : [testconn],
|
||||
'name' : {
|
||||
'invalid' : ["eth0", None, 1234],
|
||||
'valid' : ["foobar"], },
|
||||
|
@ -341,7 +339,7 @@ args = {
|
|||
|
||||
}
|
||||
|
||||
} # End of validation dict
|
||||
} # End of validation dict
|
||||
|
||||
|
||||
class TestValidation(unittest.TestCase):
|
||||
|
@ -409,7 +407,7 @@ class TestValidation(unittest.TestCase):
|
|||
@name String name indexing args"""
|
||||
logging.debug("Testing '%s'", name)
|
||||
testdict = args[name]
|
||||
if manual_dict != None:
|
||||
if manual_dict is not None:
|
||||
testdict = manual_dict
|
||||
|
||||
for paramname in testdict.keys():
|
||||
|
|
|
@ -30,6 +30,7 @@ virtimage_output = BASE + "/virtimage_output"
|
|||
|
||||
ovf_input = BASE + "/ovf_input"
|
||||
|
||||
|
||||
class TestVirtConv(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
@ -43,7 +44,7 @@ class TestVirtConv(unittest.TestCase):
|
|||
raise AssertionError("find_parser_by_file for '%s' returned "
|
||||
"wrong parser type.\n"
|
||||
"Expected: %s\n"
|
||||
"Received: %s\n" % \
|
||||
"Received: %s\n" %
|
||||
(infile, in_type,
|
||||
str((not inp) and str(inp) or inp.name)))
|
||||
|
||||
|
|
|
@ -43,17 +43,21 @@ _kvmconn = utils.open_testkvmdriver()
|
|||
_plainkvm = utils.open_plainkvm()
|
||||
_plainxen = utils.open_plainxen()
|
||||
|
||||
|
||||
def qemu_uri():
|
||||
return "qemu:///system"
|
||||
|
||||
|
||||
def xen_uri():
|
||||
return "xen:///"
|
||||
|
||||
|
||||
def build_xmlfile(filebase):
|
||||
if not filebase:
|
||||
return None
|
||||
return os.path.join("tests/xmlconfig-xml", filebase + ".xml")
|
||||
|
||||
|
||||
class TestXMLConfig(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
@ -482,11 +486,11 @@ class TestXMLConfig(unittest.TestCase):
|
|||
def testKVMKeymap(self):
|
||||
conn = utils.open_plainkvm(connver=10000)
|
||||
g = virtinst.VirtualGraphics(conn=conn, type="vnc")
|
||||
self.assertTrue(g.keymap != None)
|
||||
self.assertTrue(g.keymap is not None)
|
||||
|
||||
conn = utils.open_plainkvm(connver=11000)
|
||||
g = virtinst.VirtualGraphics(conn=conn, type="vnc")
|
||||
self.assertTrue(g.keymap == None)
|
||||
self.assertTrue(g.keymap is None)
|
||||
|
||||
|
||||
def testF11Qemu(self):
|
||||
|
@ -785,7 +789,7 @@ class TestXMLConfig(unittest.TestCase):
|
|||
|
||||
# Check keymap autoconfig
|
||||
gdev1 = virtinst.VirtualGraphics(conn=g.conn, type="vnc")
|
||||
self.assertTrue(gdev1.keymap != None)
|
||||
self.assertTrue(gdev1.keymap is not None)
|
||||
gdev1.keymap = "en-us"
|
||||
|
||||
# Check keymap None
|
||||
|
|
|
@ -25,11 +25,13 @@ from tests import utils
|
|||
conn = utils.open_testdriver()
|
||||
kvmconn = utils.open_testkvmdriver()
|
||||
|
||||
|
||||
def sanitize_file_xml(xml):
|
||||
# s/"/'/g from generated XML, matches what libxml dumps out
|
||||
# This won't work all the time, but should be good enough for testing
|
||||
return xml.replace("'", "\"")
|
||||
|
||||
|
||||
class XMLParseTest(unittest.TestCase):
|
||||
|
||||
def _roundtrip_compare(self, filename):
|
||||
|
|
1
todo.txt
1
todo.txt
|
@ -59,7 +59,6 @@ start a spice guest, shrink the window to smaller than guest resolution, scrollb
|
|||
After virtinst merge
|
||||
====================
|
||||
|
||||
enable all pep8 bits
|
||||
drop old stuff from both spec files
|
||||
update README
|
||||
virtinst initrd test: drop the big files? just stub em out
|
||||
|
|
10
virt-clone
10
virt-clone
|
@ -44,6 +44,7 @@ def get_clone_name(new_name, auto_clone, design):
|
|||
err_txt = _("A name is required for the new virtual machine.")
|
||||
cli.prompt_loop(prompt_txt, err_txt, new_name, design, "clone_name")
|
||||
|
||||
|
||||
def get_original_guest(guest_name, origfile, design):
|
||||
|
||||
origxml = None
|
||||
|
@ -63,6 +64,7 @@ def get_original_guest(guest_name, origfile, design):
|
|||
cli.prompt_loop(prompt_txt, err_txt,
|
||||
guest_name, design, "original_guest")
|
||||
|
||||
|
||||
def get_clone_macaddr(new_mac, design):
|
||||
if new_mac is None:
|
||||
pass
|
||||
|
@ -72,10 +74,12 @@ def get_clone_macaddr(new_mac, design):
|
|||
for i in new_mac:
|
||||
design.clone_mac = i
|
||||
|
||||
|
||||
def get_clone_uuid(new_uuid, design):
|
||||
if new_uuid is not None:
|
||||
design.clone_uuid = new_uuid
|
||||
|
||||
|
||||
def get_clone_diskfile(new_diskfiles, design, conn, preserve=False,
|
||||
auto_clone=False):
|
||||
if new_diskfiles is None:
|
||||
|
@ -103,6 +107,7 @@ def get_clone_diskfile(new_diskfiles, design, conn, preserve=False,
|
|||
design.clone_devices = devpath
|
||||
newidx += 1
|
||||
|
||||
|
||||
def _check_disk(conn, clone_path, orig_path, preserve):
|
||||
|
||||
prompt_txt = (_("What would you like to use as the cloned disk "
|
||||
|
@ -114,9 +119,11 @@ def _check_disk(conn, clone_path, orig_path, preserve):
|
|||
check_size=False,
|
||||
path_to_clone=orig_path)
|
||||
|
||||
|
||||
def get_clone_sparse(sparse, design):
|
||||
design.clone_sparse = sparse
|
||||
|
||||
|
||||
def get_preserve(preserve, design):
|
||||
design.preserve = preserve
|
||||
|
||||
|
@ -125,6 +132,7 @@ def get_force_target(target, design):
|
|||
for i in target or []:
|
||||
design.force_target = i
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = cli.setupParser()
|
||||
cli.add_connect_option(parser)
|
||||
|
@ -196,6 +204,8 @@ def parse_args():
|
|||
return options, parseargs
|
||||
|
||||
### Let's do it!
|
||||
|
||||
|
||||
def main(conn=None):
|
||||
cli.earlyLogging()
|
||||
options, parseargs = parse_args()
|
||||
|
|
|
@ -153,6 +153,7 @@ def parse_args():
|
|||
|
||||
return options
|
||||
|
||||
|
||||
def cleanup(msg, options, vmdef, paths):
|
||||
"""
|
||||
After failure, clean up anything we created.
|
||||
|
@ -177,6 +178,7 @@ def cleanup(msg, options, vmdef, paths):
|
|||
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def main():
|
||||
cli.earlyLogging()
|
||||
options = parse_args()
|
||||
|
@ -215,7 +217,7 @@ def main():
|
|||
logging.debug("Creating directory %s", options.output_dir)
|
||||
if options.nodry:
|
||||
os.mkdir(options.output_dir)
|
||||
clean += [ options.output_dir ]
|
||||
clean += [options.output_dir]
|
||||
except OSError, e:
|
||||
if (e.errno != errno.EEXIST):
|
||||
fail("Could not create directory %s: %s" %
|
||||
|
@ -272,7 +274,7 @@ def main():
|
|||
outfile.writelines(output)
|
||||
outfile.close()
|
||||
|
||||
clean += [ options.output_file ]
|
||||
clean += [options.output_file]
|
||||
except ValueError, e:
|
||||
cleanup(_("Couldn't export to file \"%s\": %s") %
|
||||
(options.output_file, e), options, vmdef, clean)
|
||||
|
|
|
@ -44,12 +44,15 @@ def get_networks(domain, guest, options):
|
|||
|
||||
cli.get_networks(guest, networks, macs)
|
||||
|
||||
|
||||
def get_graphics(image, guest, options):
|
||||
graphics = cli.digest_graphics(guest, options,
|
||||
default_override=bool(image.graphics))
|
||||
cli.get_graphics(guest, graphics)
|
||||
|
||||
### Option parsing
|
||||
|
||||
|
||||
def parse_args():
|
||||
usage = "%prog [options] image.xml"
|
||||
parser = cli.setupParser(usage)
|
||||
|
@ -109,8 +112,6 @@ def parse_args():
|
|||
help=optparse.SUPPRESS_HELP)
|
||||
misc.add_option("", "--force", action="store_true", dest="force",
|
||||
default=False,
|
||||
#help=_("Do not prompt for input. Answers yes where "
|
||||
# "applicable, terminates for all other prompts"),
|
||||
help=optparse.SUPPRESS_HELP)
|
||||
misc.add_option("-q", "--quiet", action="store_true", dest="quiet",
|
||||
help=_("Suppress non-error output"))
|
||||
|
@ -124,6 +125,7 @@ def parse_args():
|
|||
|
||||
return options
|
||||
|
||||
|
||||
def main(conn=None):
|
||||
cli.earlyLogging()
|
||||
options = parse_args()
|
||||
|
@ -138,7 +140,7 @@ def main(conn=None):
|
|||
try:
|
||||
image = virtinst.ImageParser.parse_file(options.image)
|
||||
except virtinst.ImageParser.ParserException, msg:
|
||||
fail( "%s '%s': %s" % (_("Cannot parse"), options.image, msg))
|
||||
fail("%s '%s': %s" % (_("Cannot parse"), options.image, msg))
|
||||
|
||||
if options.boot is not None:
|
||||
nboots = len(image.domain.boots)
|
||||
|
|
29
virt-install
29
virt-install
|
@ -46,12 +46,14 @@ from virtinst.cli import fail, print_stdout, print_stderr
|
|||
|
||||
install_methods = "--location URL, --cdrom CD/ISO, --pxe, --import, --boot hd|cdrom|..."
|
||||
install_missing = (_("An install method must be specified\n(%(methods)s)") %
|
||||
{"methods" : install_methods })
|
||||
{"methods" : install_methods})
|
||||
disk_missing = _("--disk storage must be specified (override with --nodisks)")
|
||||
|
||||
|
||||
def install_specified(location, cdpath, pxe, import_install):
|
||||
return bool(pxe or cdpath or location or import_install)
|
||||
|
||||
|
||||
def cdrom_specified(guest, diskopts=None):
|
||||
disks = guest.get_devices("disk")
|
||||
|
||||
|
@ -67,9 +69,11 @@ def cdrom_specified(guest, diskopts=None):
|
|||
|
||||
return False
|
||||
|
||||
|
||||
def storage_specified(files, disks, nodisks, filesystems):
|
||||
return bool(files or disks or nodisks or filesystems)
|
||||
|
||||
|
||||
def supports_pxe(guest):
|
||||
"""
|
||||
Return False if we are pretty sure the config doesn't support PXE
|
||||
|
@ -115,6 +119,7 @@ def get_graphics(guest, options):
|
|||
graphics = cli.digest_graphics(guest, options)
|
||||
cli.get_graphics(guest, graphics)
|
||||
|
||||
|
||||
def get_chardevs(char_type, opts, guest, cb):
|
||||
for optstr in cli.listify(opts):
|
||||
try:
|
||||
|
@ -124,6 +129,7 @@ def get_chardevs(char_type, opts, guest, cb):
|
|||
fail(_("Error in %(chartype)s device parameters: %(err)s") %
|
||||
{"chartype": char_type, "err": str(e)})
|
||||
|
||||
|
||||
def get_watchdog(watchdogs, guest):
|
||||
for optstr in cli.listify(watchdogs):
|
||||
try:
|
||||
|
@ -132,6 +138,7 @@ def get_watchdog(watchdogs, guest):
|
|||
except Exception, e:
|
||||
fail(_("Error in watchdog device parameters: %s") % str(e))
|
||||
|
||||
|
||||
def get_filesystems(filesystems, guest):
|
||||
for optstr in cli.listify(filesystems):
|
||||
try:
|
||||
|
@ -140,6 +147,7 @@ def get_filesystems(filesystems, guest):
|
|||
except Exception, e:
|
||||
fail(_("Error in filesystem device parameters: %s") % str(e))
|
||||
|
||||
|
||||
def get_disk(diskopts, size, sparse, guest, is_file_path):
|
||||
try:
|
||||
dev = None
|
||||
|
@ -159,6 +167,7 @@ def get_disk(diskopts, size, sparse, guest, is_file_path):
|
|||
|
||||
guest.add_device(d)
|
||||
|
||||
|
||||
def get_disks(guest, file_paths, disk_paths, size, sparse, need_storage):
|
||||
is_file_path = (file_paths or (not disk_paths and cli.is_prompt()))
|
||||
disks = (file_paths or disk_paths)
|
||||
|
@ -176,6 +185,7 @@ def get_disks(guest, file_paths, disk_paths, size, sparse, need_storage):
|
|||
for idx in range(len(disklist)):
|
||||
get_disk(disklist[idx], sizelist[idx], sparse, guest, is_file_path)
|
||||
|
||||
|
||||
def get_networks(guest, options):
|
||||
networks, macs = cli.digest_networks(guest, options)
|
||||
cli.get_networks(guest, networks, macs)
|
||||
|
@ -238,6 +248,7 @@ def prompt_virt(caps, arch, req_virt_type, req_accel):
|
|||
|
||||
return (req_virt_type, req_accel)
|
||||
|
||||
|
||||
def get_virt_type(conn, options):
|
||||
|
||||
# Set up all virt/hypervisor parameters
|
||||
|
@ -318,6 +329,7 @@ def get_install_media(guest, location, cdpath, need_install):
|
|||
except ValueError, e:
|
||||
fail(_("Error validating install location: %s" % str(e)))
|
||||
|
||||
|
||||
def media_prompt(guest):
|
||||
if guest.installer.is_hvm():
|
||||
prompt_txt = _("What is the install CD-ROM/ISO or URL?")
|
||||
|
@ -344,6 +356,7 @@ def media_prompt(guest):
|
|||
continue
|
||||
break
|
||||
|
||||
|
||||
def validate_install_media(guest, location, cdpath, cdinstall=False):
|
||||
if cdinstall or cdpath:
|
||||
guest.installer.cdrom = True
|
||||
|
@ -389,6 +402,7 @@ def validate_required_options(options, guest):
|
|||
|
||||
return need_storage, need_install
|
||||
|
||||
|
||||
def check_option_collisions(options, guest):
|
||||
# Disk collisions
|
||||
if options.nodisks and (options.file_paths or
|
||||
|
@ -396,7 +410,7 @@ def check_option_collisions(options, guest):
|
|||
options.disksize):
|
||||
fail(_("Cannot specify storage and use --nodisks"))
|
||||
|
||||
if ((options.file_paths or options.disksize or options.sparse == False) and
|
||||
if ((options.file_paths or options.disksize or not options.sparse) and
|
||||
options.diskopts):
|
||||
fail(_("Cannot mix --file, --nonsparse, or --file-size with --disk "
|
||||
"options. Use --disk PATH[,size=SIZE][,sparse=yes|no]"))
|
||||
|
@ -474,6 +488,7 @@ def build_installer(options, conn, virt_type, hv_name, arch, machine):
|
|||
|
||||
return installer
|
||||
|
||||
|
||||
def build_guest_instance(conn, options):
|
||||
capsguest, capsdomain = get_virt_type(conn, options)
|
||||
|
||||
|
@ -568,7 +583,8 @@ def _run_console(args):
|
|||
return child
|
||||
|
||||
os.execvp(args[0], args)
|
||||
os._exit(1) # pylint: disable=W0212
|
||||
os._exit(1) # pylint: disable=W0212
|
||||
|
||||
|
||||
def vnc_console(dom, uri):
|
||||
args = ["/usr/bin/virt-viewer",
|
||||
|
@ -583,6 +599,7 @@ def vnc_console(dom, uri):
|
|||
|
||||
return _run_console(args)
|
||||
|
||||
|
||||
def txt_console(dom, uri):
|
||||
args = ["/usr/bin/virsh",
|
||||
"--connect", uri,
|
||||
|
@ -590,6 +607,7 @@ def txt_console(dom, uri):
|
|||
|
||||
return _run_console(args)
|
||||
|
||||
|
||||
def start_install(guest, continue_inst, options):
|
||||
def show_console(dom):
|
||||
gdev = guest.get_devices("graphics")
|
||||
|
@ -606,7 +624,7 @@ def start_install(guest, continue_inst, options):
|
|||
else:
|
||||
logging.debug("No viewer to launch for graphics type '%s'",
|
||||
gtype)
|
||||
return None # SDL needs no viewer app
|
||||
return None # SDL needs no viewer app
|
||||
|
||||
# There are two main cases we care about:
|
||||
#
|
||||
|
@ -620,7 +638,7 @@ def start_install(guest, continue_inst, options):
|
|||
#
|
||||
wait_on_install = continue_inst
|
||||
wait_time = -1
|
||||
if options.wait != None:
|
||||
if options.wait is not None:
|
||||
wait_on_install = True
|
||||
wait_time = options.wait * 60
|
||||
|
||||
|
@ -681,6 +699,7 @@ def start_install(guest, continue_inst, options):
|
|||
fail(e, do_exit=False)
|
||||
cli.install_fail(guest)
|
||||
|
||||
|
||||
def check_domain(guest, dom, conscb, wait_for_install, wait_time, start_time):
|
||||
"""
|
||||
Make sure domain ends up in expected state, and wait if for install
|
||||
|
|
14
virt-manager
14
virt-manager
|
@ -65,10 +65,11 @@ def drop_tty():
|
|||
# tty. This prevents libvirt's SSH tunnels from prompting
|
||||
# for user input if SSH keys/agent aren't configured.
|
||||
if os.fork() != 0:
|
||||
os._exit(0) # pylint: disable=W0212
|
||||
os._exit(0) # pylint: disable=W0212
|
||||
|
||||
os.setsid()
|
||||
|
||||
|
||||
def drop_stdio():
|
||||
# We close STDIN/OUT/ERR since they're generally spewing
|
||||
# junk to console when domains are in process of shutting
|
||||
|
@ -85,6 +86,7 @@ def drop_stdio():
|
|||
os.dup2(0, 1)
|
||||
os.dup2(0, 2)
|
||||
|
||||
|
||||
def parse_commandline():
|
||||
optParser = optparse.OptionParser(version=cliconfig.__version__,
|
||||
usage="virt-manager [options]")
|
||||
|
@ -152,6 +154,7 @@ def launch_specific_window(engine, show, uri, uuid):
|
|||
elif show == 'summary':
|
||||
engine.show_host_summary(uri)
|
||||
|
||||
|
||||
def _conn_state_changed(conn, engine, show, uri, uuid):
|
||||
if conn.state == conn.STATE_DISCONNECTED:
|
||||
return True
|
||||
|
@ -162,6 +165,8 @@ def _conn_state_changed(conn, engine, show, uri, uuid):
|
|||
return True
|
||||
|
||||
# maps --show-* to engine (ie local instance) methods
|
||||
|
||||
|
||||
def show_engine(engine, show, uri, uuid, no_conn_auto):
|
||||
conn = None
|
||||
|
||||
|
@ -182,6 +187,8 @@ def show_engine(engine, show, uri, uuid, no_conn_auto):
|
|||
engine.autostart_conns()
|
||||
|
||||
# maps --show-* to remote manager (ie dbus call) methods
|
||||
|
||||
|
||||
def show_remote(managerObj, show, uri, uuid):
|
||||
# Do this regardless
|
||||
managerObj.show_manager()
|
||||
|
@ -189,6 +196,7 @@ def show_remote(managerObj, show, uri, uuid):
|
|||
if show or uri or uuid:
|
||||
launch_specific_window(managerObj, show, uri, uuid)
|
||||
|
||||
|
||||
def dbus_config(engine):
|
||||
"""
|
||||
Setup dbus interface
|
||||
|
@ -221,6 +229,8 @@ def dbus_config(engine):
|
|||
# Generic OptionParser callback for all --show-* options
|
||||
# This routine stores UUID to options.uuid for all --show-* options
|
||||
# where is metavar="UUID" and also sets options.show
|
||||
|
||||
|
||||
def opt_show_cb(option, opt_str, value, parser):
|
||||
if option.metavar == "UUID":
|
||||
setattr(parser.values, "uuid", value)
|
||||
|
@ -237,7 +247,7 @@ def main():
|
|||
origargs = " ".join(sys.argv[:])
|
||||
|
||||
try:
|
||||
from gi.repository import Gtk # pylint: disable=E0611
|
||||
from gi.repository import Gtk # pylint: disable=E0611
|
||||
except:
|
||||
# Don't just let the exception raise here. abrt reports bugs
|
||||
# when users mess up su/sudo and DISPLAY isn't set. Printing
|
||||
|
|
|
@ -40,11 +40,13 @@ def parse_commandline():
|
|||
|
||||
return optParser.parse_args()
|
||||
|
||||
|
||||
def _show_startup_error(message, details):
|
||||
errordlg = DialogScreen("Error Starting Virtual Machine Manager",
|
||||
message + "\n\n" + details)
|
||||
errordlg.show()
|
||||
|
||||
|
||||
def main():
|
||||
cliutils.setup_i18n()
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import logging
|
|||
|
||||
from virtManager.baseclass import vmmGObjectUI
|
||||
|
||||
|
||||
class vmmAbout(vmmGObjectUI):
|
||||
def __init__(self):
|
||||
vmmGObjectUI.__init__(self, "vmm-about.ui", "vmm-about")
|
||||
|
|
|
@ -33,6 +33,7 @@ import urlgrabber
|
|||
|
||||
from virtManager.baseclass import vmmGObjectUI
|
||||
|
||||
|
||||
class vmmCreateMeter(urlgrabber.progress.BaseMeter):
|
||||
def __init__(self, asyncjob):
|
||||
# progress meter has to run asynchronously, so pass in the
|
||||
|
@ -94,6 +95,7 @@ class asyncJobWorker(threading.Thread):
|
|||
def run(self):
|
||||
threading.Thread.run(self)
|
||||
|
||||
|
||||
def cb_wrapper(callback, asyncjob, *args, **kwargs):
|
||||
try:
|
||||
callback(asyncjob, *args, **kwargs)
|
||||
|
@ -106,6 +108,7 @@ def cb_wrapper(callback, asyncjob, *args, **kwargs):
|
|||
|
||||
asyncjob.set_error(str(e), "".join(traceback.format_exc()))
|
||||
|
||||
|
||||
def _simple_async(callback, args, title, text, parent, errorintro,
|
||||
show_progress, simplecb, errorcb):
|
||||
"""
|
||||
|
@ -134,12 +137,15 @@ def _simple_async(callback, args, title, text, parent, errorintro,
|
|||
parent.err.show_err(error,
|
||||
details=details)
|
||||
|
||||
|
||||
def idle_wrapper(fn):
|
||||
def wrapped(self, *args, **kwargs):
|
||||
return self.idle_add(fn, self, *args, **kwargs)
|
||||
return wrapped
|
||||
|
||||
# Displays a progress bar while executing the "callback" method.
|
||||
|
||||
|
||||
class vmmAsyncJob(vmmGObjectUI):
|
||||
|
||||
@staticmethod
|
||||
|
|
|
@ -471,7 +471,7 @@ class AutoDrawer(Drawer):
|
|||
|
||||
if toplevel.get_group():
|
||||
# XXX: Not in pyGtk.
|
||||
#grabbed = toplevel.get_group().get_current_grab()
|
||||
# grabbed = toplevel.get_group().get_current_grab()
|
||||
pass
|
||||
if not grabbed:
|
||||
grabbed = Gtk.grab_get_current()
|
||||
|
|
|
@ -164,7 +164,7 @@ class vmmGObject(GObject.GObject):
|
|||
|
||||
def __del__(self):
|
||||
# XXX
|
||||
#GObject.GObject.__del__(self)
|
||||
# GObject.GObject.__del__(self)
|
||||
|
||||
try:
|
||||
if self.config and self._leak_check:
|
||||
|
@ -172,6 +172,7 @@ class vmmGObject(GObject.GObject):
|
|||
except:
|
||||
logging.exception("Error removing %s", self.object_key)
|
||||
|
||||
|
||||
class vmmGObjectUI(vmmGObject):
|
||||
def __init__(self, filename, windowname):
|
||||
vmmGObject.__init__(self)
|
||||
|
|
|
@ -29,6 +29,7 @@ from virtManager.baseclass import vmmGObjectUI
|
|||
from virtManager.mediadev import MEDIA_FLOPPY
|
||||
from virtManager.storagebrowse import vmmStorageBrowser
|
||||
|
||||
|
||||
class vmmChooseCD(vmmGObjectUI):
|
||||
__gsignals__ = {
|
||||
"cdrom-chosen": (GObject.SignalFlags.RUN_FIRST, None, [object, str])
|
||||
|
|
|
@ -63,6 +63,7 @@ NETWORK_INFO_NEW_MAC = 2
|
|||
# XXX: What to do for cleanup if clone fails?
|
||||
# XXX: Disable mouse scroll for combo boxes
|
||||
|
||||
|
||||
def can_we_clone(conn, vol, path):
|
||||
"""Is the passed path even clone-able"""
|
||||
ret = True
|
||||
|
@ -94,6 +95,7 @@ def can_we_clone(conn, vol, path):
|
|||
|
||||
return (ret, msg)
|
||||
|
||||
|
||||
def do_we_default(conn, vol, path, ro, shared, devtype):
|
||||
""" Returns (do we clone by default?, info string if not)"""
|
||||
ignore = conn
|
||||
|
@ -121,6 +123,7 @@ def do_we_default(conn, vol, path, ro, shared, devtype):
|
|||
|
||||
return (not info, info)
|
||||
|
||||
|
||||
class vmmCloneVM(vmmGObjectUI):
|
||||
def __init__(self, orig_vm):
|
||||
vmmGObjectUI.__init__(self, "vmm-clone.ui", "vmm-clone")
|
||||
|
|
|
@ -140,10 +140,10 @@ class vmmConfig(object):
|
|||
nv.set_string(v)
|
||||
newValues.append(nv)
|
||||
ignore = path
|
||||
#XXX: set_list is not available with introspection
|
||||
# XXX: set_list is not available with introspection
|
||||
# val = GConf.Value()
|
||||
#val.set_list(newValues)
|
||||
#self.conf.set(path, val)
|
||||
# val.set_list(newValues)
|
||||
# self.conf.set(path, val)
|
||||
|
||||
def check_inspection(self, support_threading):
|
||||
if not support_threading:
|
||||
|
@ -151,20 +151,20 @@ class vmmConfig(object):
|
|||
|
||||
try:
|
||||
# Check we can open the Python guestfs module.
|
||||
from guestfs import GuestFS # pylint: disable=F0401
|
||||
from guestfs import GuestFS # pylint: disable=F0401
|
||||
g = GuestFS()
|
||||
|
||||
# Check for the first version which fixed Python GIL bug.
|
||||
version = g.version()
|
||||
if version["major"] == 1: # major must be 1
|
||||
if version["major"] == 1: # major must be 1
|
||||
if version["minor"] == 8:
|
||||
if version["release"] >= 6: # >= 1.8.6
|
||||
if version["release"] >= 6: # >= 1.8.6
|
||||
return True
|
||||
elif version["minor"] == 10:
|
||||
if version["release"] >= 1: # >= 1.10.1
|
||||
if version["release"] >= 1: # >= 1.10.1
|
||||
return True
|
||||
elif version["minor"] == 11:
|
||||
if version["release"] >= 2: # >= 1.11.2
|
||||
if version["release"] >= 2: # >= 1.11.2
|
||||
return True
|
||||
elif version["minor"] >= 12: # >= 1.12, 1.13, etc.
|
||||
return True
|
||||
|
|
|
@ -39,6 +39,7 @@ CONN_SSH = 0
|
|||
CONN_TCP = 1
|
||||
CONN_TLS = 2
|
||||
|
||||
|
||||
def current_user():
|
||||
try:
|
||||
import getpass
|
||||
|
@ -46,6 +47,7 @@ def current_user():
|
|||
except:
|
||||
return ""
|
||||
|
||||
|
||||
def default_conn_user(conn):
|
||||
if conn == CONN_SSH:
|
||||
return "root"
|
||||
|
@ -219,7 +221,7 @@ class vmmConnect(vmmGObjectUI):
|
|||
# Call method to create new browser, and get back an object path for it.
|
||||
interface = -1 # physical interface to use? -1 is unspec
|
||||
protocol = 0 # 0 = IPv4, 1 = IPv6, -1 = Unspecified
|
||||
service = '_libvirt._tcp' # Service name to poll for
|
||||
service = '_libvirt._tcp' # Service name to poll for
|
||||
flags = 0 # Extra option flags
|
||||
domain = "" # Domain to browse in. NULL uses default
|
||||
bpath = self.server.ServiceBrowserNew(interface, protocol, service,
|
||||
|
|
|
@ -29,6 +29,7 @@ import time
|
|||
import dbus
|
||||
import libvirt
|
||||
|
||||
|
||||
def do_we_have_session():
|
||||
pid = os.getpid()
|
||||
try:
|
||||
|
@ -126,7 +127,7 @@ def creds_dialog_main(creds):
|
|||
"""
|
||||
Libvirt openAuth callback for username/password credentials
|
||||
"""
|
||||
from gi.repository import Gtk # pylint: disable=E0611
|
||||
from gi.repository import Gtk # pylint: disable=E0611
|
||||
|
||||
dialog = Gtk.Dialog("Authentication required", None, 0,
|
||||
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
||||
|
|
|
@ -171,7 +171,7 @@ class Tunnel(object):
|
|||
os.dup(fds[1].fileno())
|
||||
os.dup(errorfds[1].fileno())
|
||||
os.execlp(*argv)
|
||||
os._exit(1) # pylint: disable=W0212
|
||||
os._exit(1) # pylint: disable=W0212
|
||||
else:
|
||||
fds[1].close()
|
||||
errorfds[1].close()
|
||||
|
@ -614,7 +614,7 @@ class vmmConsolePages(vmmGObjectUI):
|
|||
|
||||
# State for disabling modifiers when keyboard is grabbed
|
||||
# XXX
|
||||
#self.accel_groups = Gtk.accel_groups_from_object(self.topwin)
|
||||
# self.accel_groups = Gtk.accel_groups_from_object(self.topwin)
|
||||
self.accel_groups = []
|
||||
self.gtk_settings_accel = None
|
||||
self.gtk_settings_mnemonic = None
|
||||
|
@ -917,7 +917,7 @@ class vmmConsolePages(vmmGObjectUI):
|
|||
if self.viewer is None:
|
||||
return
|
||||
|
||||
v = self.viewer # close_viewer() can be reentered
|
||||
v = self.viewer # close_viewer() can be reentered
|
||||
self.viewer = None
|
||||
w = v.display
|
||||
|
||||
|
@ -1265,6 +1265,6 @@ class vmmConsolePages(vmmGObjectUI):
|
|||
desktop_h = int(req.width / desktop_ratio)
|
||||
dy = (req.height - desktop_h) / 2
|
||||
|
||||
#viewer_alloc = (x=dx, y=dy, width=desktop_w, height=desktop_h)
|
||||
# viewer_alloc = (x=dx, y=dy, width=desktop_w, height=desktop_h)
|
||||
viewer_alloc = (dx, dy, desktop_w, desktop_h)
|
||||
self.viewer.display.size_allocate(viewer_alloc)
|
||||
|
|
|
@ -1157,7 +1157,7 @@ class vmmCreate(vmmGObjectUI):
|
|||
self.widget("install-os-type").hide()
|
||||
self.widget("install-os-version").hide()
|
||||
self.mediaDetected = False
|
||||
self.detect_media_os() # Run detection
|
||||
self.detect_media_os() # Run detection
|
||||
else:
|
||||
self.widget("install-os-type-label").hide()
|
||||
self.widget("install-os-version-label").hide()
|
||||
|
|
|
@ -58,6 +58,7 @@ IP_DHCP = 0
|
|||
IP_STATIC = 1
|
||||
IP_NONE = 2
|
||||
|
||||
|
||||
class vmmCreateInterface(vmmGObjectUI):
|
||||
__gsignals__ = {}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ from virtinst import Storage
|
|||
PAGE_NAME = 0
|
||||
PAGE_FORMAT = 1
|
||||
|
||||
|
||||
class vmmCreatePool(vmmGObjectUI):
|
||||
def __init__(self, conn):
|
||||
vmmGObjectUI.__init__(self,
|
||||
|
|
|
@ -35,6 +35,7 @@ from virtinst import Storage
|
|||
DEFAULT_ALLOC = 0
|
||||
DEFAULT_CAP = 8192
|
||||
|
||||
|
||||
class vmmCreateVolume(vmmGObjectUI):
|
||||
__gsignals__ = {
|
||||
"vol-created": (GObject.SignalFlags.RUN_FIRST, None, []),
|
||||
|
|
|
@ -43,6 +43,7 @@ STORAGE_ROW_ICON = 5
|
|||
STORAGE_ROW_ICON_SIZE = 6
|
||||
STORAGE_ROW_TOOLTIP = 7
|
||||
|
||||
|
||||
class vmmDeleteDialog(vmmGObjectUI):
|
||||
def __init__(self):
|
||||
vmmGObjectUI.__init__(self, "vmm-delete.ui", "vmm-delete")
|
||||
|
@ -322,12 +323,14 @@ def prepare_storage_list(storage_list):
|
|||
infoCol.add_attribute(info_img, 'stock-size', STORAGE_ROW_ICON_SIZE)
|
||||
infoCol.set_sort_column_id(STORAGE_ROW_ICON)
|
||||
|
||||
|
||||
def storage_item_toggled(src, index, storage_list):
|
||||
active = src.get_active()
|
||||
|
||||
model = storage_list.get_model()
|
||||
model[index][STORAGE_ROW_CONFIRM] = not active
|
||||
|
||||
|
||||
def can_delete(conn, vol, path):
|
||||
"""Is the passed path even deleteable"""
|
||||
ret = True
|
||||
|
@ -353,6 +356,7 @@ def can_delete(conn, vol, path):
|
|||
|
||||
return (ret, msg)
|
||||
|
||||
|
||||
def do_we_default(conn, vm_name, vol, path, ro, shared):
|
||||
""" Returns (do we delete by default?, info string if not)"""
|
||||
info = ""
|
||||
|
|
|
@ -140,6 +140,7 @@ PAGE_CONSOLE = 0
|
|||
PAGE_DETAILS = 1
|
||||
PAGE_DYNAMIC_OFFSET = 2
|
||||
|
||||
|
||||
def prettyify_disk_bus(bus):
|
||||
if bus in ["ide", "sata", "scsi", "usb"]:
|
||||
return bus.upper()
|
||||
|
@ -155,6 +156,7 @@ def prettyify_disk_bus(bus):
|
|||
|
||||
return bus
|
||||
|
||||
|
||||
def prettyify_disk(devtype, bus, idx):
|
||||
busstr = prettyify_disk_bus(bus) or ""
|
||||
|
||||
|
@ -173,6 +175,7 @@ def prettyify_disk(devtype, bus, idx):
|
|||
|
||||
return "%s %s" % (ret, idx)
|
||||
|
||||
|
||||
def safeint(val, fmt="%.3d"):
|
||||
try:
|
||||
int(val)
|
||||
|
@ -180,12 +183,14 @@ def safeint(val, fmt="%.3d"):
|
|||
return str(val)
|
||||
return fmt % int(val)
|
||||
|
||||
|
||||
def prettyify_bytes(val):
|
||||
if val > (1024 * 1024 * 1024):
|
||||
return "%2.2f GB" % (val / (1024.0 * 1024.0 * 1024.0))
|
||||
else:
|
||||
return "%2.2f MB" % (val / (1024.0 * 1024.0))
|
||||
|
||||
|
||||
def build_redir_label(redirdev):
|
||||
# String shown in the devices details section
|
||||
addrlabel = ""
|
||||
|
@ -249,6 +254,7 @@ def build_hostdev_label(hostdev):
|
|||
|
||||
return srclabel, hwlabel
|
||||
|
||||
|
||||
def lookup_nodedev(vmmconn, hostdev):
|
||||
def intify(val, do_hex=False):
|
||||
try:
|
||||
|
@ -303,6 +309,7 @@ def lookup_nodedev(vmmconn, hostdev):
|
|||
|
||||
return found_dev
|
||||
|
||||
|
||||
class vmmDetails(vmmGObjectUI):
|
||||
__gsignals__ = {
|
||||
"action-save-domain": (GObject.SignalFlags.RUN_FIRST, None, [str, str]),
|
||||
|
@ -3029,7 +3036,7 @@ class vmmDetails(vmmGObjectUI):
|
|||
return
|
||||
|
||||
ident = "%s:%s" % (inp.type, inp.bus)
|
||||
if ident == "tablet:usb":
|
||||
if ident == "tablet:usb":
|
||||
dev = _("EvTouch USB Graphics Tablet")
|
||||
elif ident == "mouse:usb":
|
||||
dev = _("Generic USB Mouse")
|
||||
|
|
|
@ -34,6 +34,7 @@ import virtinst.support as support
|
|||
from virtManager import util
|
||||
from virtManager.libvirtobject import vmmLibvirtObject
|
||||
|
||||
|
||||
def compare_device(origdev, newdev, idx):
|
||||
devprops = {
|
||||
"disk" : ["target", "bus"],
|
||||
|
@ -74,6 +75,7 @@ def compare_device(origdev, newdev, idx):
|
|||
|
||||
return True
|
||||
|
||||
|
||||
def find_device(guest, origdev):
|
||||
devlist = guest.get_devices(origdev.virtual_device_type)
|
||||
for idx in range(len(devlist)):
|
||||
|
@ -83,6 +85,7 @@ def find_device(guest, origdev):
|
|||
|
||||
return None
|
||||
|
||||
|
||||
def start_job_progress_thread(vm, meter, progtext):
|
||||
current_thread = threading.currentThread()
|
||||
|
||||
|
@ -96,7 +99,7 @@ def start_job_progress_thread(vm, meter, progtext):
|
|||
try:
|
||||
jobinfo = vm.job_info()
|
||||
data_total = float(jobinfo[3])
|
||||
#data_processed = float(jobinfo[4])
|
||||
# data_processed = float(jobinfo[4])
|
||||
data_remaining = float(jobinfo[5])
|
||||
|
||||
# data_total is 0 if the job hasn't started yet
|
||||
|
@ -122,6 +125,7 @@ def start_job_progress_thread(vm, meter, progtext):
|
|||
t.daemon = True
|
||||
t.start()
|
||||
|
||||
|
||||
class vmmInspectionData(object):
|
||||
def __init__(self):
|
||||
self.type = None
|
||||
|
@ -134,6 +138,7 @@ class vmmInspectionData(object):
|
|||
self.icon = None
|
||||
self.applications = None
|
||||
|
||||
|
||||
class vmmDomain(vmmLibvirtObject):
|
||||
"""
|
||||
Class wrapping virDomain libvirt objects. Is also extended to be
|
||||
|
@ -1298,7 +1303,7 @@ class vmmDomain(vmmLibvirtObject):
|
|||
self.record[1]["timestamp"]))
|
||||
else:
|
||||
ret = 0.0
|
||||
return max(ret, 0, 0) # avoid negative values at poweroff
|
||||
return max(ret, 0, 0) # avoid negative values at poweroff
|
||||
|
||||
def _set_max_rate(self, record, what):
|
||||
if record[what] > self.maxRecord[what]:
|
||||
|
|
|
@ -54,6 +54,7 @@ from virtManager.systray import vmmSystray
|
|||
# XXX: gtk3 has issues here
|
||||
debug_ref_leaks = False
|
||||
|
||||
|
||||
def default_uri():
|
||||
tryuri = None
|
||||
if os.path.exists("/var/lib/xend") and os.path.exists("/proc/xen"):
|
||||
|
@ -71,6 +72,7 @@ DETAILS_PERF = 1
|
|||
DETAILS_CONFIG = 2
|
||||
DETAILS_CONSOLE = 3
|
||||
|
||||
|
||||
def _safe_getattr(obj, name):
|
||||
if not hasattr(obj, name):
|
||||
return None
|
||||
|
|
|
@ -26,6 +26,7 @@ import traceback
|
|||
|
||||
from virtManager.baseclass import vmmGObject
|
||||
|
||||
|
||||
def _launch_dialog(dialog, primary_text, secondary_text, title,
|
||||
sync=True):
|
||||
dialog.set_property("text", primary_text)
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
_is_gui = True
|
||||
|
||||
|
||||
class stubclass(object):
|
||||
def __init__(self, *args, **kwargs):
|
||||
ignore = args
|
||||
|
@ -35,12 +36,14 @@ class stubclass(object):
|
|||
ignore = attr
|
||||
ignore = val
|
||||
|
||||
|
||||
def is_gui(isgui=None):
|
||||
global _is_gui
|
||||
if isgui is not None:
|
||||
_is_gui = isgui
|
||||
return _is_gui
|
||||
|
||||
|
||||
def get_running_config():
|
||||
if _is_gui:
|
||||
import virtManager.util
|
||||
|
|
|
@ -33,18 +33,21 @@ from virtManager.mediadev import vmmMediaDevice
|
|||
|
||||
_hal_helper = None
|
||||
|
||||
|
||||
def get_hal_helper(init=True):
|
||||
global _hal_helper
|
||||
if not _hal_helper and init:
|
||||
_hal_helper = vmmHalHelper()
|
||||
return _hal_helper
|
||||
|
||||
|
||||
def cleanup():
|
||||
global _hal_helper
|
||||
if _hal_helper:
|
||||
_hal_helper.cleanup()
|
||||
_hal_helper = None
|
||||
|
||||
|
||||
def get_net_bridge_owner(name_ignore, sysfspath):
|
||||
# Now magic to determine if the device is part of a bridge
|
||||
brportpath = os.path.join(sysfspath, "brport")
|
||||
|
@ -60,6 +63,7 @@ def get_net_bridge_owner(name_ignore, sysfspath):
|
|||
|
||||
return None
|
||||
|
||||
|
||||
def get_net_mac_address(name_ignore, sysfspath):
|
||||
mac = None
|
||||
addrpath = sysfspath + "/address"
|
||||
|
@ -69,6 +73,7 @@ def get_net_mac_address(name_ignore, sysfspath):
|
|||
df.close()
|
||||
return mac
|
||||
|
||||
|
||||
def get_bonding_masters():
|
||||
masters = []
|
||||
if os.path.exists("/sys/class/net/bonding_masters"):
|
||||
|
@ -83,12 +88,14 @@ def get_bonding_masters():
|
|||
masters = rline[:].split(' ')
|
||||
return masters
|
||||
|
||||
|
||||
def is_net_bonding_slave(name_ignore, sysfspath):
|
||||
masterpath = sysfspath + "/master"
|
||||
if os.path.exists(masterpath):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
class vmmHalHelper(vmmGObject):
|
||||
__gsignals__ = {
|
||||
"netdev-added": (GObject.SignalFlags.RUN_FIRST, None, [object]),
|
||||
|
|
|
@ -43,6 +43,7 @@ from virtManager.graphwidgets import Sparkline
|
|||
INTERFACE_PAGE_INFO = 0
|
||||
INTERFACE_PAGE_ERROR = 1
|
||||
|
||||
|
||||
class vmmHost(vmmGObjectUI):
|
||||
__gsignals__ = {
|
||||
"action-exit-app": (GObject.SignalFlags.RUN_FIRST, None, []),
|
||||
|
@ -1271,6 +1272,7 @@ def init_pool_list(pool_list, changed_func):
|
|||
pool_list.append_column(poolCol)
|
||||
poolListModel.set_sort_column_id(1, Gtk.SortType.ASCENDING)
|
||||
|
||||
|
||||
def refresh_pool_in_list(pool_list, conn, uuid):
|
||||
for row in pool_list.get_model():
|
||||
if row[0] == uuid:
|
||||
|
@ -1279,6 +1281,7 @@ def refresh_pool_in_list(pool_list, conn, uuid):
|
|||
row[2] = conn.get_pool(uuid).is_active()
|
||||
return
|
||||
|
||||
|
||||
def populate_storage_pools(pool_list, conn):
|
||||
model = pool_list.get_model()
|
||||
model.clear()
|
||||
|
@ -1297,6 +1300,7 @@ def populate_storage_pools(pool_list, conn):
|
|||
pool_list.get_selection().select_iter(_iter)
|
||||
pool_list.get_selection().emit("changed")
|
||||
|
||||
|
||||
def get_pool_size_percent(conn, uuid):
|
||||
pool = conn.get_pool(uuid)
|
||||
cap = pool.get_capacity()
|
||||
|
|
|
@ -22,11 +22,12 @@ from threading import Thread
|
|||
import logging
|
||||
import os
|
||||
|
||||
from guestfs import GuestFS # pylint: disable=F0401
|
||||
from guestfs import GuestFS # pylint: disable=F0401
|
||||
|
||||
from virtManager.baseclass import vmmGObject
|
||||
from virtManager.domain import vmmInspectionData
|
||||
|
||||
|
||||
class vmmInspection(vmmGObject):
|
||||
# Can't find a way to make Thread release our reference
|
||||
_leak_check = False
|
||||
|
@ -36,7 +37,7 @@ class vmmInspection(vmmGObject):
|
|||
|
||||
self._thread = Thread(name="inspection thread", target=self._run)
|
||||
self._thread.daemon = True
|
||||
self._wait = 15 * 1000 # 15 seconds
|
||||
self._wait = 15 * 1000 # 15 seconds
|
||||
|
||||
self._q = Queue()
|
||||
self._conns = {}
|
||||
|
@ -182,17 +183,17 @@ class vmmInspection(vmmGObject):
|
|||
root = roots[0]
|
||||
|
||||
# Inspection results.
|
||||
typ = g.inspect_get_type(root) # eg. "linux"
|
||||
distro = g.inspect_get_distro(root) # eg. "fedora"
|
||||
major_version = g.inspect_get_major_version(root) # eg. 14
|
||||
minor_version = g.inspect_get_minor_version(root) # eg. 0
|
||||
hostname = g.inspect_get_hostname(root) # string
|
||||
product_name = g.inspect_get_product_name(root) # string
|
||||
typ = g.inspect_get_type(root) # eg. "linux"
|
||||
distro = g.inspect_get_distro(root) # eg. "fedora"
|
||||
major_version = g.inspect_get_major_version(root) # eg. 14
|
||||
minor_version = g.inspect_get_minor_version(root) # eg. 0
|
||||
hostname = g.inspect_get_hostname(root) # string
|
||||
product_name = g.inspect_get_product_name(root) # string
|
||||
|
||||
# Added in libguestfs 1.9.13:
|
||||
product_variant = None
|
||||
if hasattr(g, "inspect_get_product_variant"):
|
||||
product_variant = g.inspect_get_product_variant(root) # string
|
||||
product_variant = g.inspect_get_product_variant(root) # string
|
||||
|
||||
# For inspect_list_applications and inspect_get_icon we
|
||||
# require that the guest filesystems are mounted. However
|
||||
|
|
|
@ -23,6 +23,7 @@ from virtinst import Interface
|
|||
from virtManager import util
|
||||
from virtManager.libvirtobject import vmmLibvirtObject
|
||||
|
||||
|
||||
class vmmInterface(vmmLibvirtObject):
|
||||
def __init__(self, conn, interface, name, active):
|
||||
vmmLibvirtObject.__init__(self, conn)
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
import logging
|
||||
|
||||
try:
|
||||
from gi.repository import GnomeKeyring # pylint: disable=E0611
|
||||
from gi.repository import GnomeKeyring # pylint: disable=E0611
|
||||
except:
|
||||
GnomeKeyring = None
|
||||
logging.debug("GnomeKeyring bindings not installed, no keyring support")
|
||||
|
|
|
@ -29,6 +29,7 @@ import libxml2
|
|||
|
||||
from virtManager.baseclass import vmmGObject
|
||||
|
||||
|
||||
def _sanitize_xml(xml):
|
||||
xml = libxml2.parseDoc(xml).serialize()
|
||||
# Strip starting <?...> line
|
||||
|
@ -38,6 +39,7 @@ def _sanitize_xml(xml):
|
|||
xml += "\n"
|
||||
return xml
|
||||
|
||||
|
||||
class vmmLibvirtObject(vmmGObject):
|
||||
__gsignals__ = {
|
||||
"config-changed": (GObject.SignalFlags.RUN_FIRST, None, []),
|
||||
|
|
|
@ -34,6 +34,7 @@ MEDIA_CDROM = "cdrom"
|
|||
|
||||
MEDIA_TIMEOUT = 3
|
||||
|
||||
|
||||
class vmmMediaDevice(vmmGObject):
|
||||
__gsignals__ = {
|
||||
"media-added": (GObject.SignalFlags.RUN_FIRST, None, []),
|
||||
|
|
|
@ -36,6 +36,7 @@ from virtManager.baseclass import vmmGObjectUI
|
|||
from virtManager.asyncjob import vmmAsyncJob
|
||||
from virtManager.domain import vmmDomain
|
||||
|
||||
|
||||
def uri_join(uri_tuple):
|
||||
scheme, user, host, path, query, fragment = uri_tuple
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ from types import FunctionType
|
|||
from types import ClassType
|
||||
from types import MethodType
|
||||
|
||||
|
||||
def generate_wrapper(origfunc, name, do_tb):
|
||||
def newfunc(*args, **kwargs):
|
||||
tb = do_tb and ("\n%s" % "".join(traceback.format_stack())) or ""
|
||||
|
@ -40,6 +41,7 @@ def generate_wrapper(origfunc, name, do_tb):
|
|||
|
||||
return newfunc
|
||||
|
||||
|
||||
def wrap_func(module, funcobj, tb):
|
||||
name = funcobj.__name__
|
||||
logging.debug("wrapfunc %s %s", funcobj, name)
|
||||
|
@ -47,6 +49,7 @@ def wrap_func(module, funcobj, tb):
|
|||
newfunc = generate_wrapper(funcobj, name, tb)
|
||||
setattr(module, name, newfunc)
|
||||
|
||||
|
||||
def wrap_method(classobj, methodobj, tb):
|
||||
name = methodobj.__name__
|
||||
fullname = classobj.__name__ + "." + name
|
||||
|
@ -55,6 +58,7 @@ def wrap_method(classobj, methodobj, tb):
|
|||
newfunc = generate_wrapper(methodobj, fullname, tb)
|
||||
setattr(classobj, name, newfunc)
|
||||
|
||||
|
||||
def wrap_class(classobj, tb):
|
||||
logging.debug("wrapclas %s %s", classobj, classobj.__name__)
|
||||
|
||||
|
@ -63,6 +67,7 @@ def wrap_class(classobj, tb):
|
|||
if type(obj) is MethodType:
|
||||
wrap_method(classobj, obj, tb)
|
||||
|
||||
|
||||
def wrap_module(module, regex=None, tb=False):
|
||||
for name in dir(module):
|
||||
if regex and not re.match(regex, name):
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
from virtManager.baseclass import vmmGObject
|
||||
|
||||
|
||||
class vmmNetDevice(vmmGObject):
|
||||
def __init__(self, name, mac, is_shared, bridge=None, hal_path=None):
|
||||
vmmGObject.__init__(self)
|
||||
|
|
|
@ -23,6 +23,7 @@ import ipaddr
|
|||
import libxml2
|
||||
from virtManager.libvirtobject import vmmLibvirtObject
|
||||
|
||||
|
||||
class vmmNetwork(vmmLibvirtObject):
|
||||
@staticmethod
|
||||
def pretty_desc(forward, forwardDev):
|
||||
|
@ -125,7 +126,7 @@ class vmmNetwork(vmmLibvirtObject):
|
|||
routeAddr = node.xpathEval('string(./@address)')
|
||||
break
|
||||
|
||||
if goodNode == None:
|
||||
if goodNode is None:
|
||||
for node in nodes:
|
||||
family = node.xpathEval('string(./@family)')
|
||||
if not family or family == 'ipv4':
|
||||
|
@ -189,7 +190,7 @@ class vmmNetwork(vmmLibvirtObject):
|
|||
routeAddr = node.xpathEval('string(./@address)')
|
||||
break
|
||||
|
||||
if goodNode == None:
|
||||
if goodNode is None:
|
||||
for node in nodes:
|
||||
family = node.xpathEval('string(./@family)')
|
||||
if family and family == 'ipv6':
|
||||
|
|
|
@ -22,6 +22,7 @@ import virtinst
|
|||
|
||||
from virtManager.libvirtobject import vmmLibvirtObject
|
||||
|
||||
|
||||
class vmmNodeDevice(vmmLibvirtObject):
|
||||
def __init__(self, conn, backend, name):
|
||||
vmmLibvirtObject.__init__(self, conn)
|
||||
|
|
|
@ -34,6 +34,7 @@ from virtManager.asyncjob import vmmAsyncJob
|
|||
# PackageKit lookup helpers #
|
||||
#############################
|
||||
|
||||
|
||||
def check_packagekit(errbox, packages, ishv):
|
||||
"""
|
||||
Returns None when we determine nothing useful.
|
||||
|
@ -109,6 +110,7 @@ def check_packagekit(errbox, packages, ishv):
|
|||
|
||||
return do_install
|
||||
|
||||
|
||||
def _do_async_search(asyncjob, session, pk_control, packages):
|
||||
found = []
|
||||
try:
|
||||
|
@ -122,6 +124,7 @@ def _do_async_search(asyncjob, session, pk_control, packages):
|
|||
|
||||
asyncjob.set_extra_data(found)
|
||||
|
||||
|
||||
def packagekit_install(package_list):
|
||||
session = dbus.SessionBus()
|
||||
|
||||
|
@ -137,6 +140,7 @@ def packagekit_install(package_list):
|
|||
package_list, "hide-confirm-search",
|
||||
timeout=timeout)
|
||||
|
||||
|
||||
def packagekit_search(session, pk_control, package_name, packages):
|
||||
newstyle = False
|
||||
try:
|
||||
|
@ -191,6 +195,7 @@ def packagekit_search(session, pk_control, package_name, packages):
|
|||
# Service helpers #
|
||||
###################
|
||||
|
||||
|
||||
def start_libvirtd():
|
||||
"""
|
||||
Connect to systemd and start libvirtd if required
|
||||
|
|
|
@ -30,6 +30,7 @@ from virtManager.baseclass import vmmGObjectUI
|
|||
PREFS_PAGE_STATS = 0
|
||||
PREFS_PAGE_VM_PREFS = 1
|
||||
|
||||
|
||||
class vmmPreferences(vmmGObjectUI):
|
||||
def __init__(self):
|
||||
vmmGObjectUI.__init__(self, "vmm-preferences.ui", "vmm-preferences")
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
import dbus.service
|
||||
|
||||
|
||||
class vmmRemote(dbus.service.Object):
|
||||
def __init__(self, engine, bus_name, object_path="/com/redhat/virt/manager"):
|
||||
dbus.service.Object.__init__(self, bus_name, object_path)
|
||||
|
|
|
@ -32,6 +32,7 @@ import virtManager.util as util
|
|||
from virtManager.createvol import vmmCreateVolume
|
||||
from virtManager.baseclass import vmmGObjectUI
|
||||
|
||||
|
||||
class vmmStorageBrowser(vmmGObjectUI):
|
||||
__gsignals__ = {
|
||||
"storage-browse-finish": (GObject.SignalFlags.RUN_FIRST, None, [str]),
|
||||
|
|
|
@ -28,6 +28,7 @@ from virtManager import util
|
|||
from virtManager.libvirtobject import vmmLibvirtObject
|
||||
from virtManager.storagevol import vmmStorageVolume
|
||||
|
||||
|
||||
class vmmStoragePool(vmmLibvirtObject):
|
||||
__gsignals__ = {
|
||||
"refreshed": (GObject.SignalFlags.RUN_FIRST, None, [])
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
from virtManager import util
|
||||
from virtManager.libvirtobject import vmmLibvirtObject
|
||||
|
||||
|
||||
class vmmStorageVolume(vmmLibvirtObject):
|
||||
def __init__(self, conn, vol, name):
|
||||
vmmLibvirtObject.__init__(self, conn)
|
||||
|
|
|
@ -29,10 +29,11 @@ from virtManager.baseclass import vmmGObject
|
|||
from virtManager.error import vmmErrorDialog
|
||||
|
||||
try:
|
||||
import appindicator # pylint: disable=F0401
|
||||
import appindicator # pylint: disable=F0401
|
||||
except:
|
||||
appindicator = None
|
||||
|
||||
|
||||
def build_image_menu_item(label):
|
||||
hasfunc = hasattr(Gtk.ImageMenuItem, "set_use_underline")
|
||||
if hasfunc:
|
||||
|
@ -44,6 +45,7 @@ def build_image_menu_item(label):
|
|||
|
||||
return menu_item
|
||||
|
||||
|
||||
class vmmSystray(vmmGObject):
|
||||
__gsignals__ = {
|
||||
"action-toggle-manager": (GObject.SignalFlags.RUN_FIRST, None, []),
|
||||
|
|
|
@ -46,15 +46,18 @@ OPTICAL_IS_VALID = 5
|
|||
|
||||
err_dial = vmmErrorDialog()
|
||||
|
||||
|
||||
def set_error_parent(parent):
|
||||
global err_dial
|
||||
err_dial.set_parent(parent)
|
||||
err_dial = err_dial
|
||||
|
||||
|
||||
def cleanup():
|
||||
global err_dial
|
||||
err_dial = None
|
||||
|
||||
|
||||
def spin_get_helper(widget):
|
||||
adj = widget.get_adjustment()
|
||||
txt = widget.get_text()
|
||||
|
@ -69,6 +72,7 @@ def spin_get_helper(widget):
|
|||
# Helpers for shared storage UI between create/addhardware #
|
||||
############################################################
|
||||
|
||||
|
||||
def set_sparse_tooltip(widget):
|
||||
sparse_str = _("Fully allocating storage may take longer now, "
|
||||
"but the OS install phase will be quicker. \n\n"
|
||||
|
@ -79,6 +83,7 @@ def set_sparse_tooltip(widget):
|
|||
"do not support full allocation.")
|
||||
widget.set_tooltip_text(sparse_str)
|
||||
|
||||
|
||||
def host_disk_space(conn):
|
||||
pool = util.get_default_pool(conn)
|
||||
path = util.get_default_dir(conn)
|
||||
|
@ -96,6 +101,7 @@ def host_disk_space(conn):
|
|||
|
||||
return float(avail / 1024.0 / 1024.0 / 1024.0)
|
||||
|
||||
|
||||
def host_space_tick(conn, widget):
|
||||
try:
|
||||
max_storage = host_disk_space(conn)
|
||||
|
@ -113,6 +119,7 @@ def host_space_tick(conn, widget):
|
|||
|
||||
return 1
|
||||
|
||||
|
||||
def check_default_pool_active(topwin, conn):
|
||||
default_pool = util.get_default_pool(conn)
|
||||
if default_pool and not default_pool.is_active():
|
||||
|
@ -136,6 +143,8 @@ def check_default_pool_active(topwin, conn):
|
|||
#####################################################
|
||||
# Hardware model list building (for details, addhw) #
|
||||
#####################################################
|
||||
|
||||
|
||||
def build_video_combo(vm, video_dev, no_default=None):
|
||||
video_dev_model = Gtk.ListStore(str, str)
|
||||
video_dev.set_model(video_dev_model)
|
||||
|
@ -146,6 +155,7 @@ def build_video_combo(vm, video_dev, no_default=None):
|
|||
|
||||
populate_video_combo(vm, video_dev, no_default)
|
||||
|
||||
|
||||
def populate_video_combo(vm, video_dev, no_default=None):
|
||||
video_dev_model = video_dev.get_model()
|
||||
has_spice = bool([g for g in vm.get_graphics_devices()
|
||||
|
@ -168,6 +178,7 @@ def populate_video_combo(vm, video_dev, no_default=None):
|
|||
if len(video_dev_model) > 0:
|
||||
video_dev.set_active(0)
|
||||
|
||||
|
||||
def build_sound_combo(vm, combo, no_default=False):
|
||||
dev_model = Gtk.ListStore(str)
|
||||
combo.set_model(dev_model)
|
||||
|
@ -190,6 +201,7 @@ def build_sound_combo(vm, combo, no_default=False):
|
|||
if len(dev_model) > 0:
|
||||
combo.set_active(0)
|
||||
|
||||
|
||||
def build_watchdogmodel_combo(vm, combo, no_default=False):
|
||||
ignore = vm
|
||||
dev_model = Gtk.ListStore(str)
|
||||
|
@ -206,6 +218,7 @@ def build_watchdogmodel_combo(vm, combo, no_default=False):
|
|||
if len(dev_model) > 0:
|
||||
combo.set_active(0)
|
||||
|
||||
|
||||
def build_watchdogaction_combo(vm, combo, no_default=False):
|
||||
ignore = vm
|
||||
dev_model = Gtk.ListStore(str, str)
|
||||
|
@ -222,6 +235,7 @@ def build_watchdogaction_combo(vm, combo, no_default=False):
|
|||
if len(dev_model) > 0:
|
||||
combo.set_active(0)
|
||||
|
||||
|
||||
def build_source_mode_combo(vm, combo):
|
||||
source_mode = Gtk.ListStore(str, str)
|
||||
combo.set_model(source_mode)
|
||||
|
@ -232,6 +246,7 @@ def build_source_mode_combo(vm, combo):
|
|||
populate_source_mode_combo(vm, combo)
|
||||
combo.set_active(0)
|
||||
|
||||
|
||||
def populate_source_mode_combo(vm, combo):
|
||||
ignore = vm
|
||||
model = combo.get_model()
|
||||
|
@ -244,6 +259,7 @@ def populate_source_mode_combo(vm, combo):
|
|||
model.append(["private", "Private"])
|
||||
model.append(["passthrough", "Passthrough"])
|
||||
|
||||
|
||||
def build_smartcard_mode_combo(vm, combo):
|
||||
dev_model = Gtk.ListStore(str, str)
|
||||
combo.set_model(dev_model)
|
||||
|
@ -263,6 +279,7 @@ def build_smartcard_mode_combo(vm, combo):
|
|||
break
|
||||
combo.set_active(idx)
|
||||
|
||||
|
||||
def populate_smartcard_mode_combo(vm, combo):
|
||||
ignore = vm
|
||||
model = combo.get_model()
|
||||
|
@ -274,6 +291,7 @@ def populate_smartcard_mode_combo(vm, combo):
|
|||
# TODO
|
||||
# model.append(["host-certificates", "Host Certificates"])
|
||||
|
||||
|
||||
def build_redir_type_combo(vm, combo):
|
||||
source_mode = Gtk.ListStore(str, str, bool)
|
||||
combo.set_model(source_mode)
|
||||
|
@ -284,6 +302,7 @@ def build_redir_type_combo(vm, combo):
|
|||
populate_redir_type_combo(vm, combo)
|
||||
combo.set_active(0)
|
||||
|
||||
|
||||
def populate_redir_type_combo(vm, combo):
|
||||
ignore = vm
|
||||
model = combo.get_model()
|
||||
|
@ -293,6 +312,7 @@ def populate_redir_type_combo(vm, combo):
|
|||
model.append(["spicevmc", "Spice channel", False])
|
||||
model.append(["tcp", "TCP", True])
|
||||
|
||||
|
||||
def build_netmodel_combo(vm, combo):
|
||||
dev_model = Gtk.ListStore(str, str)
|
||||
combo.set_model(dev_model)
|
||||
|
@ -304,6 +324,7 @@ def build_netmodel_combo(vm, combo):
|
|||
populate_netmodel_combo(vm, combo)
|
||||
combo.set_active(0)
|
||||
|
||||
|
||||
def populate_netmodel_combo(vm, combo):
|
||||
model = combo.get_model()
|
||||
model.clear()
|
||||
|
@ -324,6 +345,7 @@ def populate_netmodel_combo(vm, combo):
|
|||
for m in mod_list:
|
||||
model.append([m, m])
|
||||
|
||||
|
||||
def build_cache_combo(vm, combo, no_default=False):
|
||||
ignore = vm
|
||||
dev_model = Gtk.ListStore(str, str)
|
||||
|
@ -341,6 +363,7 @@ def build_cache_combo(vm, combo, no_default=False):
|
|||
dev_model.append([None, "default"])
|
||||
combo.set_active(0)
|
||||
|
||||
|
||||
def build_io_combo(vm, combo, no_default=False):
|
||||
ignore = vm
|
||||
dev_model = Gtk.ListStore(str, str)
|
||||
|
@ -358,6 +381,7 @@ def build_io_combo(vm, combo, no_default=False):
|
|||
dev_model.append([None, "default"])
|
||||
combo.set_active(0)
|
||||
|
||||
|
||||
def build_disk_bus_combo(vm, combo, no_default=False):
|
||||
ignore = vm
|
||||
dev_model = Gtk.ListStore(str, str)
|
||||
|
@ -371,6 +395,7 @@ def build_disk_bus_combo(vm, combo, no_default=False):
|
|||
dev_model.append([None, "default"])
|
||||
combo.set_active(-1)
|
||||
|
||||
|
||||
def build_vnc_keymap_combo(vm, combo, no_default=False):
|
||||
ignore = vm
|
||||
|
||||
|
@ -396,6 +421,7 @@ def build_vnc_keymap_combo(vm, combo, no_default=False):
|
|||
# Storage format list/combo helpers #
|
||||
#####################################
|
||||
|
||||
|
||||
def build_storage_format_combo(vm, combo):
|
||||
dev_model = Gtk.ListStore(str)
|
||||
combo.set_model(dev_model)
|
||||
|
@ -415,6 +441,7 @@ def build_storage_format_combo(vm, combo):
|
|||
# Widgets for listing network device options (in create, addhardware) #
|
||||
#######################################################################
|
||||
|
||||
|
||||
def pretty_network_desc(nettype, source=None, netobj=None):
|
||||
if nettype == VirtualNetworkInterface.TYPE_USER:
|
||||
return _("Usermode networking")
|
||||
|
@ -436,6 +463,7 @@ def pretty_network_desc(nettype, source=None, netobj=None):
|
|||
|
||||
return ret
|
||||
|
||||
|
||||
def init_network_list(net_list, bridge_box,
|
||||
source_mode_box=None, source_mode_label=None,
|
||||
vport_expander=None):
|
||||
|
@ -452,6 +480,7 @@ def init_network_list(net_list, bridge_box,
|
|||
net_list.add_attribute(text, 'text', 2)
|
||||
net_list.add_attribute(text, 'sensitive', 3)
|
||||
|
||||
|
||||
def net_list_changed(net_list, bridge_box,
|
||||
source_mode_box, source_mode_label, vport_expander):
|
||||
active = net_list.get_active()
|
||||
|
@ -473,6 +502,7 @@ def net_list_changed(net_list, bridge_box,
|
|||
|
||||
bridge_box.set_property("visible", show_bridge)
|
||||
|
||||
|
||||
def get_network_selection(net_list, bridge_entry):
|
||||
idx = net_list.get_active()
|
||||
if idx == -1:
|
||||
|
@ -489,6 +519,7 @@ def get_network_selection(net_list, bridge_entry):
|
|||
|
||||
return net_type, net_src
|
||||
|
||||
|
||||
def populate_network_list(net_list, conn, show_direct_interfaces=True):
|
||||
model = net_list.get_model()
|
||||
model.clear()
|
||||
|
@ -633,6 +664,7 @@ def populate_network_list(net_list, conn, show_direct_interfaces=True):
|
|||
set_active(default)
|
||||
return return_warn
|
||||
|
||||
|
||||
def validate_network(parent, conn, nettype, devname, macaddr, model=None):
|
||||
set_error_parent(parent)
|
||||
|
||||
|
@ -702,6 +734,7 @@ def validate_network(parent, conn, nettype, devname, macaddr, model=None):
|
|||
|
||||
return net
|
||||
|
||||
|
||||
def generate_macaddr(conn):
|
||||
newmac = ""
|
||||
try:
|
||||
|
@ -730,6 +763,7 @@ def init_mediadev_combo(widget):
|
|||
widget.add_attribute(text, 'text', OPTICAL_LABEL)
|
||||
widget.add_attribute(text, 'sensitive', OPTICAL_IS_VALID)
|
||||
|
||||
|
||||
def populate_mediadev_combo(conn, widget, devtype):
|
||||
sigs = []
|
||||
|
||||
|
@ -745,10 +779,12 @@ def populate_mediadev_combo(conn, widget, devtype):
|
|||
|
||||
return sigs
|
||||
|
||||
|
||||
def set_mediadev_default(model):
|
||||
if len(model) == 0:
|
||||
model.append([None, _("No device present"), False, None, None, False])
|
||||
|
||||
|
||||
def set_row_from_object(row, obj):
|
||||
row[OPTICAL_DEV_PATH] = obj.get_path()
|
||||
row[OPTICAL_LABEL] = obj.pretty_label()
|
||||
|
@ -757,6 +793,7 @@ def set_row_from_object(row, obj):
|
|||
row[OPTICAL_MEDIA_KEY] = obj.get_media_key()
|
||||
row[OPTICAL_IS_VALID] = True
|
||||
|
||||
|
||||
def mediadev_removed(ignore_helper, key, widget):
|
||||
model = widget.get_model()
|
||||
active = widget.get_active()
|
||||
|
@ -777,6 +814,7 @@ def mediadev_removed(ignore_helper, key, widget):
|
|||
set_mediadev_default(model)
|
||||
mediadev_set_default_selection(widget)
|
||||
|
||||
|
||||
def mediadev_added(ignore_helper, newobj, widget, devtype):
|
||||
model = widget.get_model()
|
||||
|
||||
|
@ -797,6 +835,7 @@ def mediadev_added(ignore_helper, newobj, widget, devtype):
|
|||
|
||||
mediadev_set_default_selection(widget)
|
||||
|
||||
|
||||
def mediadev_media_changed(newobj, widget):
|
||||
model = widget.get_model()
|
||||
active = widget.get_active()
|
||||
|
@ -819,6 +858,7 @@ def mediadev_media_changed(newobj, widget):
|
|||
|
||||
mediadev_set_default_selection(widget)
|
||||
|
||||
|
||||
def mediadev_set_default_selection(widget):
|
||||
# Set the first active cdrom device as selected, otherwise none
|
||||
model = widget.get_model()
|
||||
|
@ -895,6 +935,8 @@ def build_shutdown_button_menu(widget, shutdown_cb, reboot_cb, reset_cb,
|
|||
#####################################
|
||||
# Path permissions checker for qemu #
|
||||
#####################################
|
||||
|
||||
|
||||
def check_path_search_for_qemu(parent, conn, path):
|
||||
set_error_parent(parent)
|
||||
|
||||
|
@ -950,6 +992,7 @@ def check_path_search_for_qemu(parent, conn, path):
|
|||
# Interface startmode widget builder #
|
||||
######################################
|
||||
|
||||
|
||||
def build_startmode_combo(start_list):
|
||||
start_model = Gtk.ListStore(str)
|
||||
start_list.set_model(start_model)
|
||||
|
|
|
@ -31,15 +31,19 @@ running_config = None
|
|||
xml_escape = virtinst.util.xml_escape
|
||||
|
||||
# FIXME: selinux policy also has a ~/VirtualMachines/isos dir
|
||||
|
||||
|
||||
def get_default_pool_path(conn):
|
||||
if conn.is_session_uri():
|
||||
return os.path.expanduser("~/VirtualMachines")
|
||||
return "/var/lib/libvirt/images"
|
||||
|
||||
|
||||
def get_default_pool_name(conn):
|
||||
ignore = conn
|
||||
return "default"
|
||||
|
||||
|
||||
def build_default_pool(vmmconn):
|
||||
"""
|
||||
Helper to build the 'default' storage pool
|
||||
|
@ -70,15 +74,18 @@ def build_default_pool(vmmconn):
|
|||
raise RuntimeError(_("Couldn't create default storage pool '%s': %s") %
|
||||
(path, str(e)))
|
||||
|
||||
|
||||
def get_ideal_path_info(conn, name):
|
||||
path = get_default_dir(conn)
|
||||
suffix = ".img"
|
||||
return (path, name, suffix)
|
||||
|
||||
|
||||
def get_ideal_path(conn, name):
|
||||
target, name, suffix = get_ideal_path_info(conn, name)
|
||||
return os.path.join(target, name) + suffix
|
||||
|
||||
|
||||
def get_default_pool(conn):
|
||||
pool = None
|
||||
default_name = get_default_pool_name(conn)
|
||||
|
@ -89,6 +96,7 @@ def get_default_pool(conn):
|
|||
|
||||
return pool
|
||||
|
||||
|
||||
def get_default_dir(conn):
|
||||
pool = get_default_pool(conn)
|
||||
|
||||
|
@ -97,6 +105,7 @@ def get_default_dir(conn):
|
|||
else:
|
||||
return running_config.get_default_image_dir(conn)
|
||||
|
||||
|
||||
def get_default_path(conn, name, collidelist=None):
|
||||
collidelist = collidelist or []
|
||||
pool = get_default_pool(conn)
|
||||
|
@ -180,7 +189,7 @@ def browse_local(parent, dialog_name, conn, start_folder=None,
|
|||
value, and store the user chosen path.
|
||||
|
||||
"""
|
||||
from gi.repository import Gtk # pylint: disable=E0611
|
||||
from gi.repository import Gtk # pylint: disable=E0611
|
||||
|
||||
# Initial setup
|
||||
overwrite_confirm = False
|
||||
|
@ -245,15 +254,18 @@ def browse_local(parent, dialog_name, conn, start_folder=None,
|
|||
browse_reason)
|
||||
return ret
|
||||
|
||||
|
||||
def dup_lib_conn(libconn):
|
||||
conn = _dup_all_conn(None, libconn)
|
||||
if isinstance(conn, virtManager.connection.vmmConnection):
|
||||
return conn.vmm
|
||||
return conn
|
||||
|
||||
|
||||
def dup_conn(conn):
|
||||
return _dup_all_conn(conn, None)
|
||||
|
||||
|
||||
def _dup_all_conn(conn, libconn):
|
||||
|
||||
is_readonly = False
|
||||
|
@ -284,6 +296,7 @@ def _dup_all_conn(conn, libconn):
|
|||
|
||||
return newconn
|
||||
|
||||
|
||||
def pretty_hv(gtype, domtype):
|
||||
"""
|
||||
Convert XML <domain type='foo'> and <os><type>bar</type>
|
||||
|
@ -310,6 +323,7 @@ def pretty_hv(gtype, domtype):
|
|||
|
||||
return label
|
||||
|
||||
|
||||
def uuidstr(rawuuid):
|
||||
hx = ['0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f']
|
||||
|
@ -321,6 +335,7 @@ def uuidstr(rawuuid):
|
|||
uuid.append('-')
|
||||
return "".join(uuid)
|
||||
|
||||
|
||||
def iface_in_use_by(conn, name):
|
||||
use_str = ""
|
||||
for i in conn.list_interface_names():
|
||||
|
@ -332,6 +347,7 @@ def iface_in_use_by(conn, name):
|
|||
|
||||
return use_str
|
||||
|
||||
|
||||
def pretty_mem(val):
|
||||
val = int(val)
|
||||
if val > (10 * 1024 * 1024):
|
||||
|
@ -339,6 +355,7 @@ def pretty_mem(val):
|
|||
else:
|
||||
return "%2.0f MB" % (val / 1024.0)
|
||||
|
||||
|
||||
def pretty_bytes(val):
|
||||
val = int(val)
|
||||
if val > (1024 * 1024 * 1024):
|
||||
|
@ -348,6 +365,7 @@ def pretty_bytes(val):
|
|||
|
||||
xpath = virtinst.util.get_xml_path
|
||||
|
||||
|
||||
def chkbox_helper(src, getcb, setcb, text1, text2=None,
|
||||
alwaysrecord=False,
|
||||
default=True,
|
||||
|
@ -359,7 +377,7 @@ def chkbox_helper(src, getcb, setcb, text1, text2=None,
|
|||
@alwaysrecord: Don't require user to select 'yes' to record chkbox value
|
||||
@default: What value to return if getcb tells us not to prompt
|
||||
"""
|
||||
from gi.repository import Gtk # pylint: disable=E0611
|
||||
from gi.repository import Gtk # pylint: disable=E0611
|
||||
|
||||
do_prompt = getcb()
|
||||
if not do_prompt:
|
||||
|
@ -374,6 +392,7 @@ def chkbox_helper(src, getcb, setcb, text1, text2=None,
|
|||
|
||||
return response
|
||||
|
||||
|
||||
def get_list_selection(widget):
|
||||
selection = widget.get_selection()
|
||||
active = selection.get_selected()
|
||||
|
@ -383,6 +402,7 @@ def get_list_selection(widget):
|
|||
return treestore[treeiter]
|
||||
return None
|
||||
|
||||
|
||||
def set_list_selection(widget, rownum):
|
||||
path = str(rownum)
|
||||
selection = widget.get_selection()
|
||||
|
|
|
@ -50,6 +50,7 @@ OS_VARIANT = "os.variant"
|
|||
MEMORY = "memory"
|
||||
CPUS = "cpus"
|
||||
|
||||
|
||||
class DomainConfigScreen(VmmTuiConfigScreen):
|
||||
def __init__(self):
|
||||
VmmTuiConfigScreen.__init__(self, "Create A New Virtual Machine")
|
||||
|
@ -348,7 +349,7 @@ class DomainConfigScreen(VmmTuiConfigScreen):
|
|||
return False
|
||||
|
||||
def page_has_next(self, page):
|
||||
if page is SELECT_POOL_PAGE:
|
||||
if page is SELECT_POOL_PAGE:
|
||||
return self.__has_pools
|
||||
elif page is SELECT_VOLUME_PAGE:
|
||||
return self.__has_volumes
|
||||
|
@ -572,6 +573,7 @@ class DomainConfigScreen(VmmTuiConfigScreen):
|
|||
return [snack.Label("Ready to begin installation of %s" % self.__config.get_guest_name()),
|
||||
grid]
|
||||
|
||||
|
||||
def AddDomain():
|
||||
screen = DomainConfigScreen()
|
||||
screen.start()
|
||||
|
|
|
@ -39,6 +39,7 @@ CONNECTIONS = {CONNECTION_LOCAL : "Local",
|
|||
CONNECTION_SSL : "Remote SSL/TLS with x509 certificate",
|
||||
CONNECTION_SSH : "Remote tunnel over SSH"}
|
||||
|
||||
|
||||
class AddHostConfigScreen(VmmTuiConfigScreen):
|
||||
def __init__(self):
|
||||
VmmTuiConfigScreen.__init__(self, "Add A Remote Host")
|
||||
|
@ -81,8 +82,8 @@ class AddHostConfigScreen(VmmTuiConfigScreen):
|
|||
conn = self.__connection.getSelection()
|
||||
hostname = self.__hostname.value()
|
||||
|
||||
if hv is HYPERVISOR_XEN:
|
||||
if conn is CONNECTION_LOCAL:
|
||||
if hv is HYPERVISOR_XEN:
|
||||
if conn is CONNECTION_LOCAL:
|
||||
url = "xen:///"
|
||||
elif conn is CONNECTION_KERBEROS:
|
||||
url = "xen+tcp:///" + hostname + "/"
|
||||
|
@ -91,7 +92,7 @@ class AddHostConfigScreen(VmmTuiConfigScreen):
|
|||
elif conn is CONNECTION_SSH:
|
||||
url = "xen+ssh:///" + hostname + "/"
|
||||
elif hv is HYPERVISOR_KVM:
|
||||
if conn is CONNECTION_LOCAL:
|
||||
if conn is CONNECTION_LOCAL:
|
||||
url = "qemu:///system"
|
||||
elif conn is CONNECTION_KERBEROS:
|
||||
url = "qemu+tcp://" + hostname + "/system"
|
||||
|
@ -148,6 +149,7 @@ class AddHostConfigScreen(VmmTuiConfigScreen):
|
|||
return [snack.Label("Confirm Connection"),
|
||||
grid]
|
||||
|
||||
|
||||
def AddHost():
|
||||
screen = AddHostConfigScreen()
|
||||
screen.start()
|
||||
|
|
|
@ -37,6 +37,7 @@ NETWORK_TYPE_PAGE = 6
|
|||
SELECT_PHYSICAL_NETWORK_PAGE = 7
|
||||
SUMMARY_PAGE = 8
|
||||
|
||||
|
||||
class AddNetworkConfigScreen(VmmTuiConfigScreen):
|
||||
def __init__(self):
|
||||
VmmTuiConfigScreen.__init__(self, "Create A Virtual Network Interface")
|
||||
|
@ -49,7 +50,7 @@ class AddNetworkConfigScreen(VmmTuiConfigScreen):
|
|||
self.__ipv4_address = None
|
||||
|
||||
def get_elements_for_page(self, screen, page):
|
||||
if page is NETWORK_NAME_PAGE:
|
||||
if page is NETWORK_NAME_PAGE:
|
||||
return self.get_network_name_page(screen)
|
||||
elif page is IPV4_ADDRESS_PAGE:
|
||||
return self.get_ipv4_address_page(screen)
|
||||
|
@ -203,8 +204,8 @@ class AddNetworkConfigScreen(VmmTuiConfigScreen):
|
|||
fields = []
|
||||
fields.append(("Select the DHCP range", None))
|
||||
# XXX
|
||||
#fields.append(("Start", self.__start_address.network))
|
||||
#fields.append(("End", self.__end_address.network))
|
||||
# fields.append(("Start", self.__start_address.network))
|
||||
# fields.append(("End", self.__end_address.network))
|
||||
return [Label("Selecting The DHCP Range"),
|
||||
self.create_grid_from_fields(fields),
|
||||
Label("TIP: Unless you wish to reserve some addresses to allow static network"),
|
||||
|
@ -255,6 +256,7 @@ class AddNetworkConfigScreen(VmmTuiConfigScreen):
|
|||
return [Label("Ready To Create Network"),
|
||||
self.create_grid_from_fields(fields)]
|
||||
|
||||
|
||||
def AddNetwork():
|
||||
screen = AddNetworkConfigScreen()
|
||||
screen.start()
|
||||
|
|
|
@ -32,6 +32,7 @@ POOL_DETAILS_PAGE = 2
|
|||
CONFIRM_PAGE = 3
|
||||
HELPER_TEXT = "Specify a storage location to be later split in virtual machine storage"
|
||||
|
||||
|
||||
class AddStoragePoolConfigScreen(VmmTuiConfigScreen):
|
||||
def __init__(self):
|
||||
VmmTuiConfigScreen.__init__(self, "Add A Storage Pool")
|
||||
|
@ -45,7 +46,7 @@ class AddStoragePoolConfigScreen(VmmTuiConfigScreen):
|
|||
self.__source_path = None
|
||||
|
||||
def get_elements_for_page(self, screen, page):
|
||||
if page is POOL_NAME_PAGE:
|
||||
if page is POOL_NAME_PAGE:
|
||||
return self.get_pool_name_page(screen)
|
||||
elif page is POOL_DETAILS_PAGE:
|
||||
return self.get_pool_details_page(screen)
|
||||
|
@ -62,7 +63,7 @@ class AddStoragePoolConfigScreen(VmmTuiConfigScreen):
|
|||
return page is CONFIRM_PAGE
|
||||
|
||||
def validate_input(self, page, errors):
|
||||
if page is POOL_NAME_PAGE:
|
||||
if page is POOL_NAME_PAGE:
|
||||
if utils.string_is_not_blank(self.__name.value()):
|
||||
if self.get_libvirt().storage_pool_exists(self.__name.value()):
|
||||
errors.append("Name '%s' already in use by another pool." % self.__name.value())
|
||||
|
@ -106,7 +107,7 @@ class AddStoragePoolConfigScreen(VmmTuiConfigScreen):
|
|||
if page is POOL_NAME_PAGE:
|
||||
self.__config.set_name(self.__name.value())
|
||||
self.__config.set_type(self.__type.getSelection())
|
||||
#self._reset_flags(self.__type.current())
|
||||
# self._reset_flags(self.__type.current())
|
||||
elif page is POOL_DETAILS_PAGE:
|
||||
if self.__config.needs_target_path():
|
||||
self.__config.set_target_path(self.__target_path.value())
|
||||
|
@ -172,6 +173,7 @@ class AddStoragePoolConfigScreen(VmmTuiConfigScreen):
|
|||
Label("Confirm Pool Details"),
|
||||
self.create_grid_from_fields(fields)]
|
||||
|
||||
|
||||
def AddStoragePool():
|
||||
screen = AddStoragePoolConfigScreen()
|
||||
screen.start()
|
||||
|
|
|
@ -30,6 +30,7 @@ VOLUME_FORMAT_PAGE = 3
|
|||
MAX_CAPACITY_PAGE = 4
|
||||
CONFIRM_PAGE = 5
|
||||
|
||||
|
||||
class AddVolumeConfigScreen(StorageListConfigScreen):
|
||||
def __init__(self):
|
||||
StorageListConfigScreen.__init__(self, "Add A New Storage Volume")
|
||||
|
@ -40,7 +41,7 @@ class AddVolumeConfigScreen(StorageListConfigScreen):
|
|||
self.__formats = None
|
||||
|
||||
def get_elements_for_page(self, screen, page):
|
||||
if page is SELECT_POOL_PAGE:
|
||||
if page is SELECT_POOL_PAGE:
|
||||
return self.get_storage_pool_list_page(screen)
|
||||
elif page is VOLUME_NAME_PAGE:
|
||||
return self.get_volume_name_page(screen)
|
||||
|
@ -189,6 +190,7 @@ class AddVolumeConfigScreen(StorageListConfigScreen):
|
|||
return [snack.Label("Ready To Allocation New Storage Volume"),
|
||||
grid]
|
||||
|
||||
|
||||
def AddStorageVolume():
|
||||
screen = AddVolumeConfigScreen()
|
||||
screen.start()
|
||||
|
|
|
@ -24,6 +24,7 @@ from virtManagerTui.hostlistconfigscreen import HostListConfigScreen
|
|||
CONNECTION_LIST_PAGE = 1
|
||||
CONNECTED_PAGE = 2
|
||||
|
||||
|
||||
class ChangeHostConfigScreen(HostListConfigScreen):
|
||||
def __init__(self):
|
||||
HostListConfigScreen.__init__(self, "")
|
||||
|
@ -32,13 +33,13 @@ class ChangeHostConfigScreen(HostListConfigScreen):
|
|||
return "Currently: %s" % self.get_libvirt().get_url()
|
||||
|
||||
def get_elements_for_page(self, screen, page):
|
||||
if page is CONNECTION_LIST_PAGE:
|
||||
if page is CONNECTION_LIST_PAGE:
|
||||
return self.get_connection_list_page(screen)
|
||||
elif page is CONNECTED_PAGE:
|
||||
return self.get_connected_page(screen)
|
||||
|
||||
def process_input(self, page):
|
||||
if page is CONNECTION_LIST_PAGE:
|
||||
if page is CONNECTION_LIST_PAGE:
|
||||
logging.info("Changing libvirt connection to %s",
|
||||
self.get_selected_connection())
|
||||
self.get_libvirt().open_connection(self.get_selected_connection())
|
||||
|
@ -60,6 +61,7 @@ class ChangeHostConfigScreen(HostListConfigScreen):
|
|||
ignore = screen
|
||||
return [snack.Label("Connected to %s" % self.get_selected_connection())]
|
||||
|
||||
|
||||
def ChangeHost():
|
||||
screen = ChangeHostConfigScreen()
|
||||
screen.start()
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
import urlgrabber.progress as progress
|
||||
import logging
|
||||
|
||||
|
||||
class CreateMeter(progress.BaseMeter):
|
||||
def _do_start(self, now=None):
|
||||
logging.info("Starting...")
|
||||
|
|
|
@ -26,6 +26,7 @@ import libuser
|
|||
DETAILS_PAGE = 1
|
||||
CONFIRM_PAGE = 2
|
||||
|
||||
|
||||
class CreateUserConfigScreen(ConfigScreen):
|
||||
def __init__(self):
|
||||
ConfigScreen.__init__(self, "Create A User Account")
|
||||
|
@ -37,7 +38,7 @@ class CreateUserConfigScreen(ConfigScreen):
|
|||
self.__user_worker = UserWorker()
|
||||
|
||||
def get_elements_for_page(self, screen, page):
|
||||
if page is DETAILS_PAGE:
|
||||
if page is DETAILS_PAGE:
|
||||
return self.get_details_page(screen)
|
||||
elif page is CONFIRM_PAGE:
|
||||
return self.get_confirm_page(screen)
|
||||
|
@ -108,6 +109,7 @@ class CreateUserConfigScreen(ConfigScreen):
|
|||
return [snack.Label("Create this user account?"),
|
||||
grid]
|
||||
|
||||
|
||||
def CreateUser():
|
||||
screen = CreateUserConfigScreen()
|
||||
screen.start()
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
from virtinst import Guest
|
||||
|
||||
|
||||
class DomainConfig:
|
||||
LOCAL_INSTALL = "local"
|
||||
NETWORK_INSTALL = "network"
|
||||
|
|
|
@ -20,6 +20,7 @@ import snack
|
|||
|
||||
from virtManagerTui.vmmconfigscreen import VmmTuiConfigScreen
|
||||
|
||||
|
||||
class DomainListConfigScreen(VmmTuiConfigScreen):
|
||||
'''Provides a base class for all config screens that require a domain list.'''
|
||||
|
||||
|
@ -29,7 +30,7 @@ class DomainListConfigScreen(VmmTuiConfigScreen):
|
|||
self.__domain_list = None
|
||||
|
||||
def get_domain_list_page(self, screen, defined=True, created=True):
|
||||
ignore = screen # pylint ignore since it is not used here
|
||||
ignore = screen # pylint ignore since it is not used here
|
||||
domuuids = self.get_libvirt().list_domains(defined, created)
|
||||
self.__has_domains = bool(domuuids)
|
||||
result = None
|
||||
|
|
|
@ -18,10 +18,12 @@
|
|||
|
||||
from newt_syrup.configscreen import ConfigScreen
|
||||
|
||||
|
||||
class HostConnectConfigScreen(ConfigScreen):
|
||||
def __init__(self):
|
||||
ConfigScreen.__init__(self, "Host Connect")
|
||||
|
||||
|
||||
def HostConnect():
|
||||
screen = HostConnectConfigScreen()
|
||||
screen.start()
|
||||
|
|
|
@ -20,6 +20,7 @@ import snack
|
|||
|
||||
from virtManagerTui.vmmconfigscreen import VmmTuiConfigScreen
|
||||
|
||||
|
||||
class HostListConfigScreen(VmmTuiConfigScreen):
|
||||
'''Provides a base class for working with lists of libvirt hosts.'''
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ SELECT_HOST = 1
|
|||
ADD_HOST = 2
|
||||
REMOVE_HOST = 3
|
||||
|
||||
|
||||
class HostMenuScreen(MenuScreen):
|
||||
def __init__(self):
|
||||
MenuScreen.__init__(self, "Host Menu Screen")
|
||||
|
@ -36,13 +37,14 @@ class HostMenuScreen(MenuScreen):
|
|||
("Remove A Host", REMOVE_HOST))
|
||||
|
||||
def handle_selection(self, item):
|
||||
if item is SELECT_HOST:
|
||||
if item is SELECT_HOST:
|
||||
ChangeHost()
|
||||
elif item is ADD_HOST:
|
||||
AddHost()
|
||||
elif item is REMOVE_HOST:
|
||||
RemoveHost()
|
||||
|
||||
|
||||
def HostMenu():
|
||||
screen = HostMenuScreen()
|
||||
screen.start()
|
||||
|
|
|
@ -31,16 +31,19 @@ DEFAULT_URL = "qemu:///system"
|
|||
|
||||
default_url = DEFAULT_URL
|
||||
|
||||
|
||||
def set_default_url(url):
|
||||
logging.info("Changing DEFAULT_URL to %s", url)
|
||||
global default_url
|
||||
|
||||
default_url = url
|
||||
|
||||
|
||||
def get_default_url():
|
||||
logging.info("Returning default URL of %s", default_url)
|
||||
return default_url
|
||||
|
||||
|
||||
class VirtManagerConfig:
|
||||
def __init__(self, filename=None):
|
||||
if filename is None:
|
||||
|
@ -73,6 +76,7 @@ class VirtManagerConfig:
|
|||
print >> output, entry
|
||||
output.close()
|
||||
|
||||
|
||||
class LibvirtWorker:
|
||||
'''Provides utilities for interfacing with libvirt.'''
|
||||
def __init__(self, url=None):
|
||||
|
@ -320,7 +324,7 @@ class LibvirtWorker:
|
|||
pool.conn = self.__conn
|
||||
pool.get_xml_config()
|
||||
newpool = pool.install(meter=meter,
|
||||
build=True, # config.get_build_pool(),
|
||||
build=True, # config.get_build_pool(),
|
||||
create=True)
|
||||
newpool.setAutostart(True)
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
import snack
|
||||
from virtManagerTui.domainlistconfigscreen import DomainListConfigScreen
|
||||
|
||||
|
||||
class ListDomainsConfigScreen(DomainListConfigScreen):
|
||||
LIST_PAGE = 1
|
||||
DETAIL_PAGE = 2
|
||||
|
@ -77,7 +78,7 @@ class ListDomainsConfigScreen(DomainListConfigScreen):
|
|||
|
||||
semodel, setype, vmlabel = domain.get_seclabel()
|
||||
caps = self.get_libvirt().get_capabilities()
|
||||
if caps.host.secmodel and caps.host.secmodel.model:
|
||||
if caps.host.secmodel and caps.host.secmodel.model:
|
||||
semodel = caps.host.secmodel.model
|
||||
fields.append(("Model", semodel or "None"))
|
||||
|
||||
|
@ -97,6 +98,7 @@ class ListDomainsConfigScreen(DomainListConfigScreen):
|
|||
|
||||
return [grid]
|
||||
|
||||
|
||||
def ListDomains():
|
||||
screen = ListDomainsConfigScreen()
|
||||
screen.start()
|
||||
|
|
|
@ -34,7 +34,7 @@ class ListNetworksConfigScreen(NetworkListConfigScreen):
|
|||
return (page is DETAILS_PAGE)
|
||||
|
||||
def get_elements_for_page(self, screen, page):
|
||||
if page is LIST_PAGE:
|
||||
if page is LIST_PAGE:
|
||||
return self.get_network_list_page(screen)
|
||||
elif page is DETAILS_PAGE:
|
||||
return self.get_network_details_page(screen)
|
||||
|
@ -73,6 +73,7 @@ class ListNetworksConfigScreen(NetworkListConfigScreen):
|
|||
return [Label("Network Interface Details"),
|
||||
self.create_grid_from_fields(fields)]
|
||||
|
||||
|
||||
def ListNetworks():
|
||||
screen = ListNetworksConfigScreen()
|
||||
screen.start()
|
||||
|
|
|
@ -26,12 +26,13 @@ from newt_syrup import utils
|
|||
LIST_PAGE = 1
|
||||
DETAILS_PAGE = 2
|
||||
|
||||
|
||||
class ListStoragePoolsConfigScreen(StorageListConfigScreen):
|
||||
def __init__(self):
|
||||
StorageListConfigScreen.__init__(self, "List Storage Pools")
|
||||
|
||||
def get_elements_for_page(self, screen, page):
|
||||
if page is LIST_PAGE:
|
||||
if page is LIST_PAGE:
|
||||
return self.get_storage_pool_list_page(screen)
|
||||
elif page is DETAILS_PAGE:
|
||||
return self.get_pool_details_page(screen)
|
||||
|
@ -63,6 +64,7 @@ class ListStoragePoolsConfigScreen(StorageListConfigScreen):
|
|||
return [Label("Details For Storage Pool: %s" % self.get_selected_pool()),
|
||||
self.create_grid_from_fields(fields)]
|
||||
|
||||
|
||||
def ListStoragePools():
|
||||
screen = ListStoragePoolsConfigScreen()
|
||||
screen.start()
|
||||
|
|
|
@ -16,12 +16,12 @@
|
|||
# MA 02110-1301, USA. A copy of the GNU General Public License is
|
||||
# also available at http://www.gnu.org/copyleft/gpl.html.
|
||||
|
||||
from newt_syrup.menuscreen import MenuScreen
|
||||
from newt_syrup.menuscreen import MenuScreen
|
||||
|
||||
from virtManagerTui.nodemenu import NodeMenu
|
||||
from virtManagerTui.netmenu import NetworkMenu
|
||||
from virtManagerTui.nodemenu import NodeMenu
|
||||
from virtManagerTui.netmenu import NetworkMenu
|
||||
from virtManagerTui.storagemenu import StoragePoolMenu
|
||||
from virtManagerTui.hostmenu import HostMenu
|
||||
from virtManagerTui.hostmenu import HostMenu
|
||||
|
||||
NODE_MENU = 1
|
||||
NETWORK_MENU = 2
|
||||
|
@ -29,6 +29,7 @@ STORAGE_MENU = 3
|
|||
HOST_MENU = 4
|
||||
EXIT_CONSOLE = 99
|
||||
|
||||
|
||||
class MainMenuScreen(MenuScreen):
|
||||
def __init__(self):
|
||||
MenuScreen.__init__(self, "Main Menu")
|
||||
|
@ -40,7 +41,7 @@ class MainMenuScreen(MenuScreen):
|
|||
("Host Administration", HOST_MENU))
|
||||
|
||||
def handle_selection(self, page):
|
||||
if page is NODE_MENU:
|
||||
if page is NODE_MENU:
|
||||
NodeMenu()
|
||||
elif page is NETWORK_MENU:
|
||||
NetworkMenu()
|
||||
|
@ -49,6 +50,7 @@ class MainMenuScreen(MenuScreen):
|
|||
elif page is HOST_MENU:
|
||||
HostMenu()
|
||||
|
||||
|
||||
def MainMenu():
|
||||
screen = MainMenuScreen()
|
||||
screen.start()
|
||||
|
|
|
@ -24,6 +24,7 @@ LIST_DOMAINS = 1
|
|||
SELECT_TARGET = 2
|
||||
CONFIRM_PAGE = 3
|
||||
|
||||
|
||||
class MigrateDomainConfigScreen(DomainListConfigScreen):
|
||||
def __init__(self):
|
||||
DomainListConfigScreen.__init__(self, "Migrate Virtual Machine")
|
||||
|
@ -32,7 +33,7 @@ class MigrateDomainConfigScreen(DomainListConfigScreen):
|
|||
self.__targets = None
|
||||
|
||||
def get_elements_for_page(self, screen, page):
|
||||
if page is LIST_DOMAINS:
|
||||
if page is LIST_DOMAINS:
|
||||
return self.get_domain_list_page(screen)
|
||||
elif page is SELECT_TARGET:
|
||||
return self.get_target_page(screen)
|
||||
|
@ -40,7 +41,7 @@ class MigrateDomainConfigScreen(DomainListConfigScreen):
|
|||
return self.get_confirm_page(screen)
|
||||
|
||||
def page_has_next(self, page):
|
||||
if page is LIST_DOMAINS:
|
||||
if page is LIST_DOMAINS:
|
||||
return self.has_selectable_domains()
|
||||
else:
|
||||
return page < CONFIRM_PAGE
|
||||
|
@ -52,7 +53,7 @@ class MigrateDomainConfigScreen(DomainListConfigScreen):
|
|||
return page is CONFIRM_PAGE
|
||||
|
||||
def validate_input(self, page, errors):
|
||||
if page is LIST_DOMAINS:
|
||||
if page is LIST_DOMAINS:
|
||||
return self.get_selected_domain() is not None
|
||||
elif page is SELECT_TARGET:
|
||||
if self.__targets.current() is None:
|
||||
|
@ -84,6 +85,7 @@ class MigrateDomainConfigScreen(DomainListConfigScreen):
|
|||
grid.setField(self.__confirm, 0, 0)
|
||||
return [grid]
|
||||
|
||||
|
||||
def MigrateDomain():
|
||||
screen = MigrateDomainConfigScreen()
|
||||
screen.start()
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
|
||||
from newt_syrup.menuscreen import MenuScreen
|
||||
|
||||
from virtManagerTui.addnetwork import AddNetwork
|
||||
from virtManagerTui.startnetwork import StartNetwork
|
||||
from virtManagerTui.stopnetwork import StopNetwork
|
||||
from virtManagerTui.removenetwork import RemoveNetwork
|
||||
from virtManagerTui.listnetworks import ListNetworks
|
||||
from virtManagerTui.addnetwork import AddNetwork
|
||||
from virtManagerTui.startnetwork import StartNetwork
|
||||
from virtManagerTui.stopnetwork import StopNetwork
|
||||
from virtManagerTui.removenetwork import RemoveNetwork
|
||||
from virtManagerTui.listnetworks import ListNetworks
|
||||
|
||||
ADD_NETWORK = 1
|
||||
START_NETWORK = 2
|
||||
|
@ -30,6 +30,7 @@ STOP_NETWORK = 3
|
|||
REMOVE_NETWORK = 4
|
||||
LIST_NETWORKS = 5
|
||||
|
||||
|
||||
class NetworkMenuScreen(MenuScreen):
|
||||
def __init__(self):
|
||||
MenuScreen.__init__(self, "Network Administration")
|
||||
|
@ -42,7 +43,7 @@ class NetworkMenuScreen(MenuScreen):
|
|||
("List Networks", LIST_NETWORKS))
|
||||
|
||||
def handle_selection(self, item):
|
||||
if item is ADD_NETWORK:
|
||||
if item is ADD_NETWORK:
|
||||
AddNetwork()
|
||||
elif item is START_NETWORK:
|
||||
StartNetwork()
|
||||
|
@ -53,6 +54,7 @@ class NetworkMenuScreen(MenuScreen):
|
|||
elif item is LIST_NETWORKS:
|
||||
ListNetworks()
|
||||
|
||||
|
||||
def NetworkMenu():
|
||||
screen = NetworkMenuScreen()
|
||||
screen.start()
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
import ipaddr
|
||||
|
||||
|
||||
class NetworkConfig:
|
||||
def __init__(self):
|
||||
self.__name = ""
|
||||
|
|
|
@ -20,6 +20,7 @@ import snack
|
|||
|
||||
from virtManagerTui.vmmconfigscreen import VmmTuiConfigScreen
|
||||
|
||||
|
||||
class NetworkListConfigScreen(VmmTuiConfigScreen):
|
||||
'''Provides a base class for all config screens that require a network list.'''
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import sys
|
|||
|
||||
from virtManagerTui.mainmenu import MainMenu
|
||||
|
||||
|
||||
def NodeAdmin():
|
||||
MainMenu()
|
||||
|
||||
|
|
|
@ -16,16 +16,16 @@
|
|||
# MA 02110-1301, USA. A copy of the GNU General Public License is
|
||||
# also available at http://www.gnu.org/copyleft/gpl.html.
|
||||
|
||||
from newt_syrup.menuscreen import MenuScreen
|
||||
from newt_syrup.menuscreen import MenuScreen
|
||||
|
||||
from virtManagerTui.adddomain import AddDomain
|
||||
from virtManagerTui.startdomain import StartDomain
|
||||
from virtManagerTui.stopdomain import StopDomain
|
||||
from virtManagerTui.pausedomain import PauseDomain
|
||||
from virtManagerTui.removedomain import RemoveDomain
|
||||
from virtManagerTui.listdomains import ListDomains
|
||||
from virtManagerTui.migratedomain import MigrateDomain
|
||||
from virtManagerTui.createuser import CreateUser
|
||||
from virtManagerTui.adddomain import AddDomain
|
||||
from virtManagerTui.startdomain import StartDomain
|
||||
from virtManagerTui.stopdomain import StopDomain
|
||||
from virtManagerTui.pausedomain import PauseDomain
|
||||
from virtManagerTui.removedomain import RemoveDomain
|
||||
from virtManagerTui.listdomains import ListDomains
|
||||
from virtManagerTui.migratedomain import MigrateDomain
|
||||
from virtManagerTui.createuser import CreateUser
|
||||
|
||||
ADD_DOMAIN = 1
|
||||
START_DOMAIN = 2
|
||||
|
@ -36,6 +36,7 @@ LIST_DOMAINS = 6
|
|||
MIGRATE_DOMAIN = 7
|
||||
CREATE_USER = 8
|
||||
|
||||
|
||||
class NodeMenuScreen(MenuScreen):
|
||||
def __init__(self):
|
||||
MenuScreen.__init__(self, "Node Administration")
|
||||
|
@ -68,6 +69,7 @@ class NodeMenuScreen(MenuScreen):
|
|||
elif item is CREATE_USER:
|
||||
CreateUser()
|
||||
|
||||
|
||||
def NodeMenu():
|
||||
screen = NodeMenuScreen()
|
||||
screen.start()
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
import snack
|
||||
from virtManagerTui.domainlistconfigscreen import DomainListConfigScreen
|
||||
|
||||
|
||||
class PauseDomainConfigScreen(DomainListConfigScreen):
|
||||
LIST_PAGE = 1
|
||||
STOP_PAGE = 2
|
||||
|
@ -67,6 +68,7 @@ class PauseDomainConfigScreen(DomainListConfigScreen):
|
|||
grid.setField(snack.Label("%s was successfully paused." % self.get_selected_domain().get_name()), 0, 0)
|
||||
return [grid]
|
||||
|
||||
|
||||
def PauseDomain():
|
||||
screen = PauseDomainConfigScreen()
|
||||
screen.start()
|
||||
|
|
|
@ -20,6 +20,7 @@ from virtinst import Storage
|
|||
|
||||
ROOT_TARGET_PATH = "/var/lib/libvirt/images/%s"
|
||||
|
||||
|
||||
class PoolConfig:
|
||||
def __init__(self, libvirt):
|
||||
self.__libvirt = libvirt
|
||||
|
@ -58,7 +59,7 @@ class PoolConfig:
|
|||
self.__needs_source_path = False
|
||||
self.__needs_build_pool = False
|
||||
if pooltype is not None:
|
||||
if pooltype is Storage.StoragePool.TYPE_DIR:
|
||||
if pooltype is Storage.StoragePool.TYPE_DIR:
|
||||
self.__needs_target_path = True
|
||||
self.__target_path = ROOT_TARGET_PATH % self.__name
|
||||
self.__build_pool = True
|
||||
|
@ -149,5 +150,5 @@ class PoolConfig:
|
|||
def set_build_pool(self, build_pool):
|
||||
self.__build_pool = build_pool
|
||||
|
||||
def get_build_pool(self):
|
||||
def get_build_pool(self):
|
||||
return self.__build_pool
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
import snack
|
||||
from virtManagerTui.domainlistconfigscreen import DomainListConfigScreen
|
||||
|
||||
|
||||
class RemoveDomainConfigScreen(DomainListConfigScreen):
|
||||
LIST_PAGE = 1
|
||||
CONFIRM_PAGE = 2
|
||||
|
@ -30,7 +31,7 @@ class RemoveDomainConfigScreen(DomainListConfigScreen):
|
|||
self.__confirm_remove = None
|
||||
|
||||
def get_elements_for_page(self, screen, page):
|
||||
if page is self.LIST_PAGE:
|
||||
if page is self.LIST_PAGE:
|
||||
return self.get_domain_list_page(screen)
|
||||
elif page is self.CONFIRM_PAGE:
|
||||
return self.get_confirm_page(screen)
|
||||
|
@ -38,21 +39,21 @@ class RemoveDomainConfigScreen(DomainListConfigScreen):
|
|||
return self.get_remove_page(screen)
|
||||
|
||||
def page_has_next(self, page):
|
||||
if page is self.LIST_PAGE:
|
||||
if page is self.LIST_PAGE:
|
||||
return self.has_selectable_domains()
|
||||
elif page is self.CONFIRM_PAGE:
|
||||
return True
|
||||
return False
|
||||
|
||||
def page_has_back(self, page):
|
||||
if page is self.CONFIRM_PAGE:
|
||||
if page is self.CONFIRM_PAGE:
|
||||
return True
|
||||
elif page is self.REMOVE_PAGE:
|
||||
return True
|
||||
return False
|
||||
|
||||
def get_back_page(self, page):
|
||||
if page is self.CONFIRM_PAGE:
|
||||
if page is self.CONFIRM_PAGE:
|
||||
return self.LIST_PAGE
|
||||
elif page is self.REMOVE_PAGE:
|
||||
return self.LIST_PAGE
|
||||
|
@ -89,6 +90,7 @@ class RemoveDomainConfigScreen(DomainListConfigScreen):
|
|||
grid.setField(snack.Label("%s has been removed." % self.get_selected_domain().get_name()), 0, 0)
|
||||
return [grid]
|
||||
|
||||
|
||||
def RemoveDomain():
|
||||
screen = RemoveDomainConfigScreen()
|
||||
screen.start()
|
||||
|
|
|
@ -23,13 +23,14 @@ from virtManagerTui.hostlistconfigscreen import HostListConfigScreen
|
|||
SELECT_HOST_PAGE = 1
|
||||
CONFIRM_REMOVE_PAGE = 2
|
||||
|
||||
|
||||
class RemoveHostConfigScreen(HostListConfigScreen):
|
||||
def __init__(self):
|
||||
HostListConfigScreen.__init__(self, "Remove Host Connection")
|
||||
self.__confirm = None
|
||||
|
||||
def get_elements_for_page(self, screen, page):
|
||||
if page is SELECT_HOST_PAGE:
|
||||
if page is SELECT_HOST_PAGE:
|
||||
return self.get_connection_list_page(screen)
|
||||
elif page is CONFIRM_REMOVE_PAGE:
|
||||
return self.get_confirm_remove_page(screen)
|
||||
|
@ -44,7 +45,7 @@ class RemoveHostConfigScreen(HostListConfigScreen):
|
|||
return page is CONFIRM_REMOVE_PAGE
|
||||
|
||||
def validate_input(self, page, errors):
|
||||
if page is SELECT_HOST_PAGE:
|
||||
if page is SELECT_HOST_PAGE:
|
||||
return True
|
||||
elif page is CONFIRM_REMOVE_PAGE:
|
||||
if self.__confirm.value():
|
||||
|
@ -66,6 +67,7 @@ class RemoveHostConfigScreen(HostListConfigScreen):
|
|||
return [snack.Label("Remove Host Connection"),
|
||||
grid]
|
||||
|
||||
|
||||
def RemoveHost():
|
||||
screen = RemoveHostConfigScreen()
|
||||
screen.start()
|
||||
|
|
|
@ -25,6 +25,7 @@ LIST_PAGE = 1
|
|||
CONFIRM_PAGE = 2
|
||||
REMOVE_PAGE = 3
|
||||
|
||||
|
||||
class RemoveNetworkConfigScreen(NetworkListConfigScreen):
|
||||
def __init__(self):
|
||||
NetworkListConfigScreen.__init__(self, "Remove A Network")
|
||||
|
@ -32,7 +33,7 @@ class RemoveNetworkConfigScreen(NetworkListConfigScreen):
|
|||
self.__confirm_remove = None
|
||||
|
||||
def get_elements_for_page(self, screen, page):
|
||||
if page is LIST_PAGE:
|
||||
if page is LIST_PAGE:
|
||||
return self.get_network_list_page(screen, started=False)
|
||||
elif page is CONFIRM_PAGE:
|
||||
return self.get_confirm_page(screen)
|
||||
|
@ -54,13 +55,13 @@ class RemoveNetworkConfigScreen(NetworkListConfigScreen):
|
|||
return False
|
||||
|
||||
def get_back_page(self, page):
|
||||
if page is CONFIRM_PAGE:
|
||||
if page is CONFIRM_PAGE:
|
||||
return LIST_PAGE
|
||||
elif page is REMOVE_PAGE:
|
||||
return LIST_PAGE
|
||||
|
||||
def validate_input(self, page, errors):
|
||||
if page is LIST_PAGE:
|
||||
if page is LIST_PAGE:
|
||||
return True
|
||||
elif page is CONFIRM_PAGE:
|
||||
network = self.get_selected_network()
|
||||
|
@ -87,6 +88,7 @@ class RemoveNetworkConfigScreen(NetworkListConfigScreen):
|
|||
network_name = self.__deleted_network_name
|
||||
return [Label("Network has been removed: %s" % network_name)]
|
||||
|
||||
|
||||
def RemoveNetwork():
|
||||
screen = RemoveNetworkConfigScreen()
|
||||
screen.start()
|
||||
|
|
|
@ -26,13 +26,14 @@ LIST_POOLS_PAGE = 1
|
|||
CONFIRM_PAGE = 2
|
||||
FINISHED_REMOVING = 3
|
||||
|
||||
|
||||
class RemoveStoragePoolConfigScreen(StorageListConfigScreen):
|
||||
def __init__(self):
|
||||
StorageListConfigScreen.__init__(self, "Remove A Storage Pool")
|
||||
self.__confirm = None
|
||||
|
||||
def get_elements_for_page(self, screen, page):
|
||||
if page is LIST_POOLS_PAGE:
|
||||
if page is LIST_POOLS_PAGE:
|
||||
return self.get_storage_pool_list_page(screen)
|
||||
elif page is CONFIRM_PAGE:
|
||||
return self.get_confirm_page(screen)
|
||||
|
@ -91,6 +92,7 @@ class RemoveStoragePoolConfigScreen(StorageListConfigScreen):
|
|||
state = "was not "
|
||||
return [Label("Storage pool '%s' %sdeleted." % (pool, state))]
|
||||
|
||||
|
||||
def RemoveStoragePool():
|
||||
screen = RemoveStoragePoolConfigScreen()
|
||||
screen.start()
|
||||
|
|
|
@ -25,6 +25,7 @@ SELECT_POOL_PAGE = 1
|
|||
SELECT_VOLUME_PAGE = 2
|
||||
CONFIRM_PAGE = 3
|
||||
|
||||
|
||||
class RemoveVolumeConfigScreen(StorageListConfigScreen):
|
||||
def __init__(self):
|
||||
StorageListConfigScreen.__init__(self, "Add A New Storage Volume")
|
||||
|
@ -32,7 +33,7 @@ class RemoveVolumeConfigScreen(StorageListConfigScreen):
|
|||
self.__confirm = None
|
||||
|
||||
def get_elements_for_page(self, screen, page):
|
||||
if page is SELECT_POOL_PAGE:
|
||||
if page is SELECT_POOL_PAGE:
|
||||
return self.get_storage_pool_list_page(screen)
|
||||
elif page is SELECT_VOLUME_PAGE:
|
||||
return self.get_storage_volume_list_page(screen)
|
||||
|
@ -40,14 +41,14 @@ class RemoveVolumeConfigScreen(StorageListConfigScreen):
|
|||
return self.get_confirm_page(screen)
|
||||
|
||||
def page_has_next(self, page):
|
||||
if page is SELECT_POOL_PAGE:
|
||||
if page is SELECT_POOL_PAGE:
|
||||
return self.has_selectable_pools()
|
||||
elif page is SELECT_VOLUME_PAGE:
|
||||
return self.has_selectable_volumes()
|
||||
return False
|
||||
|
||||
def validate_input(self, page, errors):
|
||||
if page is SELECT_POOL_PAGE:
|
||||
if page is SELECT_POOL_PAGE:
|
||||
return self.get_selected_pool() is not None
|
||||
elif page is SELECT_VOLUME_PAGE:
|
||||
return self.get_selected_volume() is not None
|
||||
|
@ -77,6 +78,7 @@ class RemoveVolumeConfigScreen(StorageListConfigScreen):
|
|||
return [snack.Label("Remove Selected Storage Volume"),
|
||||
grid]
|
||||
|
||||
|
||||
def RemoveStorageVolume():
|
||||
screen = RemoveVolumeConfigScreen()
|
||||
screen.start()
|
||||
|
|
|
@ -21,6 +21,7 @@ import snack
|
|||
|
||||
from virtManagerTui.domainlistconfigscreen import DomainListConfigScreen
|
||||
|
||||
|
||||
class StartDomainConfigScreen(DomainListConfigScreen):
|
||||
LIST_PAGE = 1
|
||||
START_PAGE = 2
|
||||
|
@ -66,6 +67,7 @@ class StartDomainConfigScreen(DomainListConfigScreen):
|
|||
grid.setField(snack.Label("%s was successfully started." % self.get_selected_domain().get_name()), 0, 0)
|
||||
return [grid]
|
||||
|
||||
|
||||
def StartDomain():
|
||||
screen = StartDomainConfigScreen()
|
||||
screen.start()
|
||||
|
|
|
@ -24,12 +24,13 @@ from virtManagerTui.networklistconfigscreen import NetworkListConfigScreen
|
|||
LIST_PAGE = 1
|
||||
START_PAGE = 2
|
||||
|
||||
|
||||
class StartNetworkConfigScreen(NetworkListConfigScreen):
|
||||
def __init__(self):
|
||||
NetworkListConfigScreen.__init__(self, "Start A Network")
|
||||
|
||||
def get_elements_for_page(self, screen, page):
|
||||
if page is LIST_PAGE:
|
||||
if page is LIST_PAGE:
|
||||
return self.get_network_list_page(screen, started=False)
|
||||
elif page is START_PAGE:
|
||||
return self.get_start_network_page(screen)
|
||||
|
@ -55,6 +56,7 @@ class StartNetworkConfigScreen(NetworkListConfigScreen):
|
|||
network = self.get_selected_network()
|
||||
return [Label("%s was successfully started." % network.get_name())]
|
||||
|
||||
|
||||
def StartNetwork():
|
||||
screen = StartNetworkConfigScreen()
|
||||
screen.start()
|
||||
|
|
|
@ -23,12 +23,13 @@ from virtManagerTui.storagelistconfigscreen import StorageListConfigScreen
|
|||
LIST_POOLS_PAGE = 1
|
||||
FINAL_PAGE = 2
|
||||
|
||||
|
||||
class StartStoragePoolConfigScreen(StorageListConfigScreen):
|
||||
def __init__(self):
|
||||
StorageListConfigScreen.__init__(self, "Start A Storage Pool")
|
||||
|
||||
def get_elements_for_page(self, screen, page):
|
||||
if page is LIST_POOLS_PAGE:
|
||||
if page is LIST_POOLS_PAGE:
|
||||
return self.get_storage_pool_list_page(screen, created=False)
|
||||
elif page is FINAL_PAGE:
|
||||
return self.get_final_page(screen)
|
||||
|
@ -56,6 +57,7 @@ class StartStoragePoolConfigScreen(StorageListConfigScreen):
|
|||
self.set_finished()
|
||||
return [Label("Storage pool started: %s" % self.get_selected_pool())]
|
||||
|
||||
|
||||
def StartStoragePool():
|
||||
screen = StartStoragePoolConfigScreen()
|
||||
screen.start()
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
import snack
|
||||
from virtManagerTui.domainlistconfigscreen import DomainListConfigScreen
|
||||
|
||||
|
||||
class StopDomainConfigScreen(DomainListConfigScreen):
|
||||
LIST_PAGE = 1
|
||||
STOP_PAGE = 2
|
||||
|
@ -66,6 +67,7 @@ class StopDomainConfigScreen(DomainListConfigScreen):
|
|||
grid.setField(snack.Label("%s was successfully stopped." % self.get_selected_domain().get_name()), 0, 0)
|
||||
return [grid]
|
||||
|
||||
|
||||
def StopDomain():
|
||||
screen = StopDomainConfigScreen()
|
||||
screen.start()
|
||||
|
|
|
@ -24,12 +24,13 @@ import logging
|
|||
LIST_PAGE = 1
|
||||
STOP_PAGE = 2
|
||||
|
||||
|
||||
class StopNetworkConfigScreen(NetworkListConfigScreen):
|
||||
def __init__(self):
|
||||
NetworkListConfigScreen.__init__(self, "Stop A Network")
|
||||
|
||||
def get_elements_for_page(self, screen, page):
|
||||
if page is LIST_PAGE:
|
||||
if page is LIST_PAGE:
|
||||
return self.get_network_list_page(screen, defined=False)
|
||||
elif page is STOP_PAGE:
|
||||
return self.get_stop_network_page(screen)
|
||||
|
@ -58,6 +59,7 @@ class StopNetworkConfigScreen(NetworkListConfigScreen):
|
|||
network = self.get_selected_network()
|
||||
return [Label("%s has been stopped." % network.get_name())]
|
||||
|
||||
|
||||
def StopNetwork():
|
||||
screen = StopNetworkConfigScreen()
|
||||
screen.start()
|
||||
|
|
|
@ -23,12 +23,13 @@ from virtManagerTui.storagelistconfigscreen import StorageListConfigScreen
|
|||
LIST_POOLS_PAGE = 1
|
||||
FINAL_PAGE = 2
|
||||
|
||||
|
||||
class StopStoragePoolConfigScreen(StorageListConfigScreen):
|
||||
def __init__(self):
|
||||
StorageListConfigScreen.__init__(self, "Stop A Storage Pool")
|
||||
|
||||
def get_elements_for_page(self, screen, page):
|
||||
if page is LIST_POOLS_PAGE:
|
||||
if page is LIST_POOLS_PAGE:
|
||||
return self.get_storage_pool_list_page(screen, defined=False)
|
||||
elif page is FINAL_PAGE:
|
||||
return self.get_final_page(screen)
|
||||
|
@ -56,6 +57,7 @@ class StopStoragePoolConfigScreen(StorageListConfigScreen):
|
|||
self.set_finished()
|
||||
return [Label("Storage pool stopped: %s" % self.get_selected_pool())]
|
||||
|
||||
|
||||
def StopStoragePool():
|
||||
screen = StopStoragePoolConfigScreen()
|
||||
screen.start()
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue