Run pep8 with check-pylint, fix the fallout
This commit is contained in:
parent
d0d20148f7
commit
677f73fca7
|
@ -46,7 +46,7 @@ appversion = "::VERSION::"
|
|||
gettext_app = "virt-manager"
|
||||
gettext_dir = "::GETTEXTDIR::"
|
||||
virtinst_str = "::VIRTINST_VERSION::"
|
||||
virtinst_version = tuple([ int(num) for num in virtinst_str.split('.')])
|
||||
virtinst_version = tuple([int(num) for num in virtinst_str.split('.')])
|
||||
|
||||
gconf_dir = "/apps/" + appname
|
||||
asset_dir = "::ASSETDIR::"
|
||||
|
@ -62,7 +62,7 @@ def _show_startup_error(msg, details):
|
|||
from virtManager.error import vmmErrorDialog
|
||||
err = vmmErrorDialog()
|
||||
title = _("Error starting Virtual Machine Manager")
|
||||
err.show_err(title + ": " + msg, details, title, async=False,
|
||||
err.show_err(title + ": " + msg, details, title, async=False,
|
||||
debug=False)
|
||||
|
||||
def setup_i18n():
|
||||
|
@ -199,7 +199,7 @@ def parse_commandline():
|
|||
help="Do not autostart connections")
|
||||
optParser.add_option("--show-domain-creator", action="callback",
|
||||
callback=opt_show_cb, dest="show", help="Create a new virtual machine")
|
||||
optParser.add_option("--show-domain-editor", type="string",
|
||||
optParser.add_option("--show-domain-editor", type="string",
|
||||
metavar="UUID", action="callback", callback=opt_show_cb,
|
||||
help="Edit a domain configuration")
|
||||
optParser.add_option("--show-domain-performance", type="string",
|
||||
|
@ -300,7 +300,7 @@ def opt_show_cb(option, opt_str, value, parser):
|
|||
if option.metavar == "UUID":
|
||||
setattr(parser.values, "uuid", value)
|
||||
s = str(option)
|
||||
show = s[s.rindex('-')+1:]
|
||||
show = s[s.rindex('-') + 1:]
|
||||
setattr(parser.values, "show", show)
|
||||
|
||||
# Run me!
|
||||
|
|
|
@ -57,9 +57,9 @@ char_widget_mappings = {
|
|||
"source_mode" : "char-mode",
|
||||
"source_host" : "char-host",
|
||||
"source_port" : "char-port",
|
||||
"bind_port": "char-bind-port",
|
||||
"bind_host": "char-bind-host",
|
||||
"protocol" : "char-use-telnet",
|
||||
"bind_port" : "char-bind-port",
|
||||
"bind_host" : "char-bind-host",
|
||||
"protocol" : "char-use-telnet",
|
||||
}
|
||||
|
||||
class vmmAddHardware(vmmGObjectUI):
|
||||
|
@ -179,7 +179,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
notebook.set_show_tabs(False)
|
||||
|
||||
black = gtk.gdk.color_parse("#000")
|
||||
for num in range(PAGE_SUMMARY+1):
|
||||
for num in range(PAGE_SUMMARY + 1):
|
||||
name = "page" + str(num) + "-title"
|
||||
self.window.get_widget(name).modify_bg(gtk.STATE_NORMAL, black)
|
||||
|
||||
|
@ -381,7 +381,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
# Sound init
|
||||
sound_box = self.window.get_widget("sound-model")
|
||||
sound_box.set_active(0)
|
||||
|
||||
|
||||
# Hostdev init
|
||||
host_devtype = self.window.get_widget("host-device-type")
|
||||
self.populate_host_device_type_model(host_devtype.get_model())
|
||||
|
@ -453,11 +453,11 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
model.append([bus, device, icon, desc, gtk.ICON_SIZE_BUTTON])
|
||||
|
||||
if self.vm.is_hvm():
|
||||
add_dev("ide", virtinst.VirtualDisk.DEVICE_DISK, "IDE disk")
|
||||
add_dev("ide", virtinst.VirtualDisk.DEVICE_CDROM, "IDE cdrom")
|
||||
add_dev("fdc", virtinst.VirtualDisk.DEVICE_FLOPPY, "Floppy disk")
|
||||
add_dev("ide", virtinst.VirtualDisk.DEVICE_DISK, "IDE disk")
|
||||
add_dev("ide", virtinst.VirtualDisk.DEVICE_CDROM, "IDE cdrom")
|
||||
add_dev("fdc", virtinst.VirtualDisk.DEVICE_FLOPPY, "Floppy disk")
|
||||
add_dev("scsi", virtinst.VirtualDisk.DEVICE_DISK, "SCSI disk")
|
||||
add_dev("usb", virtinst.VirtualDisk.DEVICE_DISK, "USB disk")
|
||||
add_dev("usb", virtinst.VirtualDisk.DEVICE_DISK, "USB disk")
|
||||
if self.vm.get_hv_type() == "kvm":
|
||||
add_dev("virtio", virtinst.VirtualDisk.DEVICE_DISK, "Virtio Disk")
|
||||
if self.vm.get_connection().is_xen():
|
||||
|
@ -478,8 +478,8 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
|
||||
def populate_host_device_type_model(self, model):
|
||||
model.clear()
|
||||
for m in [ ["PCI Device", "pci", None, "net", "80203"],
|
||||
["USB Device", "usb_device", None, None, None]]:
|
||||
for m in [["PCI Device", "pci", None, "net", "80203"],
|
||||
["USB Device", "usb_device", None, None, None]]:
|
||||
model.append(m)
|
||||
|
||||
def populate_host_device_model(self, model, devtype, devcap, subtype,
|
||||
|
@ -728,8 +728,8 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
value = gtk.Label(value)
|
||||
value.set_alignment(0, .5)
|
||||
|
||||
summary_table.attach(label, 0, 1, row, row+1, gtk.FILL, 0)
|
||||
summary_table.attach(value, 1, 2, row, row+1, gtk.FILL, 0)
|
||||
summary_table.attach(label, 0, 1, row, row + 1, gtk.FILL, 0)
|
||||
summary_table.attach(value, 1, 2, row, row + 1, gtk.FILL, 0)
|
||||
|
||||
row += 1
|
||||
if row == 10:
|
||||
|
@ -1136,14 +1136,14 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
if not diskpath:
|
||||
return self.err.val_err(_("A storage path must be specified."))
|
||||
|
||||
disk = virtinst.VirtualDisk(conn = self.conn.vmm,
|
||||
path = diskpath,
|
||||
size = disksize,
|
||||
sparse = sparse,
|
||||
readOnly = readonly,
|
||||
device = device,
|
||||
bus = bus,
|
||||
driverCache = cache)
|
||||
disk = virtinst.VirtualDisk(conn=self.conn.vmm,
|
||||
path=diskpath,
|
||||
size=disksize,
|
||||
sparse=sparse,
|
||||
readOnly=readonly,
|
||||
device=device,
|
||||
bus=bus,
|
||||
driverCache=cache)
|
||||
|
||||
if (disk.type == virtinst.VirtualDisk.TYPE_FILE and
|
||||
not self.vm.is_hvm() and
|
||||
|
@ -1172,7 +1172,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
# Disk collision
|
||||
if disk.is_conflict_disk(self.conn.vmm):
|
||||
res = self.err.yes_no(_('Disk "%s" is already in use by another '
|
||||
'guest!' % disk.path),
|
||||
'guest!' % disk.path),
|
||||
_("Do you really want to use the disk?"))
|
||||
if not res:
|
||||
return False
|
||||
|
@ -1246,8 +1246,8 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
|
||||
try:
|
||||
self._dev = virtinst.VirtualHostDevice.device_from_node(
|
||||
conn = self.vm.get_connection().vmm,
|
||||
name = nodedev_name)
|
||||
conn=self.vm.get_connection().vmm,
|
||||
name=nodedev_name)
|
||||
except Exception, e:
|
||||
return self.err.val_err(_("Host device parameter error"), str(e))
|
||||
|
||||
|
|
|
@ -204,4 +204,3 @@ class vmmAsyncJob(vmmGObjectUI):
|
|||
if self.run_main:
|
||||
gtk.main_quit()
|
||||
return False
|
||||
|
||||
|
|
|
@ -453,14 +453,15 @@ class vmmCloneVM(vmmGObjectUI):
|
|||
num_c = min(len(self.target_list), 3)
|
||||
if num_c:
|
||||
scroll = self.window.get_widget("clone-storage-scroll")
|
||||
scroll.set_size_request(-1, 80*num_c)
|
||||
scroll.set_size_request(-1, 80 * num_c)
|
||||
storage_box.show_all()
|
||||
|
||||
no_storage = not bool(len(self.target_list))
|
||||
self.window.get_widget("clone-storage-box").set_property("visible",
|
||||
not no_storage)
|
||||
self.window.get_widget("clone-no-storage-pass").set_property("visible",
|
||||
no_storage)
|
||||
self.window.get_widget("clone-storage-box").set_property("visible",
|
||||
not no_storage)
|
||||
self.window.get_widget("clone-no-storage-pass").set_property(
|
||||
"visible",
|
||||
no_storage)
|
||||
|
||||
skip_targets = []
|
||||
new_disks = []
|
||||
|
@ -498,9 +499,9 @@ class vmmCloneVM(vmmGObjectUI):
|
|||
self.netmenu.popup(None, None, None, 0, event.time)
|
||||
|
||||
def net_change_mac(self, ignore, origmac):
|
||||
row = self.net_list[origmac]
|
||||
row = self.net_list[origmac]
|
||||
orig_mac = row[NETWORK_INFO_ORIG_MAC]
|
||||
new_mac = row[NETWORK_INFO_NEW_MAC]
|
||||
new_mac = row[NETWORK_INFO_NEW_MAC]
|
||||
typ = row[NETWORK_INFO_LABEL]
|
||||
|
||||
self.change_mac_window.get_widget("change-mac-orig").set_text(orig_mac)
|
||||
|
|
|
@ -87,8 +87,8 @@ class vmmConfig(object):
|
|||
self.appversion = appversion
|
||||
self.conf_dir = gconf_dir
|
||||
self.conf = gconf.client_get_default()
|
||||
self.conf.add_dir (gconf_dir,
|
||||
gconf.CLIENT_PRELOAD_NONE)
|
||||
self.conf.add_dir(gconf_dir,
|
||||
gconf.CLIENT_PRELOAD_NONE)
|
||||
|
||||
self.glade_dir = glade_dir
|
||||
self.icon_dir = icon_dir
|
||||
|
@ -300,7 +300,7 @@ class vmmConfig(object):
|
|||
return False
|
||||
|
||||
# Keys preferences
|
||||
def get_keys_combination(self, syms = False):
|
||||
def get_keys_combination(self, syms=False):
|
||||
val = self.conf.get_string(self.conf_dir + "/keys/grab-keys")
|
||||
if syms == True:
|
||||
return val
|
||||
|
@ -494,7 +494,7 @@ class vmmConfig(object):
|
|||
urls.insert(0, url)
|
||||
length = self.get_url_list_length()
|
||||
if len(urls) > length:
|
||||
del urls[len(urls) -1]
|
||||
del urls[len(urls) - 1]
|
||||
self.conf.set_list(gconf_path, gconf.VALUE_STRING, urls)
|
||||
|
||||
def add_media_url(self, url):
|
||||
|
@ -707,7 +707,9 @@ class vmmConfig(object):
|
|||
# one if the attributes match - which they will since UUID
|
||||
# is our unique key
|
||||
|
||||
secret = vmmSecret(self.get_secret_name(vm), password, { "uuid" : vm.get_uuid(), "hvuri": vm.get_connection().get_uri() })
|
||||
secret = vmmSecret(self.get_secret_name(vm), password,
|
||||
{"uuid" : vm.get_uuid(),
|
||||
"hvuri": vm.get_connection().get_uri()})
|
||||
_id = self.keyring.add_secret(secret)
|
||||
if _id != None:
|
||||
self.conf.set_int(self.conf_dir + "/console/passwords/" + vm.get_uuid(), _id)
|
||||
|
|
|
@ -49,7 +49,7 @@ def default_conn_user(conn):
|
|||
class vmmConnect(vmmGObjectUI):
|
||||
__gsignals__ = {
|
||||
"completed": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, (str,object,object)),
|
||||
gobject.TYPE_NONE, (str, object, object)),
|
||||
"cancelled": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, ())
|
||||
}
|
||||
|
|
|
@ -22,7 +22,8 @@ import gobject
|
|||
import gtk
|
||||
|
||||
import logging
|
||||
import os, sys
|
||||
import os
|
||||
import sys
|
||||
import traceback
|
||||
import re
|
||||
import threading
|
||||
|
@ -283,15 +284,15 @@ class vmmConnection(vmmGObject):
|
|||
if self.vmm is None:
|
||||
return ""
|
||||
mem = self.host_memory_size()
|
||||
if mem > (10*1024*1024):
|
||||
return "%2.2f GB" % (mem/(1024.0*1024.0))
|
||||
if mem > (10 * 1024 * 1024):
|
||||
return "%2.2f GB" % (mem / (1024.0 * 1024.0))
|
||||
else:
|
||||
return "%2.0f MB" % (mem/1024.0)
|
||||
return "%2.0f MB" % (mem / 1024.0)
|
||||
|
||||
def host_memory_size(self):
|
||||
if self.vmm is None:
|
||||
return 0
|
||||
return self.hostinfo[1]*1024
|
||||
return self.hostinfo[1] * 1024
|
||||
|
||||
def host_architecture(self):
|
||||
if self.vmm is None:
|
||||
|
@ -771,7 +772,7 @@ class vmmConnection(vmmGObject):
|
|||
|
||||
def _netdev_added(self, ignore, netdev):
|
||||
name = netdev.get_name()
|
||||
if self.netdevs.has_key(name):
|
||||
if name in self.netdevs:
|
||||
return
|
||||
|
||||
self.netdevs[name] = netdev
|
||||
|
@ -779,13 +780,13 @@ class vmmConnection(vmmGObject):
|
|||
# Optical HAL listener
|
||||
def _optical_added(self, ignore, dev):
|
||||
key = dev.get_key()
|
||||
if self.mediadevs.has_key(key):
|
||||
if key in self.mediadevs:
|
||||
return
|
||||
|
||||
self._add_mediadev(key, dev)
|
||||
|
||||
def _nodedev_mediadev_added(self, ignore1, ignore2, name):
|
||||
if self.mediadevs.has_key(name):
|
||||
if name in self.mediadevs:
|
||||
return
|
||||
|
||||
vobj = self.get_nodedev(name)
|
||||
|
@ -796,7 +797,7 @@ class vmmConnection(vmmGObject):
|
|||
self._add_mediadev(name, mediadev)
|
||||
|
||||
def _nodedev_mediadev_removed(self, ignore1, ignore2, name):
|
||||
if not self.mediadevs.has_key(name):
|
||||
if name not in self.mediadevs:
|
||||
return
|
||||
|
||||
self._remove_mediadev(name)
|
||||
|
@ -852,8 +853,8 @@ class vmmConnection(vmmGObject):
|
|||
self._open_thread()
|
||||
else:
|
||||
logging.debug("Scheduling background open thread for " + self.uri)
|
||||
self.connectThread = threading.Thread(target = self._open_thread,
|
||||
name = "Connect %s" % self.uri)
|
||||
self.connectThread = threading.Thread(target=self._open_thread,
|
||||
name="Connect %s" % self.uri)
|
||||
self.connectThread.setDaemon(True)
|
||||
self.connectThread.start()
|
||||
|
||||
|
@ -928,8 +929,8 @@ class vmmConnection(vmmGObject):
|
|||
ent.connect("activate", _on_ent_activate)
|
||||
entry.append(ent)
|
||||
|
||||
box.attach(label[row], 0, 1, row, row+1, gtk.FILL, 0, 0, 0)
|
||||
box.attach(entry[row], 1, 2, row, row+1, gtk.FILL, 0, 0, 0)
|
||||
box.attach(label[row], 0, 1, row, row + 1, gtk.FILL, 0, 0, 0)
|
||||
box.attach(entry[row], 1, 2, row, row + 1, gtk.FILL, 0, 0, 0)
|
||||
row = row + 1
|
||||
|
||||
vbox = dialog.get_child()
|
||||
|
@ -1107,7 +1108,7 @@ class vmmConnection(vmmGObject):
|
|||
try:
|
||||
net = self.vmm.networkLookupByName(name)
|
||||
uuid = util.uuidstr(net.UUID())
|
||||
if not origNets.has_key(uuid):
|
||||
if uuid not in origNets:
|
||||
# Brand new network
|
||||
currentNets[uuid] = vmmNetwork(self, net, uuid, True)
|
||||
newNets.append(uuid)
|
||||
|
@ -1127,7 +1128,7 @@ class vmmConnection(vmmGObject):
|
|||
try:
|
||||
net = self.vmm.networkLookupByName(name)
|
||||
uuid = util.uuidstr(net.UUID())
|
||||
if not origNets.has_key(uuid):
|
||||
if uuid not in origNets:
|
||||
currentNets[uuid] = vmmNetwork(self, net, uuid, False)
|
||||
newNets.append(uuid)
|
||||
else:
|
||||
|
@ -1180,7 +1181,7 @@ class vmmConnection(vmmGObject):
|
|||
try:
|
||||
pool = self.vmm.storagePoolLookupByName(name)
|
||||
uuid = util.uuidstr(pool.UUID())
|
||||
if not origPools.has_key(uuid):
|
||||
if uuid not in origPools:
|
||||
currentPools[uuid] = vmmStoragePool(self, pool, uuid, True)
|
||||
newPools.append(uuid)
|
||||
startPools.append(uuid)
|
||||
|
@ -1197,7 +1198,7 @@ class vmmConnection(vmmGObject):
|
|||
try:
|
||||
pool = self.vmm.storagePoolLookupByName(name)
|
||||
uuid = util.uuidstr(pool.UUID())
|
||||
if not origPools.has_key(uuid):
|
||||
if uuid not in origPools:
|
||||
currentPools[uuid] = vmmStoragePool(self, pool, uuid, False)
|
||||
newPools.append(uuid)
|
||||
else:
|
||||
|
@ -1242,7 +1243,7 @@ class vmmConnection(vmmGObject):
|
|||
def check_obj(name, is_active):
|
||||
key = name
|
||||
|
||||
if not orig.has_key(key):
|
||||
if key not in orig:
|
||||
obj = self.vmm.interfaceLookupByName(name)
|
||||
# Object is brand new this tick period
|
||||
current[key] = vmmInterface(self, obj, key, is_active)
|
||||
|
@ -1303,7 +1304,7 @@ class vmmConnection(vmmGObject):
|
|||
def check_obj(name):
|
||||
key = name
|
||||
|
||||
if not orig.has_key(key):
|
||||
if key not in orig:
|
||||
obj = self.vmm.nodeDeviceLookupByName(name)
|
||||
vdev = virtinst.NodeDeviceParser.parse(obj.XMLDesc(0))
|
||||
|
||||
|
@ -1370,7 +1371,7 @@ class vmmConnection(vmmGObject):
|
|||
# Filter out active domains which haven't changed
|
||||
if newActiveIDs != None:
|
||||
for _id in newActiveIDs:
|
||||
if oldActiveIDs.has_key(_id):
|
||||
if _id in oldActiveIDs:
|
||||
# No change, copy across existing VM object
|
||||
vm = oldActiveIDs[_id]
|
||||
curUUIDs[vm.get_uuid()] = vm
|
||||
|
@ -1392,7 +1393,7 @@ class vmmConnection(vmmGObject):
|
|||
# Filter out inactive domains which haven't changed
|
||||
if newInactiveNames != None:
|
||||
for name in newInactiveNames:
|
||||
if oldInactiveNames.has_key(name):
|
||||
if name in oldInactiveNames:
|
||||
# No change, copy across existing VM object
|
||||
vm = oldInactiveNames[name]
|
||||
curUUIDs[vm.get_uuid()] = vm
|
||||
|
@ -1415,7 +1416,7 @@ class vmmConnection(vmmGObject):
|
|||
# only new domains
|
||||
for uuid in maybeNewUUIDs.keys():
|
||||
rawvm = maybeNewUUIDs[uuid]
|
||||
if not(self.vms.has_key(uuid)):
|
||||
if uuid not in self.vms:
|
||||
vm = vmmDomain(self, rawvm, uuid)
|
||||
newUUIDs.append(uuid)
|
||||
curUUIDs[uuid] = vm
|
||||
|
@ -1427,7 +1428,7 @@ class vmmConnection(vmmGObject):
|
|||
# Finalize list of domains which went away altogether
|
||||
for uuid in self.vms.keys():
|
||||
vm = self.vms[uuid]
|
||||
if not(curUUIDs.has_key(uuid)):
|
||||
if uuid not in curUUIDs:
|
||||
oldUUIDs[uuid] = vm
|
||||
|
||||
return (startedUUIDs, newUUIDs, oldUUIDs, curUUIDs, activeUUIDs)
|
||||
|
@ -1582,8 +1583,12 @@ class vmmConnection(vmmGObject):
|
|||
pcentCpuTime = 0
|
||||
if len(self.record) > 0:
|
||||
prevTimestamp = self.record[0]["timestamp"]
|
||||
host_cpus = self.host_active_processor_count()
|
||||
|
||||
pcentCpuTime = ((cpuTime) * 100.0 /
|
||||
((now - prevTimestamp) *
|
||||
1000.0 * 1000.0 * 1000.0 * host_cpus))
|
||||
|
||||
pcentCpuTime = (cpuTime) * 100.0 / ((now - prevTimestamp)*1000.0*1000.0*1000.0*self.host_active_processor_count())
|
||||
# Due to timing diffs between getting wall time & getting
|
||||
# the domain's time, its possible to go a tiny bit over
|
||||
# 100% utilization. This freaks out users of the data, so
|
||||
|
@ -1620,9 +1625,9 @@ class vmmConnection(vmmGObject):
|
|||
def cpu_time_vector(self):
|
||||
vector = []
|
||||
stats = self.record
|
||||
for i in range(self.config.get_stats_history_length()+1):
|
||||
for i in range(self.config.get_stats_history_length() + 1):
|
||||
if i < len(stats):
|
||||
vector.append(stats[i]["cpuTimePercent"]/100.0)
|
||||
vector.append(stats[i]["cpuTimePercent"] / 100.0)
|
||||
else:
|
||||
vector.append(0)
|
||||
return vector
|
||||
|
@ -1645,10 +1650,10 @@ class vmmConnection(vmmGObject):
|
|||
|
||||
def pretty_current_memory(self):
|
||||
mem = self.current_memory()
|
||||
if mem > (10*1024*1024):
|
||||
return "%2.2f GB" % (mem/(1024.0*1024.0))
|
||||
if mem > (10 * 1024 * 1024):
|
||||
return "%2.2f GB" % (mem / (1024.0 * 1024.0))
|
||||
else:
|
||||
return "%2.0f MB" % (mem/1024.0)
|
||||
return "%2.0f MB" % (mem / 1024.0)
|
||||
|
||||
def current_memory_percentage(self):
|
||||
if len(self.record) == 0:
|
||||
|
@ -1658,9 +1663,9 @@ class vmmConnection(vmmGObject):
|
|||
def current_memory_vector(self):
|
||||
vector = []
|
||||
stats = self.record
|
||||
for i in range(self.config.get_stats_history_length()+1):
|
||||
for i in range(self.config.get_stats_history_length() + 1):
|
||||
if i < len(stats):
|
||||
vector.append(stats[i]["memoryPercent"]/100.0)
|
||||
vector.append(stats[i]["memoryPercent"] / 100.0)
|
||||
else:
|
||||
vector.append(0)
|
||||
return vector
|
||||
|
@ -1693,11 +1698,11 @@ class vmmConnection(vmmGObject):
|
|||
|
||||
def disk_io_vector_limit(self, dummy):
|
||||
"""No point to accumulate unnormalized I/O for a conenction"""
|
||||
return [ 0.0 ]
|
||||
return [0.0]
|
||||
|
||||
def network_traffic_vector_limit(self, dummy):
|
||||
"""No point to accumulate unnormalized Rx/Tx for a conenction"""
|
||||
return [ 0.0 ]
|
||||
return [0.0]
|
||||
|
||||
|
||||
####################################
|
||||
|
@ -1711,4 +1716,3 @@ class vmmConnection(vmmGObject):
|
|||
self.config.get_iso_paths)
|
||||
|
||||
gobject.type_register(vmmConnection)
|
||||
|
||||
|
|
|
@ -88,11 +88,13 @@ class vmmConsolePages(vmmGObjectUI):
|
|||
# we encapsulate this into try/except block
|
||||
try:
|
||||
keys = map(int, grab_keys.split(','))
|
||||
self.vncViewer.set_grab_keys( keys )
|
||||
self.vncViewer.set_grab_keys(keys)
|
||||
except:
|
||||
logging.debug("Error in grab_keys configuration in GConf")
|
||||
except Exception, e:
|
||||
logging.debug("Error when getting the grab keys combination: %s" % str(e))
|
||||
logging.exception("Error in grab_keys configuration "
|
||||
"in GConf")
|
||||
except:
|
||||
logging.exception("Error when getting the grab keys "
|
||||
"combination")
|
||||
|
||||
self.init_vnc()
|
||||
|
||||
|
@ -484,7 +486,7 @@ class vmmConsolePages(vmmGObjectUI):
|
|||
if username:
|
||||
argv += ['-l', username]
|
||||
|
||||
argv += [ server ]
|
||||
argv += [server]
|
||||
|
||||
# Build 'nc' command run on the remote host
|
||||
#
|
||||
|
@ -576,8 +578,8 @@ class vmmConsolePages(vmmGObjectUI):
|
|||
|
||||
def guest_not_avail(self):
|
||||
return (not self.vm.get_handle() or
|
||||
self.vm.status() in [ libvirt.VIR_DOMAIN_SHUTOFF,
|
||||
libvirt.VIR_DOMAIN_CRASHED ] or
|
||||
self.vm.status() in [libvirt.VIR_DOMAIN_SHUTOFF,
|
||||
libvirt.VIR_DOMAIN_CRASHED] or
|
||||
self.vm.get_id() < 0)
|
||||
|
||||
def try_login(self, src_ignore=None):
|
||||
|
@ -639,11 +641,11 @@ class vmmConsolePages(vmmGObjectUI):
|
|||
self.vncViewer.open_host(connhost, str(vncport))
|
||||
|
||||
except:
|
||||
(typ, value, stacktrace) = sys.exc_info ()
|
||||
(typ, value, stacktrace) = sys.exc_info()
|
||||
details = \
|
||||
"Unable to start virtual machine '%s'" % \
|
||||
(str(typ) + " " + str(value) + "\n" + \
|
||||
traceback.format_exc (stacktrace))
|
||||
traceback.format_exc(stacktrace))
|
||||
logging.error(details)
|
||||
|
||||
def set_credentials(self, src_ignore=None):
|
||||
|
|
|
@ -58,9 +58,9 @@ INSTALL_PAGE_IMPORT = 3
|
|||
class vmmCreate(vmmGObjectUI):
|
||||
__gsignals__ = {
|
||||
"action-show-console": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, (str,str)),
|
||||
gobject.TYPE_NONE, (str, str)),
|
||||
"action-show-terminal": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, (str,str)),
|
||||
gobject.TYPE_NONE, (str, str)),
|
||||
"action-show-help": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, [str]),
|
||||
}
|
||||
|
@ -493,11 +493,11 @@ class vmmCreate(vmmGObjectUI):
|
|||
|
||||
# Memory
|
||||
memory = int(self.conn.host_memory_size())
|
||||
mem_label = _("Up to %(maxmem)s available on the host") % {'maxmem': \
|
||||
self.pretty_memory(memory) }
|
||||
mem_label = (_("Up to %(maxmem)s available on the host") %
|
||||
{'maxmem': self.pretty_memory(memory)})
|
||||
mem_label = ("<span size='small' color='#484848'>%s</span>" %
|
||||
mem_label)
|
||||
self.window.get_widget("config-mem").set_range(50, memory/1024)
|
||||
self.window.get_widget("config-mem").set_range(50, memory / 1024)
|
||||
self.window.get_widget("phys-mem-label").set_markup(mem_label)
|
||||
|
||||
# CPU
|
||||
|
@ -517,8 +517,8 @@ class vmmCreate(vmmGObjectUI):
|
|||
cmax = int(cmax)
|
||||
if cmax <= 0:
|
||||
cmax = 1
|
||||
cpu_label = _("Up to %(numcpus)d available") % { 'numcpus': \
|
||||
int(phys_cpus)}
|
||||
cpu_label = (_("Up to %(numcpus)d available") %
|
||||
{'numcpus': int(phys_cpus)})
|
||||
cpu_label = ("<span size='small' color='#484848'>%s</span>" %
|
||||
cpu_label)
|
||||
self.window.get_widget("config-cpus").set_range(1, cmax)
|
||||
|
@ -631,7 +631,7 @@ class vmmCreate(vmmGObjectUI):
|
|||
|
||||
arch_list.set_active(default)
|
||||
|
||||
def populate_conn_list(self, urihint = None):
|
||||
def populate_conn_list(self, urihint=None):
|
||||
conn_list = self.window.get_widget("create-conn")
|
||||
model = conn_list.get_model()
|
||||
model.clear()
|
||||
|
@ -714,8 +714,8 @@ class vmmCreate(vmmGObjectUI):
|
|||
newdom) = virtinst.CapabilitiesParser.guest_lookup(
|
||||
conn=self.conn.vmm,
|
||||
caps=self.caps,
|
||||
os_type = gtype,
|
||||
type = dtype,
|
||||
os_type=gtype,
|
||||
type=dtype,
|
||||
accelerated=True,
|
||||
arch=arch)
|
||||
|
||||
|
@ -1130,7 +1130,7 @@ class vmmCreate(vmmGObjectUI):
|
|||
# Update page number
|
||||
page_lbl = ("<span color='#59B0E2'>%s</span>" %
|
||||
_("Step %(current_page)d of %(max_page)d") %
|
||||
{'current_page': pagenum+1, 'max_page': PAGE_FINISH+1})
|
||||
{'current_page': pagenum + 1, 'max_page': PAGE_FINISH + 1})
|
||||
|
||||
self.window.get_widget("config-pagenum").set_markup(page_lbl)
|
||||
|
||||
|
@ -1413,10 +1413,10 @@ class vmmCreate(vmmGObjectUI):
|
|||
if not diskpath:
|
||||
return self.verr(_("A storage path must be specified."))
|
||||
|
||||
disk = virtinst.VirtualDisk(conn = self.conn.vmm,
|
||||
path = diskpath,
|
||||
size = disksize,
|
||||
sparse = sparse)
|
||||
disk = virtinst.VirtualDisk(conn=self.conn.vmm,
|
||||
path=diskpath,
|
||||
size=disksize,
|
||||
sparse=sparse)
|
||||
|
||||
except Exception, e:
|
||||
return self.verr(_("Storage parameter error."), str(e))
|
||||
|
@ -1481,9 +1481,9 @@ class vmmCreate(vmmGObjectUI):
|
|||
|
||||
# Interesting methods
|
||||
def build_installer(self, instclass):
|
||||
installer = instclass(conn = self.conn.vmm,
|
||||
type = self.capsdomain.hypervisor_type,
|
||||
os_type = self.capsguest.os_type)
|
||||
installer = instclass(conn=self.conn.vmm,
|
||||
type=self.capsdomain.hypervisor_type,
|
||||
os_type=self.capsguest.os_type)
|
||||
installer.arch = self.capsguest.arch
|
||||
|
||||
return installer
|
||||
|
@ -1496,9 +1496,9 @@ class vmmCreate(vmmGObjectUI):
|
|||
|
||||
# FIXME: some things are dependent on domain type (vcpu max)
|
||||
if instmeth == INSTALL_PAGE_URL:
|
||||
self.change_caps(gtype = "xen")
|
||||
self.change_caps(gtype="xen")
|
||||
else:
|
||||
self.change_caps(gtype = "hvm")
|
||||
self.change_caps(gtype="hvm")
|
||||
|
||||
def reset_guest_type(self):
|
||||
self.change_caps()
|
||||
|
@ -1616,7 +1616,7 @@ class vmmCreate(vmmGObjectUI):
|
|||
for dev in guest.get_all_devices():
|
||||
dev.conn = guest.conn
|
||||
|
||||
guest.start_install(False, meter = meter)
|
||||
guest.start_install(False, meter=meter)
|
||||
logging.debug("Install completed")
|
||||
|
||||
# Make sure we pick up the domain object
|
||||
|
@ -1675,7 +1675,7 @@ class vmmCreate(vmmGObjectUI):
|
|||
return "%.1f Gb" % float(size)
|
||||
|
||||
def pretty_memory(self, mem):
|
||||
return "%d MB" % (mem/1024.0)
|
||||
return "%d MB" % (mem / 1024.0)
|
||||
|
||||
# Distro detection methods
|
||||
|
||||
|
|
|
@ -370,8 +370,8 @@ class vmmCreateInterface(vmmGObjectUI):
|
|||
self.window.get_widget("interface-name-entry").hide()
|
||||
self.window.get_widget("interface-name-label").hide()
|
||||
|
||||
if itype in [ Interface.Interface.INTERFACE_TYPE_BRIDGE,
|
||||
Interface.Interface.INTERFACE_TYPE_BOND ]:
|
||||
if itype in [Interface.Interface.INTERFACE_TYPE_BRIDGE,
|
||||
Interface.Interface.INTERFACE_TYPE_BOND]:
|
||||
widget = "interface-name-entry"
|
||||
else:
|
||||
widget = "interface-name-label"
|
||||
|
@ -524,13 +524,13 @@ class vmmCreateInterface(vmmGObjectUI):
|
|||
continue
|
||||
|
||||
if itype == Interface.Interface.INTERFACE_TYPE_ETHERNET:
|
||||
if row_dict.has_key(name):
|
||||
if name in row_dict:
|
||||
del(row_dict[name])
|
||||
|
||||
# We only want 'unconfigured' interfaces here
|
||||
continue
|
||||
|
||||
if row_dict.has_key(name):
|
||||
if name in row_dict:
|
||||
# Interface was listed via nodedev APIs
|
||||
row = row_dict[name]
|
||||
row[INTERFACE_ROW_KEY] = key
|
||||
|
@ -640,8 +640,8 @@ class vmmCreateInterface(vmmGObjectUI):
|
|||
active = src.get_active()
|
||||
model = slave_list.get_model()
|
||||
|
||||
if itype in [ Interface.Interface.INTERFACE_TYPE_ETHERNET,
|
||||
Interface.Interface.INTERFACE_TYPE_VLAN ]:
|
||||
if itype in [Interface.Interface.INTERFACE_TYPE_ETHERNET,
|
||||
Interface.Interface.INTERFACE_TYPE_VLAN]:
|
||||
# Deselect any selected rows
|
||||
for row in model:
|
||||
if row == model[index]:
|
||||
|
@ -656,8 +656,8 @@ class vmmCreateInterface(vmmGObjectUI):
|
|||
|
||||
def update_interface_name(self, ignore1=None, ignore2=None):
|
||||
itype = self.get_config_interface_type()
|
||||
if itype not in [ Interface.Interface.INTERFACE_TYPE_VLAN,
|
||||
Interface.Interface.INTERFACE_TYPE_ETHERNET ]:
|
||||
if itype not in [Interface.Interface.INTERFACE_TYPE_VLAN,
|
||||
Interface.Interface.INTERFACE_TYPE_ETHERNET]:
|
||||
# The rest have editable name fields, so don't overwrite
|
||||
return
|
||||
|
||||
|
@ -874,7 +874,7 @@ class vmmCreateInterface(vmmGObjectUI):
|
|||
# Update page number
|
||||
page_lbl = ("<span color='#59B0E2'>%s</span>" %
|
||||
_("Step %(current_page)d of %(max_page)d") %
|
||||
{'current_page': next_page, 'max_page': PAGE_DETAILS+1})
|
||||
{'current_page': next_page, 'max_page': PAGE_DETAILS + 1})
|
||||
|
||||
self.window.get_widget("header-pagenum").set_markup(page_lbl)
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ class vmmCreateMeter(progress.BaseMeter):
|
|||
self.asyncjob.pulse_pbar(out, text)
|
||||
else:
|
||||
frac = self.re.fraction_read()
|
||||
out = "%3i%% %5sB" % (frac*100, fread)
|
||||
out = "%3i%% %5sB" % (frac * 100, fread)
|
||||
self.asyncjob.set_pbar_fraction(frac, out, text)
|
||||
|
||||
def _do_end(self, amount_read, now=None):
|
||||
|
|
|
@ -81,7 +81,7 @@ class vmmCreateNetwork(vmmGObjectUI):
|
|||
notebook.set_show_tabs(False)
|
||||
|
||||
black = gtk.gdk.color_parse("#000")
|
||||
for num in range(PAGE_SUMMARY+1):
|
||||
for num in range(PAGE_SUMMARY + 1):
|
||||
name = "page" + str(num) + "-title"
|
||||
self.window.get_widget(name).modify_bg(gtk.STATE_NORMAL, black)
|
||||
|
||||
|
@ -268,7 +268,7 @@ class vmmCreateNetwork(vmmGObjectUI):
|
|||
elif page_number == PAGE_DHCP:
|
||||
ip = self.get_config_ip4()
|
||||
start = int(ip.len() / 2)
|
||||
end = ip.len()-2
|
||||
end = ip.len() - 2
|
||||
if self.window.get_widget("net-dhcp-start").get_text() == "":
|
||||
self.window.get_widget("net-dhcp-start").set_text(str(ip[start]))
|
||||
if self.window.get_widget("net-dhcp-end").get_text() == "":
|
||||
|
@ -288,14 +288,17 @@ class vmmCreateNetwork(vmmGObjectUI):
|
|||
end = self.get_config_dhcp_end()
|
||||
self.window.get_widget("summary-dhcp-start").set_text(str(start))
|
||||
self.window.get_widget("summary-dhcp-end").set_text(str(end))
|
||||
self.window.get_widget("label-dhcp-start").set_text( _("Start address:") )
|
||||
self.window.get_widget("label-dhcp-start").set_text(
|
||||
_("Start address:"))
|
||||
self.window.get_widget("label-dhcp-start").show()
|
||||
self.window.get_widget("label-dhcp-end").show()
|
||||
self.window.get_widget("summary-dhcp-start").show()
|
||||
self.window.get_widget("summary-dhcp-end").show()
|
||||
else:
|
||||
self.window.get_widget("label-dhcp-start").set_text( _("Status:") )
|
||||
self.window.get_widget("summary-dhcp-start").set_text( _("Disabled") )
|
||||
self.window.get_widget("label-dhcp-start").set_text(
|
||||
_("Status:"))
|
||||
self.window.get_widget("summary-dhcp-start").set_text(
|
||||
_("Disabled"))
|
||||
self.window.get_widget("label-dhcp-end").hide()
|
||||
self.window.get_widget("summary-dhcp-end").hide()
|
||||
|
||||
|
|
|
@ -342,7 +342,7 @@ class vmmCreatePool(vmmGObjectUI):
|
|||
return (False, False)
|
||||
if self._pool.type in [Storage.StoragePool.TYPE_DIR,
|
||||
Storage.StoragePool.TYPE_FS,
|
||||
Storage.StoragePool.TYPE_NETFS ]:
|
||||
Storage.StoragePool.TYPE_NETFS]:
|
||||
# Building for these simply entails creating a directory
|
||||
return (True, False)
|
||||
elif self._pool.type in [Storage.StoragePool.TYPE_LOGICAL,
|
||||
|
@ -410,7 +410,7 @@ class vmmCreatePool(vmmGObjectUI):
|
|||
def _async_pool_create(self, asyncjob, *args, **kwargs):
|
||||
print args, kwargs
|
||||
newconn = None
|
||||
|
||||
|
||||
# Open a seperate connection to install on since this is async
|
||||
newconn = util.dup_lib_conn(self._pool.conn)
|
||||
meter = vmmCreateMeter(asyncjob)
|
||||
|
@ -492,11 +492,12 @@ class vmmCreatePool(vmmGObjectUI):
|
|||
return self.err.val_err(_("Pool Parameter Error"), str(e))
|
||||
|
||||
buildval = self.window.get_widget("pool-build").get_active()
|
||||
buildsen = self.window.get_widget("pool-build").get_property("sensitive")
|
||||
buildsen = self.window.get_widget("pool-build").get_property(
|
||||
"sensitive")
|
||||
if buildsen and buildval:
|
||||
ret = self.err.yes_no(_("Building a pool of this type will "
|
||||
"format the source device. Are you "
|
||||
"sure you want to 'build' this pool?"))
|
||||
ret = self.err.yes_no(_("Building a pool of this type will "
|
||||
"format the source device. Are you "
|
||||
"sure you want to 'build' this pool?"))
|
||||
if not ret:
|
||||
return ret
|
||||
|
||||
|
|
|
@ -20,7 +20,8 @@
|
|||
|
||||
import gtk
|
||||
|
||||
import os, stat
|
||||
import os
|
||||
import stat
|
||||
import traceback
|
||||
import logging
|
||||
|
||||
|
@ -157,7 +158,7 @@ class vmmDeleteDialog(vmmGObjectUI):
|
|||
for path in paths:
|
||||
try:
|
||||
logging.debug("Deleting path: %s" % path)
|
||||
meter.start(text = _("Deleting path '%s'") % path)
|
||||
meter.start(text=_("Deleting path '%s'") % path)
|
||||
self._async_delete_path(newconn, path, meter)
|
||||
except Exception, e:
|
||||
storage_errors.append((str(e),
|
||||
|
|
|
@ -59,10 +59,10 @@ HW_LIST_TYPE_HOSTDEV = 11
|
|||
HW_LIST_TYPE_VIDEO = 12
|
||||
HW_LIST_TYPE_WATCHDOG = 13
|
||||
|
||||
remove_pages = [ HW_LIST_TYPE_NIC, HW_LIST_TYPE_INPUT,
|
||||
HW_LIST_TYPE_GRAPHICS, HW_LIST_TYPE_SOUND, HW_LIST_TYPE_CHAR,
|
||||
HW_LIST_TYPE_HOSTDEV, HW_LIST_TYPE_DISK, HW_LIST_TYPE_VIDEO,
|
||||
HW_LIST_TYPE_WATCHDOG]
|
||||
remove_pages = [HW_LIST_TYPE_NIC, HW_LIST_TYPE_INPUT,
|
||||
HW_LIST_TYPE_GRAPHICS, HW_LIST_TYPE_SOUND, HW_LIST_TYPE_CHAR,
|
||||
HW_LIST_TYPE_HOSTDEV, HW_LIST_TYPE_DISK, HW_LIST_TYPE_VIDEO,
|
||||
HW_LIST_TYPE_WATCHDOG]
|
||||
|
||||
# Boot device columns
|
||||
BOOT_DEV_TYPE = 0
|
||||
|
@ -113,10 +113,10 @@ def safeint(val, fmt="%.3d"):
|
|||
return fmt % int(val)
|
||||
|
||||
def prettyify_bytes(val):
|
||||
if val > (1024*1024*1024):
|
||||
return "%2.2f GB" % (val/(1024.0*1024.0*1024.0))
|
||||
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))
|
||||
return "%2.2f MB" % (val / (1024.0 * 1024.0))
|
||||
|
||||
def build_hostdev_label(hostdev):
|
||||
# String shown in the devices details section
|
||||
|
@ -218,11 +218,11 @@ def lookup_nodedev(vmmconn, hostdev):
|
|||
class vmmDetails(vmmGObjectUI):
|
||||
__gsignals__ = {
|
||||
"action-show-console": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, (str,str)),
|
||||
gobject.TYPE_NONE, (str, str)),
|
||||
"action-save-domain": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, (str,str)),
|
||||
gobject.TYPE_NONE, (str, str)),
|
||||
"action-destroy-domain": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, (str,str)),
|
||||
gobject.TYPE_NONE, (str, str)),
|
||||
"action-suspend-domain": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, (str, str)),
|
||||
"action-resume-domain": (gobject.SIGNAL_RUN_FIRST,
|
||||
|
@ -240,9 +240,9 @@ class vmmDetails(vmmGObjectUI):
|
|||
"action-view-manager": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, []),
|
||||
"action-migrate-domain": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, (str,str)),
|
||||
gobject.TYPE_NONE, (str, str)),
|
||||
"action-clone-domain": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, (str,str)),
|
||||
gobject.TYPE_NONE, (str, str)),
|
||||
"details-closed": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, ()),
|
||||
}
|
||||
|
@ -535,7 +535,7 @@ class vmmDetails(vmmGObjectUI):
|
|||
self.disk_io_graph.set_property("reversed", True)
|
||||
self.disk_io_graph.set_property("filled", False)
|
||||
self.disk_io_graph.set_property("num_sets", 2)
|
||||
self.disk_io_graph.set_property("rgb", map(lambda x: x/255.0,
|
||||
self.disk_io_graph.set_property("rgb", map(lambda x: x / 255.0,
|
||||
[0x82, 0x00, 0x3B, 0x29, 0x5C, 0x45]))
|
||||
graph_table.attach(self.disk_io_graph, 1, 2, 2, 3)
|
||||
|
||||
|
@ -544,7 +544,7 @@ class vmmDetails(vmmGObjectUI):
|
|||
self.network_traffic_graph.set_property("filled", False)
|
||||
self.network_traffic_graph.set_property("num_sets", 2)
|
||||
self.network_traffic_graph.set_property("rgb",
|
||||
map(lambda x: x/255.0,
|
||||
map(lambda x: x / 255.0,
|
||||
[0x82, 0x00, 0x3B,
|
||||
0x29, 0x5C, 0x45]))
|
||||
graph_table.attach(self.network_traffic_graph, 1, 2, 3, 4)
|
||||
|
@ -584,7 +584,7 @@ class vmmDetails(vmmGObjectUI):
|
|||
clock_combo.pack_start(text, True)
|
||||
clock_combo.add_attribute(text, 'text', 0)
|
||||
clock_model.set_sort_column_id(0, gtk.SORT_ASCENDING)
|
||||
for offset in [ "localtime", "utc" ]:
|
||||
for offset in ["localtime", "utc"]:
|
||||
clock_model.append([offset])
|
||||
|
||||
# Security info tooltips
|
||||
|
@ -737,7 +737,7 @@ class vmmDetails(vmmGObjectUI):
|
|||
on_graphics = (self.last_console_page == PAGE_CONSOLE)
|
||||
|
||||
group = None
|
||||
usable_types = [ "pty" ]
|
||||
usable_types = ["pty"]
|
||||
for dev in devs:
|
||||
sensitive = False
|
||||
msg = ""
|
||||
|
@ -1083,8 +1083,8 @@ class vmmDetails(vmmGObjectUI):
|
|||
self.topwin,
|
||||
_("Save Virtual Machine Screenshot"),
|
||||
self.vm.get_connection(),
|
||||
_type = ("png", "PNG files"),
|
||||
dialog_type = gtk.FILE_CHOOSER_ACTION_SAVE,
|
||||
_type=("png", "PNG files"),
|
||||
dialog_type=gtk.FILE_CHOOSER_ACTION_SAVE,
|
||||
browse_reason=self.config.CONFIG_DIR_SCREENSHOT)
|
||||
if not path:
|
||||
return
|
||||
|
@ -1096,11 +1096,11 @@ class vmmDetails(vmmGObjectUI):
|
|||
|
||||
# Save along with a little metadata about us & the domain
|
||||
image.save(filename, 'png',
|
||||
{ 'tEXt::Hypervisor URI': self.vm.get_connection().get_uri(),
|
||||
'tEXt::Domain Name': self.vm.get_name(),
|
||||
'tEXt::Domain UUID': self.vm.get_uuid(),
|
||||
'tEXt::Generator App': self.config.get_appname(),
|
||||
'tEXt::Generator Version': self.config.get_appversion() })
|
||||
{'tEXt::Hypervisor URI': self.vm.get_connection().get_uri(),
|
||||
'tEXt::Domain Name': self.vm.get_name(),
|
||||
'tEXt::Domain UUID': self.vm.get_uuid(),
|
||||
'tEXt::Generator App': self.config.get_appname(),
|
||||
'tEXt::Generator Version': self.config.get_appversion()})
|
||||
|
||||
msg = gtk.MessageDialog(self.topwin,
|
||||
gtk.DIALOG_MODAL,
|
||||
|
@ -1144,7 +1144,7 @@ class vmmDetails(vmmGObjectUI):
|
|||
|
||||
def serial_close_tab(self, src_ignore, pagenum):
|
||||
tab_idx = (pagenum - PAGE_DYNAMIC_OFFSET)
|
||||
if (tab_idx < 0) or (tab_idx > len(self.serial_tabs)-1):
|
||||
if (tab_idx < 0) or (tab_idx > len(self.serial_tabs) - 1):
|
||||
return
|
||||
return self._close_serial_tab(self.serial_tabs[tab_idx])
|
||||
|
||||
|
@ -1436,7 +1436,7 @@ class vmmDetails(vmmGObjectUI):
|
|||
self.vm.define_apic,
|
||||
self.vm.define_clock,
|
||||
self.vm.define_seclabel,
|
||||
self.vm.define_description,],
|
||||
self.vm.define_description],
|
||||
[(enable_acpi,),
|
||||
(enable_apic,),
|
||||
(clock,),
|
||||
|
@ -1797,8 +1797,8 @@ class vmmDetails(vmmGObjectUI):
|
|||
|
||||
vm_memory = self.vm.current_memory()
|
||||
host_memory = self.vm.get_connection().host_memory_size()
|
||||
mem_txt = "%d MB of %d MB" % (int(round(vm_memory/1024.0)),
|
||||
int(round(host_memory/1024.0)))
|
||||
mem_txt = "%d MB of %d MB" % (int(round(vm_memory / 1024.0)),
|
||||
int(round(host_memory / 1024.0)))
|
||||
|
||||
if self.config.get_stats_enable_disk_poll():
|
||||
dsk_txt = _dsk_rx_tx_text(self.vm.disk_read_rate(),
|
||||
|
@ -1890,9 +1890,9 @@ class vmmDetails(vmmGObjectUI):
|
|||
def refresh_config_memory(self):
|
||||
host_mem_widget = self.window.get_widget("state-host-memory")
|
||||
vm_mem_widget = self.window.get_widget("state-vm-memory")
|
||||
host_mem = self.vm.get_connection().host_memory_size()/1024
|
||||
vm_cur_mem = self.vm.get_memory()/1024.0
|
||||
vm_max_mem = self.vm.maximum_memory()/1024.0
|
||||
host_mem = self.vm.get_connection().host_memory_size() / 1024
|
||||
vm_cur_mem = self.vm.get_memory() / 1024.0
|
||||
vm_max_mem = self.vm.maximum_memory() / 1024.0
|
||||
|
||||
host_mem_widget.set_text("%d MB" % (int(round(host_mem))))
|
||||
vm_mem_widget.set_text("%d MB" % int(round(vm_cur_mem)))
|
||||
|
@ -1982,7 +1982,7 @@ class vmmDetails(vmmGObjectUI):
|
|||
name = vnet.get_name()
|
||||
name_dict[name] = vnet
|
||||
|
||||
if source and name_dict.has_key(source):
|
||||
if source and source in name_dict:
|
||||
netobj = name_dict[source]
|
||||
|
||||
desc = uihelpers.pretty_network_desc(nettype, source, netobj)
|
||||
|
@ -2358,7 +2358,7 @@ class vmmDetails(vmmGObjectUI):
|
|||
|
||||
# Append all remaining boot_rows that aren't enabled
|
||||
for dev in old_order:
|
||||
if boot_rows.has_key(dev):
|
||||
if dev in boot_rows:
|
||||
boot_model.append(boot_rows[dev])
|
||||
del(boot_rows[dev])
|
||||
|
||||
|
|
|
@ -561,7 +561,7 @@ class vmmDomainBase(vmmLibvirtObject):
|
|||
bus = dev.bus
|
||||
key = devtype + (bus or "")
|
||||
|
||||
if not idx_mapping.has_key(key):
|
||||
if key not in idx_mapping:
|
||||
idx_mapping[key] = 1
|
||||
|
||||
dev.disk_bus_index = idx_mapping[key]
|
||||
|
@ -624,9 +624,11 @@ class vmmDomainBase(vmmLibvirtObject):
|
|||
cpuTime = info[4] - prevCpuTime
|
||||
cpuTimeAbs = info[4]
|
||||
|
||||
pcentCpuTime = ((cpuTime) * 100.0 /
|
||||
(((now - prevTimestamp)*1000.0*1000.0*1000.0) *
|
||||
self.connection.host_active_processor_count()))
|
||||
pcentCpuTime = (
|
||||
(cpuTime) * 100.0 /
|
||||
(((now - prevTimestamp) * 1000.0 * 1000.0 * 1000.0) *
|
||||
self.connection.host_active_processor_count()))
|
||||
|
||||
# Due to timing diffs between getting wall time & getting
|
||||
# the domain's time, its possible to go a tiny bit over
|
||||
# 100% utilization. This freaks out users of the data, so
|
||||
|
@ -670,17 +672,17 @@ class vmmDomainBase(vmmLibvirtObject):
|
|||
|
||||
def get_memory_pretty(self):
|
||||
mem = self.get_memory()
|
||||
if mem > (10*1024*1024):
|
||||
return "%2.2f GB" % (mem/(1024.0*1024.0))
|
||||
if mem > (10 * 1024 * 1024):
|
||||
return "%2.2f GB" % (mem / (1024.0 * 1024.0))
|
||||
else:
|
||||
return "%2.0f MB" % (mem/1024.0)
|
||||
return "%2.0f MB" % (mem / 1024.0)
|
||||
|
||||
def maximum_memory_pretty(self):
|
||||
mem = self.maximum_memory()
|
||||
if mem > (10*1024*1024):
|
||||
return "%2.2f GB" % (mem/(1024.0*1024.0))
|
||||
if mem > (10 * 1024 * 1024):
|
||||
return "%2.2f GB" % (mem / (1024.0 * 1024.0))
|
||||
else:
|
||||
return "%2.0f MB" % (mem/1024.0)
|
||||
return "%2.0f MB" % (mem / 1024.0)
|
||||
|
||||
def cpu_time_pretty(self):
|
||||
return "%2.2f %%" % self.cpu_time_percentage()
|
||||
|
@ -706,19 +708,19 @@ class vmmDomainBase(vmmLibvirtObject):
|
|||
stats = self.record
|
||||
ceil = float(max(self.maxRecord[name1], self.maxRecord[name2]))
|
||||
maxlen = self.config.get_stats_history_length()
|
||||
for n in [ name1, name2 ]:
|
||||
for n in [name1, name2]:
|
||||
for i in range(maxlen + 1):
|
||||
if i < len(stats):
|
||||
vector.append(float(stats[i][n])/ceil)
|
||||
vector.append(float(stats[i][n]) / ceil)
|
||||
else:
|
||||
vector.append(0.0)
|
||||
return vector
|
||||
|
||||
def in_out_vector_limit(self, data, limit):
|
||||
l = len(data)/2
|
||||
l = len(data) / 2
|
||||
end = [l, limit][l > limit]
|
||||
if l > limit:
|
||||
data = data[0:end] + data[l:l+end]
|
||||
data = data[0:end] + data[l:l + end]
|
||||
d = map(lambda x, y: (x + y) / 2, data[0:end], data[end:end * 2])
|
||||
return d
|
||||
|
||||
|
@ -1136,9 +1138,9 @@ class vmmDomain(vmmDomainBase):
|
|||
def _update_start_vcpus(self, ignore, oldstatus, status):
|
||||
ignore = status
|
||||
|
||||
if oldstatus not in [ libvirt.VIR_DOMAIN_SHUTDOWN,
|
||||
libvirt.VIR_DOMAIN_SHUTOFF,
|
||||
libvirt.VIR_DOMAIN_CRASHED ]:
|
||||
if oldstatus not in [libvirt.VIR_DOMAIN_SHUTDOWN,
|
||||
libvirt.VIR_DOMAIN_SHUTOFF,
|
||||
libvirt.VIR_DOMAIN_CRASHED]:
|
||||
return
|
||||
|
||||
# Want to track the startup vcpu amount, which is the
|
||||
|
@ -1288,17 +1290,18 @@ class vmmDomain(vmmDomainBase):
|
|||
rdBytes, wrBytes = self._disk_io()
|
||||
rxBytes, txBytes = self._network_traffic()
|
||||
|
||||
newStats = { "timestamp": now,
|
||||
"cpuTime": cpuTime,
|
||||
"cpuTimeAbs": cpuTimeAbs,
|
||||
"cpuTimePercent": pcentCpuTime,
|
||||
"currMemPercent": pcentCurrMem,
|
||||
"maxMemPercent": pcentMaxMem,
|
||||
"diskRdKB": rdBytes / 1024,
|
||||
"diskWrKB": wrBytes / 1024,
|
||||
"netRxKB": rxBytes / 1024,
|
||||
"netTxKB": txBytes / 1024,
|
||||
}
|
||||
newStats = {
|
||||
"timestamp": now,
|
||||
"cpuTime": cpuTime,
|
||||
"cpuTimeAbs": cpuTimeAbs,
|
||||
"cpuTimePercent": pcentCpuTime,
|
||||
"currMemPercent": pcentCurrMem,
|
||||
"maxMemPercent": pcentMaxMem,
|
||||
"diskRdKB": rdBytes / 1024,
|
||||
"diskWrKB": wrBytes / 1024,
|
||||
"netRxKB": rxBytes / 1024,
|
||||
"netTxKB": txBytes / 1024,
|
||||
}
|
||||
|
||||
nSamples = 5
|
||||
if nSamples > len(self.record):
|
||||
|
@ -1308,8 +1311,8 @@ class vmmDomain(vmmDomainBase):
|
|||
avg = ["cpuTimeAbs"]
|
||||
percent = 0
|
||||
else:
|
||||
startCpuTime = self.record[nSamples-1]["cpuTimeAbs"]
|
||||
startTimestamp = self.record[nSamples-1]["timestamp"]
|
||||
startCpuTime = self.record[nSamples - 1]["cpuTimeAbs"]
|
||||
startTimestamp = self.record[nSamples - 1]["timestamp"]
|
||||
|
||||
avg = ((newStats["cpuTimeAbs"] - startCpuTime) / nSamples)
|
||||
percent = ((newStats["cpuTimeAbs"] - startCpuTime) * 100.0 /
|
||||
|
@ -1319,7 +1322,7 @@ class vmmDomain(vmmDomainBase):
|
|||
newStats["cpuTimeMovingAvg"] = avg
|
||||
newStats["cpuTimeMovingAvgPercent"] = percent
|
||||
|
||||
for r in [ "diskRd", "diskWr", "netRx", "netTx" ]:
|
||||
for r in ["diskRd", "diskWr", "netRx", "netTx"]:
|
||||
newStats[r + "Rate"] = self._get_cur_rate(r + "KB")
|
||||
self._set_max_rate(newStats, r + "Rate")
|
||||
|
||||
|
|
|
@ -377,7 +377,7 @@ class vmmEngine(vmmGObject):
|
|||
|
||||
def _do_vm_removed(self, connection, hvuri, vmuuid):
|
||||
ignore = connection
|
||||
if self.connections[hvuri]["windowDetails"].has_key(vmuuid):
|
||||
if vmuuid in self.connections[hvuri]["windowDetails"]:
|
||||
self.connections[hvuri]["windowDetails"][vmuuid].close()
|
||||
del self.connections[hvuri]["windowDetails"][vmuuid]
|
||||
|
||||
|
@ -453,7 +453,7 @@ class vmmEngine(vmmGObject):
|
|||
"""
|
||||
Present VM console if recently started
|
||||
"""
|
||||
if not(self.connections[uri]["windowConsole"].has_key(uuid)):
|
||||
if uuid not in self.connections[uri]["windowConsole"]:
|
||||
return
|
||||
|
||||
console = self.connections[uri]["windowConsole"][uuid]
|
||||
|
@ -845,7 +845,7 @@ class vmmEngine(vmmGObject):
|
|||
vm.abort_job()
|
||||
except Exception, e:
|
||||
logging.exception("Error cancelling save job")
|
||||
asyncjob.show_warning(_("Error cancelling save job: %s") % str(e))
|
||||
asyncjob.show_warning(_("Error cancelling save job: %s") % str(e))
|
||||
return
|
||||
|
||||
asyncjob.job_canceled = True
|
||||
|
|
|
@ -48,7 +48,7 @@ def _launch_dialog(dialog, primary_text, secondary_text, title,
|
|||
return res
|
||||
|
||||
class vmmErrorDialog (object):
|
||||
def __init__ (self, parent=None):
|
||||
def __init__(self, parent=None):
|
||||
self._parent = parent
|
||||
self._simple = None
|
||||
|
||||
|
@ -149,8 +149,8 @@ class _errorDialog (gtk.MessageDialog):
|
|||
"""
|
||||
Custom error dialog with optional check boxes or details drop down
|
||||
"""
|
||||
def __init__ (self, *args, **kwargs):
|
||||
gtk.MessageDialog.__init__ (self, *args, **kwargs)
|
||||
def __init__(self, *args, **kwargs):
|
||||
gtk.MessageDialog.__init__(self, *args, **kwargs)
|
||||
self.set_title("")
|
||||
|
||||
self.chk_vbox = None
|
||||
|
@ -176,16 +176,16 @@ class _errorDialog (gtk.MessageDialog):
|
|||
def init_details(self):
|
||||
# Init details buffer
|
||||
self.buffer = gtk.TextBuffer()
|
||||
self.buf_expander = gtk.Expander (_("Details"))
|
||||
sw = gtk.ScrolledWindow ()
|
||||
sw.set_shadow_type (gtk.SHADOW_IN)
|
||||
sw.set_size_request (400, 240)
|
||||
sw.set_policy (gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
details = gtk.TextView (self.buffer)
|
||||
details.set_editable (False)
|
||||
details.set_overwrite (False)
|
||||
details.set_cursor_visible (False)
|
||||
details.set_wrap_mode (gtk.WRAP_WORD)
|
||||
self.buf_expander = gtk.Expander(_("Details"))
|
||||
sw = gtk.ScrolledWindow()
|
||||
sw.set_shadow_type(gtk.SHADOW_IN)
|
||||
sw.set_size_request(400, 240)
|
||||
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
details = gtk.TextView(self.buffer)
|
||||
details.set_editable(False)
|
||||
details.set_overwrite(False)
|
||||
details.set_cursor_visible(False)
|
||||
details.set_wrap_mode(gtk.WRAP_WORD)
|
||||
sw.add(details)
|
||||
self.buf_expander.add(sw)
|
||||
self.vbox.pack_start(self.buf_expander)
|
||||
|
|
|
@ -78,7 +78,7 @@ def draw_fill(cairo_ct, cell_area, points, taper=False):
|
|||
if not len(points):
|
||||
return
|
||||
|
||||
last_point = _line_helper(cairo_ct, cell_area, points, for_fill = True)
|
||||
last_point = _line_helper(cairo_ct, cell_area, points, for_fill=True)
|
||||
if not last_point:
|
||||
# Nothing to draw
|
||||
#return
|
||||
|
|
|
@ -81,11 +81,11 @@ class vmmHalHelper(gobject.GObject):
|
|||
self.hal_iface.connect_to_signal("DeviceRemoved",
|
||||
self._device_removed)
|
||||
except Exception, e:
|
||||
(_type, value, stacktrace) = sys.exc_info ()
|
||||
(_type, value, stacktrace) = sys.exc_info()
|
||||
logging.error("Unable to connect to HAL to list network "
|
||||
"devices: '%s'" +
|
||||
str(_type) + " " + str(value) + "\n" +
|
||||
traceback.format_exc (stacktrace))
|
||||
traceback.format_exc(stacktrace))
|
||||
self.startup_error = str(e)
|
||||
|
||||
def connect(self, name, callback, *args):
|
||||
|
@ -200,7 +200,7 @@ class vmmHalHelper(gobject.GObject):
|
|||
# If running a device in bridged mode, there's a reasonable
|
||||
# chance that the actual ethernet device has been renamed to
|
||||
# something else. ethN -> pethN
|
||||
psysfspath = sysfspath[0:len(sysfspath)-len(name)] + "p" + name
|
||||
psysfspath = sysfspath[0:len(sysfspath) - len(name)] + "p" + name
|
||||
if os.path.exists(psysfspath):
|
||||
logging.debug("Device %s named to p%s" % (name, name))
|
||||
name = "p" + name
|
||||
|
@ -228,7 +228,7 @@ class vmmHalHelper(gobject.GObject):
|
|||
# If running a device in bridged mode, there's areasonable
|
||||
# chance that the actual ethernet device has beenrenamed to
|
||||
# something else. ethN -> pethN
|
||||
pvlanpath = (vlanpath[0:len(vlanpath)-len(vlanname)] +
|
||||
pvlanpath = (vlanpath[0:len(vlanpath) - len(vlanname)] +
|
||||
"p" + vlanname)
|
||||
if os.path.exists(pvlanpath):
|
||||
logging.debug("Device %s named to p%s" % (vlanname,
|
||||
|
@ -302,10 +302,10 @@ def get_net_bridge_owner(name_ignore, sysfspath):
|
|||
(ignore, bridge) = os.path.split(dest)
|
||||
return bridge
|
||||
except:
|
||||
(_type, value, stacktrace) = sys.exc_info ()
|
||||
(_type, value, stacktrace) = sys.exc_info()
|
||||
logging.error("Unable to determine if device is shared:" +
|
||||
str(_type) + " " + str(value) + "\n" +
|
||||
traceback.format_exc (stacktrace))
|
||||
traceback.format_exc(stacktrace))
|
||||
return None
|
||||
|
||||
def get_net_mac_address(name_ignore, sysfspath):
|
||||
|
|
|
@ -85,4 +85,3 @@ class vmmKeyring:
|
|||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
|
|
|
@ -70,18 +70,18 @@ gtk.rc_parse_string(rcstring)
|
|||
|
||||
class vmmManager(vmmGObjectUI):
|
||||
__gsignals__ = {
|
||||
"action-show-connect":(gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, []),
|
||||
"action-show-connect": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, []),
|
||||
"action-show-console": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, (str,str)),
|
||||
gobject.TYPE_NONE, (str, str)),
|
||||
"action-show-terminal": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, (str,str)),
|
||||
gobject.TYPE_NONE, (str, str)),
|
||||
"action-refresh-console": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, (str,str)),
|
||||
gobject.TYPE_NONE, (str, str)),
|
||||
"action-refresh-terminal": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, (str,str)),
|
||||
gobject.TYPE_NONE, (str, str)),
|
||||
"action-show-details": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, (str,str)),
|
||||
gobject.TYPE_NONE, (str, str)),
|
||||
"action-show-about": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, []),
|
||||
"action-show-host": (gobject.SIGNAL_RUN_FIRST,
|
||||
|
@ -109,11 +109,12 @@ class vmmManager(vmmGObjectUI):
|
|||
"action-show-help": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, [str]),
|
||||
"action-migrate-domain": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, (str,str)),
|
||||
gobject.TYPE_NONE, (str, str)),
|
||||
"action-clone-domain": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, (str,str)),
|
||||
gobject.TYPE_NONE, (str, str)),
|
||||
"action-exit-app": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, []),}
|
||||
gobject.TYPE_NONE, []),
|
||||
}
|
||||
|
||||
def __init__(self, engine):
|
||||
vmmGObjectUI.__init__(self, "vmm-manager.glade", "vmm-manager")
|
||||
|
@ -183,10 +184,8 @@ class vmmManager(vmmGObjectUI):
|
|||
# Initialize stat polling columns based on global polling
|
||||
# preferences (we want signal handlers for this)
|
||||
for typ, init_val in \
|
||||
[ (cfg.STATS_DISK,
|
||||
self.config.get_stats_enable_disk_poll()),
|
||||
(cfg.STATS_NETWORK,
|
||||
self.config.get_stats_enable_net_poll())]:
|
||||
[(cfg.STATS_DISK, self.config.get_stats_enable_disk_poll()),
|
||||
(cfg.STATS_NETWORK, self.config.get_stats_enable_net_poll())]:
|
||||
self.enable_polling(None, None, init_val, typ)
|
||||
|
||||
self.engine.connect("connection-added", self._add_connection)
|
||||
|
@ -656,7 +655,7 @@ class vmmManager(vmmGObjectUI):
|
|||
if conn.get_state() != vmmConnection.STATE_DISCONNECTED:
|
||||
conn.close()
|
||||
|
||||
def open_connection(self, ignore = None):
|
||||
def open_connection(self, ignore=None):
|
||||
conn = self.current_connection()
|
||||
if conn.get_state() == vmmConnection.STATE_DISCONNECTED:
|
||||
conn.open()
|
||||
|
@ -664,21 +663,22 @@ class vmmManager(vmmGObjectUI):
|
|||
|
||||
def _connect_error(self, conn, details):
|
||||
if conn.get_driver() == "xen" and not conn.is_remote():
|
||||
self.err.show_err(_("Unable to open a connection to the Xen hypervisor/daemon.\n\n" +
|
||||
"Verify that:\n" +
|
||||
" - A Xen host kernel was booted\n" +
|
||||
" - The Xen service has been started\n"),
|
||||
details,
|
||||
title=_("Virtual Machine Manager Connection Failure"))
|
||||
self.err.show_err(
|
||||
_("Unable to open a connection to the Xen hypervisor/daemon.\n\n" +
|
||||
"Verify that:\n" +
|
||||
" - A Xen host kernel was booted\n" +
|
||||
" - The Xen service has been started\n"),
|
||||
details,
|
||||
title=_("Virtual Machine Manager Connection Failure"))
|
||||
else:
|
||||
self.err.show_err(_("Unable to open a connection to the libvirt "
|
||||
"management daemon.\n\n" +
|
||||
"Libvirt URI is: %s\n\n" % conn.get_uri() +
|
||||
"Verify that:\n" +
|
||||
" - The 'libvirtd' daemon has been started\n"),
|
||||
details,
|
||||
title=_("Virtual Machine Manager Connection "
|
||||
"Failure"))
|
||||
self.err.show_err(
|
||||
_("Unable to open a connection to the libvirt "
|
||||
"management daemon.\n\n" +
|
||||
"Libvirt URI is: %s\n\n" % conn.get_uri() +
|
||||
"Verify that:\n" +
|
||||
" - The 'libvirtd' daemon has been started\n"),
|
||||
details,
|
||||
title=_("Virtual Machine Manager Connection Failure"))
|
||||
|
||||
|
||||
####################################
|
||||
|
@ -758,7 +758,7 @@ class vmmManager(vmmGObjectUI):
|
|||
|
||||
def _append_vm(self, model, vm, conn):
|
||||
row_key = self.vm_row_key(vm)
|
||||
if self.rows.has_key(row_key):
|
||||
if row_key in self.rows:
|
||||
return
|
||||
|
||||
parent = self.rows[conn.get_uri()].iter
|
||||
|
@ -810,7 +810,7 @@ class vmmManager(vmmGObjectUI):
|
|||
# Make sure error page isn't showing
|
||||
self.window.get_widget("vm-notebook").set_current_page(0)
|
||||
|
||||
if self.rows.has_key(conn.get_uri()):
|
||||
if conn.get_uri() in self.rows:
|
||||
return
|
||||
|
||||
conn.connect("vm-added", self.vm_added)
|
||||
|
@ -865,7 +865,7 @@ class vmmManager(vmmGObjectUI):
|
|||
vmlist = self.window.get_widget("vm-list")
|
||||
model = vmlist.get_model()
|
||||
|
||||
if not self.rows.has_key(self.vm_row_key(vm)):
|
||||
if self.vm_row_key(vm) not in self.rows:
|
||||
return
|
||||
|
||||
row = self.rows[self.vm_row_key(vm)]
|
||||
|
|
|
@ -44,7 +44,7 @@ class vmmMediaDevice(vmmGObject):
|
|||
if nodedev.device_type != "storage":
|
||||
return None
|
||||
|
||||
if nodedev.drive_type not in [ MEDIA_CDROM, MEDIA_FLOPPY]:
|
||||
if nodedev.drive_type not in [MEDIA_CDROM, MEDIA_FLOPPY]:
|
||||
return None
|
||||
|
||||
drvtype = nodedev.drive_type
|
||||
|
@ -62,7 +62,7 @@ class vmmMediaDevice(vmmGObject):
|
|||
return obj
|
||||
|
||||
def __init__(self, path, key, has_media, media_label, media_key,
|
||||
nodedev_obj = None, media_type = MEDIA_CDROM):
|
||||
nodedev_obj=None, media_type=MEDIA_CDROM):
|
||||
vmmGObject.__init__(self)
|
||||
|
||||
self.path = path
|
||||
|
|
|
@ -109,7 +109,7 @@ class vmmNetwork(vmmLibvirtObject):
|
|||
gateway = IP(addrStr)
|
||||
|
||||
network = IP(gateway.int() & netmask.int())
|
||||
return IP(str(network)+ "/" + netmaskStr)
|
||||
return IP(str(network) + "/" + netmaskStr)
|
||||
|
||||
def get_ipv4_forward(self):
|
||||
xml = self.get_xml()
|
||||
|
|
|
@ -116,7 +116,7 @@ class vmmPreferences(vmmGObjectUI):
|
|||
self.window.get_widget("prefs-stats-update-interval").set_value(
|
||||
self.config.get_stats_update_interval())
|
||||
def refresh_history_length(self, ignore1=None, ignore2=None,
|
||||
ignore3=None,ignore4=None):
|
||||
ignore3=None, ignore4=None):
|
||||
self.window.get_widget("prefs-stats-history-len").set_value(
|
||||
self.config.get_stats_history_length())
|
||||
|
||||
|
@ -203,35 +203,35 @@ class vmmPreferences(vmmGObjectUI):
|
|||
except:
|
||||
defs['keysyms'].append(ev.keyval)
|
||||
|
||||
label.set_text( self.grabkeys_get_string(defs['keysyms']) )
|
||||
label.set_text(self.grabkeys_get_string(defs['keysyms']))
|
||||
|
||||
def grabkeys_dlg_release(self, src_ignore, ev, defs):
|
||||
label = defs['label']
|
||||
defs['keysyms'].remove(ev.keyval)
|
||||
label.set_text( self.grabkeys_get_string(defs['keysyms']) )
|
||||
label.set_text(self.grabkeys_get_string(defs['keysyms']))
|
||||
|
||||
def change_grab_keys(self, src_ignore):
|
||||
dialog = gtk.Dialog ( _("Configure grab key combination"),
|
||||
None,
|
||||
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
|
||||
(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
|
||||
gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
|
||||
label = gtk.Label( _("Please press desired grab key combination") )
|
||||
dialog = gtk.Dialog(_("Configure grab key combination"),
|
||||
None,
|
||||
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
|
||||
(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
|
||||
gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
|
||||
label = gtk.Label(_("Please press desired grab key combination"))
|
||||
dialog.set_size_request(325, 160)
|
||||
(dialog.get_content_area()).add(
|
||||
gtk.Label( _("You can now define grab keys by pressing them.\n"
|
||||
"To confirm your selection please click OK button\n"
|
||||
"while you have desired keys pressed.") )
|
||||
)
|
||||
gtk.Label(_("You can now define grab keys by pressing them.\n"
|
||||
"To confirm your selection please click OK button\n"
|
||||
"while you have desired keys pressed.")))
|
||||
|
||||
(dialog.get_content_area()).add(label)
|
||||
defs = { 'label': label, 'keysyms': [] }
|
||||
defs = {'label': label, 'keysyms': []}
|
||||
dialog.connect("key-press-event", self.grabkeys_dlg_press, defs)
|
||||
dialog.connect("key-release-event", self.grabkeys_dlg_release, defs)
|
||||
dialog.show_all()
|
||||
result = dialog.run()
|
||||
|
||||
if result == gtk.RESPONSE_ACCEPT:
|
||||
self.config.set_keys_combination( defs['keysyms'] )
|
||||
self.config.set_keys_combination(defs['keysyms'])
|
||||
|
||||
self.refresh_grabkeys_combination()
|
||||
dialog.destroy()
|
||||
|
|
|
@ -42,12 +42,12 @@ class vmmSecret:
|
|||
return self.attributes
|
||||
|
||||
def has_attribute(self, key):
|
||||
return self.attributes.has_key(key)
|
||||
return key in self.attributes
|
||||
|
||||
def add_attribute(self, key, value):
|
||||
if type(value) != str:
|
||||
value = str(value)
|
||||
|
||||
|
||||
self.attributes[key] = value
|
||||
|
||||
def list_attributes(self):
|
||||
|
|
|
@ -75,7 +75,7 @@ class vmmSerialConsole(gtk.HBox):
|
|||
self.closetty()
|
||||
|
||||
def vm_status_changed(self, src_ignore, oldstatus_ignore, status):
|
||||
if status in [ libvirt.VIR_DOMAIN_RUNNING ]:
|
||||
if status in [libvirt.VIR_DOMAIN_RUNNING]:
|
||||
self.opentty()
|
||||
else:
|
||||
self.closetty()
|
||||
|
@ -142,4 +142,3 @@ class vmmSerialConsole(gtk.HBox):
|
|||
else:
|
||||
self.closetty()
|
||||
return False
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ class vmmStoragePool(vmmLibvirtObject):
|
|||
new_vol_list = {}
|
||||
|
||||
for volname in vols:
|
||||
if self._volumes.has_key(volname):
|
||||
if volname in self._volumes:
|
||||
new_vol_list[volname] = self._volumes[volname]
|
||||
else:
|
||||
new_vol_list[volname] = vmmStorageVolume(self.connection,
|
||||
|
@ -141,9 +141,9 @@ class vmmStoragePool(vmmLibvirtObject):
|
|||
|
||||
|
||||
def _prettyify(self, val):
|
||||
if val > (1024*1024*1024):
|
||||
return "%2.2f GB" % (val/(1024.0*1024.0*1024.0))
|
||||
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))
|
||||
return "%2.2f MB" % (val / (1024.0 * 1024.0))
|
||||
|
||||
vmmLibvirtObject.type_register(vmmStoragePool)
|
||||
|
|
|
@ -23,7 +23,7 @@ import virtinst.util as util
|
|||
from virtManager.libvirtobject import vmmLibvirtObject
|
||||
|
||||
class vmmStorageVolume(vmmLibvirtObject):
|
||||
__gsignals__ = { }
|
||||
__gsignals__ = {}
|
||||
|
||||
def __init__(self, connection, vol, name):
|
||||
vmmLibvirtObject.__init__(self, connection)
|
||||
|
@ -49,15 +49,15 @@ class vmmStorageVolume(vmmLibvirtObject):
|
|||
del(self.vol)
|
||||
|
||||
def get_target_path(self):
|
||||
return util.get_xml_path(self.get_xml(),"/volume/target/path")
|
||||
return util.get_xml_path(self.get_xml(), "/volume/target/path")
|
||||
|
||||
def get_format(self):
|
||||
return util.get_xml_path(self.get_xml(),"/volume/target/format/@type")
|
||||
return util.get_xml_path(self.get_xml(), "/volume/target/format/@type")
|
||||
|
||||
def get_allocation(self):
|
||||
return long(util.get_xml_path(self.get_xml(),"/volume/allocation"))
|
||||
return long(util.get_xml_path(self.get_xml(), "/volume/allocation"))
|
||||
def get_capacity(self):
|
||||
return long(util.get_xml_path(self.get_xml(),"/volume/capacity"))
|
||||
return long(util.get_xml_path(self.get_xml(), "/volume/capacity"))
|
||||
|
||||
def get_pretty_capacity(self):
|
||||
return self._prettyify(self.get_capacity())
|
||||
|
@ -65,12 +65,12 @@ class vmmStorageVolume(vmmLibvirtObject):
|
|||
return self._prettyify(self.get_allocation())
|
||||
|
||||
def get_type(self):
|
||||
return util.get_xml_path(self.get_xml(),"/volume/format/@type")
|
||||
return util.get_xml_path(self.get_xml(), "/volume/format/@type")
|
||||
|
||||
def _prettyify(self, val):
|
||||
if val > (1024*1024*1024):
|
||||
return "%2.2f GB" % (val/(1024.0*1024.0*1024.0))
|
||||
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))
|
||||
return "%2.2f MB" % (val / (1024.0 * 1024.0))
|
||||
|
||||
vmmLibvirtObject.type_register(vmmStorageVolume)
|
||||
|
|
|
@ -61,9 +61,9 @@ class vmmSystray(vmmGObject):
|
|||
"action-show-host": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, [str]),
|
||||
"action-show-details": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, (str,str)),
|
||||
gobject.TYPE_NONE, (str, str)),
|
||||
"action-show-console": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, (str,str)),
|
||||
gobject.TYPE_NONE, (str, str)),
|
||||
"action-exit-app": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, []),
|
||||
}
|
||||
|
@ -133,11 +133,11 @@ class vmmSystray(vmmGObject):
|
|||
return
|
||||
|
||||
if self.systray_indicator:
|
||||
self.systray_icon = appindicator.Indicator ("virt-manager",
|
||||
self.systray_icon = appindicator.Indicator("virt-manager",
|
||||
"virt-manager-icon",
|
||||
appindicator.CATEGORY_OTHER)
|
||||
self.systray_icon.set_status (appindicator.STATUS_ACTIVE)
|
||||
self.systray_icon.set_menu (self.systray_menu)
|
||||
self.systray_icon.set_status(appindicator.STATUS_ACTIVE)
|
||||
self.systray_icon.set_menu(self.systray_menu)
|
||||
|
||||
else:
|
||||
iconfile = self.config.get_icon_dir() + "/virt-manager-icon.svg"
|
||||
|
@ -158,9 +158,9 @@ class vmmSystray(vmmGObject):
|
|||
else:
|
||||
if self.systray_indicator:
|
||||
if do_show:
|
||||
self.systray_icon.set_status (appindicator.STATUS_ACTIVE)
|
||||
self.systray_icon.set_status(appindicator.STATUS_ACTIVE)
|
||||
else:
|
||||
self.systray_icon.set_status (appindicator.STATUS_PASSIVE)
|
||||
self.systray_icon.set_status(appindicator.STATUS_PASSIVE)
|
||||
else:
|
||||
self.systray_icon.set_visible(do_show)
|
||||
|
||||
|
@ -250,8 +250,8 @@ class vmmSystray(vmmGObject):
|
|||
uuid = vm.get_uuid()
|
||||
uri = vm.get_connection().get_uri()
|
||||
|
||||
if self.conn_vm_menuitems.has_key(uri):
|
||||
if self.conn_vm_menuitems[uri].has_key(uuid):
|
||||
if uri in self.conn_vm_menuitems:
|
||||
if uuid in self.conn_vm_menuitems[uri]:
|
||||
return self.conn_vm_menuitems[uri][uuid]
|
||||
return None
|
||||
|
||||
|
@ -294,7 +294,7 @@ class vmmSystray(vmmGObject):
|
|||
conn.connect("vm-removed", self.vm_removed)
|
||||
conn.connect("state-changed", self.conn_state_changed)
|
||||
|
||||
if self.conn_menuitems.has_key(conn.get_uri()):
|
||||
if conn.get_uri() in self.conn_menuitems:
|
||||
return
|
||||
|
||||
menu_item = gtk.MenuItem(conn.get_pretty_desc_inactive(), False)
|
||||
|
@ -312,7 +312,7 @@ class vmmSystray(vmmGObject):
|
|||
self.populate_vm_list(conn)
|
||||
|
||||
def conn_removed(self, engine_ignore, conn):
|
||||
if not self.conn_menuitems.has_key(conn.get_uri()):
|
||||
if conn.get_uri() in self.conn_menuitems:
|
||||
return
|
||||
|
||||
menu_item = self.conn_menuitems[conn.get_uri()]
|
||||
|
@ -353,7 +353,7 @@ class vmmSystray(vmmGObject):
|
|||
for i in range(0, len(vm_names)):
|
||||
name = vm_names[i]
|
||||
uuid = vm_mappings[name]
|
||||
if self.conn_vm_menuitems[uri].has_key(uuid):
|
||||
if uuid in self.conn_vm_menuitems[uri]:
|
||||
vm_item = self.conn_vm_menuitems[uri][uuid]
|
||||
vm_submenu.insert(vm_item, i)
|
||||
|
||||
|
@ -364,7 +364,7 @@ class vmmSystray(vmmGObject):
|
|||
vm.connect("status-changed", self.vm_state_changed)
|
||||
|
||||
vm_mappings = self.conn_vm_menuitems[uri]
|
||||
if vm_mappings.has_key(uuid):
|
||||
if uuid in vm_mappings:
|
||||
return
|
||||
|
||||
# Build VM list entry
|
||||
|
@ -386,7 +386,7 @@ class vmmSystray(vmmGObject):
|
|||
if not vm_mappings:
|
||||
return
|
||||
|
||||
if vm_mappings.has_key(uuid):
|
||||
if uuid in vm_mappings:
|
||||
conn_item = self.conn_menuitems[uri]
|
||||
vm_menu_item = vm_mappings[uuid]
|
||||
vm_menu = conn_item.get_submenu()
|
||||
|
|
|
@ -20,7 +20,8 @@
|
|||
|
||||
import logging
|
||||
import traceback
|
||||
import os, statvfs
|
||||
import os
|
||||
import statvfs
|
||||
|
||||
import libvirt
|
||||
import gtk
|
||||
|
@ -215,7 +216,7 @@ def populate_netmodel_combo(vm, combo):
|
|||
# [xml value, label]
|
||||
model.append([None, _("Hypervisor default")])
|
||||
if vm.is_hvm():
|
||||
mod_list = [ "rtl8139", "ne2k_pci", "pcnet" ]
|
||||
mod_list = ["rtl8139", "ne2k_pci", "pcnet"]
|
||||
if vm.get_hv_type() == "kvm":
|
||||
mod_list.append("e1000")
|
||||
mod_list.append("virtio")
|
||||
|
@ -343,7 +344,7 @@ def populate_network_list(net_list, conn):
|
|||
|
||||
label = pretty_network_desc(nettype, net.get_name(), net)
|
||||
if not net.is_active():
|
||||
label += " (%s)" % _("Inactive")
|
||||
label += " (%s)" % _("Inactive")
|
||||
|
||||
hasNet = True
|
||||
# FIXME: Should we use 'default' even if it's inactive?
|
||||
|
@ -386,7 +387,7 @@ def populate_network_list(net_list, conn):
|
|||
brlabel = _("(Empty bridge)")
|
||||
else:
|
||||
sensitive = False
|
||||
brlabel = "(%s)" % _("Not bridged")
|
||||
brlabel = "(%s)" % _("Not bridged")
|
||||
|
||||
label = _("Host device %s %s") % (br.get_name(), brlabel)
|
||||
if hasShared and not brIdxLabel:
|
||||
|
@ -477,12 +478,12 @@ def validate_network(parent, conn, nettype, devname, macaddr, model=None):
|
|||
elif nettype == VirtualNetworkInterface.TYPE_USER:
|
||||
pass
|
||||
|
||||
net = VirtualNetworkInterface(conn = conn.vmm,
|
||||
type = nettype,
|
||||
bridge = bridge,
|
||||
network = netname,
|
||||
macaddr = macaddr,
|
||||
model = model)
|
||||
net = VirtualNetworkInterface(conn=conn.vmm,
|
||||
type=nettype,
|
||||
bridge=bridge,
|
||||
network=netname,
|
||||
macaddr=macaddr,
|
||||
model=model)
|
||||
except Exception, e:
|
||||
return err_dial.val_err(_("Error with network parameters."), str(e))
|
||||
|
||||
|
@ -565,7 +566,7 @@ def mediadev_removed(ignore_helper, key, widget):
|
|||
del(model[idx])
|
||||
|
||||
if idx > active and active != -1:
|
||||
widget.set_active(active-1)
|
||||
widget.set_active(active - 1)
|
||||
elif idx == active:
|
||||
widget.set_active(-1)
|
||||
|
||||
|
@ -746,4 +747,3 @@ def build_startmode_combo(start_list):
|
|||
start_model.append(["none"])
|
||||
start_model.append(["onboot"])
|
||||
start_model.append(["hotplug"])
|
||||
|
||||
|
|
|
@ -393,4 +393,3 @@ def iface_in_use_by(conn, name):
|
|||
use_str += iface.get_name()
|
||||
|
||||
return use_str
|
||||
|
||||
|
|
|
@ -6,7 +6,12 @@ cp src/virt-manager.py.in src/_virt-manager
|
|||
cd src || exit 1
|
||||
|
||||
IGNOREFILES="IPy.py"
|
||||
FILES="virtManager/ _virt-manager"
|
||||
|
||||
##################
|
||||
# pylint Section #
|
||||
##################
|
||||
|
||||
PYLINT_FILES="virtManager/ _virt-manager"
|
||||
|
||||
# Deliberately ignored warnings:
|
||||
# Don't print pylint config warning
|
||||
|
@ -79,7 +84,8 @@ SHOW_REPORT="n"
|
|||
AWK=awk
|
||||
[ `uname -s` = 'SunOS' ] && AWK=nawk
|
||||
|
||||
pylint --ignore=$IGNOREFILES $FILES \
|
||||
echo "Running pylint"
|
||||
pylint --ignore=$IGNOREFILES $PYLINT_FILES \
|
||||
--reports=$SHOW_REPORT \
|
||||
--output-format=colorized \
|
||||
--dummy-variables-rgx="dummy|ignore.*|.*_ignore" \
|
||||
|
@ -112,5 +118,31 @@ BEGIN { found=0; cur_line="" }
|
|||
}
|
||||
}'
|
||||
|
||||
################
|
||||
# pep8 section #
|
||||
################
|
||||
|
||||
SKIP_PEP8=""
|
||||
skip_pep8() {
|
||||
if [ ! -z ${SKIP_PEP8} ] ; then
|
||||
SKIP_PEP8="${SKIP_PEP8},"
|
||||
fi
|
||||
SKIP_PEP8="${SKIP_PEP8}$1"
|
||||
}
|
||||
|
||||
skip_pep8 "E203" # Space before : in dictionary defs
|
||||
skip_pep8 "E221" # Multiple spaces before operator (warns
|
||||
# about column aligning assigments
|
||||
skip_pep8 "E241" # Space after , column alignment nono
|
||||
skip_pep8 "E261" # 2 spaces before inline comment?
|
||||
skip_pep8 "E301" # 1 blank line between methods
|
||||
skip_pep8 "E302" # 2 blank lines between function defs
|
||||
skip_pep8 "E303" # Too many blank lines
|
||||
skip_pep8 "E501" # Line too long
|
||||
|
||||
echo "Running pep8"
|
||||
pep8 -r --exclude=$IGNOREFILES --ignore $SKIP_PEP8 \
|
||||
virt-manager.py.in virtManager/*.py
|
||||
|
||||
cd - > /dev/null
|
||||
rm src/_virt-manager
|
||||
|
|
Loading…
Reference in New Issue