From a72003f44b8ce1cfe6b64c01a5e139126a1afccc Mon Sep 17 00:00:00 2001 From: unman Date: Thu, 26 Jan 2017 20:36:39 +0000 Subject: [PATCH] Add extended information and Network diagram to Manager --- Makefile | 2 + about.ui | 14 +++++++ informationnotes.ui | 67 ++++++++++++++++++++++++++++++++ networknotes.ui | 67 ++++++++++++++++++++++++++++++++ qubesmanager/about.py | 16 ++++++++ qubesmanager/informationnotes.py | 37 ++++++++++++++++++ qubesmanager/networknotes.py | 37 ++++++++++++++++++ qubesmanager/qvm_about.sh | 11 ++++++ qubesmanager/qvm_net.py | 39 +++++++++++++++++++ rpm_spec/qmgr.spec | 26 ++++++++++++- 10 files changed, 314 insertions(+), 2 deletions(-) create mode 100644 informationnotes.ui create mode 100644 networknotes.ui create mode 100644 qubesmanager/informationnotes.py create mode 100644 qubesmanager/networknotes.py create mode 100755 qubesmanager/qvm_about.sh create mode 100755 qubesmanager/qvm_net.py diff --git a/Makefile b/Makefile index 3563e89..99e09d3 100644 --- a/Makefile +++ b/Makefile @@ -29,6 +29,8 @@ res: pyuic4 -o qubesmanager/ui_logdlg.py logdlg.ui pyuic4 -o qubesmanager/ui_about.py about.ui pyuic4 -o qubesmanager/ui_releasenotes.py releasenotes.ui + pyuic4 -o qubesmanager/ui_informationnotes.py informationnotes.ui + pyuic4 -o qubesmanager/ui_networknotes.py networknotes.ui update-repo-current: ln -f $(RPMS_DIR)/x86_64/qubes-manager-*$(VERSION)*.rpm ../yum/current-release/current/dom0/rpm/ diff --git a/about.ui b/about.ui index 97f944f..623877c 100644 --- a/about.ui +++ b/about.ui @@ -81,6 +81,20 @@ + + + + Version Information + + + + + + + Qubes Networking + + + diff --git a/informationnotes.ui b/informationnotes.ui new file mode 100644 index 0000000..fd9925a --- /dev/null +++ b/informationnotes.ui @@ -0,0 +1,67 @@ + + + InformationNotesDialog + + + + 0 + 0 + 600 + 600 + + + + More Information + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + InformationNotesDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + InformationNotesDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/networknotes.ui b/networknotes.ui new file mode 100644 index 0000000..17633be --- /dev/null +++ b/networknotes.ui @@ -0,0 +1,67 @@ + + + NetworkNotesDialog + + + + 0 + 0 + 400 + 600 + + + + Qubes Networking + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + NetworkNotesDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + NetworkNotesDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/qubesmanager/about.py b/qubesmanager/about.py index 5e7dbd6..fa45328 100644 --- a/qubesmanager/about.py +++ b/qubesmanager/about.py @@ -24,6 +24,8 @@ from PyQt4.QtCore import SIGNAL, SLOT from PyQt4.QtGui import QDialog, QIcon from qubesmanager.releasenotes import ReleaseNotesDialog +from qubesmanager.informationnotes import InformationNotesDialog +from qubesmanager.networknotes import NetworkNotesDialog from ui_about import * @@ -42,8 +44,22 @@ class AboutDialog(Ui_AboutDialog, QDialog): self.connect(self.ok, SIGNAL("clicked()"), SLOT("accept()")) self.connect(self.releaseNotes, SIGNAL("clicked()"), self.on_release_notes_clicked) + self.connect(self.informationNotes, SIGNAL("clicked()"), + self.on_information_notes_clicked) + self.connect(self.networkNotes, SIGNAL("clicked()"), + self.on_network_notes_clicked) def on_release_notes_clicked(self): release_notes_dialog = ReleaseNotesDialog() release_notes_dialog.exec_() self.accept() + + def on_information_notes_clicked(self): + information_notes_dialog = InformationNotesDialog() + information_notes_dialog.exec_() + self.accept() + + def on_network_notes_clicked(self): + network_notes_dialog = NetworkNotesDialog() + network_notes_dialog.exec_() + self.accept() diff --git a/qubesmanager/informationnotes.py b/qubesmanager/informationnotes.py new file mode 100644 index 0000000..2da4811 --- /dev/null +++ b/qubesmanager/informationnotes.py @@ -0,0 +1,37 @@ +#!/usr/bin/python2 +# coding=utf-8 +# +# The Qubes OS Project, http://www.qubes-os.org +# +# Copyright (C) 2015 Marek Marczykowski-Górecki +# +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# +from PyQt4.QtCore import SIGNAL +from PyQt4.QtGui import QDialog, QIcon + +from ui_informationnotes import * +import subprocess + + +class InformationNotesDialog(Ui_InformationNotesDialog, QDialog): + def __init__(self): + super(InformationNotesDialog, self).__init__() + + self.setupUi(self) + details = subprocess.check_output(['/usr/libexec/qubes-manager/qvm_about.sh']) + self.informationNotes.setText(details) diff --git a/qubesmanager/networknotes.py b/qubesmanager/networknotes.py new file mode 100644 index 0000000..2133c41 --- /dev/null +++ b/qubesmanager/networknotes.py @@ -0,0 +1,37 @@ +#!/usr/bin/python2 +# coding=utf-8 +# +# The Qubes OS Project, http://www.qubes-os.org +# +# Copyright (C) 2015 Marek Marczykowski-Górecki +# +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# +from PyQt4.QtCore import SIGNAL +from PyQt4.QtGui import QDialog, QIcon + +from ui_networknotes import * +import subprocess + + +class NetworkNotesDialog(Ui_NetworkNotesDialog, QDialog): + def __init__(self): + super(NetworkNotesDialog, self).__init__() + + self.setupUi(self) + details = subprocess.check_output(['/usr/libexec/qubes-manager/qvm_net.py']) + self.networkNotes.setText(details) diff --git a/qubesmanager/qvm_about.sh b/qubesmanager/qvm_about.sh new file mode 100755 index 0000000..aec0282 --- /dev/null +++ b/qubesmanager/qvm_about.sh @@ -0,0 +1,11 @@ +#!/usr/bin/sh +xl info|grep xen_version +uname -sr +echo " " +echo "Installed Packages: " +echo " " +dnf list installed |awk '$1~/qubes/ && $1!~/@qubes*/ { printf "%-50s\t%s \n",$1 ,$2}' + + + + diff --git a/qubesmanager/qvm_net.py b/qubesmanager/qvm_net.py new file mode 100755 index 0000000..cd67200 --- /dev/null +++ b/qubesmanager/qvm_net.py @@ -0,0 +1,39 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +""" +Show network tree + +@author: unman +""" + +from qubes.qubes import QubesVmCollection +qvm_collection = QubesVmCollection() +qvm_collection.lock_db_for_reading() +qvm_collection.load() +qvm_collection.unlock_db() +qvm_collection.pop(0) + +def tree(netvm, padding): + names={} + padding = padding + ' ' + connected = netvm.connected_vms + for i in connected: + names[i] = connected[i].name + for name in sorted(names.values()): + vm = qvm_collection.get_qid_by_name(name) + if qvm_collection[vm].is_running(): + vm_name = qvm_collection[vm].name + '* ' + else: + vm_name = qvm_collection[vm].name + if qvm_collection[vm].is_template(): + print padding,'|->',vm_name,'(Tpl)' + else: + print padding,'|->',vm_name + if qvm_collection[vm].is_netvm() : + tree(qvm_collection[vm], padding) + +padding='' +for vm in qvm_collection: + if qvm_collection[vm].is_netvm() and not qvm_collection[vm].netvm : + print qvm_collection[vm].name + tree(qvm_collection[vm], padding) diff --git a/rpm_spec/qmgr.spec b/rpm_spec/qmgr.spec index ae64117..a32b003 100644 --- a/rpm_spec/qmgr.spec +++ b/rpm_spec/qmgr.spec @@ -35,6 +35,10 @@ cp qubes-vm-settings $RPM_BUILD_ROOT/usr/bin mkdir -p $RPM_BUILD_ROOT/usr/libexec/qubes-manager/ cp qubesmanager/mount_for_backup.sh $RPM_BUILD_ROOT/usr/libexec/qubes-manager/ +cp qubesmanager/qvm_about.sh $RPM_BUILD_ROOT/usr/libexec/qubes-manager/ +cp qubesmanager/qvm_net.py $RPM_BUILD_ROOT/usr/libexec/qubes-manager/ +cp qubesmanager/qvm_net.pyo $RPM_BUILD_ROOT/usr/libexec/qubes-manager/ +cp qubesmanager/qvm_net.pyc $RPM_BUILD_ROOT/usr/libexec/qubes-manager/ mkdir -p $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager/ cp qubesmanager/main.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager @@ -52,6 +56,8 @@ cp qubesmanager/settings.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager cp qubesmanager/log_dialog.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager cp qubesmanager/about.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager cp qubesmanager/releasenotes.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager +cp qubesmanager/informationnotes.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager +cp qubesmanager/networknotes.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager cp qubesmanager/create_new_vm.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager cp qubesmanager/thread_monitor.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager cp qubesmanager/resources_rc.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager @@ -67,6 +73,8 @@ cp qubesmanager/ui_settingsdlg.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesm cp qubesmanager/ui_logdlg.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager cp qubesmanager/ui_about.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager cp qubesmanager/ui_releasenotes.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager +cp qubesmanager/ui_informationnotes.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager +cp qubesmanager/ui_networknotes.py{,c,o} $RPM_BUILD_ROOT%{python_sitearch}/qubesmanager mkdir -p $RPM_BUILD_ROOT/usr/share/applications cp qubes-manager.desktop $RPM_BUILD_ROOT/usr/share/applications @@ -91,6 +99,10 @@ rm -rf $RPM_BUILD_ROOT /usr/bin/qubes-manager /usr/bin/qubes-vm-settings /usr/libexec/qubes-manager/mount_for_backup.sh +/usr/libexec/qubes-manager/qvm_about.sh +/usr/libexec/qubes-manager/qvm_net.py +/usr/libexec/qubes-manager/qvm_net.pyo +/usr/libexec/qubes-manager/qvm_net.pyc %dir %{python_sitearch}/qubesmanager %{python_sitearch}/qubesmanager/__init__.py %{python_sitearch}/qubesmanager/__init__.pyo @@ -140,6 +152,12 @@ rm -rf $RPM_BUILD_ROOT %{python_sitearch}/qubesmanager/releasenotes.py %{python_sitearch}/qubesmanager/releasenotes.pyc %{python_sitearch}/qubesmanager/releasenotes.pyo +%{python_sitearch}/qubesmanager/informationnotes.py +%{python_sitearch}/qubesmanager/informationnotes.pyc +%{python_sitearch}/qubesmanager/informationnotes.pyo +%{python_sitearch}/qubesmanager/networknotes.py +%{python_sitearch}/qubesmanager/networknotes.pyc +%{python_sitearch}/qubesmanager/networknotes.pyo %{python_sitearch}/qubesmanager/create_new_vm.py %{python_sitearch}/qubesmanager/create_new_vm.pyc %{python_sitearch}/qubesmanager/create_new_vm.pyo @@ -182,8 +200,12 @@ rm -rf $RPM_BUILD_ROOT %{python_sitearch}/qubesmanager/ui_releasenotes.py %{python_sitearch}/qubesmanager/ui_releasenotes.pyc %{python_sitearch}/qubesmanager/ui_releasenotes.pyo - - +%{python_sitearch}/qubesmanager/ui_informationnotes.py +%{python_sitearch}/qubesmanager/ui_informationnotes.pyc +%{python_sitearch}/qubesmanager/ui_informationnotes.pyo +%{python_sitearch}/qubesmanager/ui_networknotes.py +%{python_sitearch}/qubesmanager/ui_networknotes.pyc +%{python_sitearch}/qubesmanager/ui_networknotes.pyo /usr/share/applications/qubes-manager.desktop /etc/xdg/autostart/qubes-manager.desktop /etc/dbus-1/system.d/org.qubesos.QubesManager.conf