Merge branch 'master' of ssh://git.qubes-os.org/var/lib/qubes/git/joanna/qubes-manager

This commit is contained in:
Marek Marczykowski 2011-04-06 22:16:04 +02:00
commit a880c52881
3 changed files with 70 additions and 48 deletions

View File

@ -1,14 +1,15 @@
RPMS_DIR=rpm/
VERSION := $(shell cat version)
help:
@echo "make rpms -- generate binary rpm packages"
@echo "make res -- compile resources"
@echo "make update-repo -- copy newly generated rpms to qubes yum repo"
@echo "make update-repo-testing -- same, but to -testing repo"
@echo "make rpms -- generate binary rpm packages"
@echo "make res -- compile resources"
@echo "make update-repo-current -- copy newly generated rpms to qubes yum repo"
@echo "make update-repo-unstable -- same, but to -testing repo"
rpms:
rpmbuild --define "_rpmdir $(RPMS_DIR)" -bb rpm_spec/qmgr.spec
rpm --addsign $(RPMS_DIR)/x86_64/*.rpm
rpm --addsign $(RPMS_DIR)/x86_64/qubes-manager*$(VERSION)*.rpm
res:
pyrcc4 -o qubesmanager/qrc_resources.py resources.qrc
@ -16,9 +17,8 @@ res:
pyuic4 -o qubesmanager/ui_editfwrulesdlg.py editfwrulesdlg.ui
pyuic4 -o qubesmanager/ui_newfwruledlg.py newfwruledlg.ui
update-repo:
ln -f $(RPMS_DIR)/x86_64/qubes-manager-*.rpm ../yum/r1/dom0/rpm/
update-repo-testing:
ln -f $(RPMS_DIR)/x86_64/qubes-manager-*.rpm ../yum/r1-testing/dom0/rpm/
update-repo-current:
ln -f $(RPMS_DIR)/x86_64/qubes-manager-*$(VERSION)*.rpm ../yum/current-release/current/dom0/rpm/
update-repo-unstable:
ln -f $(RPMS_DIR)/x86_64/qubes-manager-*$(VERSION)*.rpm ../yum/current-release/unstable/dom0/rpm/

View File

@ -60,14 +60,14 @@ class VmStatusIcon(QLabel):
(icon_pixmap, icon_sz) = self.set_vm_icon(self.vm)
self.setPixmap (icon_pixmap)
self.setFixedSize (icon_sz)
self.previous_power_state = vm.is_running()
self.previous_power_state = vm.last_power_state
def update(self):
if self.previous_power_state != self.vm.is_running():
if self.previous_power_state != self.vm.last_power_state:
(icon_pixmap, icon_sz) = self.set_vm_icon(self.vm)
self.setPixmap (icon_pixmap)
self.setFixedSize (icon_sz)
self.previous_power_state = self.vm.is_running()
self.previous_power_state = self.vm.last_power_state
def set_vm_icon(self, vm):
if vm.qid == 0:
@ -82,7 +82,7 @@ class VmStatusIcon(QLabel):
icon = QIcon()
icon_sz = QSize (VmManagerWindow.row_height * 0.8, VmManagerWindow.row_height * 0.8)
if vm.is_running():
if vm.last_power_state:
icon_pixmap = icon.pixmap(icon_sz)
else:
icon_pixmap = icon.pixmap(icon_sz, QIcon.Disabled)
@ -99,7 +99,7 @@ class VmInfoWidget (QWidget):
self.label_name = QLabel (vm.name)
self.vm_running = vm.is_running()
self.vm_running = vm.last_power_state
layout0.addWidget(self.label_name, alignment=Qt.AlignLeft)
layout1 = QHBoxLayout()
@ -171,7 +171,8 @@ class VmUsageWidget (QWidget):
self.cpu_widget.setMinimum(0)
self.cpu_widget.setMaximum(100)
self.mem_widget.setMinimum(0)
self.mem_widget.setMaximum(100)
self.mem_widget.setMaximum(qubes_host.memory_total/(1024*1024))
self.mem_widget.setFormat ("%v MB");
self.cpu_label = QLabel("CPU")
self.mem_label = QLabel("MEM")
@ -192,10 +193,8 @@ class VmUsageWidget (QWidget):
self.update_load(vm)
def update_load(self, vm):
self.cpu_load = vm.get_cpu_total_load() if vm.is_running() else 0
assert self.cpu_load >= 0 and self.cpu_load <= 100, "load = {0}".format(self.load)
self.mem_load = vm.get_mem()*100/qubes_host.memory_total if vm.is_running() else 0
assert self.mem_load >= 0 and self.mem_load <= 100, "mem = {0}".format(self.load)
self.cpu_load = vm.get_cpu_total_load() if vm.last_power_state else 0
self.mem_load = vm.get_mem()/(1024*1024) if vm.last_power_state else 0
self.cpu_widget.setValue(self.cpu_load)
self.mem_widget.setValue(self.mem_load)
@ -210,12 +209,12 @@ class LoadChartWidget (QWidget):
def __init__(self, vm, parent = None):
super (LoadChartWidget, self).__init__(parent)
self.load = vm.get_cpu_total_load() if vm.is_running() else 0
self.load = vm.get_cpu_total_load() if vm.last_power_state else 0
assert self.load >= 0 and self.load <= 100, "load = {0}".format(self.load)
self.load_history = [self.load]
def update_load (self, vm):
self.load = vm.get_cpu_total_load() if vm.is_running() else 0
self.load = vm.get_cpu_total_load() if vm.last_power_state else 0
assert self.load >= 0 and self.load <= 100, "load = {0}".format(self.load)
self.load_history.append (self.load)
self.repaint()
@ -249,12 +248,12 @@ class MemChartWidget (QWidget):
def __init__(self, vm, parent = None):
super (MemChartWidget, self).__init__(parent)
self.load = vm.get_mem()*100/qubes_host.memory_total if vm.is_running() else 0
self.load = vm.get_mem()*100/qubes_host.memory_total if vm.last_power_state else 0
assert self.load >= 0 and self.load <= 100, "mem = {0}".format(self.load)
self.load_history = [self.load]
def update_load (self, vm):
self.load = vm.get_mem()*100/qubes_host.memory_total if vm.is_running() else 0
self.load = vm.get_mem()*100/qubes_host.memory_total if vm.last_power_state else 0
assert self.load >= 0 and self.load <= 100, "load = {0}".format(self.load)
self.load_history.append (self.load)
self.repaint()
@ -390,7 +389,7 @@ class VmManagerWindow(QMainWindow):
self.action_updatevm = self.createAction ("Commit VM changes", slot=self.update_vm,
icon="updateable", tip="Commit changes to template (only for 'updateable' template VMs); VM must be stopped")
self.action_showallvms = self.createAction ("Show/Hide Inactive VMs", slot=None, checkable=True,
self.action_showallvms = self.createAction ("Show/Hide Inactive VMs", slot=self.toggle_inactive_view, checkable=True,
icon="showallvms", tip="Show/Hide Inactive VMs")
self.action_showcpuload = self.createAction ("Show/Hide CPU Load chart", slot=self.showcpuload, checkable=True,
@ -410,10 +409,11 @@ class VmManagerWindow(QMainWindow):
self.toolbar.setFloatable(False)
self.addActions (self.toolbar, (self.action_createvm, self.action_removevm,
None,
self.action_resumevm, self.action_pausevm, self.action_shutdownvm,
self.action_resumevm, self.action_shutdownvm,
self.action_updatevm, self.action_editfwrules,
None,
self.action_showcpuload,
self.action_showallvms,
))
self.table = QTableWidget()
@ -441,10 +441,15 @@ class VmManagerWindow(QMainWindow):
self.connect(self.table, SIGNAL("itemSelectionChanged()"), self.table_selection_changed)
self.setFixedWidth (self.get_minimum_table_width())
self.fill_table()
tbl_W = self.get_minimum_table_width()
self.counter = 0
self.shutdown_monitor = {}
QTimer.singleShot (self.update_interval, self.update_table)
QTimer.singleShot (self.fw_rules_apply_check_interval, self.check_apply_fw_rules)
def set_table_geom_height(self):
# TODO: '6' -- WTF?!
tbl_H = self.toolbar.height() + 6 + \
self.table.horizontalHeader().height() + 6
@ -455,12 +460,8 @@ class VmManagerWindow(QMainWindow):
for i in range (0, n):
tbl_H += self.table.rowHeight(i)
self.setGeometry(self.x(), self.y(), self.x() + tbl_W, self.y() + tbl_H)
self.setFixedHeight(tbl_H)
self.counter = 0
self.shutdown_monitor = {}
QTimer.singleShot (self.update_interval, self.update_table)
QTimer.singleShot (self.fw_rules_apply_check_interval, self.check_apply_fw_rules)
def addActions(self, target, actions):
for action in actions:
@ -492,10 +493,9 @@ class VmManagerWindow(QMainWindow):
self.qvm_collection.load()
self.qvm_collection.unlock_db()
if self.show_inactive_vms:
vms_list = [vm for vm in self.qvm_collection.values() if not vm.internal]
else:
vms_list = [vm for vm in self.qvm_collection.values() if not vm.internal and vm.is_running()]
vms_list = [vm for vm in self.qvm_collection.values()]
for vm in vms_list:
vm.last_power_state = vm.is_running()
no_vms = len (vms_list)
vms_to_display = []
@ -526,10 +526,18 @@ class VmManagerWindow(QMainWindow):
vms_in_table = []
for (row_no, vm) in enumerate(vms_list):
row_no = 0
for vm in vms_list:
if (not self.show_inactive_vms) and (not vm.last_power_state):
continue
if vm.internal:
continue
vm_row = VmRowInTable (vm, row_no, self.table)
vms_in_table.append (vm_row)
row_no += 1
self.table.setRowCount(row_no)
self.set_table_geom_height()
self.vms_list = vms_list
self.vms_in_table = vms_in_table
self.reload_table = False
@ -540,13 +548,22 @@ class VmManagerWindow(QMainWindow):
# When calling update_table() directly, always use out_of_schedule=True!
def update_table(self, out_of_schedule=False):
if self.reload_table:
self.fill_table()
for vm_row in self.vms_in_table:
vm_row.update(self.counter)
if manager_window.isVisible():
some_vms_have_changed_power_state = False
for vm in self.vms_list:
state = vm.is_running();
if vm.last_power_state != state:
vm.last_power_state = state
some_vms_have_changed_power_state = True
self.table_selection_changed()
if self.reload_table or ((not self.show_inactive_vms) and some_vms_have_changed_power_state):
self.fill_table()
for vm_row in self.vms_in_table:
vm_row.update(self.counter)
self.table_selection_changed()
if not out_of_schedule:
self.counter += 1
@ -567,11 +584,11 @@ class VmManagerWindow(QMainWindow):
# Update available actions:
self.action_removevm.setEnabled(not vm.installed_by_rpm and not vm.is_running())
self.action_resumevm.setEnabled(not vm.is_running())
self.action_pausevm.setEnabled(vm.is_running() and vm.qid != 0)
self.action_shutdownvm.setEnabled(vm.is_running() and vm.qid != 0)
self.action_updatevm.setEnabled(vm.is_updateable() and not vm.is_running())
self.action_removevm.setEnabled(not vm.installed_by_rpm and not vm.last_power_state)
self.action_resumevm.setEnabled(not vm.last_power_state)
self.action_pausevm.setEnabled(vm.last_power_state and vm.qid != 0)
self.action_shutdownvm.setEnabled(vm.last_power_state and vm.qid != 0)
self.action_updatevm.setEnabled(vm.is_updateable() and not vm.last_power_state)
self.action_editfwrules.setEnabled(vm.is_networked() and not (vm.is_netvm() and not vm.is_proxyvm()))
def get_minimum_table_width(self):
@ -847,6 +864,11 @@ class VmManagerWindow(QMainWindow):
self.__cpugraphs = self.action_showcpuload.isChecked()
self.update_table_columns()
def toggle_inactive_view(self):
self.show_inactive_vms = self.action_showallvms.isChecked()
self.mark_table_for_update()
self.update_table(out_of_schedule = True)
def edit_fw_rules(self):
vm = self.get_selected_vm()
dialog = EditFwRulesDlg()

View File

@ -1 +1 @@
1.0.4
1.0.7