mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 17:57:34 +03:00
Tons of misc pylint fixes
This commit is contained in:
parent
d323fbbe23
commit
ae471007fc
5
setup.py
5
setup.py
@ -26,7 +26,7 @@ from virtcli import cliconfig
|
||||
def _generate_potfiles_in():
|
||||
def find(dirname, ext):
|
||||
ret = []
|
||||
for root, dirnames, filenames in os.walk(dirname):
|
||||
for root, ignore, filenames in os.walk(dirname):
|
||||
for filename in fnmatch.filter(filenames, ext):
|
||||
ret.append(os.path.join(root, filename))
|
||||
ret.sort(key=lambda s: s.lower())
|
||||
@ -421,10 +421,11 @@ class CheckPylint(Command):
|
||||
"I0011", # I0011: Warn about locally disabled pylint msgs
|
||||
"R0201", # R0201: Method could be a function
|
||||
|
||||
"W0142", # W0142: *Used * or ** magic*
|
||||
"W0142", # W0142: Used * or ** magic*
|
||||
"W0603", # W0603: Using the global statement
|
||||
"W0702", # W0702: No exception type specified for 'catch'
|
||||
"W0703", # W0703: Catch 'Exception'
|
||||
"W1401", # W1401: Anomalous backslash in string
|
||||
|
||||
|
||||
# May be useful to enable someday
|
||||
|
@ -129,33 +129,30 @@ test_files = {
|
||||
}
|
||||
|
||||
|
||||
"""
|
||||
CLI test matrix
|
||||
|
||||
Any global args for every invocation should be added to default_args
|
||||
function, so that individual tests can easily overwrite them.
|
||||
|
||||
Format:
|
||||
|
||||
"appname" {
|
||||
"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
|
||||
"--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
|
||||
"--opt1 --opt2",
|
||||
}
|
||||
} # End categoryfoo
|
||||
|
||||
}
|
||||
"
|
||||
"""
|
||||
# CLI test matrix
|
||||
#
|
||||
# Any global args for every invocation should be added to default_args
|
||||
# function, so that individual tests can easily overwrite them.
|
||||
#
|
||||
# Format:
|
||||
#
|
||||
# "appname" {
|
||||
# "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
|
||||
# "--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
|
||||
# "--opt1 --opt2",
|
||||
# }
|
||||
# } # End categoryfoo
|
||||
#
|
||||
#}
|
||||
|
||||
|
||||
def default_args(app, cli, testtype):
|
||||
|
@ -29,7 +29,6 @@ from optparse import OptionGroup
|
||||
|
||||
import virtinst.cli as cli
|
||||
from virtinst.cli import fail, print_stdout, print_stderr
|
||||
import virtinst.util as util
|
||||
import virtconv.formats as formats
|
||||
import virtconv.vmcfg as vmcfg
|
||||
import virtconv.diskcfg as diskcfg
|
||||
|
@ -279,7 +279,7 @@ def get_virt_type(conn, options):
|
||||
caps=capabilities,
|
||||
os_type=req_virt_type,
|
||||
arch=arch,
|
||||
type=req_hv_type,
|
||||
typ=req_hv_type,
|
||||
accelerated=req_accel,
|
||||
machine=options.machine)
|
||||
except Exception, e:
|
||||
@ -566,7 +566,7 @@ def _run_console(args):
|
||||
return child
|
||||
|
||||
os.execvp(args[0], args)
|
||||
os._exit(1)
|
||||
os._exit(1) # pylint: disable=W0212
|
||||
|
||||
def vnc_console(dom, uri):
|
||||
args = ["/usr/bin/virt-viewer",
|
||||
|
@ -65,7 +65,7 @@ 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)
|
||||
os._exit(0) # pylint: disable=W0212
|
||||
|
||||
os.setsid()
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
import logging
|
||||
import optparse
|
||||
import os
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
|
@ -304,6 +304,12 @@ class OverBox(Gtk.Box):
|
||||
over.y = 0
|
||||
self.overWidget.size_allocate(over)
|
||||
|
||||
# These make pylint happy
|
||||
def show_all(self, *args, **kwargs):
|
||||
return Gtk.Box.show(self, *args, **kwargs)
|
||||
def destroy(self, *args, **kwargs):
|
||||
return Gtk.Box.destroy(self, *args, **kwargs)
|
||||
|
||||
|
||||
class Drawer(OverBox):
|
||||
"""
|
||||
|
@ -151,7 +151,7 @@ class vmmConfig(object):
|
||||
|
||||
try:
|
||||
# Check we can open the Python guestfs module.
|
||||
from guestfs import GuestFS
|
||||
from guestfs import GuestFS # pylint: disable=F0401
|
||||
g = GuestFS()
|
||||
|
||||
# Check for the first version which fixed Python GIL bug.
|
||||
|
@ -160,12 +160,12 @@ class vmmConnect(vmmGObjectUI):
|
||||
elif default.startswith("xen"):
|
||||
self.widget("hypervisor").set_active(0)
|
||||
|
||||
def add_service(self, interface, protocol, name, type, domain, flags):
|
||||
def add_service(self, interface, protocol, name, typ, domain, flags):
|
||||
ignore = flags
|
||||
try:
|
||||
# Async service resolving
|
||||
res = self.server.ServiceResolverNew(interface, protocol, name,
|
||||
type, domain, -1, 0)
|
||||
typ, domain, -1, 0)
|
||||
resint = dbus.Interface(self.bus.get_object(
|
||||
"org.freedesktop.Avahi", res),
|
||||
"org.freedesktop.Avahi.ServiceResolver")
|
||||
@ -174,12 +174,12 @@ class vmmConnect(vmmGObjectUI):
|
||||
except Exception, e:
|
||||
logging.exception(e)
|
||||
|
||||
def remove_service(self, interface, protocol, name, type, domain, flags):
|
||||
def remove_service(self, interface, protocol, name, typ, domain, flags):
|
||||
ignore = domain
|
||||
ignore = protocol
|
||||
ignore = flags
|
||||
ignore = interface
|
||||
ignore = type
|
||||
ignore = typ
|
||||
|
||||
try:
|
||||
model = self.widget("hostname").get_model()
|
||||
@ -190,13 +190,13 @@ class vmmConnect(vmmGObjectUI):
|
||||
except Exception, e:
|
||||
logging.exception(e)
|
||||
|
||||
def add_conn_to_list(self, interface, protocol, name, type, domain,
|
||||
def add_conn_to_list(self, interface, protocol, name, typ, domain,
|
||||
host, aprotocol, address, port, text, flags):
|
||||
ignore = domain
|
||||
ignore = protocol
|
||||
ignore = flags
|
||||
ignore = interface
|
||||
ignore = type
|
||||
ignore = typ
|
||||
ignore = text
|
||||
ignore = aprotocol
|
||||
ignore = port
|
||||
|
@ -259,7 +259,7 @@ class vmmConnection(vmmGObject):
|
||||
self._check_caps()
|
||||
return self._caps
|
||||
|
||||
def get_max_vcpus(self, _type=None):
|
||||
def get_max_vcpus(self, _type):
|
||||
return virtinst.util.get_max_vcpus(self.vmm, _type)
|
||||
|
||||
def get_host_info(self):
|
||||
@ -1543,11 +1543,12 @@ class vmmConnection(vmmGObject):
|
||||
vector.append(0)
|
||||
return vector
|
||||
|
||||
def stats_memory_vector(self):
|
||||
return self._vector_helper("memoryPercent")
|
||||
|
||||
def host_cpu_time_vector(self):
|
||||
return self._vector_helper("cpuHostPercent")
|
||||
guest_cpu_time_vector = host_cpu_time_vector
|
||||
def stats_memory_vector(self):
|
||||
return self._vector_helper("memoryPercent")
|
||||
|
||||
def host_cpu_time_vector_limit(self, limit):
|
||||
cpudata = self.host_cpu_time_vector()
|
||||
@ -1555,11 +1556,10 @@ class vmmConnection(vmmGObject):
|
||||
cpudata = cpudata[0:limit]
|
||||
return cpudata
|
||||
guest_cpu_time_vector_limit = host_cpu_time_vector_limit
|
||||
def disk_io_vector_limit(self, dummy):
|
||||
# No point to accumulate unnormalized I/O for a conenction
|
||||
|
||||
def disk_io_vector_limit(self, ignore):
|
||||
return [0.0]
|
||||
def network_traffic_vector_limit(self, dummy):
|
||||
# No point to accumulate unnormalized Rx/Tx for a connection
|
||||
def network_traffic_vector_limit(self, ignore):
|
||||
return [0.0]
|
||||
|
||||
def _get_record_helper(self, record_name):
|
||||
|
@ -171,7 +171,7 @@ class Tunnel(object):
|
||||
os.dup(fds[1].fileno())
|
||||
os.dup(errorfds[1].fileno())
|
||||
os.execlp(*argv)
|
||||
os._exit(1)
|
||||
os._exit(1) # pylint: disable=W0212
|
||||
else:
|
||||
fds[1].close()
|
||||
errorfds[1].close()
|
||||
@ -1128,8 +1128,6 @@ class vmmConsolePages(vmmGObjectUI):
|
||||
|
||||
msg = (_("Cannot display graphical console type '%s'")
|
||||
% ginfo.gtype)
|
||||
if ginfo.gtype == "spice":
|
||||
msg += ":\n %s" % self.config.get_spice_error()
|
||||
|
||||
self.activate_unavailable_page(msg)
|
||||
return
|
||||
|
@ -566,7 +566,7 @@ class vmmCreate(vmmGObjectUI):
|
||||
# CPU
|
||||
phys_cpus = self.conn.host_active_processor_count()
|
||||
|
||||
max_v = self.conn.get_max_vcpus(_type=self.capsdomain.hypervisor_type)
|
||||
max_v = self.conn.get_max_vcpus(self.capsdomain.hypervisor_type)
|
||||
cmax = phys_cpus
|
||||
if int(max_v) < int(phys_cpus):
|
||||
cmax = max_v
|
||||
@ -830,7 +830,7 @@ class vmmCreate(vmmGObjectUI):
|
||||
conn=self.conn.vmm,
|
||||
caps=self.caps,
|
||||
os_type=gtype,
|
||||
type=dtype,
|
||||
typ=dtype,
|
||||
accelerated=True,
|
||||
arch=arch)
|
||||
|
||||
|
@ -168,6 +168,8 @@ class vmmCreateNetwork(vmmGObjectUI):
|
||||
notebook.prev_page()
|
||||
|
||||
def change_ipv4_enable(self, src):
|
||||
ignore = src
|
||||
|
||||
white = Gdk.Color.parse("#f0f0f0")[1]
|
||||
net4 = self.widget("net-ipv4-network")
|
||||
start4 = self.widget("net-dhcpv4-start")
|
||||
@ -191,6 +193,8 @@ class vmmCreateNetwork(vmmGObjectUI):
|
||||
end4.modify_bg(Gtk.StateType.NORMAL, white)
|
||||
|
||||
def change_ipv6_enable(self, src):
|
||||
ignore = src
|
||||
|
||||
white = Gdk.Color.parse("#f0f0f0")[1]
|
||||
net6 = self.widget("net-ipv6-network")
|
||||
start6 = self.widget("net-dhcpv6-start")
|
||||
@ -304,6 +308,8 @@ class vmmCreateNetwork(vmmGObjectUI):
|
||||
|
||||
|
||||
def change_dhcpv4_enable(self, src):
|
||||
ignore = src
|
||||
|
||||
white = Gdk.Color.parse("#f0f0f0")[1]
|
||||
start4 = self.widget("net-dhcpv4-start")
|
||||
end4 = self.widget("net-dhcpv4-end")
|
||||
@ -352,6 +358,8 @@ class vmmCreateNetwork(vmmGObjectUI):
|
||||
src.modify_bg(Gtk.StateType.NORMAL, green)
|
||||
|
||||
def change_dhcpv6_enable(self, src):
|
||||
ignore = src
|
||||
|
||||
white = Gdk.Color.parse("#f0f0f0")[1]
|
||||
start6 = self.widget("net-dhcpv6-start")
|
||||
end6 = self.widget("net-dhcpv6-end")
|
||||
@ -382,7 +390,7 @@ class vmmCreateNetwork(vmmGObjectUI):
|
||||
end = self.get_config_dhcpv6_end()
|
||||
self.change_dhcpv6(src, end)
|
||||
|
||||
def change_dhcpv6(self,src,addr):
|
||||
def change_dhcpv6(self, src, addr):
|
||||
ip = self.get_config_ip6()
|
||||
black = Gdk.Color.parse("#000000")[1]
|
||||
src.modify_text(Gtk.StateType.NORMAL, black)
|
||||
@ -478,10 +486,10 @@ class vmmCreateNetwork(vmmGObjectUI):
|
||||
def populate_summary(self):
|
||||
self.widget("summary-name").set_text(self.get_config_name())
|
||||
self.widget("summary-domain").set_text(self.get_config_domain_name())
|
||||
self.widget("summary-ip4-network").set_text("");
|
||||
self.widget("summary-ip4-gateway").set_text("");
|
||||
self.widget("summary-ip6-network").set_text("");
|
||||
self.widget("summary-ip6-gateway").set_text("");
|
||||
self.widget("summary-ip4-network").set_text("")
|
||||
self.widget("summary-ip4-gateway").set_text("")
|
||||
self.widget("summary-ip6-network").set_text("")
|
||||
self.widget("summary-ip6-gateway").set_text("")
|
||||
|
||||
ip = self.get_config_ip4()
|
||||
if ip:
|
||||
|
@ -45,6 +45,7 @@ def _launch_dialog(dialog, primary_text, secondary_text, title,
|
||||
|
||||
return res
|
||||
|
||||
|
||||
class vmmErrorDialog(vmmGObject):
|
||||
def __init__(self, parent=None):
|
||||
vmmGObject.__init__(self)
|
||||
@ -175,6 +176,10 @@ class _errorDialog (Gtk.MessageDialog):
|
||||
"""
|
||||
Custom error dialog with optional check boxes or details drop down
|
||||
"""
|
||||
# pylint: disable=E1101
|
||||
# pylint can't detect functions we inheirit from Gtk, ex:
|
||||
# Instance of '_errorDialog' has no 'set_title' member
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
Gtk.MessageDialog.__init__(self, *args, **kwargs)
|
||||
self.set_title("")
|
||||
|
@ -20,6 +20,10 @@ from gi.repository import GObject
|
||||
from gi.repository import Gtk
|
||||
# pylint: enable=E0611
|
||||
|
||||
# pylint: disable=E1101
|
||||
# pylint can't detect functions we inheirit from Gtk, ex:
|
||||
# Instance of 'Sparkline' has no 'get_style_context' member
|
||||
|
||||
|
||||
def rect_print(name, rect):
|
||||
# For debugging
|
||||
@ -260,6 +264,10 @@ class CellRendererSparkline(Gtk.CellRenderer):
|
||||
name = self._sanitize_param_spec_name(param_spec.name)
|
||||
setattr(self, name, value)
|
||||
|
||||
def set_property(self, *args, **kwargs):
|
||||
# Make pylint happy
|
||||
return Gtk.CellRenderer.set_property(self, *args, **kwargs)
|
||||
|
||||
|
||||
class Sparkline(Gtk.DrawingArea):
|
||||
__gproperties__ = {
|
||||
@ -392,3 +400,11 @@ class Sparkline(Gtk.DrawingArea):
|
||||
def do_set_property(self, param_spec, value):
|
||||
name = self._sanitize_param_spec_name(param_spec.name)
|
||||
setattr(self, name, value)
|
||||
|
||||
# These make pylint happy
|
||||
def set_property(self, *args, **kwargs):
|
||||
return Gtk.DrawingArea.set_property(self, *args, **kwargs)
|
||||
def show(self, *args, **kwargs):
|
||||
return Gtk.DrawingArea.show(self, *args, **kwargs)
|
||||
def destroy(self, *args, **kwargs):
|
||||
return Gtk.DrawingArea.destroy(self, *args, **kwargs)
|
||||
|
@ -22,7 +22,7 @@ from threading import Thread
|
||||
import logging
|
||||
import os
|
||||
|
||||
from guestfs import GuestFS
|
||||
from guestfs import GuestFS # pylint: disable=F0401
|
||||
|
||||
from virtManager.baseclass import vmmGObject
|
||||
from virtManager.domain import vmmInspectionData
|
||||
|
@ -29,7 +29,6 @@ from gi.repository import Gtk
|
||||
# pylint: enable=E0611
|
||||
|
||||
import libvirt
|
||||
import virtinst
|
||||
from virtinst import uriutil
|
||||
|
||||
from virtManager import util
|
||||
|
@ -123,7 +123,7 @@ class vmmNetwork(vmmLibvirtObject):
|
||||
routeVia = node.xpathEval('string(./@via)')
|
||||
if routeVia:
|
||||
routeAddr = node.xpathEval('string(./@address)')
|
||||
break;
|
||||
break
|
||||
|
||||
if goodNode == None:
|
||||
for node in nodes:
|
||||
@ -132,7 +132,7 @@ class vmmNetwork(vmmLibvirtObject):
|
||||
tmp = node.xpathEval('string(./@via)')
|
||||
if tmp:
|
||||
continue
|
||||
goodNode = node;
|
||||
goodNode = node
|
||||
break
|
||||
|
||||
if goodNode:
|
||||
@ -187,7 +187,7 @@ class vmmNetwork(vmmLibvirtObject):
|
||||
routeVia = node.xpathEval('string(./@via)')
|
||||
if routeVia:
|
||||
routeAddr = node.xpathEval('string(./@address)')
|
||||
break;
|
||||
break
|
||||
|
||||
if goodNode == None:
|
||||
for node in nodes:
|
||||
@ -196,7 +196,7 @@ class vmmNetwork(vmmLibvirtObject):
|
||||
tmp = node.xpathEval('string(./@via)')
|
||||
if tmp:
|
||||
continue
|
||||
goodNode = node;
|
||||
goodNode = node
|
||||
break
|
||||
|
||||
if goodNode:
|
||||
|
@ -29,7 +29,7 @@ from virtManager.baseclass import vmmGObject
|
||||
from virtManager.error import vmmErrorDialog
|
||||
|
||||
try:
|
||||
import appindicator
|
||||
import appindicator # pylint: disable=F0401
|
||||
except:
|
||||
appindicator = None
|
||||
|
||||
|
@ -202,8 +202,9 @@ class AddNetworkConfigScreen(VmmTuiConfigScreen):
|
||||
self.__end_address = Entry(15, self.__config.get_ipv4_end_address())
|
||||
fields = []
|
||||
fields.append(("Select the DHCP range", None))
|
||||
fields.append(("Start", self.__start_address.network))
|
||||
fields.append(("End", self.__end_address.network))
|
||||
# XXX
|
||||
#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"),
|
||||
|
@ -18,11 +18,11 @@
|
||||
|
||||
from snack import Label
|
||||
from virtManagerTui.networklistconfigscreen import NetworkListConfigScreen
|
||||
import ipaddr
|
||||
|
||||
LIST_PAGE = 1
|
||||
DETAILS_PAGE = 2
|
||||
|
||||
|
||||
class ListNetworksConfigScreen(NetworkListConfigScreen):
|
||||
def __init__(self):
|
||||
NetworkListConfigScreen.__init__(self, "List Networks")
|
||||
@ -47,7 +47,6 @@ class ListNetworksConfigScreen(NetworkListConfigScreen):
|
||||
result = network.get_ipv4_network()
|
||||
netaddr = result[0]
|
||||
dhcp = result[1]
|
||||
route = result[2]
|
||||
|
||||
fields.append(("Basic details", None))
|
||||
fields.append(("Name", network.get_name()))
|
||||
|
@ -66,17 +66,16 @@ class NetworkConfig:
|
||||
return "RESERVED"
|
||||
return "OTHER"
|
||||
|
||||
#FIXME ??
|
||||
#def is_public_ipv4_network(self):
|
||||
# if self.__ipv4_address.is_private
|
||||
# return False
|
||||
# if self.__ipv4_address.is_loopback
|
||||
# return False
|
||||
# if self.__ipv4_address.is_multicast
|
||||
# return False
|
||||
# if self.__ipv4_address.is_reserved
|
||||
# return False
|
||||
# return True
|
||||
def is_public_ipv4_network(self):
|
||||
if self.__ipv4_address.is_private:
|
||||
return False
|
||||
if self.__ipv4_address.is_loopback:
|
||||
return False
|
||||
if self.__ipv4_address.is_multicast:
|
||||
return False
|
||||
if self.__ipv4_address.is_reserved:
|
||||
return False
|
||||
return True
|
||||
|
||||
def set_ipv4_start_address(self, address):
|
||||
self.__ipv4_start = address
|
||||
|
@ -117,12 +117,12 @@ def run_vdiskadm(args):
|
||||
class disk(object):
|
||||
"""Definition of an individual disk instance."""
|
||||
|
||||
def __init__(self, path=None, format=DISK_FORMAT_NONE, bus="ide",
|
||||
type=DISK_TYPE_DISK):
|
||||
def __init__(self, path=None, fmt=DISK_FORMAT_NONE, bus="ide",
|
||||
typ=DISK_TYPE_DISK):
|
||||
self.path = path
|
||||
self.format = format
|
||||
self.format = fmt
|
||||
self.bus = bus
|
||||
self.type = type
|
||||
self.type = typ
|
||||
self.clean = []
|
||||
self.csum_dict = {}
|
||||
|
||||
|
@ -101,7 +101,7 @@ def output_formats():
|
||||
"""
|
||||
return [p.name for p in _parsers if p.can_export]
|
||||
|
||||
def find_input(path, format=None):
|
||||
def find_input(path, fmt=None):
|
||||
"""
|
||||
Search for a configuration file automatically. If @format is given,
|
||||
then only search using a matching format parser.
|
||||
@ -113,7 +113,7 @@ def find_input(path, format=None):
|
||||
for p in _parsers:
|
||||
if not p.can_identify:
|
||||
continue
|
||||
if format and format != p.name:
|
||||
if fmt and fmt != p.name:
|
||||
continue
|
||||
|
||||
if os.path.isfile(path):
|
||||
|
@ -26,7 +26,7 @@ NETDEV_TYPE_NETWORK = 3
|
||||
class netdev(object):
|
||||
"""Definition of an individual network device."""
|
||||
|
||||
def __init__(self, mac="auto", type=NETDEV_TYPE_UNKNOWN,
|
||||
def __init__(self, mac="auto", typ=NETDEV_TYPE_UNKNOWN,
|
||||
source=None, driver=None):
|
||||
"""
|
||||
@mac: either a MAC address, or "auto"
|
||||
@ -35,6 +35,6 @@ class netdev(object):
|
||||
@driver: device emulated for VM (e.g. vmxnet)
|
||||
"""
|
||||
self.mac = mac
|
||||
self.type = type
|
||||
self.type = typ
|
||||
self.source = source
|
||||
self.driver = driver
|
||||
|
@ -29,38 +29,38 @@ import logging
|
||||
|
||||
# Mapping of ResourceType value to device type
|
||||
# http://konkretcmpi.org/cim218/CIM_ResourceAllocationSettingData.html
|
||||
"""
|
||||
"Other" [1]
|
||||
"Computer System" [2]
|
||||
"Processor" [3]
|
||||
"Memory" [4]
|
||||
"IDE Controller" [5]
|
||||
"Parallel SCSI HBA" [6]
|
||||
"FC HBA" [7]
|
||||
"iSCSI HBA" [8]
|
||||
"IB HCA" [9]
|
||||
"Ethernet Adapter" [10]
|
||||
"Other Network Adapter" [11]
|
||||
"I/O Slot" [12]
|
||||
"I/O Device" [13]
|
||||
"Floppy Drive" [14]
|
||||
"CD Drive" [15]
|
||||
"DVD drive" [16]
|
||||
"Disk Drive" [17]
|
||||
"Tape Drive" [18]
|
||||
"Storage Extent" [19]
|
||||
"Other storage device" [20]
|
||||
"Serial port" [21]
|
||||
"Parallel port" [22]
|
||||
"USB Controller" [23]
|
||||
"Graphics controller" [24]
|
||||
"IEEE 1394 Controller" [25]
|
||||
"Partitionable Unit" [26]
|
||||
"Base Partitionable Unit" [27]
|
||||
"Power" [28]
|
||||
"Cooling Capacity" [29]
|
||||
"Ethernet Switch Port" [30]
|
||||
"""
|
||||
#
|
||||
# "Other" [1]
|
||||
# "Computer System" [2]
|
||||
# "Processor" [3]
|
||||
# "Memory" [4]
|
||||
# "IDE Controller" [5]
|
||||
# "Parallel SCSI HBA" [6]
|
||||
# "FC HBA" [7]
|
||||
# "iSCSI HBA" [8]
|
||||
# "IB HCA" [9]
|
||||
# "Ethernet Adapter" [10]
|
||||
# "Other Network Adapter" [11]
|
||||
# "I/O Slot" [12]
|
||||
# "I/O Device" [13]
|
||||
# "Floppy Drive" [14]
|
||||
# "CD Drive" [15]
|
||||
# "DVD drive" [16]
|
||||
# "Disk Drive" [17]
|
||||
# "Tape Drive" [18]
|
||||
# "Storage Extent" [19]
|
||||
# "Other storage device" [20]
|
||||
# "Serial port" [21]
|
||||
# "Parallel port" [22]
|
||||
# "USB Controller" [23]
|
||||
# "Graphics controller" [24]
|
||||
# "IEEE 1394 Controller" [25]
|
||||
# "Partitionable Unit" [26]
|
||||
# "Base Partitionable Unit" [27]
|
||||
# "Power" [28]
|
||||
# "Cooling Capacity" [29]
|
||||
# "Ethernet Switch Port" [30]
|
||||
|
||||
|
||||
DEVICE_CPU = "3"
|
||||
DEVICE_MEMORY = "4"
|
||||
@ -243,8 +243,8 @@ def _parse_hw_section(vm, nodes, file_refs, disk_section):
|
||||
|
||||
path = file_refs[ref]
|
||||
|
||||
disk = diskcfg.disk(path=path, format=fmt, bus=bus,
|
||||
type=diskcfg.DISK_TYPE_DISK)
|
||||
disk = diskcfg.disk(path=path, fmt=fmt, bus=bus,
|
||||
typ=diskcfg.DISK_TYPE_DISK)
|
||||
|
||||
vm.disks[(bus, dev_num)] = disk
|
||||
|
||||
|
@ -257,7 +257,7 @@ class virtimage_parser(formats.parser):
|
||||
|
||||
devid = (bus, nr_disk)
|
||||
vm.disks[devid] = diskcfg.disk(bus=bus,
|
||||
type=diskcfg.DISK_TYPE_DISK)
|
||||
typ=diskcfg.DISK_TYPE_DISK)
|
||||
vm.disks[devid].format = fmt
|
||||
vm.disks[devid].path = disk.file
|
||||
nr_disk = nr_disk + 1
|
||||
@ -265,10 +265,10 @@ class virtimage_parser(formats.parser):
|
||||
nics = domain.interface
|
||||
nic_idx = 0
|
||||
while nic_idx in range(0, nics):
|
||||
# XXX Eventually need to add support for mac addresses if given
|
||||
vm.netdevs[nic_idx] = netdevcfg.netdev(
|
||||
type=netdevcfg.NETDEV_TYPE_UNKNOWN)
|
||||
typ=netdevcfg.NETDEV_TYPE_UNKNOWN)
|
||||
nic_idx = nic_idx + 1
|
||||
""" Eventually need to add support for mac addresses if given"""
|
||||
vm.validate()
|
||||
return vm
|
||||
|
||||
|
@ -195,7 +195,7 @@ def parse_netdev_entry(vm, fullkey, value):
|
||||
return
|
||||
|
||||
if not vm.netdevs.get(inst):
|
||||
vm.netdevs[inst] = netdevcfg.netdev(type=netdevcfg.NETDEV_TYPE_UNKNOWN)
|
||||
vm.netdevs[inst] = netdevcfg.netdev(typ=netdevcfg.NETDEV_TYPE_UNKNOWN)
|
||||
|
||||
# "vlance", "vmxnet", "e1000"
|
||||
if key == "virtualdev":
|
||||
@ -235,7 +235,7 @@ def parse_disk_entry(vm, fullkey, value):
|
||||
devid = (bus, inst)
|
||||
if not vm.disks.get(devid):
|
||||
vm.disks[devid] = diskcfg.disk(bus=bus,
|
||||
type=diskcfg.DISK_TYPE_DISK)
|
||||
typ=diskcfg.DISK_TYPE_DISK)
|
||||
disk = vm.disks[devid]
|
||||
|
||||
if key == "devicetype":
|
||||
|
@ -614,7 +614,7 @@ class Capabilities(object):
|
||||
return True
|
||||
return False
|
||||
|
||||
def guestForOSType(self, type=None, arch=None):
|
||||
def guestForOSType(self, typ=None, arch=None):
|
||||
if self.host is None:
|
||||
return None
|
||||
|
||||
@ -625,7 +625,7 @@ class Capabilities(object):
|
||||
|
||||
for a in archs:
|
||||
for g in self.guests:
|
||||
if (type is None or g.os_type == type) and \
|
||||
if (typ is None or g.os_type == typ) and \
|
||||
(a is None or g.arch == a):
|
||||
return g
|
||||
|
||||
@ -681,7 +681,7 @@ def parse(xml):
|
||||
Capabilities,
|
||||
CapabilitiesParserException)
|
||||
|
||||
def guest_lookup(conn, caps=None, os_type=None, arch=None, type=None,
|
||||
def guest_lookup(conn, caps=None, os_type=None, arch=None, typ=None,
|
||||
accelerated=False, machine=None):
|
||||
"""
|
||||
Simple virtualization availability lookup
|
||||
@ -691,8 +691,8 @@ def guest_lookup(conn, caps=None, os_type=None, arch=None, type=None,
|
||||
we return the default virt type associated with those values. These are
|
||||
typically:
|
||||
|
||||
- os_type : hvm, then xen
|
||||
- type : kvm over plain qemu
|
||||
- os_type : hvm, then xen
|
||||
- typ : kvm over plain qemu
|
||||
- arch : host arch over all others
|
||||
|
||||
Otherwise the default will be the first listed in the capabilities xml.
|
||||
@ -703,8 +703,8 @@ def guest_lookup(conn, caps=None, os_type=None, arch=None, type=None,
|
||||
@type conn: libvirt.virConnect
|
||||
@param caps: Optional L{Capabilities} instance (saves a lookup)
|
||||
@type caps: L{Capabilities}
|
||||
@param type: Virtualization type ('hvm', 'xen', ...)
|
||||
@type type: C{str}
|
||||
@param typ: Virtualization type ('hvm', 'xen', ...)
|
||||
@type typ: C{str}
|
||||
@param arch: Guest architecture ('x86_64', 'i686' ...)
|
||||
@type arch: C{str}
|
||||
@param os_type: Hypervisor name ('qemu', 'kvm', 'xen', ...)
|
||||
@ -721,7 +721,7 @@ def guest_lookup(conn, caps=None, os_type=None, arch=None, type=None,
|
||||
if not caps:
|
||||
caps = parse(conn.getCapabilities())
|
||||
|
||||
guest = caps.guestForOSType(type=os_type, arch=arch)
|
||||
guest = caps.guestForOSType(os_type, arch)
|
||||
if not guest:
|
||||
archstr = _("for arch '%s'") % arch
|
||||
if not arch:
|
||||
@ -735,7 +735,7 @@ def guest_lookup(conn, caps=None, os_type=None, arch=None, type=None,
|
||||
{'virttype' : osstr, 'arch' : archstr})
|
||||
|
||||
domain = guest.bestDomainType(accelerated=accelerated,
|
||||
dtype=type,
|
||||
dtype=typ,
|
||||
machine=machine)
|
||||
|
||||
if domain == None:
|
||||
@ -745,7 +745,7 @@ def guest_lookup(conn, caps=None, os_type=None, arch=None, type=None,
|
||||
raise ValueError(_("Host does not support domain type %(domain)s"
|
||||
"%(machine)s for virtualization type "
|
||||
"'%(virttype)s' arch '%(arch)s'") %
|
||||
{'domain': type, 'virttype': guest.os_type,
|
||||
{'domain': typ, 'virttype': guest.os_type,
|
||||
'arch': guest.arch, 'machine': machinestr})
|
||||
|
||||
return (guest, domain)
|
||||
|
@ -455,8 +455,8 @@ class CloneDesign(object):
|
||||
else:
|
||||
while 1:
|
||||
mac = util.randomMAC(self.original_conn.getType().lower(),
|
||||
conn=self.original_conn)
|
||||
dummy, msg = self._check_mac(mac)
|
||||
conn=self.original_conn)
|
||||
ignore, msg = self._check_mac(mac)
|
||||
if msg is not None:
|
||||
continue
|
||||
else:
|
||||
|
@ -262,9 +262,11 @@ class DistroInstaller(Installer.Installer):
|
||||
transient = not self.livecd
|
||||
if not self._location_is_path:
|
||||
# Xen needs a boot.iso if its a http://, ftp://, or nfs: url
|
||||
(store_ignore, os_type_ignore, os_variant_ignore, media) = \
|
||||
OSDistro.acquireBootDisk(guest, self.location, meter,
|
||||
self.scratchdir)
|
||||
(store_ignore, os_type_ignore,
|
||||
os_variant_ignore, media) = OSDistro.getBootDisk(guest,
|
||||
self.location,
|
||||
meter,
|
||||
self.scratchdir)
|
||||
cdrom = media
|
||||
|
||||
self._tmpfiles.append(cdrom)
|
||||
@ -381,7 +383,7 @@ class DistroInstaller(Installer.Installer):
|
||||
|
||||
# Need to fetch the kernel & initrd from a remote site, or
|
||||
# out of a loopback mounted disk image/device
|
||||
ignore, os_type, os_variant, media = OSDistro.acquireKernel(guest,
|
||||
ignore, os_type, os_variant, media = OSDistro.getKernel(guest,
|
||||
self.location, meter,
|
||||
self.scratchdir,
|
||||
self.os_type)
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
import re
|
||||
|
||||
from virtinst import util
|
||||
from virtinst import XMLBuilderDomain
|
||||
from virtinst.XMLBuilderDomain import _xml_property
|
||||
|
||||
|
@ -41,7 +41,6 @@ class FullVirtGuest(Guest):
|
||||
return None
|
||||
return self.installer.loader
|
||||
def _set_loader(self, val):
|
||||
print val
|
||||
if not self.installer:
|
||||
return
|
||||
self.installer.loader = val
|
||||
|
@ -80,7 +80,7 @@ class Guest(XMLBuilderDomain.XMLBuilderDomain):
|
||||
return vals
|
||||
|
||||
@staticmethod
|
||||
def list_os_variants(type, sortpref=None, supported=False, filtervars=None):
|
||||
def list_os_variants(typ, sortpref=None, supported=False, filtervars=None):
|
||||
"""
|
||||
Return a list of sorted os variants for the passed distro type
|
||||
|
||||
@ -89,7 +89,7 @@ class Guest(XMLBuilderDomain.XMLBuilderDomain):
|
||||
the sorted list have all fedora distros first
|
||||
@param filtervars: List of only variants we want to show by default
|
||||
"""
|
||||
vals = osdict.sort_helper(Guest._OS_TYPES[type]["variants"],
|
||||
vals = osdict.sort_helper(Guest._OS_TYPES[typ]["variants"],
|
||||
sortpref)
|
||||
ret = []
|
||||
for v in vals:
|
||||
@ -98,19 +98,19 @@ class Guest(XMLBuilderDomain.XMLBuilderDomain):
|
||||
continue
|
||||
elif supported:
|
||||
if not osdict.lookup_osdict_key(None, None,
|
||||
type, v, "supported"):
|
||||
typ, v, "supported"):
|
||||
continue
|
||||
|
||||
ret.append(v)
|
||||
return ret
|
||||
|
||||
@staticmethod
|
||||
def get_os_type_label(type):
|
||||
return Guest._OS_TYPES[type]["label"]
|
||||
def get_os_type_label(typ):
|
||||
return Guest._OS_TYPES[typ]["label"]
|
||||
|
||||
@staticmethod
|
||||
def get_os_variant_label(type, variant):
|
||||
return Guest._OS_TYPES[type]["variants"][variant]["label"]
|
||||
def get_os_variant_label(typ, variant):
|
||||
return Guest._OS_TYPES[typ]["variants"][variant]["label"]
|
||||
|
||||
@staticmethod
|
||||
def cpuset_str_to_tuple(conn, cpuset):
|
||||
@ -176,7 +176,7 @@ class Guest(XMLBuilderDomain.XMLBuilderDomain):
|
||||
# Set up the connection, since it is fundamental for other init
|
||||
conn = conn or connection
|
||||
if conn == None:
|
||||
logging.debug("No conn passed to Guest, opening URI '%s'" %
|
||||
logging.debug("No conn passed to Guest, opening URI '%s'",
|
||||
hypervisorURI)
|
||||
conn = self._open_uri(hypervisorURI)
|
||||
|
||||
@ -1581,12 +1581,12 @@ class Guest(XMLBuilderDomain.XMLBuilderDomain):
|
||||
device type and param (bus, model, etc.)
|
||||
"""
|
||||
try:
|
||||
support._set_rhel6(self._is_rhel6())
|
||||
support.set_rhel6(self._is_rhel6())
|
||||
return osdict.lookup_device_param(self.conn, self.type,
|
||||
self.os_type, self.os_variant,
|
||||
device_key, param)
|
||||
finally:
|
||||
support._set_rhel6(False)
|
||||
support.set_rhel6(False)
|
||||
|
||||
|
||||
def _wait_for_domain(conn, name):
|
||||
|
@ -507,7 +507,7 @@ class Installer(XMLBuilderDomain.XMLBuilderDomain):
|
||||
guest, domain = CapabilitiesParser.guest_lookup(conn=self.conn,
|
||||
caps=self._get_caps(),
|
||||
os_type=self.os_type,
|
||||
type=self.type,
|
||||
typ=self.type,
|
||||
arch=self.arch,
|
||||
machine=self.machine)
|
||||
|
||||
|
@ -151,16 +151,16 @@ def _acquireMedia(iskernel, guest, baseuri, progresscb,
|
||||
None, media_cb)
|
||||
|
||||
# Helper method to lookup install media distro and fetch an install kernel
|
||||
def acquireKernel(guest, baseuri, progresscb, scratchdir, type=None):
|
||||
def getKernel(guest, baseuri, progresscb, scratchdir, typ):
|
||||
iskernel = True
|
||||
return _acquireMedia(iskernel, guest, baseuri, progresscb,
|
||||
scratchdir, type)
|
||||
scratchdir, typ)
|
||||
|
||||
# Helper method to lookup install media distro and fetch a boot iso
|
||||
def acquireBootDisk(guest, baseuri, progresscb, scratchdir, type=None):
|
||||
def getBootDisk(guest, baseuri, progresscb, scratchdir):
|
||||
iskernel = False
|
||||
return _acquireMedia(iskernel, guest, baseuri, progresscb,
|
||||
scratchdir, type)
|
||||
scratchdir)
|
||||
|
||||
def _check_ostype_valid(os_type):
|
||||
return bool(os_type in osdict.sort_helper(osdict.OS_TYPES))
|
||||
@ -279,6 +279,8 @@ class Distro:
|
||||
initrdpath)
|
||||
|
||||
def acquireBootDisk(self, guest, fetcher, progresscb):
|
||||
ignore = guest
|
||||
|
||||
if self._hasTreeinfo(fetcher, progresscb):
|
||||
return fetcher.acquireFile(self._getTreeinfoMedia("boot.iso"),
|
||||
progresscb)
|
||||
@ -811,7 +813,7 @@ class SuseDistro(Distro):
|
||||
|
||||
# Build a list of all .ko files
|
||||
modpaths = {}
|
||||
for root, dummy, files in os.walk(cpiodir + "/kernel/lib/modules", topdown=False):
|
||||
for root, ignore, files in os.walk(cpiodir + "/kernel/lib/modules", topdown=False):
|
||||
for name in files:
|
||||
if name.endswith(".ko"):
|
||||
modpaths[name] = os.path.join(root, name)
|
||||
|
@ -236,7 +236,7 @@ class StoragePool(StorageObject):
|
||||
Base class for building and installing libvirt storage pool xml
|
||||
"""
|
||||
|
||||
"""@group Types: TYPE_*"""
|
||||
# @group Types: TYPE_*
|
||||
TYPE_DIR = "dir"
|
||||
TYPE_FS = "fs"
|
||||
TYPE_NETFS = "netfs"
|
||||
@ -399,7 +399,7 @@ class StoragePool(StorageObject):
|
||||
raise ValueError(_("Host name must be a string"))
|
||||
self._host = val
|
||||
|
||||
"""uuid: uuid of the storage object. optional: generated if not set"""
|
||||
# uuid: uuid of the storage object. optional: generated if not set
|
||||
def get_uuid(self):
|
||||
return self._uuid
|
||||
def set_uuid(self, val):
|
||||
@ -945,9 +945,10 @@ class MultipathPool(StoragePool):
|
||||
def _get_source_xml(self):
|
||||
return ""
|
||||
|
||||
"""
|
||||
Storage Volume classes
|
||||
"""
|
||||
|
||||
##########################
|
||||
# Storage Volume classes #
|
||||
##########################
|
||||
|
||||
class StorageVolume(StorageObject):
|
||||
"""
|
||||
|
@ -68,7 +68,7 @@ class User(object):
|
||||
if self._euid != User.current().euid:
|
||||
return self._euid == 0
|
||||
|
||||
import ucred
|
||||
import ucred # pylint: disable=F0401
|
||||
cred = ucred.get(os.getpid())
|
||||
if priv in [ self.PRIV_CLONE,
|
||||
self.PRIV_CREATE_DOMAIN,
|
||||
|
@ -395,7 +395,7 @@ class VirtualCharDevice(VirtualDevice):
|
||||
return xml
|
||||
|
||||
def _char_xml(self):
|
||||
raise NotImplementedError("Must be implemented in subclass.")
|
||||
pass
|
||||
|
||||
def _get_target_xml(self):
|
||||
xml = ""
|
||||
|
@ -26,6 +26,7 @@ from virtinst import support
|
||||
from virtinst.XMLBuilderDomain import _xml_property
|
||||
|
||||
def _get_mode_prop(channel_type):
|
||||
# pylint: disable=W0212
|
||||
xpath = "./channel[@name='%s']/@mode" % channel_type
|
||||
def get_mode(s):
|
||||
return s._channels.get(channel_type, None)
|
||||
|
@ -145,8 +145,7 @@ class VirtualNetworkInterface(VirtualDevice):
|
||||
def __init__(self, macaddr=None, type=TYPE_BRIDGE, bridge=None,
|
||||
network=None, model=None, conn=None,
|
||||
parsexml=None, parsexmlnode=None, caps=None):
|
||||
VirtualDevice.__init__(self, conn, parsexml,
|
||||
parsexmlnode, caps)
|
||||
VirtualDevice.__init__(self, conn, parsexml, parsexmlnode, caps)
|
||||
|
||||
self._network = None
|
||||
self._bridge = None
|
||||
@ -192,7 +191,7 @@ class VirtualNetworkInterface(VirtualDevice):
|
||||
found = False
|
||||
for ignore in range(256):
|
||||
self._random_mac = util.randomMAC(self.conn.getType().lower(),
|
||||
conn=self.conn)
|
||||
conn=self.conn)
|
||||
ret = self.is_conflict_net(self.conn, self._random_mac)
|
||||
if ret[1] is not None:
|
||||
continue
|
||||
|
@ -283,6 +283,11 @@ def _xml_property(fget=None, fset=None, fdel=None, doc=None,
|
||||
@param default_converter: If the virtinst value is "default", use
|
||||
this function to get the actual XML value
|
||||
"""
|
||||
|
||||
# pylint: disable=W0212
|
||||
# Accessing _xml vals of self. This should be a class method, but
|
||||
# we break it out to be more readable
|
||||
|
||||
def new_getter(self, *args, **kwargs):
|
||||
val = None
|
||||
getval = fget(self, *args, **kwargs)
|
||||
|
@ -19,18 +19,16 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
# MA 02110-1301 USA.
|
||||
|
||||
import os
|
||||
import sys
|
||||
import itertools
|
||||
import locale
|
||||
import logging
|
||||
import logging.handlers
|
||||
import gettext
|
||||
import locale
|
||||
import re
|
||||
import difflib
|
||||
import tempfile
|
||||
import optparse
|
||||
import os
|
||||
import re
|
||||
import shlex
|
||||
import itertools
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
import libvirt
|
||||
|
||||
@ -91,12 +89,14 @@ class VirtOptionParser(optparse.OptionParser):
|
||||
def _get_encoding(self, f):
|
||||
encoding = getattr(f, "encoding", None)
|
||||
if not encoding:
|
||||
(dummy, encoding) = locale.getlocale()
|
||||
encoding = locale.getlocale()[1]
|
||||
if not encoding:
|
||||
encoding = "UTF-8"
|
||||
return encoding
|
||||
|
||||
def print_help(self, file=None):
|
||||
# pylint: disable=W0622
|
||||
# Redefining built in type 'file'
|
||||
if file is None:
|
||||
file = sys.stdout
|
||||
|
||||
@ -206,11 +206,11 @@ def setupLogging(appname, debug=False, do_quiet=False):
|
||||
libvirt.registerErrorHandler(f=libvirt_callback, ctx=None)
|
||||
|
||||
# Register python error handler to log exceptions
|
||||
def exception_log(type, val, tb):
|
||||
def exception_log(typ, val, tb):
|
||||
import traceback
|
||||
s = traceback.format_exception(type, val, tb)
|
||||
s = traceback.format_exception(typ, val, tb)
|
||||
logging.exception("".join(s))
|
||||
sys.__excepthook__(type, val, tb)
|
||||
sys.__excepthook__(typ, val, tb)
|
||||
sys.excepthook = exception_log
|
||||
|
||||
# Log the app command string
|
||||
@ -239,6 +239,8 @@ def _open_test_uri(uri):
|
||||
conn = open_connection(uri)
|
||||
|
||||
def sanitize_xml(xml):
|
||||
import difflib
|
||||
|
||||
orig = xml
|
||||
xml = re.sub("arch='.*'", "arch='i686'", xml)
|
||||
xml = re.sub("domain type='.*'", "domain type='test'", xml)
|
||||
|
@ -24,10 +24,8 @@ from virtinst.VirtualDevice import VirtualDevice
|
||||
|
||||
HV_ALL = "all"
|
||||
|
||||
"""
|
||||
Default values for OS_TYPES keys. Can be overwritten at os_type or
|
||||
variant level
|
||||
"""
|
||||
# Default values for OS_TYPES keys. Can be overwritten at os_type or
|
||||
# variant level
|
||||
|
||||
NET = VirtualDevice.VIRTUAL_DEV_NET
|
||||
DISK = VirtualDevice.VIRTUAL_DEV_DISK
|
||||
|
@ -69,43 +69,42 @@ SUPPORT_CONN_HV_FILESYSTEM = 5007
|
||||
# Flags for check_stream_support
|
||||
SUPPORT_STREAM_UPLOAD = 6000
|
||||
|
||||
"""
|
||||
Possible keys:
|
||||
# Possible keys:
|
||||
#
|
||||
# "version" : Minimum libvirt version required for this feature. Not used
|
||||
# if 'args' provided
|
||||
#
|
||||
# "force_version" : Demand that version check is met for the checked
|
||||
# libvirt version. Normally we will make a best effort
|
||||
# attempt, because determining the daemon version depends
|
||||
# on a fairly new API call getLibVersion. So for things like
|
||||
# testing API availability (e.g. createXMLFrom) we won't
|
||||
# force the check, but for things like XML options (AC97)
|
||||
# we want to be ABSOLUTELY SURE it is supported so we
|
||||
# don't enable it by default and break guest creation.
|
||||
# This isn't required for versions after >= 0.7.3
|
||||
#
|
||||
# "function" : Function name to check exists. If object not specified,
|
||||
# function is checked against libvirt module.
|
||||
#
|
||||
# "args": Argument tuple to actually test object.function with.
|
||||
#
|
||||
# "flag": A flag to check exists. This will be appended to the argument
|
||||
# list if args are provided, otherwise we will only check against
|
||||
# the local libvirt version.
|
||||
#
|
||||
# "drv_version" : A list of tuples of the form
|
||||
# (driver name (e.g qemu, xen, lxc), minimum supported version)
|
||||
# If a hypervisor is not listed, it is assumed to be NOT
|
||||
# SUPPORTED.
|
||||
#
|
||||
# "drv_libvirt_version" : List of tuples, similar to drv_version, but
|
||||
# the version number is minimum supported _libvirt_
|
||||
# version
|
||||
# "hv_version" : A list of tuples of the same form as drv_version, however
|
||||
# listing the actual <domain type='%s'/> from the XML.
|
||||
# example: 'kvm'
|
||||
|
||||
- "version" : Minimum libvirt version required for this feature. Not used
|
||||
if 'args' provided
|
||||
|
||||
- "force_version" : Demand that version check is met for the checked
|
||||
libvirt version. Normally we will make a best effort
|
||||
attempt, because determining the daemon version depends
|
||||
on a fairly new API call getLibVersion. So for things like
|
||||
testing API availability (e.g. createXMLFrom) we won't
|
||||
force the check, but for things like XML options (AC97)
|
||||
we want to be ABSOLUTELY SURE it is supported so we
|
||||
don't enable it by default and break guest creation.
|
||||
This isn't required for versions after >= 0.7.3
|
||||
|
||||
- "function" : Function name to check exists. If object not specified,
|
||||
function is checked against libvirt module.
|
||||
|
||||
- "args": Argument tuple to actually test object.function with.
|
||||
|
||||
- "flag": A flag to check exists. This will be appended to the argument
|
||||
list if args are provided, otherwise we will only check against
|
||||
the local libvirt version.
|
||||
|
||||
- "drv_version" : A list of tuples of the form
|
||||
(driver name (e.g qemu, xen, lxc), minimum supported version)
|
||||
If a hypervisor is not listed, it is assumed to be NOT
|
||||
SUPPORTED.
|
||||
|
||||
- "drv_libvirt_version" : List of tuples, similar to drv_version, but
|
||||
the version number is minimum supported _libvirt_
|
||||
version
|
||||
- "hv_version" : A list of tuples of the same form as drv_version, however
|
||||
listing the actual <domain type='%s'/> from the XML.
|
||||
example: 'kvm'
|
||||
"""
|
||||
|
||||
_support_dict = {
|
||||
SUPPORT_CONN_STORAGE : {
|
||||
@ -282,17 +281,17 @@ _support_dict = {
|
||||
# really offer any XML feature introspection, we have to use hacks to
|
||||
# make sure we aren't generating bogus config on non RHEL
|
||||
_rhel6 = False
|
||||
def _set_rhel6(val):
|
||||
def set_rhel6(val):
|
||||
global _rhel6
|
||||
_rhel6 = bool(val)
|
||||
def _get_rhel6():
|
||||
def get_rhel6():
|
||||
return _rhel6
|
||||
|
||||
# Pull a connection object from the passed libvirt object
|
||||
def _get_conn_from_object(obj):
|
||||
if not hasattr(obj, "_conn"):
|
||||
return obj
|
||||
return obj._conn
|
||||
return getattr(obj, "_conn")
|
||||
|
||||
# Check that command is present in the python bindings, and return the
|
||||
# the requested function
|
||||
@ -424,7 +423,7 @@ def _check_support(conn, feature, data=None):
|
||||
|
||||
uri = conn.getURI()
|
||||
drv_type = uriutil.get_uri_driver(uri)
|
||||
is_rhel6 = _get_rhel6()
|
||||
is_rhel6 = get_rhel6()
|
||||
force_version = get_value("force_version") or False
|
||||
|
||||
minimum_libvirt_version = get_value("version") or 0
|
||||
|
@ -505,7 +505,7 @@ def is_blktap_capable():
|
||||
# available under the LGPL,
|
||||
# Copyright 2004, 2005 Mike Wray <mike.wray@hp.com>
|
||||
# Copyright 2005 XenSource Ltd
|
||||
def randomMAC(type="xen", conn=None):
|
||||
def randomMAC(typ, conn=None):
|
||||
"""Generate a random MAC address.
|
||||
|
||||
00-16-3E allocated to xensource
|
||||
@ -534,7 +534,7 @@ def randomMAC(type="xen", conn=None):
|
||||
ouis = { 'xen': [ 0x00, 0x16, 0x3E ], 'qemu': [ 0x52, 0x54, 0x00 ] }
|
||||
|
||||
try:
|
||||
oui = ouis[type]
|
||||
oui = ouis[typ]
|
||||
except KeyError:
|
||||
oui = ouis['xen']
|
||||
|
||||
@ -551,8 +551,7 @@ def randomMAC(type="xen", conn=None):
|
||||
# Copyright 2005 XenSource Ltd
|
||||
def randomUUID():
|
||||
"""Generate a random UUID."""
|
||||
|
||||
return [ random.randint(0, 255) for dummy in range(0, 16) ]
|
||||
return [random.randint(0, 255) for ignore in range(0, 16)]
|
||||
|
||||
def uuidToString(u, conn=None):
|
||||
if conn and hasattr(conn, "_virtinst__fake_conn_predictable"):
|
||||
@ -563,29 +562,31 @@ def uuidToString(u, conn=None):
|
||||
"%02x" * 6]) % tuple(u)
|
||||
|
||||
|
||||
def get_max_vcpus(conn, type=None):
|
||||
def get_max_vcpus(conn, typ):
|
||||
"""@param conn: libvirt connection to poll for max possible vcpus
|
||||
@type type: optional guest type (kvm, etc.)"""
|
||||
if type is None:
|
||||
type = conn.getType()
|
||||
if typ is None:
|
||||
typ = conn.getType()
|
||||
try:
|
||||
m = conn.getMaxVcpus(type.lower())
|
||||
m = conn.getMaxVcpus(typ.lower())
|
||||
except libvirt.libvirtError:
|
||||
m = 32
|
||||
return m
|
||||
|
||||
|
||||
def xml_escape(str):
|
||||
"""Replaces chars ' " < > & with xml safe counterparts"""
|
||||
if str is None:
|
||||
def xml_escape(xml):
|
||||
"""
|
||||
Replaces chars ' " < > & with xml safe counterparts
|
||||
"""
|
||||
if xml is None:
|
||||
return None
|
||||
|
||||
str = str.replace("&", "&")
|
||||
str = str.replace("'", "'")
|
||||
str = str.replace("\"", """)
|
||||
str = str.replace("<", "<")
|
||||
str = str.replace(">", ">")
|
||||
return str
|
||||
xml = xml.replace("&", "&")
|
||||
xml = xml.replace("'", "'")
|
||||
xml = xml.replace("\"", """)
|
||||
xml = xml.replace("<", "<")
|
||||
xml = xml.replace(">", ">")
|
||||
return xml
|
||||
|
||||
|
||||
def _xorg_keymap():
|
||||
|
Loading…
x
Reference in New Issue
Block a user