From f6f55314cbf2783f77d88187be3752653b8ce4da Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Thu, 18 Apr 2013 16:03:43 -0400 Subject: [PATCH] Remove virt-manager-tui Was originally added with hopes for being used in an ovirt related product, but was more or less a code dump, and the author has been allocated to other things. He confirmed it's okay to remove. That, and it's currently broken, and we've had approximately 0 user feedback since it was committed. --- MANIFEST.in | 1 - setup.py | 27 +- todo.txt | 1 - virt-manager | 3 - virt-manager-tui | 78 --- virt-manager.spec.in | 43 +- virtManager/baseclass.py | 8 +- virtManager/guidiff.py | 52 -- virtManagerTui/__init__.py | 19 - virtManagerTui/adddomain.py | 578 ---------------------- virtManagerTui/addhost.py | 155 ------ virtManagerTui/addnetwork.py | 262 ---------- virtManagerTui/addpool.py | 179 ------- virtManagerTui/addvolume.py | 196 -------- virtManagerTui/changehost.py | 67 --- virtManagerTui/createmeter.py | 31 -- virtManagerTui/createuser.py | 115 ----- virtManagerTui/domainconfig.py | 226 --------- virtManagerTui/domainlistconfigscreen.py | 57 --- virtManagerTui/hostlistconfigscreen.py | 55 -- virtManagerTui/hostmenu.py | 50 -- virtManagerTui/libvirtworker.py | 545 -------------------- virtManagerTui/listdomains.py | 104 ---- virtManagerTui/listnetworks.py | 79 --- virtManagerTui/listpools.py | 70 --- virtManagerTui/mainmenu.py | 56 --- virtManagerTui/migratedomain.py | 91 ---- virtManagerTui/netmenu.py | 60 --- virtManagerTui/networkconfig.py | 112 ----- virtManagerTui/networklistconfigscreen.py | 57 --- virtManagerTui/nodeadmin.py | 29 -- virtManagerTui/nodemenu.py | 75 --- virtManagerTui/pausedomain.py | 74 --- virtManagerTui/poolconfig.py | 154 ------ virtManagerTui/removedomain.py | 96 ---- virtManagerTui/removehost.py | 73 --- virtManagerTui/removenetwork.py | 94 ---- virtManagerTui/removepool.py | 98 ---- virtManagerTui/removevolume.py | 84 ---- virtManagerTui/startdomain.py | 73 --- virtManagerTui/startnetwork.py | 62 --- virtManagerTui/startpool.py | 63 --- virtManagerTui/stopdomain.py | 73 --- virtManagerTui/stopnetwork.py | 65 --- virtManagerTui/stoppool.py | 63 --- virtManagerTui/storagelistconfigscreen.py | 80 --- virtManagerTui/storagemenu.py | 70 --- virtManagerTui/userworker.py | 39 -- virtManagerTui/vmmconfigscreen.py | 77 --- virtManagerTui/volumeconfig.py | 86 ---- virtcli/cliconfig.py | 2 - 51 files changed, 10 insertions(+), 4897 deletions(-) delete mode 100755 virt-manager-tui delete mode 100644 virtManager/guidiff.py delete mode 100644 virtManagerTui/__init__.py delete mode 100644 virtManagerTui/adddomain.py delete mode 100644 virtManagerTui/addhost.py delete mode 100644 virtManagerTui/addnetwork.py delete mode 100644 virtManagerTui/addpool.py delete mode 100644 virtManagerTui/addvolume.py delete mode 100644 virtManagerTui/changehost.py delete mode 100644 virtManagerTui/createmeter.py delete mode 100644 virtManagerTui/createuser.py delete mode 100644 virtManagerTui/domainconfig.py delete mode 100644 virtManagerTui/domainlistconfigscreen.py delete mode 100644 virtManagerTui/hostlistconfigscreen.py delete mode 100644 virtManagerTui/hostmenu.py delete mode 100644 virtManagerTui/libvirtworker.py delete mode 100644 virtManagerTui/listdomains.py delete mode 100644 virtManagerTui/listnetworks.py delete mode 100644 virtManagerTui/listpools.py delete mode 100644 virtManagerTui/mainmenu.py delete mode 100644 virtManagerTui/migratedomain.py delete mode 100644 virtManagerTui/netmenu.py delete mode 100644 virtManagerTui/networkconfig.py delete mode 100644 virtManagerTui/networklistconfigscreen.py delete mode 100644 virtManagerTui/nodeadmin.py delete mode 100644 virtManagerTui/nodemenu.py delete mode 100644 virtManagerTui/pausedomain.py delete mode 100644 virtManagerTui/poolconfig.py delete mode 100644 virtManagerTui/removedomain.py delete mode 100644 virtManagerTui/removehost.py delete mode 100644 virtManagerTui/removenetwork.py delete mode 100644 virtManagerTui/removepool.py delete mode 100644 virtManagerTui/removevolume.py delete mode 100644 virtManagerTui/startdomain.py delete mode 100644 virtManagerTui/startnetwork.py delete mode 100644 virtManagerTui/startpool.py delete mode 100644 virtManagerTui/stopdomain.py delete mode 100644 virtManagerTui/stopnetwork.py delete mode 100644 virtManagerTui/stoppool.py delete mode 100644 virtManagerTui/storagelistconfigscreen.py delete mode 100644 virtManagerTui/storagemenu.py delete mode 100644 virtManagerTui/userworker.py delete mode 100644 virtManagerTui/vmmconfigscreen.py delete mode 100644 virtManagerTui/volumeconfig.py diff --git a/MANIFEST.in b/MANIFEST.in index fe40530d..c5166ac6 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -12,7 +12,6 @@ recursive-include po * recursive-include tests * recursive-include ui * recursive-include virtManager * -recursive-include virtManagerTui * recursive-include virtcli * recursive-include virtconv * recursive-include virtinst * diff --git a/setup.py b/setup.py index 1665ffad..ab3073a1 100755 --- a/setup.py +++ b/setup.py @@ -33,12 +33,11 @@ def _generate_potfiles_in(): ret.sort(key=lambda s: s.lower()) return ret - scripts = ["virt-manager", "virt-manager-tui", "virt-install", + scripts = ["virt-manager", "virt-install", "virt-clone", "virt-image", "virt-convert"] potfiles = "\n".join(scripts) + "\n\n" potfiles += "\n".join(find("virtManager", "*.py")) + "\n\n" - potfiles += "\n".join(find("virtManagerTui", "*.py")) + "\n\n" potfiles += "\n".join(find("virtcli", "*.py")) + "\n\n" potfiles += "\n".join(find("virtconv", "*.py")) + "\n\n" potfiles += "\n".join(find("virtinst", "*.py")) + "\n\n" @@ -81,8 +80,6 @@ class my_build(build_extra): def _make_bin_wrappers(self): cmds = ["virt-manager", "virt-install", "virt-clone", "virt-image", "virt-convert"] - if cliconfig.with_tui: - cmds += ["virt-manager-tui"] if not os.path.exists("build"): os.mkdir("build") @@ -247,7 +244,6 @@ class configure(Command): user_options = [ ("pkgversion=", None, "user specified version-id"), ("prefix=", None, "installation prefix"), - ("without-tui", None, "don't install virt-manager-tui"), ("qemu-user=", None, "user libvirt uses to launch qemu processes (default=root)"), ("libvirt-package-names=", None, @@ -272,7 +268,6 @@ class configure(Command): pass def initialize_options(self): - self.without_tui = 0 self.qemu_user = "root" self.libvirt_package_names = "" self.kvm_package_names = "" @@ -289,7 +284,6 @@ class configure(Command): template += "[config]\n" template += "prefix = %s\n" % self.prefix template += "pkgversion = %s\n" % self.pkgversion - template += "with_tui = %s\n" % int(not self.without_tui) template += "default_qemu_user = %s\n" % self.qemu_user template += "libvirt_packages = %s\n" % self.libvirt_package_names template += "hv_packages = %s\n" % self.kvm_package_names @@ -303,16 +297,6 @@ class configure(Command): print "Generated %s" % cliconfig.cfgpath -tui_files = [ - ("share/virt-manager/", ["virt-manager-tui"]), - - ("share/virt-manager/virtManagerTui", - glob.glob("virtManagerTui/*.py")), -] -if not cliconfig.with_tui: - tui_files = [] - - class TestBaseCommand(Command): user_options = [('debug', 'd', 'Show debug output')] boolean_options = ['debug'] @@ -447,9 +431,9 @@ class CheckPylint(Command): def run(self): files = ["setup.py", "virt-install", "virt-clone", "virt-image", - "virt-convert", "virt-manager", "virt-manager-tui", + "virt-convert", "virt-manager", "virtcli", "virtinst", "virtconv", "virtManager", - "virtManagerTui", "tests"] + "tests"] output_format = sys.stdout.isatty() and "colorized" or "text" @@ -478,8 +462,7 @@ setup( "build/virt-clone", "build/virt-install", "build/virt-image", - "build/virt-convert"] + - (cliconfig.with_tui and ["build/virt-manager-tui"] or [])), + "build/virt-convert"]), data_files=[ ("share/virt-manager/", [ @@ -510,7 +493,7 @@ setup( ("share/virt-manager/virtconv", glob.glob("virtconv/*.py")), ("share/virt-manager/virtconv/parsers", glob.glob("virtconv/parsers/*.py")), - ] + tui_files, + ], cmdclass={ 'build': my_build, diff --git a/todo.txt b/todo.txt index ef24dce2..6e7802e9 100644 --- a/todo.txt +++ b/todo.txt @@ -4,7 +4,6 @@ revive import blacklist for virtinst code, maybe just a unittest that checks Gtk isn't in globals ? -is tui working? maybe just remove it, check with mcpierce gsettings port (or fix gconf bindings) website: wiki-ify the whole thing, drop static content, move site styling into virt-manager.git, kill the old web repo. and get that old hideous screenshot off the front page. linux-kvm.org should be the template here. consider dropping python-distutils-extra dep. I think we rely on about 300 diff --git a/virt-manager b/virt-manager index 4d7077e2..5a58b4b4 100755 --- a/virt-manager +++ b/virt-manager @@ -234,9 +234,6 @@ def main(): config.askpass_package = cliconfig.askpass_package config.default_graphics_from_config = cliconfig.default_graphics - import virtManager.guidiff - virtManager.guidiff.is_gui(True) - # Now we've got basic environment up & running we can fork if not options.nofork and not options.debug: drop_tty() diff --git a/virt-manager-tui b/virt-manager-tui deleted file mode 100755 index f7838151..00000000 --- a/virt-manager-tui +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/python - -# virt-manager-tui.py - Copyright (C) 2010 Red Hat, Inc. -# Written by Darryl L. Pierce, . -# -# 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. -# - -import logging -import optparse -import sys -import traceback - -from newt_syrup.dialogscreen import DialogScreen - -from virtcli import cliutils, cliconfig - - -def parse_commandline(): - optParser = optparse.OptionParser(version=cliconfig.__version__) - - optParser.add_option("-c", "--connect", dest="uri", - help="Connect to hypervisor at URI", metavar="URI") - optParser.add_option("--debug", action="store_true", dest="debug", - help="Print debug output to stdout (implies --no-fork)", - default=False) - - return optParser.parse_args() - - -def _show_startup_error(message, details): - errordlg = DialogScreen("Error Starting Virtual Machine Manager", - message + "\n\n" + details) - errordlg.show() - - -def main(): - cliutils.setup_i18n() - - (options, ignore) = parse_commandline() - cliutils.setup_logging("virt-manager-tui", options.debug) - - import virtManager - logging.debug("Launched as: %s", " ".join(sys.argv[:])) - - import virtManager.guidiff - virtManager.guidiff.is_gui(False) - - # Hack in the default URI for this instance of the tui - if options.uri: - import virtManagerTui.libvirtworker - virtManagerTui.libvirtworker.default_url = options.uri - - # start the app - from virtManagerTui.mainmenu import MainMenu - MainMenu() - -if __name__ == "__main__": - try: - main() - except SystemExit: - raise - except Exception, error: - logging.exception(error) - _show_startup_error(str(error), "".join(traceback.format_exc())) diff --git a/virt-manager.spec.in b/virt-manager.spec.in index cd5f6f71..223adecf 100644 --- a/virt-manager.spec.in +++ b/virt-manager.spec.in @@ -1,7 +1,6 @@ # -*- rpm-spec -*- -%define with_tui 1 %define with_guestfs 0 %define disable_unsupported_rhel 0 %define askpass_package "openssh-askpass" @@ -60,14 +59,6 @@ Requires: python-libguestfs %endif -%if %{with_tui} == 0 -Obsoletes: virt-manager-common <= %{verrel} -Conflicts: virt-manager-common > %{verrel} -%else -Requires: virt-manager-common = %{verrel} -%endif - - BuildRequires: python-distutils-extra BuildRequires: intltool BuildRequires: /usr/bin/pod2man @@ -114,21 +105,6 @@ Package includes several command line utilities, including virt-install machine). -%if %{with_tui} -%package tui -Summary: Virtual Machine Manager text user interface -Group: Applications/Emulators - -Requires: virt-manager-common = %{verrel} -Requires: python-newt_syrup >= 0.1.2 -Requires: libuser-python - -%description tui -An interactive text user interface for Virtual Machine Manager. -%endif - - - %prep %setup -q @@ -161,14 +137,9 @@ An interactive text user interface for Virtual Machine Manager. %define _default_graphics --default-graphics=%{default_graphics} %endif -%if ! %{with_tui} -%define _tui_opt --without-tui -%endif - python setup.py configure \ --pkgversion="%{version}" \ - %{?_tui_opt} \ %{?_qemu_user} \ %{?_kvm_packages} \ %{?_libvirt_packages} \ @@ -210,7 +181,8 @@ fi %{_mandir}/man1/%{name}.1* %{_datadir}/%{name}/ui/*.ui -%{_datadir}/%{name}/%{name} +%{_datadir}/%{name}/virt-manager +%{_datadir}/%{name}/virtManager %{_datadir}/%{name}/icons %{_datadir}/icons/hicolor/*/apps/* @@ -225,7 +197,6 @@ fi %{_datadir}/%{name}/virtcli %{_datadir}/%{name}/virtconv %{_datadir}/%{name}/virtinst -%{_datadir}/%{name}/virtManager %files -n virt-install @@ -246,16 +217,6 @@ fi %{_bindir}/virt-convert -%if %{with_tui} -%files tui - -%{_bindir}/%{name}-tui -%{_datadir}/%{name}/%{name}-tui - -%{_datadir}/%{name}/virtManagerTui -%endif - - %changelog * Mon Apr 01 2013 Cole Robinson - 0.9.5-1 - virt-manager release 0.9.5 diff --git a/virtManager/baseclass.py b/virtManager/baseclass.py index 6c3123e4..633dd265 100644 --- a/virtManager/baseclass.py +++ b/virtManager/baseclass.py @@ -23,14 +23,12 @@ import sys import logging import virtManager -import virtManager.guidiff # pylint: disable=E0611 +from gi.repository import Gdk from gi.repository import GLib from gi.repository import GObject -if virtManager.guidiff.is_gui(): - from gi.repository import Gtk - from gi.repository import Gdk +from gi.repository import Gtk # pylint: enable=E0611 @@ -39,7 +37,7 @@ class vmmGObject(GObject.GObject): def __init__(self): GObject.GObject.__init__(self) - self.config = virtManager.guidiff.get_running_config() + self.config = virtManager.util.running_config self._gobject_handles = [] self._gobject_timeouts = [] diff --git a/virtManager/guidiff.py b/virtManager/guidiff.py deleted file mode 100644 index 6d219c2c..00000000 --- a/virtManager/guidiff.py +++ /dev/null @@ -1,52 +0,0 @@ -# -# Copyright (C) 2011 Red Hat, Inc. -# Copyright (C) 2011 Cole Robinson -# -# 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. -# - -_is_gui = True - - -class stubclass(object): - def __init__(self, *args, **kwargs): - ignore = args - ignore = kwargs - - def __getattr__(self, attr): - def stub(*args, **kwargs): - ignore = args - ignore = kwargs - return stub - - def __setattr__(self, attr, val): - ignore = attr - ignore = val - - -def is_gui(isgui=None): - global _is_gui - if isgui is not None: - _is_gui = isgui - return _is_gui - - -def get_running_config(): - if _is_gui: - import virtManager.util - return virtManager.util.running_config - else: - return stubclass() diff --git a/virtManagerTui/__init__.py b/virtManagerTui/__init__.py deleted file mode 100644 index 4fecfc5f..00000000 --- a/virtManagerTui/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# __init__.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -from virtManagerTui.nodeadmin import NodeAdmin diff --git a/virtManagerTui/adddomain.py b/virtManagerTui/adddomain.py deleted file mode 100644 index 6a226851..00000000 --- a/virtManagerTui/adddomain.py +++ /dev/null @@ -1,578 +0,0 @@ -# -# adddomain.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -import snack -import os - -from virtManagerTui.vmmconfigscreen import VmmTuiConfigScreen -from virtManagerTui.createmeter import CreateMeter -from virtManagerTui.domainconfig import DomainConfig - -from virtinst import Guest - -VM_DETAILS_PAGE = 1 -LOCAL_INSTALL_PAGE = 2 -SELECT_CDROM_PAGE = 3 -SELECT_ISO_PAGE = 4 -NETWORK_INSTALL_PAGE = 5 -OS_TYPE_PAGE = 6 -OS_VARIANT_PAGE = 7 -RAM_CPU_PAGE = 8 -ENABLE_STORAGE_PAGE = 9 -LOCAL_STORAGE_PAGE = 10 -SELECT_POOL_PAGE = 11 -SELECT_VOLUME_PAGE = 12 -BRIDGE_PAGE = 13 -VIRT_DETAILS_PAGE = 14 -CONFIRM_PAGE = 15 - -LOCATION = "location" -KICKSTART = "kickstart" -KERNELOPTS = "kernel.options" -OS_TYPE = "os.type" -OS_VARIANT = "os.variant" -MEMORY = "memory" -CPUS = "cpus" - - -class DomainConfigScreen(VmmTuiConfigScreen): - def __init__(self): - VmmTuiConfigScreen.__init__(self, "Create A New Virtual Machine") - self.__config = DomainConfig() - self.__config.set_architecture(self.get_libvirt().get_default_architecture()) - self.__config.set_virt_type(self.get_libvirt().get_default_virt_type()) - - self.__guest_name = None - self.__install_url = None - self.__storage_volume = None - self.__network_bridges = None - self.__os_types = None - self.__os_variants = None - self.__virt_types = None - self.__storage_size = None - self.__storage_type = None - self.__storage_pool = None - self.__kickstart_url = None - self.__kernel_options = None - self.__install_type = None - self.__cpus = None - self.__memory = None - self.__allocate_storage = None - self.__enable_storage = None - self.__has_volumes = None - self.__install_media = None - self.__has_pools = None - self.__mac_address = None - self.__architectures = None - self.__iso_path = None - self.__install_source = None - self.__has_install_media = None - - def get_elements_for_page(self, screen, page): - if page is VM_DETAILS_PAGE: - return self.get_vm_details_page(screen) - elif page is LOCAL_INSTALL_PAGE: - return self.get_local_install_page(screen) - elif page is SELECT_CDROM_PAGE: - return self.get_select_cdrom_page(screen) - elif page is SELECT_ISO_PAGE: - return self.get_select_iso_page(screen) - elif page is NETWORK_INSTALL_PAGE: - return self.get_network_install_page(screen) - elif page is OS_TYPE_PAGE: - return self.get_os_type_page(screen) - elif page is OS_VARIANT_PAGE: - return self.get_os_variant_page(screen) - elif page is RAM_CPU_PAGE: - return self.get_ram_and_cpu_page(screen) - elif page is ENABLE_STORAGE_PAGE: - return self.get_enable_storage_page(screen) - elif page is LOCAL_STORAGE_PAGE: - return self.get_local_storage_page(screen) - elif page is SELECT_POOL_PAGE: - return self.get_select_pool_page(screen) - elif page is SELECT_VOLUME_PAGE: - return self.get_select_volume_page(screen) - elif page is BRIDGE_PAGE: - return self.get_bridge_page(screen) - elif page is VIRT_DETAILS_PAGE: - return self.get_virt_details_page(screen) - elif page is CONFIRM_PAGE: - return self.get_confirm_page(screen) - return [] - - def get_page_list(self): - return ["Virtual Machine Details", - "Local Installation Details", - "Setup CD-ROM Device", - "Setup ISO File", - "Setup Network Installation", - "Select Operating System Type", - "Select Operating System Variant", - "Set Memory Size", - "Enable Storage", - "Setup Local Storage", - "Select Storage Pool", - "Select Storage Volume", - "Setup Bridge", - "Review Virtual Machine Details", - "Confirm Virtual Machine"] - - def validate_input(self, page, errors): - if page is VM_DETAILS_PAGE: - if len(self.__guest_name.value()) > 0: - if self.get_libvirt().domain_exists(self.__guest_name.value()): - errors.append("Guest name '%s' is already in use." % self.__guest_name.value()) - else: - return True - else: - errors.append("Guest name must be a string between 0 and 50 characters.") - elif page is LOCAL_INSTALL_PAGE: - if self.__install_source.getSelection() == DomainConfig.INSTALL_SOURCE_CDROM: - return True - elif self.__install_source.getSelection() == DomainConfig.INSTALL_SOURCE_ISO: - return True - elif page is SELECT_CDROM_PAGE: - if self.__install_media.getSelection() is not None: - if len(self.get_libvirt().list_installable_volumes()) == 0: - errors.append("No installable media detected.") - else: - return True - else: - errors.append("You must select an install media.") - elif page is SELECT_ISO_PAGE: - if len(self.__iso_path.value()) > 0: - if os.path.exists(self.__iso_path.value()): - if os.path.isfile(self.__iso_path.value()): - return True - else: - errors.append("%s is not a file." % self.__iso_path.value()) - else: - errors.append("No such install media exists:") - errors.append(self.__iso_path.value()) - else: - errors.append("An install media selection is required.") - elif page is NETWORK_INSTALL_PAGE: - if len(self.__install_url.value()) > 0: - return True - else: - errors.append("An install tree is required.") - elif page is OS_TYPE_PAGE: - return True - elif page is OS_VARIANT_PAGE: - return True - elif page is RAM_CPU_PAGE: - if (len(self.__memory.value()) > 0 and - len(self.__cpus.value()) > 0 and - int(self.__memory.value()) > 0 and - int(self.__cpus.value()) > 0): - return True - else: - if len(self.__memory.value()) == 0: - errors.append("A value must be entered for memory.") - elif int(self.__memory.value()) <= 0: - errors.append("A positive integer value must be entered for memory.") - if len(self.__cpus.value()) == 0: - errors.append("A value must be entered for CPUs.") - elif int(self.__cpus.value()) <= 0: - errors.append("A positive integer value must be entered for memory.") - elif page is ENABLE_STORAGE_PAGE: - return True - elif page is LOCAL_STORAGE_PAGE: - if len(self.__storage_size.value()) > 0: - if float(self.__storage_size.value()) > 0: - return True - else: - errors.append("A positive value must be entered for the storage size.") - else: - errors.append("A value must be entered for the storage size.") - elif page is SELECT_POOL_PAGE: - if self.__storage_pool.getSelection() is not None: - return True - else: - errors.append("Please select a storage pool.") - elif page is SELECT_VOLUME_PAGE: - if self.__storage_volume.getSelection() is not None: - return True - else: - errors.append("Please select a storage volume.") - elif page is BRIDGE_PAGE: - if self.__network_bridges.getSelection() is not None: - if len(self.__mac_address.value()) > 0: - return True - else: - errors.append("MAC address must be supplied.") - else: - errors.append("A network bridge must be selected.") - elif page is VIRT_DETAILS_PAGE: - if (self.__virt_types.getSelection() is not None and - self.__architectures.getSelection() is not None): - return True - if self.__virt_types.getSelection() is None: - errors.append("Please select a virtualization type.") - if self.__architectures.getSelection() is None: - errors.append("Please selection an architecture.") - elif page is CONFIRM_PAGE: - return True - return False - - def process_input(self, page): - if page is VM_DETAILS_PAGE: - self.__config.set_guest_name(self.__guest_name.value()) - self.__config.set_install_type(self.__install_type.getSelection()) - elif page is LOCAL_INSTALL_PAGE: - self.__config.set_use_cdrom_source(self.__install_source.getSelection() == DomainConfig.INSTALL_SOURCE_CDROM) - elif page is SELECT_CDROM_PAGE: - self.__config.set_install_media(self.__install_media.getSelection()) - elif page is SELECT_ISO_PAGE: - self.__config.set_iso_path(self.__iso_path.value()) - elif page is NETWORK_INSTALL_PAGE: - self.__config.set_install_url(self.__install_url.value()) - self.__config.set_kickstart_url(self.__kickstart_url.value()) - self.__config.set_kernel_options(self.__kernel_options.value()) - elif page is OS_TYPE_PAGE: - self.__config.set_os_type(self.__os_types.getSelection()) - elif page is OS_VARIANT_PAGE: - self.__config.set_os_variant(self.__os_variants.getSelection()) - elif page is RAM_CPU_PAGE: - self.__config.set_memory(int(self.__memory.value())) - self.__config.set_cpus(int(self.__cpus.value())) - elif page is ENABLE_STORAGE_PAGE: - self.__config.set_enable_storage(self.__enable_storage.value()) - if self.__storage_type.getSelection() == DomainConfig.NEW_STORAGE: - self.__config.set_use_local_storage(True) - elif self.__storage_type.getSelection() == DomainConfig.EXISTING_STORAGE: - self.__config.set_use_local_storage(False) - elif page is LOCAL_STORAGE_PAGE: - self.__config.set_storage_size(float(self.__storage_size.value())) - self.__config.set_allocate_storage(self.__allocate_storage.value()) - elif page is SELECT_POOL_PAGE: - self.__config.set_use_local_storage(False) - self.__config.set_storage_pool(self.__storage_pool.getSelection()) - elif page is SELECT_VOLUME_PAGE: - self.__config.set_storage_volume(self.__storage_volume.getSelection()) - volume = self.get_libvirt().get_storage_volume(self.__config.get_storage_pool(), - self.__config.get_storage_volume()) - self.__config.set_storage_size(volume.info()[1] / 1024.0 ** 3) - elif page is BRIDGE_PAGE: - self.__config.set_network_bridge(self.__network_bridges.getSelection()) - elif page is VIRT_DETAILS_PAGE: - self.__config.set_virt_type(self.__virt_types.getSelection()) - self.__config.set_architecture(self.__architectures.getSelection()) - elif page is CONFIRM_PAGE: - self.get_libvirt().define_domain(self.__config, CreateMeter()) - self.set_finished() - - def get_back_page(self, page): - result = page - if page is OS_TYPE_PAGE: - install_type = self.__config.get_install_type() - if install_type == DomainConfig.LOCAL_INSTALL: - if self.__config.get_use_cdrom_source(): - result = SELECT_CDROM_PAGE - else: - result = SELECT_ISO_PAGE - elif install_type == DomainConfig.NETWORK_INSTALL: - result = NETWORK_INSTALL_PAGE - elif install_type == DomainConfig.PXE_INSTALL: - result = VM_DETAILS_PAGE - elif page is LOCAL_STORAGE_PAGE or page is SELECT_VOLUME_PAGE: - result = ENABLE_STORAGE_PAGE - elif page is SELECT_POOL_PAGE: - result = ENABLE_STORAGE_PAGE - elif page is NETWORK_INSTALL_PAGE: - result = VM_DETAILS_PAGE - elif page is SELECT_CDROM_PAGE or page == SELECT_ISO_PAGE: - result = LOCAL_INSTALL_PAGE - elif page is BRIDGE_PAGE: - if self.__config.get_use_local_storage(): - result = LOCAL_STORAGE_PAGE - else: - result = SELECT_VOLUME_PAGE - else: - if page > 1: - result = page - 1 - return result - - def get_next_page(self, page): - result = page - if page is VM_DETAILS_PAGE: - install_type = self.__config.get_install_type() - if install_type == DomainConfig.LOCAL_INSTALL: - result = LOCAL_INSTALL_PAGE - elif install_type == DomainConfig.NETWORK_INSTALL: - result = NETWORK_INSTALL_PAGE - elif install_type == DomainConfig.PXE_INSTALL: - result = OS_TYPE_PAGE - elif page is LOCAL_INSTALL_PAGE: - if self.__config.get_use_cdrom_source(): - result = SELECT_CDROM_PAGE - else: - result = SELECT_ISO_PAGE - elif page is SELECT_CDROM_PAGE or page == SELECT_ISO_PAGE: - result = OS_TYPE_PAGE - elif page is NETWORK_INSTALL_PAGE: - result = OS_TYPE_PAGE - elif page is ENABLE_STORAGE_PAGE: - result = BRIDGE_PAGE - if self.__config.get_enable_storage(): - if self.__config.get_use_local_storage(): - result = LOCAL_STORAGE_PAGE - else: - result = SELECT_POOL_PAGE - elif page is LOCAL_STORAGE_PAGE: - result = BRIDGE_PAGE - else: - result = page + 1 - return result - - def page_has_finish(self, page): - if page is CONFIRM_PAGE: - return True - return False - - def page_has_next(self, page): - if page is SELECT_POOL_PAGE: - return self.__has_pools - elif page is SELECT_VOLUME_PAGE: - return self.__has_volumes - elif page is SELECT_CDROM_PAGE: - return self.__has_install_media - elif page < CONFIRM_PAGE: - return True - - def get_vm_details_page(self, screen): - self.__guest_name = snack.Entry(50, self.__config.get_guest_name()) - self.__install_type = snack.RadioBar(screen, (("Local install media (ISO image or CDROM)", - DomainConfig.LOCAL_INSTALL, - self.__config.is_install_type(DomainConfig.LOCAL_INSTALL)), - ("Network Install (HTTP, FTP, or NFS)", - DomainConfig.NETWORK_INSTALL, - self.__config.is_install_type(DomainConfig.NETWORK_INSTALL)), - ("Network Boot (PXE)", - DomainConfig.PXE_INSTALL, - self.__config.is_install_type(DomainConfig.PXE_INSTALL)))) - grid = snack.Grid(2, 3) - grid.setField(snack.Label("Name:"), 0, 0, anchorRight=1) - grid.setField(self.__guest_name, 1, 0, anchorLeft=1) - grid.setField(snack.Label("Choose how you would like to install the operating system"), 1, 1, anchorLeft=1, anchorTop=1) - grid.setField(self.__install_type, 1, 2, anchorLeft=1) - return [snack.Label("Enter your machine details"), - grid] - - def get_local_install_page(self, screen): - self.__install_source = snack.RadioBar(screen, (("Use CDROM or DVD", - DomainConfig.INSTALL_SOURCE_CDROM, - self.__config.get_use_cdrom_source()), - ("Use ISO image", - DomainConfig.INSTALL_SOURCE_ISO, - self.__config.get_use_cdrom_source() is False))) - grid = snack.Grid(1, 1) - grid.setField(self.__install_source, 0, 0, anchorLeft=1) - return [snack.Label("Locate your install media"), - grid] - - def get_select_cdrom_page(self, screen): - fields = [] - self.__has_install_media = False - devs = self.get_libvirt().list_installable_volumes() - if len(devs) > 0: - drives = [] - for dev in devs: - row = [dev.pretty_label(), dev.get_path(), - self.__config.is_install_media(dev.get_path())] - drives.append(row) - if len(drives) > 0: - self.__has_install_media = True - self.__install_media = snack.RadioBar(screen, (drives)) - fields.append((self.__install_media, None)) - if self.__has_install_media is False: - fields.append(("No media detected.", None)) - return [snack.Label("Select the install media"), - self.create_grid_from_fields(fields)] - - def get_select_iso_page(self, screen): - ignore = screen - self.__iso_path = snack.Entry(50, self.__config.get_iso_path()) - grid = snack.Grid(1, 2) - grid.setField(snack.Label("Enter ISO path:"), 0, 0, anchorLeft=1) - grid.setField(self.__iso_path, 0, 1, anchorLeft=1) - return [snack.Label("Enter the full path to an install ISO"), - grid] - - def get_network_install_page(self, screen): - ignore = screen - self.__install_url = snack.Entry(50, self.__config.get_install_url()) - self.__kickstart_url = snack.Entry(50, self.__config.get_kickstart_url()) - self.__kernel_options = snack.Entry(50, self.__config.get_kernel_options()) - grid = snack.Grid(2, 3) - grid.setField(snack.Label("URL:"), 0, 0, anchorRight=1) - grid.setField(self.__install_url, 1, 0, anchorLeft=1) - grid.setField(snack.Label("Kickstart URL:"), 0, 1, anchorRight=1) - grid.setField(self.__kickstart_url, 1, 1, anchorLeft=1) - grid.setField(snack.Label("Kernel Options:"), 0, 2, anchorRight=1) - grid.setField(self.__kernel_options, 1, 2, anchorLeft=1) - return [snack.Label("Provide the operating system URL"), - grid] - - def get_os_type_page(self, screen): - types = [] - for typ in Guest.list_os_types(): - types.append([Guest.get_os_type_label(typ), typ, self.__config.is_os_type(typ)]) - self.__os_types = snack.RadioBar(screen, types) - grid = snack.Grid(1, 1) - grid.setField(self.__os_types, 0, 0, anchorLeft=1) - return [snack.Label("Choose the operating system type"), - grid] - - def get_os_variant_page(self, screen): - variants = [] - typ = self.__config.get_os_type() - for variant in Guest.list_os_variants(typ): - variants.append([Guest.get_os_variant_label(typ, variant), variant, self.__config.is_os_variant(variant)]) - self.__os_variants = snack.RadioBar(screen, variants) - grid = snack.Grid(1, 1) - grid.setField(self.__os_variants, 0, 0, anchorLeft=1) - return [snack.Label("Choose the operating system version"), - grid] - - def get_ram_and_cpu_page(self, screen): - ignore = screen - self.__memory = snack.Entry(10, str(self.__config.get_memory())) - self.__cpus = snack.Entry(10, str(self.__config.get_cpus())) - grid = snack.Grid(2, 2) - grid.setField(snack.Label("Memory (RAM):"), 0, 0, anchorRight=1) - grid.setField(self.__memory, 1, 0, anchorLeft=1) - grid.setField(snack.Label("CPUs:"), 0, 1, anchorRight=1) - grid.setField(self.__cpus, 1, 1, anchorLeft=1) - return [snack.Label("Choose memory and CPU settings"), - grid] - - def get_enable_storage_page(self, screen): - self.__enable_storage = snack.Checkbox("Enable storage for this virtual machine", self.__config.get_enable_storage()) - self.__storage_type = snack.RadioBar(screen, ((["Create a disk image on the computer's hard disk", - DomainConfig.NEW_STORAGE, - self.__config.get_use_local_storage()]), - (["Select managed or other existing storage", - DomainConfig.EXISTING_STORAGE, - self.__config.get_use_local_storage() is False]))) - grid = snack.Grid(1, 2) - grid.setField(self.__enable_storage, 0, 0, anchorLeft=1) - grid.setField(self.__storage_type, 0, 1, anchorLeft=1) - return [snack.Label("Configure storage"), - grid] - - def get_local_storage_page(self, screen): - ignore = screen - self.__storage_size = snack.Entry(6, str(self.__config.get_storage_size())) - self.__allocate_storage = snack.Checkbox("Allocate entire disk now", self.__config.get_allocate_storage()) - grid = snack.Grid(2, 2) - grid.setField(self.__allocate_storage, 0, 0, growx=1, anchorLeft=1) - grid.setField(snack.Label("Storage size (GB):"), 0, 1, anchorLeft=1) - grid.setField(self.__storage_size, 1, 1) - return [snack.Label("Configure local storage"), - grid] - - def get_select_pool_page(self, screen): - pools = [] - for pool in self.get_libvirt().list_storage_pools(): - pools.append([pool, pool, pool == self.__config.get_storage_pool()]) - if len(pools) > 0: - self.__storage_pool = snack.RadioBar(screen, (pools)) - grid = snack.Grid(2, 1) - grid.setField(snack.Label("Storage pool:"), 0, 0, anchorTop=1) - grid.setField(self.__storage_pool, 1, 0) - self.__has_pools = True - else: - grid = snack.Label("There are no storage pools available.") - self.__has_pools = False - return [snack.Label("Configure Managed Storage: Select A Pool"), - grid] - - def get_select_volume_page(self, screen): - volumes = [] - for volume in self.get_libvirt().list_storage_volumes(self.__config.get_storage_pool()): - volumes.append([volume, volume, volume == self.__config.get_storage_volume()]) - if len(volumes) > 0: - self.__storage_volume = snack.RadioBar(screen, (volumes)) - grid = snack.Grid(2, 1) - grid.setField(snack.Label("Storage volumes:"), 0, 0, anchorTop=1) - grid.setField(self.__storage_volume, 1, 0) - self.__has_volumes = True - else: - grid = snack.Label("This storage pool has no defined volumes.") - self.__has_volumes = False - return [snack.Label("Configure Managed Storage: Select A Volume"), - grid] - - def get_bridge_page(self, screen): - bridges = [] - for bridge in self.get_libvirt().list_bridges(): - bridges.append(["Virtual network '%s'" % bridge.name(), bridge.name(), self.__config.get_network_bridge() is bridge.name()]) - self.__network_bridges = snack.RadioBar(screen, (bridges)) - if self.__config.get_mac_address() is None: - self.__config.set_mac_address(self.get_libvirt().generate_mac_address()) - self.__mac_address = snack.Entry(20, self.__config.get_mac_address()) - grid = snack.Grid(1, 1) - grid.setField(self.__network_bridges, 0, 0) - return [snack.Label("Select an existing bridge"), - grid] - - def get_virt_details_page(self, screen): - virt_types = [] - for typ in self.get_libvirt().list_virt_types(): - virt_types.append([typ, typ, self.__config.is_virt_type(typ)]) - self.__virt_types = snack.RadioBar(screen, (virt_types)) - archs = [] - for arch in self.get_libvirt().list_architectures(): - archs.append([arch, arch, self.__config.is_architecture(arch)]) - self.__architectures = snack.RadioBar(screen, (archs)) - grid = snack.Grid(2, 2) - grid.setField(snack.Label("Virt Type:"), 0, 0, anchorRight=1, anchorTop=1) - grid.setField(self.__virt_types, 1, 0, anchorLeft=1) - grid.setField(snack.Label("Architecture:"), 0, 1, anchorRight=1, anchorTop=1) - grid.setField(self.__architectures, 1, 1, anchorLeft=1) - return [snack.Label("Configure virtualization details"), - grid] - - def get_confirm_page(self, screen): - ignore = screen - grid = snack.Grid(2, 6) - grid.setField(snack.Label("OS:"), 0, 0, anchorRight=1) - grid.setField(snack.Label(Guest.get_os_variant_label(self.__config.get_os_type(), - self.__config.get_os_variant())), 1, 0, anchorLeft=1) - grid.setField(snack.Label("Install:"), 0, 1, anchorRight=1) - grid.setField(snack.Label(self.__config.get_install_type_text()), 1, 1, anchorLeft=1) - grid.setField(snack.Label("Memory:"), 0, 2, anchorRight=1) - grid.setField(snack.Label("%s MB" % self.__config.get_memory()), 1, 2, anchorLeft=1) - grid.setField(snack.Label("CPUs:"), 0, 3, anchorRight=1) - grid.setField(snack.Label("%d" % self.__config.get_cpus()), 1, 3, anchorLeft=1) - grid.setField(snack.Label("Storage:"), 0, 4, anchorRight=1) - grid.setField(snack.Label("%s (on %s)" % (self.__config.get_storage_volume(), - self.__config.get_storage_pool())), - 1, 4, anchorLeft=1) - grid.setField(snack.Label("Network:"), 0, 5, anchorRight=1) - grid.setField(snack.Label(self.__config.get_network_bridge()), 1, 5, anchorLeft=1) - return [snack.Label("Ready to begin installation of %s" % self.__config.get_guest_name()), - grid] - - -def AddDomain(): - screen = DomainConfigScreen() - screen.start() diff --git a/virtManagerTui/addhost.py b/virtManagerTui/addhost.py deleted file mode 100644 index a66819cf..00000000 --- a/virtManagerTui/addhost.py +++ /dev/null @@ -1,155 +0,0 @@ -# addhost.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -import snack - -from virtManagerTui.vmmconfigscreen import VmmTuiConfigScreen - -DETAILS_PAGE = 1 -CONFIRM_PAGE = 2 - -HYPERVISOR_XEN = "xen" -HYPERVISOR_KVM = "kvm" - -HYPERVISORS = {HYPERVISOR_XEN : "Xen", - HYPERVISOR_KVM : "QEMU/KVM"} - -CONNECTION_LOCAL = "local" -CONNECTION_KERBEROS = "kerberos" -CONNECTION_SSL = "ssl" -CONNECTION_SSH = "ssh" - -CONNECTIONS = {CONNECTION_LOCAL : "Local", - CONNECTION_KERBEROS : "Remote Password or Kerberos", - CONNECTION_SSL : "Remote SSL/TLS with x509 certificate", - CONNECTION_SSH : "Remote tunnel over SSH"} - - -class AddHostConfigScreen(VmmTuiConfigScreen): - def __init__(self): - VmmTuiConfigScreen.__init__(self, "Add A Remote Host") - self.__configured = False - self.__connection = None - self.__hostname = None - self.__autoconnect = None - self.__hypervisor = None - - def get_elements_for_page(self, screen, page): - if page is DETAILS_PAGE: - return self.get_details_page(screen) - elif page is CONFIRM_PAGE: - return self.get_confirm_page(screen) - - def page_has_next(self, page): - return page < CONFIRM_PAGE - - def page_has_back(self, page): - return page > DETAILS_PAGE - - def page_has_finish(self, page): - return page is CONFIRM_PAGE - - def validate_input(self, page, errors): - if page is DETAILS_PAGE: - if self.__connection.getSelection() is CONNECTION_LOCAL: - return True - elif len(self.__hostname.value()) > 0: - return True - else: - errors.append("You must enter a remote hostname.") - elif page is CONFIRM_PAGE: - return True - return False - - def process_input(self, page): - if page is CONFIRM_PAGE: - hv = self.__hypervisor.getSelection() - conn = self.__connection.getSelection() - hostname = self.__hostname.value() - - if hv is HYPERVISOR_XEN: - if conn is CONNECTION_LOCAL: - url = "xen:///" - elif conn is CONNECTION_KERBEROS: - url = "xen+tcp:///" + hostname + "/" - elif conn is CONNECTION_SSL: - url = "xen+tls:///" + hostname + "/" - elif conn is CONNECTION_SSH: - url = "xen+ssh:///" + hostname + "/" - elif hv is HYPERVISOR_KVM: - if conn is CONNECTION_LOCAL: - url = "qemu:///system" - elif conn is CONNECTION_KERBEROS: - url = "qemu+tcp://" + hostname + "/system" - elif conn is CONNECTION_SSL: - url = "qemu+tls://" + hostname + "/system" - elif conn is CONNECTION_SSH: - url = "qemu+ssh://" + hostname + "/system" - - self.get_virt_manager_config().add_connection(url) - self.set_finished() - - def get_details_page(self, screen): - if not self.__configured: - self.__hypervisor = snack.RadioBar(screen, ((HYPERVISORS[HYPERVISOR_XEN], HYPERVISOR_XEN, True), - (HYPERVISORS[HYPERVISOR_KVM], HYPERVISOR_KVM, False))) - self.__connection = snack.RadioBar(screen, ((CONNECTIONS[CONNECTION_LOCAL], CONNECTION_LOCAL, True), - (CONNECTIONS[CONNECTION_KERBEROS], CONNECTION_KERBEROS, False), - (CONNECTIONS[CONNECTION_SSL], CONNECTION_SSL, False), - (CONNECTIONS[CONNECTION_SSH], CONNECTION_SSH, False))) - self.__hostname = snack.Entry(50, "") - self.__autoconnect = snack.Checkbox("Autoconnect on Startup") - self.__configured = True - grid = snack.Grid(2, 4) - grid.setField(snack.Label("Hypervisor:"), 0, 0, anchorRight=1, anchorTop=1) - grid.setField(self.__hypervisor, 1, 0, anchorLeft=1) - grid.setField(snack.Label("Connection:"), 0, 1, anchorRight=1, anchorTop=1) - grid.setField(self.__connection, 1, 1, anchorLeft=1) - grid.setField(snack.Label("Hostname:"), 0, 2, anchorRight=1) - grid.setField(self.__hostname, 1, 2, anchorLeft=1) - grid.setField(snack.Label(""), 0, 3, anchorRight=1) - grid.setField(self.__autoconnect, 1, 3, anchorLeft=1) - return [snack.Label("Add Connection"), - grid] - - def get_confirm_page(self, screen): - ignore = screen - - grid = snack.Grid(2, 4) - grid.setField(snack.Label("Hypervisor:"), 0, 0, anchorRight=1) - grid.setField(snack.Label(HYPERVISORS[self.__hypervisor.getSelection()]), 1, 0, anchorLeft=1) - grid.setField(snack.Label("Connection:"), 0, 1, anchorRight=1) - grid.setField(snack.Label(CONNECTIONS[self.__connection.getSelection()]), 1, 1, anchorLeft=1) - if self.__connection.getSelection() is not CONNECTION_LOCAL: - hostname = self.__hostname.value() - else: - hostname = "local" - grid.setField(snack.Label("Hostname:"), 0, 2, anchorRight=1) - grid.setField(snack.Label(hostname), 1, 2, anchorLeft=1) - grid.setField(snack.Label("Autoconnect on Startup:"), 0, 3, anchorRight=1) - label = "Yes" - if not self.__autoconnect.value(): - label = "No" - grid.setField(snack.Label(label), 1, 3, anchorLeft=1) - return [snack.Label("Confirm Connection"), - grid] - - -def AddHost(): - screen = AddHostConfigScreen() - screen.start() diff --git a/virtManagerTui/addnetwork.py b/virtManagerTui/addnetwork.py deleted file mode 100644 index 0b4593e6..00000000 --- a/virtManagerTui/addnetwork.py +++ /dev/null @@ -1,262 +0,0 @@ -# addnetwork.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -from snack import Checkbox -from snack import Entry -from snack import Label -from snack import RadioBar - -import ipaddr -import logging -import re - -from virtManagerTui.vmmconfigscreen import VmmTuiConfigScreen -from virtManagerTui.networkconfig import NetworkConfig - -NETWORK_NAME_PAGE = 1 -IPV4_ADDRESS_PAGE = 2 -PUBLIC_NETWORK_ALERT_PAGE = 3 -NETWORK_DETAILS_PAGE = 4 -DHCP_RANGE_PAGE = 5 -NETWORK_TYPE_PAGE = 6 -SELECT_PHYSICAL_NETWORK_PAGE = 7 -SUMMARY_PAGE = 8 - - -class AddNetworkConfigScreen(VmmTuiConfigScreen): - def __init__(self): - VmmTuiConfigScreen.__init__(self, "Create A Virtual Network Interface") - self.__config = NetworkConfig() - self.__end_address = None - self.__start_address = None - self.__name = None - self.__isolated_network = None - self.__physical_devices = None - self.__ipv4_address = None - - def get_elements_for_page(self, screen, page): - if page is NETWORK_NAME_PAGE: - return self.get_network_name_page(screen) - elif page is IPV4_ADDRESS_PAGE: - return self.get_ipv4_address_page(screen) - elif page is PUBLIC_NETWORK_ALERT_PAGE: - return self.get_public_network_alert_page(screen) - elif page is NETWORK_DETAILS_PAGE: - return self.get_network_details_page(screen) - elif page is DHCP_RANGE_PAGE: - return self.get_dhcp_range_page(screen) - elif page is NETWORK_TYPE_PAGE: - return self.get_network_type_page(screen) - elif page is SELECT_PHYSICAL_NETWORK_PAGE: - return self.get_select_physical_network_page(screen) - elif page is SUMMARY_PAGE: - return self.get_summary_page(screen) - - def validate_input(self, page, errors): - if page is NETWORK_NAME_PAGE: - if len(self.__name.value()) > 0: - if re.match("^[a-zA-Z0-9_]*$", self.__name.value()): - return True - else: - errors.append("The network name can only contain letters, numbers and the underscore, and no spaces.") - else: - errors.append("Network name must be non-blank and less than 50 characters") - elif page is IPV4_ADDRESS_PAGE: - if len(self.__ipv4_address.value()) > 0: - try: - self.__config.set_ipv4_address(self.__ipv4_address.value()) - return True - except Exception, error: - errors.append("The network address could not be understood: %s" % str(error)) - else: - errors.append("Network must be entered in the format 1.2.3.4/8") - elif page is PUBLIC_NETWORK_ALERT_PAGE: - return True - elif page is NETWORK_DETAILS_PAGE: - return True - elif page is DHCP_RANGE_PAGE: - try: - if len(self.__start_address.value()) > 0 and len(self.__end_address.value()) > 0: - start = ipaddr.IPNetwork(self.__start_address.value(), ) - end = ipaddr.IPNetwork(self.__end_address.value()) - if not self.__config.is_bad_address(start) and not self.__config.is_bad_address(end): - return True - else: - errors.append("Start and/or end address are outside of the choosen network.") - else: - errors.append("Start and end address must be non-blank.") - except Exception, error: - logging.error(str(error)) - errors.append("The start and/or end addresses could not be understood.") - elif page is NETWORK_TYPE_PAGE: - return True - elif page is SELECT_PHYSICAL_NETWORK_PAGE: - return True - elif page is SUMMARY_PAGE: - return True - return False - - def process_input(self, page): - if page is NETWORK_NAME_PAGE: - self.__config.set_name(self.__name.value()) - elif page is DHCP_RANGE_PAGE: - self.__config.set_ipv4_start_address(self.__start_address.value()) - self.__config.set_ipv4_end_address(self.__end_address.value()) - elif page is NETWORK_TYPE_PAGE: - self.__config.set_isolated_network(self.__isolated_network.value()) - elif page is SELECT_PHYSICAL_NETWORK_PAGE: - self.__config.set_physical_device(self.__physical_devices.getSelection()) - elif page is SUMMARY_PAGE: - self.get_libvirt().define_network(self.__config) - self.set_finished() - - def get_next_page(self, page): - if page is IPV4_ADDRESS_PAGE: - if self.__config.is_public_ipv4_network(): - return PUBLIC_NETWORK_ALERT_PAGE - else: - return NETWORK_DETAILS_PAGE - if page is NETWORK_TYPE_PAGE: - if self.__config.is_isolated_network(): - return SUMMARY_PAGE - else: - return SELECT_PHYSICAL_NETWORK_PAGE - return VmmTuiConfigScreen.get_next_page(self, page) - - def get_back_page(self, page): - if page is NETWORK_DETAILS_PAGE: - return IPV4_ADDRESS_PAGE - if page is SUMMARY_PAGE: - if self.__config.is_isolated_network(): - return NETWORK_TYPE_PAGE - else: - return SELECT_PHYSICAL_NETWORK_PAGE - return VmmTuiConfigScreen.get_back_page(self, page) - - def page_has_finish(self, page): - if page is SUMMARY_PAGE: - return True - return False - - def page_has_next(self, page): - if page < SUMMARY_PAGE: - return True - - def page_has_back(self, page): - if page > NETWORK_NAME_PAGE: - return True - return False - - def get_network_name_page(self, screen): - ignore = screen - self.__name = Entry(50, self.__config.get_name()) - fields = [] - fields.append(("Network name", self.__name)) - - return [Label("Please choose a name for your virtual network"), - self.create_grid_from_fields(fields)] - - def get_ipv4_address_page(self, screen): - ignore = screen - self.__ipv4_address = Entry(18, self.__config.get_ipv4_address()) - fields = [] - fields.append(("Network", self.__ipv4_address)) - return [Label("You will need to choose an IPv4 address space for the virtual network"), - self.create_grid_from_fields(fields)] - - def get_network_details_page(self, screen): - ignore = screen - fields = [] - fields.append(("Network details", None)) - fields.append(("Network", self.__config.get_ipv4_address())) - fields.append(("Netmask", self.__config.get_ipv4_netmask())) - fields.append(("Broadcast", self.__config.get_ipv4_broadcast())) - fields.append(("Gateway", self.__config.get_ipv4_gateway())) - fields.append(("Size", "%i" % self.__config.get_ipv4_max_addresses())) - fields.append(("Type", self.__config.get_ipv4_network_type())) - return [self.create_grid_from_fields(fields)] - - def get_public_network_alert_page(self, screen): - ignore = screen - return [Label("Check Network Address"), - Label("The network should normally use a private IPv4 address."), - Label("Use this non-private address anyway?")] - - def get_dhcp_range_page(self, screen): - ignore = screen - self.__start_address = Entry(15, self.__config.get_ipv4_start_address()) - self.__end_address = Entry(15, self.__config.get_ipv4_end_address()) - fields = [] - fields.append(("Select the DHCP range", None)) - # XXX: Broken after gtk3/ipaddr conversion - # fields.append(("Start", self.__start_address.network)) - # fields.append(("End", self.__end_address.network)) - return [Label("Selecting The DHCP Range"), - self.create_grid_from_fields(fields), - Label("TIP: Unless you wish to reserve some addresses to allow static network"), - Label("configuration in virtual machines, these paraemters can be left with"), - Label("their default values.")] - - def get_network_type_page(self, screen): - ignore = screen - self.__isolated_network = Checkbox("Isolated virtual network", - self.__config.is_isolated_network()) - fields = [] - fields.append((self.__isolated_network, None)) - - return [Label("Please indicate whether this virtual network should be"), - Label("connected to the physical network."), - self.create_grid_from_fields(fields)] - - def get_select_physical_network_page(self, screen): - ignore = screen - devices = [] - devices.append(["NAT to any physical device", "", self.__config.get_physical_device() == ""]) - for device in self.get_libvirt().list_network_devices(): - devices.append(["NAT to physical device %s" % device, device, self.__config.get_physical_device() == device]) - self.__physical_devices = RadioBar(screen, (devices)) - fields = [] - fields.append(("Forward to physical network", self.__physical_devices)) - return [Label("Connecting To Physical Network"), - self.create_grid_from_fields(fields)] - - def get_summary_page(self, screen): - ignore = screen - fields = [] - fields.append(("Summary", None)) - fields.append(("Network name", self.__config.get_name())) - fields.append(("IPv4 network", None)) - fields.append(("Network", self.__config.get_ipv4_address())) - fields.append(("Gateway", self.__config.get_ipv4_gateway())) - fields.append(("Netmask", self.__config.get_ipv4_netmask())) - fields.append(("DHCP", None)) - fields.append(("Start address", self.__config.get_ipv4_start_address())) - fields.append(("End address", self.__config.get_ipv4_end_address())) - fields.append(("Forwarding", None)) - forwarding = "Isolated virtual network" - if not self.__config.is_isolated_network(): - forwarding = "NAT to %s" % self.__config.get_physical_device_text() - fields.append(("Connectivity", forwarding)) - - return [Label("Ready To Create Network"), - self.create_grid_from_fields(fields)] - - -def AddNetwork(): - screen = AddNetworkConfigScreen() - screen.start() diff --git a/virtManagerTui/addpool.py b/virtManagerTui/addpool.py deleted file mode 100644 index f8e907ca..00000000 --- a/virtManagerTui/addpool.py +++ /dev/null @@ -1,179 +0,0 @@ -# addstorage.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -from snack import Checkbox -from snack import Entry -from snack import Label -from snack import RadioBar - -from newt_syrup import utils - -from virtManagerTui.vmmconfigscreen import VmmTuiConfigScreen -from virtManagerTui.poolconfig import PoolConfig -from virtinst import Storage - -POOL_NAME_PAGE = 1 -POOL_DETAILS_PAGE = 2 -CONFIRM_PAGE = 3 -HELPER_TEXT = "Specify a storage location to be later split in virtual machine storage" - - -class AddStoragePoolConfigScreen(VmmTuiConfigScreen): - def __init__(self): - VmmTuiConfigScreen.__init__(self, "Add A Storage Pool") - self.__config = PoolConfig(self.get_libvirt()) - self.__hostname = None - self.__formats = None - self.__name = None - self.__type = None - self.__build_pool = None - self.__target_path = None - self.__source_path = None - - def get_elements_for_page(self, screen, page): - if page is POOL_NAME_PAGE: - return self.get_pool_name_page(screen) - elif page is POOL_DETAILS_PAGE: - return self.get_pool_details_page(screen) - elif page is CONFIRM_PAGE: - return self.get_confirm_page(screen) - - def page_has_next(self, page): - return page < CONFIRM_PAGE - - def page_has_back(self, page): - return page > POOL_NAME_PAGE - - def page_has_finish(self, page): - return page is CONFIRM_PAGE - - def validate_input(self, page, errors): - if page is POOL_NAME_PAGE: - if utils.string_is_not_blank(self.__name.value()): - if self.get_libvirt().storage_pool_exists(self.__name.value()): - errors.append("Name '%s' already in use by another pool." % self.__name.value()) - else: - return True - else: - errors.append("Storage object name must be a string between 0 and 50 characters.") - elif page is POOL_DETAILS_PAGE: - result = True - if self.__config.needs_target_path(): - if utils.string_is_not_blank(self.__target_path.value()): - if self.__target_path.value()[0:1] is not '/': - errors.append("'%s' is not an absolute path." % self.__target_path.value()) - result = False - else: - errors.append("You must enter a target path.") - result = False - if self.__config.needs_format(): - if self.__formats.getSelection() is None: - errors.append("You must select a pool format.") - result = False - if self.__config.needs_hostname(): - if not utils.string_is_not_blank(self.__hostname.value()): - errors.append("You must enter a hostname.") - result = False - if self.__config.needs_source_path(): - if utils.string_is_not_blank(self.__source_path.value()): - if self.__config.source_must_be_absolute(): - if self.__source_path.value()[0:1] is not '/': - errors.append("'%s' is not an absolute path." % self.__source_path.value()) - result = False - else: - errors.append("You must enter a source path.") - result = False - return result - elif page is CONFIRM_PAGE: - return True - return False - - def process_input(self, page): - if page is POOL_NAME_PAGE: - self.__config.set_name(self.__name.value()) - self.__config.set_type(self.__type.getSelection()) - # self._reset_flags(self.__type.current()) - elif page is POOL_DETAILS_PAGE: - if self.__config.needs_target_path(): - self.__config.set_target_path(self.__target_path.value()) - if self.__config.needs_format(): - self.__config.set_format(self.__formats.getSelection()) - if self.__config.needs_hostname(): - self.__config.set_hostname(self.__hostname.value()) - if self.__config.needs_source_path(): - self.__config.set_source_path(self.__source_path.value()) - if self.__config.needs_build_pool(): - self.__config.set_build_pool(self.__build_pool.value()) - elif page is CONFIRM_PAGE: - self.get_libvirt().define_storage_pool(self.__config.get_name(), config=self.__config) - self.get_libvirt().create_storage_pool(self.__config.get_name()) - self.set_finished() - - def get_pool_name_page(self, screen): - self.__name = Entry(50, self.__config.get_name()) - pooltypes = [] - for pooltype in Storage.StoragePool.get_pool_types(): - pooltypes.append(["%s: %s" % (pooltype, Storage.StoragePool.get_pool_type_desc(pooltype)), - pooltype, - self.__config.get_type() is pooltype]) - self.__type = RadioBar(screen, pooltypes) - fields = [] - fields.append(("Name", self.__name)) - fields.append(("Type", self.__type)) - - return [Label("Add Storage Pool"), - Label(HELPER_TEXT), - self.create_grid_from_fields(fields)] - - def get_pool_details_page(self, screen): - fields = [] - if self.__config.needs_target_path(): - self.__target_path = Entry(50, self.__config.get_target_path()) - fields.append(("Target Path", self.__target_path)) - if self.__config.needs_format(): - formats = [] - for fmt in self.__config.get_formats(): - formats.append([fmt, fmt, fmt is self.__config.get_format()]) - self.__formats = RadioBar(screen, formats) - fields.append(("Format", self.__formats)) - if self.__config.needs_hostname(): - self.__hostname = Entry(50, self.__config.get_hostname()) - fields.append(("Host Name", self.__hostname)) - if self.__config.needs_source_path(): - self.__source_path = Entry(50, self.__config.get_source_path()) - fields.append(("Source Path", self.__source_path)) - if self.__config.needs_build_pool(): - self.__build_pool = Checkbox("Build Pool", self.__config.get_build_pool()) - fields.append((None, self.__build_pool)) - return [Label("Add Storage Pool"), - Label(HELPER_TEXT), - self.create_grid_from_fields(fields)] - - def get_confirm_page(self, screen): - ignore = screen - fields = [] - fields.append(("Name", self.__config.get_name())) - fields.append(("Target Path", self.__config.get_target_path())) - return [Label("Add Storage Pool"), - Label("Confirm Pool Details"), - self.create_grid_from_fields(fields)] - - -def AddStoragePool(): - screen = AddStoragePoolConfigScreen() - screen.start() diff --git a/virtManagerTui/addvolume.py b/virtManagerTui/addvolume.py deleted file mode 100644 index 5893c1c7..00000000 --- a/virtManagerTui/addvolume.py +++ /dev/null @@ -1,196 +0,0 @@ -# addvolume.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -import snack - -from virtManagerTui.createmeter import CreateMeter -from virtManagerTui.storagelistconfigscreen import StorageListConfigScreen -from virtManagerTui.volumeconfig import StorageVolumeConfig - -from newt_syrup import utils - -SELECT_POOL_PAGE = 1 -VOLUME_NAME_PAGE = 2 -VOLUME_FORMAT_PAGE = 3 -MAX_CAPACITY_PAGE = 4 -CONFIRM_PAGE = 5 - - -class AddVolumeConfigScreen(StorageListConfigScreen): - def __init__(self): - StorageListConfigScreen.__init__(self, "Add A New Storage Volume") - self.__config = StorageVolumeConfig() - self.__name = None - self.__capacity = None - self.__allocation = None - self.__formats = None - - def get_elements_for_page(self, screen, page): - if page is SELECT_POOL_PAGE: - return self.get_storage_pool_list_page(screen) - elif page is VOLUME_NAME_PAGE: - return self.get_volume_name_page(screen) - elif page is VOLUME_FORMAT_PAGE: - return self.get_volume_format_page(screen) - elif page is MAX_CAPACITY_PAGE: - return self.get_max_capacity_page(screen) - elif page is CONFIRM_PAGE: - return self.get_confirm_page(screen) - - def page_has_next(self, page): - if page is SELECT_POOL_PAGE: - return self.has_selectable_pools() - else: - if page < CONFIRM_PAGE: - return True - return False - - def page_has_back(self, page): - if page > SELECT_POOL_PAGE: - return True - return False - - def page_has_finish(self, page): - return page is CONFIRM_PAGE - - def get_next_page(self, page): - if page is VOLUME_NAME_PAGE: - if self.__config.needs_format(): - return VOLUME_FORMAT_PAGE - else: - return MAX_CAPACITY_PAGE - return StorageListConfigScreen.get_next_page(self, page) - - def get_back_page(self, page): - if page is MAX_CAPACITY_PAGE: - if self.__config.needs_format(): - return VOLUME_FORMAT_PAGE - else: - return VOLUME_NAME_PAGE - return StorageListConfigScreen.get_back_page(self, page) - - def validate_input(self, page, errors): - if page is SELECT_POOL_PAGE: - if self.get_selected_pool() is not None: - return True - else: - errors.append("You must select a storage pool.") - elif page is VOLUME_NAME_PAGE: - if utils.string_is_not_blank(self.__name.value()): - return True - else: - errors.append("Storage object name can only contain alphanumeric, '_', '.', or '-' characters.") - elif page is VOLUME_FORMAT_PAGE: - if self.__formats.current() is not None: - return True - else: - errors.append("You must select a volume format.") - elif page is MAX_CAPACITY_PAGE: - if utils.string_is_not_blank(self.__capacity.value()): - if utils.string_is_not_blank(self.__allocation.value()): - capacity = int(self.__capacity.value()) - allocation = int(self.__allocation.value()) - if capacity > 0: - if capacity <= self.__config.get_pool().info()[3] / (1024 ** 2): - if allocation >= 0: - if allocation <= capacity: - return True - else: - errors.append("Allocation cannot exceed the maximum capacity.") - else: - errors.append("The allocation must be greater than or equal to 0.") - else: - errors.append("The maximum capacity cannot exceed the storage pool size.") - else: - errors.append("The capacity must be greater than zero.") - else: - errors.append("An allocation value must be entered.") - else: - errors.append("A maximum volume capacity must be entered.") - elif page is CONFIRM_PAGE: - return True - return False - - def process_input(self, page): - if page is SELECT_POOL_PAGE: - self.__config.set_pool(self.get_libvirt().get_storage_pool(self.get_selected_pool())) - elif page is VOLUME_NAME_PAGE: - self.__config.set_name(self.__name.value()) - elif page is VOLUME_FORMAT_PAGE: - self.__config.set_format(self.__formats.current()) - elif page is MAX_CAPACITY_PAGE: - self.__config.set_max_capacity(int(self.__capacity.value())) - self.__config.set_allocation(int(self.__allocation.value())) - elif page is CONFIRM_PAGE: - self.get_libvirt().define_storage_volume(self.__config, CreateMeter()) - self.set_finished() - - def get_volume_name_page(self, screen): - ignore = screen - self.__name = snack.Entry(50, self.__config.get_name()) - grid = snack.Grid(2, 1) - grid.setField(snack.Label("Name:"), 0, 0, anchorRight=1) - grid.setField(self.__name, 1, 0, anchorLeft=1) - return [snack.Label("New Storage Volume"), - grid, - snack.Label("Name of the volume to create. File extension may be appended.")] - - def get_volume_format_page(self, screen): - ignore = screen - self.__formats = snack.Listbox(0) - for fmt in self.__config.get_formats_for_pool(): - self.__formats.append(fmt, fmt) - grid = snack.Grid(1, 1) - grid.setField(self.__formats, 0, 0) - return [snack.Label("Select The Volume Format"), - grid] - - def get_max_capacity_page(self, screen): - ignore = screen - self.__capacity = snack.Entry(6, str(self.__config.get_max_capacity())) - self.__allocation = snack.Entry(6, str(self.__config.get_allocation())) - grid = snack.Grid(2, 2) - grid.setField(snack.Label("Max. Capacity (MB):"), 0, 0, anchorRight=1) - grid.setField(self.__capacity, 1, 0, anchorLeft=1) - grid.setField(snack.Label("Allocation (MB):"), 0, 1, anchorRight=1) - grid.setField(self.__allocation, 1, 1, anchorLeft=1) - return [snack.Label("Storage Volume Quota"), - snack.Label("%s's available space: %s" % (self.__config.get_pool().name(), - utils.size_as_mb_or_gb(self.__config.get_pool().info()[3]))), - grid] - - def get_confirm_page(self, screen): - ignore = screen - grid = snack.Grid(2, 5) - grid.setField(snack.Label("Volume Name:"), 0, 0, anchorRight=1) - grid.setField(snack.Label("%s (%s)" % (self.__config.get_name(), self.__config.get_pool().name())), 1, 0, anchorLeft=1) - if self.__config.needs_format(): - grid.setField(snack.Label("Format:"), 0, 1, anchorRight=1) - grid.setField(snack.Label(self.__config.get_format()), 1, 1, anchorLeft=1) - # NOTE: here we multiply the sizes by 1024^2 since the size_as_mb_or_gb is expect bytes - grid.setField(snack.Label("Max. Capacity:"), 0, 2, anchorRight=1) - grid.setField(snack.Label("%s" % (utils.size_as_mb_or_gb(self.__config.get_max_capacity() * (1024 ** 2)))), 1, 2, anchorLeft=1) - grid.setField(snack.Label("Allocation:"), 0, 3, anchorRight=1) - grid.setField(snack.Label("%s" % (utils.size_as_mb_or_gb(self.__config.get_allocation() * (1024 ** 2)))), 1, 3, anchorLeft=1) - return [snack.Label("Ready To Allocation New Storage Volume"), - grid] - - -def AddStorageVolume(): - screen = AddVolumeConfigScreen() - screen.start() diff --git a/virtManagerTui/changehost.py b/virtManagerTui/changehost.py deleted file mode 100644 index 3cdab63d..00000000 --- a/virtManagerTui/changehost.py +++ /dev/null @@ -1,67 +0,0 @@ -# changehost.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -import snack - -import logging -from virtManagerTui.hostlistconfigscreen import HostListConfigScreen - -CONNECTION_LIST_PAGE = 1 -CONNECTED_PAGE = 2 - - -class ChangeHostConfigScreen(HostListConfigScreen): - def __init__(self): - HostListConfigScreen.__init__(self, "") - - def get_title(self): - return "Currently: %s" % self.get_libvirt().get_url() - - def get_elements_for_page(self, screen, page): - if page is CONNECTION_LIST_PAGE: - return self.get_connection_list_page(screen) - elif page is CONNECTED_PAGE: - return self.get_connected_page(screen) - - def process_input(self, page): - if page is CONNECTION_LIST_PAGE: - logging.info("Changing libvirt connection to %s", - self.get_selected_connection()) - self.get_libvirt().open_connection(self.get_selected_connection()) - elif page is CONNECTED_PAGE: - self.set_finished() - - def page_has_next(self, page): - if page is CONNECTION_LIST_PAGE: - return self.has_selectable_connections() - return False - - def page_has_back(self, page): - return page > CONNECTION_LIST_PAGE - - def page_has_finish(self, page): - return page is CONNECTED_PAGE - - def get_connected_page(self, screen): - ignore = screen - return [snack.Label("Connected to %s" % self.get_selected_connection())] - - -def ChangeHost(): - screen = ChangeHostConfigScreen() - screen.start() diff --git a/virtManagerTui/createmeter.py b/virtManagerTui/createmeter.py deleted file mode 100644 index 7ffc34ab..00000000 --- a/virtManagerTui/createmeter.py +++ /dev/null @@ -1,31 +0,0 @@ -# createmeter.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -import urlgrabber.progress as progress -import logging - - -class CreateMeter(progress.BaseMeter): - def _do_start(self, now=None): - logging.info("Starting...") - - def _do_end(self, amount_read, now=None): - logging.info("Ending: read=%d", amount_read) - - def _do_update(self, amount_read, now=None): - logging.info("Update: read=%d", amount_read) diff --git a/virtManagerTui/createuser.py b/virtManagerTui/createuser.py deleted file mode 100644 index 44d04d42..00000000 --- a/virtManagerTui/createuser.py +++ /dev/null @@ -1,115 +0,0 @@ -# -# createuser.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -import snack -from newt_syrup.configscreen import ConfigScreen -from virtManagerTui.userworker import UserWorker - -import libuser - -DETAILS_PAGE = 1 -CONFIRM_PAGE = 2 - - -class CreateUserConfigScreen(ConfigScreen): - def __init__(self): - ConfigScreen.__init__(self, "Create A User Account") - self.__username = None - self.__password = None - self.__confirm = None - self.__adminuser = None - self.__useradmin = libuser.admin() - self.__user_worker = UserWorker() - - def get_elements_for_page(self, screen, page): - if page is DETAILS_PAGE: - return self.get_details_page(screen) - elif page is CONFIRM_PAGE: - return self.get_confirm_page(screen) - - def validate_input(self, page, errors): - if page is DETAILS_PAGE: - if len(self.__username.value()) > 0: - name = self.__username.value() - if self.__useradmin.lookupUserByName(name) is None: - if len(self.__password.value()) > 0: - if self.__password.value() == self.__confirm.value(): - return True - else: - errors.append("Passwords do not match.") - else: - errors.append("You must enter a password.") - else: - errors.append("User %s already exists." % name) - else: - errors.append("You must enter a username.") - self.__confirm.value() - return False - - def process_input(self, page): - if page is CONFIRM_PAGE: - self.__user_worker.create_user(self.__username.value(), - self.__password.value(), - "wheel" if self.__adminuser.value() else None) - self.set_finished() - - def page_has_next(self, page): - return (page is DETAILS_PAGE) - - def page_has_back(self, page): - return (page is CONFIRM_PAGE) - - def page_has_finish(self, page): - return (page is CONFIRM_PAGE) - - def get_details_page(self, screen): - ignore = screen - - if self.__username is None: - self.__username = snack.Entry(50, "") - self.__password = snack.Entry(50, "", password=1) - self.__confirm = snack.Entry(50, "", password=1) - self.__adminuser = snack.Checkbox("This user is an administrator", False) - grid = snack.Grid(2, 4) - grid.setField(snack.Label("Username:"), 0, 0, anchorRight=1) - grid.setField(self.__username, 1, 0, anchorLeft=1) - grid.setField(snack.Label("Password:"), 0, 1, anchorRight=1) - grid.setField(self.__password, 1, 1, anchorLeft=1) - grid.setField(snack.Label("Confirm password:"), 0, 2, anchorRight=1) - grid.setField(self.__confirm, 1, 2, anchorLeft=1) - grid.setField(snack.Label(" "), 0, 3) - grid.setField(self.__adminuser, 1, 3, anchorLeft=1) - return [snack.Label("Enter The User Details"), - grid] - - def get_confirm_page(self, screen): - ignore = screen - grid = snack.Grid(1, 2) - grid.setField(snack.Label("Username: %s" % self.__username.value()), 0, 0) - admin_label = "is not" - if self.__adminuser.value(): - admin_label = "is" - grid.setField(snack.Label("This user %s an administrator." % admin_label), 0, 1) - return [snack.Label("Create this user account?"), - grid] - - -def CreateUser(): - screen = CreateUserConfigScreen() - screen.start() diff --git a/virtManagerTui/domainconfig.py b/virtManagerTui/domainconfig.py deleted file mode 100644 index b1cc2bf5..00000000 --- a/virtManagerTui/domainconfig.py +++ /dev/null @@ -1,226 +0,0 @@ -# domainconfig.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -from virtinst import Guest - - -class DomainConfig: - LOCAL_INSTALL = "local" - NETWORK_INSTALL = "network" - PXE_INSTALL = "pxe" - INSTALL_TYPE_TEXT = {LOCAL_INSTALL : "Local CDROM/ISO", - NETWORK_INSTALL : "URL INstall Tree", - PXE_INSTALL : "PXE Install"} - - INSTALL_SOURCE_CDROM = "cdrom" - INSTALL_SOURCE_ISO = "iso" - - NEW_STORAGE = "new" - EXISTING_STORAGE = "existing" - - def __init__(self): - self.__guest_name = "" - self.__install_type = DomainConfig.LOCAL_INSTALL - self.__use_cdrom_source = True - self.__install_location = "" - self.__install_media = "" - self.__iso_path = "" - self.__install_url = "" - self.__kickstart_url = "" - self.__kernel_options = "" - self.__os_type = "other" - self.__os_variant = None - self.__memory = 512 - self.__cpus = 1 - self.__enable_storage = True - self.__use_local_storage = True - self.__existing_storage = False - self.__storage_size = 8.0 - self.__allocate_storage = True - self.__storage_pool = "" - self.__storage_volume = "" - self.__network_bridge = None - self.__mac_address = None - self.__virt_type = None - self.__architecture = None - - def set_guest_name(self, name): - self.__guest_name = name - - def get_guest_name(self): - return self.__guest_name - - def set_install_type(self, typ): - self.__install_type = typ - - def get_install_type(self): - return self.__install_type - - def get_install_type_text(self): - return DomainConfig.INSTALL_TYPE_TEXT[self.get_install_type()] - - def is_install_type(self, typ): - return self.__install_type == typ - - def set_install_location(self, location): - self.__install_location = location - - def set_use_cdrom_source(self, use): - self.__use_cdrom_source = use - - def get_use_cdrom_source(self): - return self.__use_cdrom_source - - def get_install_location(self): - return self.__install_location - - def is_install_location(self, location): - return self.__install_location == location - - def set_install_media(self, media): - self.__install_media = media - - def get_install_media(self): - return self.__install_media - - def is_install_media(self, media): - return self.__install_media == media - - def set_iso_path(self, path): - self.__iso_path = path - - def get_iso_path(self): - return self.__iso_path - - def set_install_url(self, url): - self.__install_url = url - - def get_install_url(self): - return self.__install_url - - def set_kickstart_url(self, url): - self.__kickstart_url = url - - def get_kickstart_url(self): - return self.__kickstart_url - - def set_kernel_options(self, options): - self.__kernel_options = options - - def get_kernel_options(self): - return self.__kernel_options - - def set_os_type(self, typ): - self.__os_type = typ - self.__os_variant = Guest.list_os_variants(typ)[0] - - def get_os_type(self): - return self.__os_type - - def is_os_type(self, typ): - return self.__os_type == typ - - def set_os_variant(self, variant): - self.__os_variant = variant - - def get_os_variant(self): - return self.__os_variant - - def is_os_variant(self, variant): - return self.__os_variant == variant - - def set_memory(self, memory): - self.__memory = int(memory) - - def get_memory(self): - return self.__memory - - def set_cpus(self, cpus): - self.__cpus = cpus - - def get_cpus(self): - return self.__cpus - - def set_enable_storage(self, enable): - self.__enable_storage = enable - - def get_enable_storage(self): - return self.__enable_storage - - def set_use_local_storage(self, use): - self.__use_local_storage = use - - def get_use_local_storage(self): - return self.__use_local_storage - - def set_storage_size(self, size): - self.__storage_size = size - - def get_storage_size(self): - return self.__storage_size - - def set_allocate_storage(self, allocate): - self.__allocate_storage = allocate - - def get_allocate_storage(self): - return self.__allocate_storage - - def set_storage_pool(self, pool): - self.__storage_pool = pool - - def get_storage_pool(self): - return self.__storage_pool - - def set_storage_volume(self, volume): - self.__storage_volume = volume - - def get_storage_volume(self): - return self.__storage_volume - - def is_existing_storage(self, storage): - return self.__existing_storage == storage - - def set_network_bridge(self, bridge): - self.__network_bridge = bridge - - def get_network_bridge(self): - return self.__network_bridge - - def set_mac_address(self, address): - self.__mac_address = address - - def get_mac_address(self): - return self.__mac_address - - def set_virt_type(self, typ): - self.__virt_type = typ - - def get_virt_type(self): - return self.__virt_type - - def is_virt_type(self, typ): - return self.__virt_type == typ - - def set_architecture(self, architecture): - self.__architecture = architecture - - def get_architecture(self): - return self.__architecture - - def is_architecture(self, architecture): - return self.__architecture == architecture diff --git a/virtManagerTui/domainlistconfigscreen.py b/virtManagerTui/domainlistconfigscreen.py deleted file mode 100644 index 13b7cc93..00000000 --- a/virtManagerTui/domainlistconfigscreen.py +++ /dev/null @@ -1,57 +0,0 @@ -# domainlistconfigscreen.py - Copyright (C) 2011 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -import snack - -from virtManagerTui.vmmconfigscreen import VmmTuiConfigScreen - - -class DomainListConfigScreen(VmmTuiConfigScreen): - '''Provides a base class for all config screens that require a domain list.''' - - def __init__(self, title): - VmmTuiConfigScreen.__init__(self, title) - self.__has_domains = None - self.__domain_list = None - - def get_domain_list_page(self, screen, defined=True, created=True): - ignore = screen # pylint ignore since it is not used here - domuuids = self.get_libvirt().list_domains(defined, created) - self.__has_domains = bool(domuuids) - result = None - - if self.__has_domains: - self.__domain_list = snack.Listbox(0) - for uuid in domuuids: - domain = self.get_libvirt().get_domain(uuid) - - # dom is a vmmDomain - self.__domain_list.append(domain.get_name(), domain) - result = [self.__domain_list] - else: - grid = snack.Grid(1, 1) - grid.setField(snack.Label("There are no domains available."), 0, 0) - result = [grid] - - return result - - def get_selected_domain(self): - return self.__domain_list.current() - - def has_selectable_domains(self): - return self.__has_domains diff --git a/virtManagerTui/hostlistconfigscreen.py b/virtManagerTui/hostlistconfigscreen.py deleted file mode 100644 index ba51466f..00000000 --- a/virtManagerTui/hostlistconfigscreen.py +++ /dev/null @@ -1,55 +0,0 @@ -# hostlistconfigscreen.py - Copyright (C) 2011 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -import snack - -from virtManagerTui.vmmconfigscreen import VmmTuiConfigScreen - - -class HostListConfigScreen(VmmTuiConfigScreen): - '''Provides a base class for working with lists of libvirt hosts.''' - - def __init__(self, title): - VmmTuiConfigScreen.__init__(self, title) - self.__has_connections = None - self.__connection_list = None - - def get_connection_list_page(self, screen): - ignore = screen - connections = self.get_virt_manager_config().get_connection_list() - result = None - - if len(connections) > 0: - self.__has_connections = True - self.__connection_list = snack.Listbox(0) - for connection in connections: - self.__connection_list.append(connection, connection) - result = self.__connection_list - else: - self.__has_connections = False - result = snack.Label("There are no defined connections.") - grid = snack.Grid(1, 1) - grid.setField(result, 0, 0) - return [snack.Label("Host List"), - grid] - - def get_selected_connection(self): - return self.__connection_list.current() - - def has_selectable_connections(self): - return self.__has_connections diff --git a/virtManagerTui/hostmenu.py b/virtManagerTui/hostmenu.py deleted file mode 100644 index 4eb3b40c..00000000 --- a/virtManagerTui/hostmenu.py +++ /dev/null @@ -1,50 +0,0 @@ -# hostmenu.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -from newt_syrup.menuscreen import MenuScreen - -from virtManagerTui.changehost import ChangeHost -from virtManagerTui.addhost import AddHost -from virtManagerTui.removehost import RemoveHost - -SELECT_HOST = 1 -ADD_HOST = 2 -REMOVE_HOST = 3 - - -class HostMenuScreen(MenuScreen): - def __init__(self): - MenuScreen.__init__(self, "Host Menu Screen") - - def get_menu_items(self): - return (("Select A Host", SELECT_HOST), - ("Add A Host", ADD_HOST), - ("Remove A Host", REMOVE_HOST)) - - def handle_selection(self, item): - if item is SELECT_HOST: - ChangeHost() - elif item is ADD_HOST: - AddHost() - elif item is REMOVE_HOST: - RemoveHost() - - -def HostMenu(): - screen = HostMenuScreen() - screen.start() diff --git a/virtManagerTui/libvirtworker.py b/virtManagerTui/libvirtworker.py deleted file mode 100644 index 80dfed5e..00000000 --- a/virtManagerTui/libvirtworker.py +++ /dev/null @@ -1,545 +0,0 @@ -# libvirtworker.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -import os -import logging - -import virtinst -import libvirt - -from virtManager.connection import vmmConnection - -from virtManagerTui.domainconfig import DomainConfig - -DEFAULT_POOL_TARGET_PATH = "/var/lib/libvirt/images" -DEFAULT_URL = "qemu:///system" - -default_url = DEFAULT_URL - - -def set_default_url(url): - logging.info("Changing DEFAULT_URL to %s", url) - global default_url - - default_url = url - - -def get_default_url(): - logging.info("Returning default URL of %s", default_url) - return default_url - - -class VirtManagerConfig: - def __init__(self, filename=None): - if filename is None: - filename = os.path.expanduser("~/.virt-manager/virt-manager-tui.conf") - self.__filename = filename - - def get_connection_list(self): - result = [] - if os.path.exists(self.__filename): - inp = file(self.__filename, "r") - for entry in inp: - result.append(entry[0:-1]) - return result - - def add_connection(self, connection): - connections = self.get_connection_list() - if connections.count(connection) is 0: - connections.append(connection) - self._save_connections(connections) - - def remove_connection(self, connection): - connections = self.get_connection_list() - if connections.count(connection) > 0: - connections.remove(connection) - self._save_connections(connections) - - def _save_connections(self, connections): - output = file(self.__filename, "w") - for entry in connections: - print >> output, entry - output.close() - - -class LibvirtWorker: - '''Provides utilities for interfacing with libvirt.''' - def __init__(self, url=None): - if url is None: - url = get_default_url() - logging.info("Connecting to libvirt: %s", url) - self.__url = None - self.__conn = None - self.__vmmconn = None - self.__guest = None - self.__domain = None - - self.open_connection(url) - - self.__capabilities = self.__vmmconn.get_capabilities() - self.__net = virtinst.VirtualNetworkInterface(conn=self.__conn) - self.__net.setup(self.__conn) - (self.__new_guest, self.__new_domain) = virtinst.CapabilitiesParser.guest_lookup(conn=self.__conn) - - def get_connection(self): - '''Returns the underlying connection.''' - return self.__conn - - def get_url(self): - return self.__url - - def open_connection(self, url): - '''Lets the user change the url for the connection.''' - old_conn = self.__conn - old_url = self.__url - old_vmmconn = self.__vmmconn - - try: - self.__vmmconn = vmmConnection(url) - self.__vmmconn.open(sync=True) - - self.__conn = self.__vmmconn.vmm - self.__url = url - set_default_url(url) - except Exception, error: - self.__conn = old_conn - self.__url = old_url - self.__vmmconn = old_vmmconn - raise error - - def get_capabilities(self): - '''Returns the capabilities for this libvirt host.''' - return self.__capabilities - - def list_installable_volumes(self): - ''' - Return a list of host CDROM devices that have media in them - XXX: virt-manager code provides other info here: can list all - CDROM devices and whether them are empty, or report an error - if HAL missing and libvirt is too old - ''' - devs = self.__vmmconn.mediadevs.values() - ret = [] - for dev in devs: - if dev.has_media() and dev.media_type == "cdrom": - ret.append(dev) - return ret - - def list_network_devices(self): - ''' - Return a list of physical network devices on the host - ''' - ret = [] - for path in self.__vmmconn.list_net_device_paths(): - net = self.__vmmconn.get_net_device(path) - ret.append(net.get_name()) - return ret - - def list_domains(self, defined=True, created=True): - '''Lists all domains.''' - self.__vmmconn.tick() - uuids = self.__vmmconn.list_vm_uuids() - result = [] - for uuid in uuids: - include = False - domain = self.get_domain(uuid) - if domain.status() in [libvirt.VIR_DOMAIN_RUNNING]: - if created: - include = True - else: - if defined: - include = True - if include: - result.append(uuid) - return result - - def get_domain(self, uuid): - '''Returns the specified domain.''' - return self.__vmmconn.get_vm(uuid) - - def domain_exists(self, name): - '''Returns whether a domain with the specified node exists.''' - domains = self.list_domains() - if name in domains: - return True - return False - - def undefine_domain(self, name): - '''Undefines the specified domain.''' - domain = self.get_domain(name) - domain.undefine() - - def migrate_domain(self, name, target): - '''Migrates the specified domain to the target machine.''' - target_conn = libvirt.open(target) - virtmachine = self.get_domain(name) - virtmachine.migrate(target_conn, libvirt.VIR_MIGRATE_LIVE, None, None, 0) - - def list_networks(self, defined=True, started=True): - '''Lists all networks that meet the given criteria. - - Keyword arguments: - defined -- Include defined, but not started, networks. (default True) - started -- Include only started networks. (default True) - - ''' - self.__vmmconn.tick() - uuids = self.__vmmconn.list_net_uuids() - result = [] - for uuid in uuids: - include = False - net = self.__vmmconn.get_net(uuid) - if net.is_active(): - if started: - include = True - else: - if defined: - include = True - if include: - result.append(uuid) - return result - - def get_network(self, uuid): - '''Returns the specified network. Raises an exception if the netowrk does not exist. - - Keyword arguments: - uuid -- the network's identifier - - ''' - self.__vmmconn.tick() - result = self.__vmmconn.get_net(uuid) - if result is None: - raise Exception("No such network exists: uuid=%s" % uuid) - - return result - - def network_exists(self, name): - '''Returns True if the specified network exists. - - Keyword arguments: - name -- the name of the network - - ''' - networks = self.list_networks() - if name in networks: - return True - return False - - def define_network(self, config): - '''Defines a new network. - - Keyword arguments: - config -- the network descriptor - - ''' - # since there's no other way currently, we'll have to use XML - name = config.get_name() - ip = config.get_ipv4_address_raw() - start = config.get_ipv4_start_address() - end = config.get_ipv4_end_address() - fw = config.get_physical_device() - - xml = "" + \ - " %s\n" % name - if not config.is_public_ipv4_network(): - if fw is not "": - xml += " \n" % fw[1] - else: - xml += " \n" - - xml += " \n" % (str(ip[1]), str(ip.netmask())) - xml += " \n" - xml += " \n" % (str(start), str(end)) - xml += " \n" - xml += " \n" - xml += "\n" - - self.__vmmconn.create_network(xml) - - def undefine_network(self, name): - '''Undefines the specified network.''' - network = self.get_network(name) - network.undefine() - - def list_storage_pools(self, defined=True, created=True): - '''Returns the list of all defined storage pools.''' - pools = [] - if defined: - pools.extend(self.__conn.listDefinedStoragePools()) - if created: - pools.extend(self.__conn.listStoragePools()) - return pools - - def storage_pool_exists(self, name): - '''Returns whether a storage pool exists.''' - pools = self.list_storage_pools() - if name in pools: - return True - return False - - def create_storage_pool(self, name): - '''Starts the named storage pool if it is not currently started.''' - if name not in self.list_storage_pools(defined=False): - pool = self.get_storage_pool(name) - pool.create(0) - - def destroy_storage_pool(self, name): - '''Stops the specified storage pool.''' - if name in self.list_storage_pools(defined=False): - pool = self.get_storage_pool(name) - pool.destroy() - - def define_storage_pool(self, name, config=None, meter=None): - '''Defines a storage pool with the given name.''' - if config is None: - pool = virtinst.Storage.DirectoryPool(conn=self.__conn, - name=name, - target_path=DEFAULT_POOL_TARGET_PATH) - newpool = pool.install(build=True, create=True, meter=meter) - newpool.setAutostart(True) - else: - pool = config.get_pool() - pool.target_path = config.get_target_path() - if config.needs_hostname(): - pool.host = config.get_hostname() - if config.needs_source_path(): - pool.source_path = config.get_source_path() - if config.needs_format(): - pool.format = config.get_format() - pool.conn = self.__conn - pool.get_xml_config() - newpool = pool.install(meter=meter, - build=True, # config.get_build_pool(), - create=True) - newpool.setAutostart(True) - - def undefine_storage_pool(self, name): - '''Undefines the specified storage pool.''' - pool = self.get_storage_pool(name) - pool.undefine() - - def get_storage_pool(self, name): - '''Returns the storage pool with the specified name.''' - return self.__conn.storagePoolLookupByName(name) - - def list_storage_volumes(self, poolname): - '''Returns the list of all defined storage volumes for a given pool.''' - pool = self.get_storage_pool(poolname) - return pool.listVolumes() - - def define_storage_volume(self, config, meter): - '''Defines a new storage volume.''' - self.create_storage_pool(config.get_pool().name()) - volume = config.create_volume() - volume.install(meter=meter) - - def remove_storage_volume(self, poolname, volumename): - '''Removes the specified storage volume.''' - volume = self.get_storage_volume(poolname, volumename) - volume.delete(0) - - def get_storage_volume(self, poolname, volumename): - '''Returns a reference to the specified storage volume.''' - pool = self.get_storage_pool(poolname) - volume = pool.storageVolLookupByName(volumename) - return volume - - def list_bridges(self): - '''Lists all defined and active bridges.''' - bridges = self.__conn.listNetworks() - bridges.extend(self.__conn.listDefinedNetworks()) - result = [] - for name in bridges: - bridge = self.__conn.networkLookupByName(name) - result.append(bridge) - return result - - def generate_mac_address(self): - return self.__net.macaddr - - def get_storage_size(self, poolname, volumename): - '''Returns the size of the specified storage volume.''' - volume = self.get_storage_volume(poolname, volumename) - return volume.info()[1] / (1024.0 ** 3) - - def get_virt_types(self): - result = [] - for guest in self.__capabilities.guests: - guest_type = guest.os_type - for domain in guest.domains: - domain_type = domain.hypervisor_type - label = domain_type - - if domain_type is "kvm" and guest_type is "xen": - label = "xenner" - elif domain_type is "xen": - if guest_type is "xen": - label = "xen (paravirt)" - elif guest_type is "kvm": - label = "xen (fullvirt)" - elif domain_type is "test": - if guest_type is "xen": - label = "test (xen)" - elif guest_type is "hvm": - label = "test (hvm)" - - for row in result: - if row[0] == label: - label = None - break - if label is None: - continue - - result.append([label, domain_type, guest_type]) - return result - - def list_virt_types(self): - virt_types = self.get_virt_types() - result = [] - for typ in virt_types: - result.append(typ[0]) - return result - - def get_default_architecture(self): - '''Returns a default hypervisor type for new domains.''' - return self.__new_guest.arch - - def get_hypervisor(self, virt_type): - virt_types = self.get_virt_types() - for typ in virt_types: - if typ[0] is virt_type: - return typ[1] - return None - - def get_default_virt_type(self): - '''Returns the default virtualization type for new domains.''' - return self.__new_domain.hypervisor_type - - def get_os_type(self, virt_type): - virt_types = self.get_virt_types() - for typ in virt_types: - if typ[0] is virt_type: - return typ[2] - return None - - def list_architectures(self): - result = [] - for guest in self.__capabilities.guests: - for domain in guest.domains: - ignore = domain - label = guest.arch - for row in result: - if row == label: - label = None - break - if label is None: - continue - - result.append(label) - return result - - def define_domain(self, config, meter): - location = None - extra = None - kickstart = None - - if config.get_install_type() == DomainConfig.LOCAL_INSTALL: - if config.get_use_cdrom_source(): - iclass = virtinst.DistroInstaller - location = config.get_install_media() - else: - iclass = virtinst.LiveCDInstaller - location = config.get_iso_path() - elif config.get_install_type() == DomainConfig.NETWORK_INSTALL: - iclass = virtinst.DistroInstaller - location = config.get_install_url() - extra = config.get_kernel_options() - kickstart = config.get_kickstart_url() - elif config.get_install_type() == DomainConfig.PXE_INSTALL: - iclass = virtinst.PXEInstaller - - installer = iclass(conn=self.__conn, - type=self.get_hypervisor(config.get_virt_type()), - os_type=self.get_os_type(config.get_virt_type())) - self.__guest = installer.guest_from_installer() - self.__guest.name = config.get_guest_name() - self.__guest.vcpus = config.get_cpus() - self.__guest.memory = config.get_memory() - self.__guest.maxmemory = config.get_memory() - - self.__guest.installer.location = location - if config.get_use_cdrom_source(): - self.__guest.installer.cdrom = True - extraargs = "" - if extra: - extraargs += extra - if kickstart: - extraargs += " ks=%s" % kickstart - if extraargs: - self.__guest.installer.extraarags = extraargs - - self.__guest.uuid = virtinst.util.randomUUID(self.__conn) - - if config.get_os_type() != "generic": - self.__guest.os_type = config.get_os_type() - if config.get_os_variant() != "generic": - self.__guest.os_variant = config.get_os_variant() - - self.__guest.add_device( - virtinst.VirtualGraphics(type=virtinst.VirtualGraphics.TYPE_VNC)) - self.__guest.add_device(virtinst.VirtualAudio()) - - self._setup_nics(config) - self._setup_disks(config) - - self.__guest.conn = self.__conn - self.__domain = self.__guest.start_install(False, meter=meter) - - def _setup_nics(self, config): - nic = virtinst.VirtualNetworkInterface(type=virtinst.VirtualNetworkInterface.TYPE_VIRTUAL, - bridge=config.get_network_bridge(), - network=config.get_network_bridge(), - macaddr=config.get_mac_address()) - self.__guest.add_device(nic) - # ensure the network is running - if config.get_network_bridge() not in self.__conn.listNetworks(): - network = self.__conn.networkLookupByName(config.get_network_bridge()) - network.create() - - def _setup_disks(self, config): - if config.get_enable_storage(): - path = None - if config.get_use_local_storage(): - if self.storage_pool_exists("default") is False: - self.define_storage_pool("default") - pool = self.__conn.storagePoolLookupByName("default") - path = virtinst.Storage.StorageVolume.find_free_name(config.get_guest_name(), - pool_object=pool, - suffix=".img") - path = os.path.join(DEFAULT_POOL_TARGET_PATH, path) - else: - volume = self.get_storage_volume(config.get_storage_pool(), - config.get_storage_volume()) - path = volume.path() - - if path is not None: - storage = virtinst.VirtualDisk(conn=self.__conn, - path=path, - size=config.get_storage_size()) - self.__guest.add_device(storage) - self.__guest.conn = self.__conn diff --git a/virtManagerTui/listdomains.py b/virtManagerTui/listdomains.py deleted file mode 100644 index 23236a84..00000000 --- a/virtManagerTui/listdomains.py +++ /dev/null @@ -1,104 +0,0 @@ -# -# listdomains.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -import snack -from virtManagerTui.domainlistconfigscreen import DomainListConfigScreen - - -class ListDomainsConfigScreen(DomainListConfigScreen): - LIST_PAGE = 1 - DETAIL_PAGE = 2 - - def __init__(self): - DomainListConfigScreen.__init__(self, 'List Virtual Machines') - - def page_has_next(self, page): - return (page == self.LIST_PAGE) - - def page_has_back(self, page): - return (page == self.DETAIL_PAGE) - - def validate_input(self, page, errors): - if page == self.LIST_PAGE: - if self.get_selected_domain() is None: - errors.append("Please select a virtual machine to view.") - else: - return True - - def get_elements_for_page(self, screen, page): - if page == self.LIST_PAGE: - return self.get_domain_list_page(screen) - elif page == self.DETAIL_PAGE: - return self.get_detail_page_elements(screen) - - def get_detail_page_elements(self, screen): - ignore = screen - domain = self.get_selected_domain() - fields = [] - - # build the list to display - fields.append(("Basic Details", None)) - fields.append(("Name", domain.get_name())) - fields.append(("UUID", domain.get_uuid())) - fields.append(("Status", domain.run_status())) - fields.append(("Description", domain.get_description() or "")) - fields.append(("", None)) - - fields.append(("Hypervisor Details", None)) - fields.append(("Hypervisor", domain.get_pretty_hv_type())) - fields.append(("Architecture", domain.get_arch() or "Unknown")) - fields.append(("Emulator", domain.get_emulator() or "None")) - fields.append(("", None)) - - fields.append(("Machine Settings", None)) - if bool(domain.get_acpi()): - fields.append(("ACPI", "Enabled")) - if bool(domain.get_apic()): - fields.append(("APIC", "Enabled")) - fields.append(("Clock offset", domain.get_clock() or "Same as host")) - fields.append(("", None)) - - fields.append(("Security", None)) - - semodel, setype, vmlabel = domain.get_seclabel() - caps = self.get_libvirt().get_capabilities() - if caps.host.secmodel and caps.host.secmodel.model: - semodel = caps.host.secmodel.model - fields.append(("Model", semodel or "None")) - - if semodel is not None and semodel != "apparmor": - fields.append(("Type", setype)) - fields.append(("Label", vmlabel)) - - grid = snack.Grid(2, len(fields)) - row = 0 - for field in fields: - if field[1] is not None: - grid.setField(snack.Label("%s : " % field[0]), 0, row, anchorRight=1) - grid.setField(snack.Label(field[1]), 1, row, anchorLeft=1) - else: - grid.setField(snack.Label("%s" % field[0]), 1, row) - row += 1 - - return [grid] - - -def ListDomains(): - screen = ListDomainsConfigScreen() - screen.start() diff --git a/virtManagerTui/listnetworks.py b/virtManagerTui/listnetworks.py deleted file mode 100644 index 28be40d7..00000000 --- a/virtManagerTui/listnetworks.py +++ /dev/null @@ -1,79 +0,0 @@ -# listnetworks.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -from snack import Label -from virtManagerTui.networklistconfigscreen import NetworkListConfigScreen - -LIST_PAGE = 1 -DETAILS_PAGE = 2 - - -class ListNetworksConfigScreen(NetworkListConfigScreen): - def __init__(self): - NetworkListConfigScreen.__init__(self, "List Networks") - - def page_has_next(self, page): - return (page is LIST_PAGE) and self.has_selectable_networks() - - def page_has_back(self, page): - return (page is DETAILS_PAGE) - - def get_elements_for_page(self, screen, page): - if page is LIST_PAGE: - return self.get_network_list_page(screen) - elif page is DETAILS_PAGE: - return self.get_network_details_page(screen) - - def get_network_details_page(self, screen): - ignore = screen - network = self.get_selected_network() - fields = [] - - result = network.get_ipv4_network() - netaddr = result[0] - dhcp = result[1] - - fields.append(("Basic details", None)) - fields.append(("Name", network.get_name())) - fields.append(("Device", network.get_bridge_device())) - fields.append(("Autostart", "Yes" if network.get_autostart() else "No")) - fields.append(("State", "Active" if network.is_active() else "Inactive")) - fields.append(("Autostart", "On Boot" if network.get_autostart() else "Never")) - - fields.append(("IPv4 configuration", None)) - fields.append(("Network", str(netaddr))) - - if dhcp is not None: - dhcp_start = str(dhcp[0]) - dhcp_end = str(dhcp[1]) - else: - dhcp_start = "Disabled" - dhcp_end = "Disabled" - - fields.append(("DHCP start", dhcp_start)) - fields.append(("DHCP end", dhcp_end)) - - fields.append(("Forwarding", network.pretty_forward_mode())) - - return [Label("Network Interface Details"), - self.create_grid_from_fields(fields)] - - -def ListNetworks(): - screen = ListNetworksConfigScreen() - screen.start() diff --git a/virtManagerTui/listpools.py b/virtManagerTui/listpools.py deleted file mode 100644 index 8e717c66..00000000 --- a/virtManagerTui/listpools.py +++ /dev/null @@ -1,70 +0,0 @@ -# listpools.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -from snack import Label -from snack import Listbox - -from virtManagerTui.storagelistconfigscreen import StorageListConfigScreen - -from newt_syrup import utils - -LIST_PAGE = 1 -DETAILS_PAGE = 2 - - -class ListStoragePoolsConfigScreen(StorageListConfigScreen): - def __init__(self): - StorageListConfigScreen.__init__(self, "List Storage Pools") - - def get_elements_for_page(self, screen, page): - if page is LIST_PAGE: - return self.get_storage_pool_list_page(screen) - elif page is DETAILS_PAGE: - return self.get_pool_details_page(screen) - - def page_has_next(self, page): - if page is LIST_PAGE and self.has_selectable_pools(): - return True - return False - - def page_has_back(self, page): - if page is DETAILS_PAGE: - return True - return False - - def get_pool_details_page(self, screen): - ignore = screen - pool = self.get_libvirt().get_storage_pool(self.get_selected_pool()) - volumes = Listbox(0) - for name in pool.listVolumes(): - volume = pool.storageVolLookupByName(name) - volumes.append("%s (%s)" % (name, utils.size_as_mb_or_gb(volume.info()[1])), name) - autostart = "No" - if pool.autostart(): - autostart = "Yes" - fields = [] - fields.append(("Name", pool.name())) - fields.append(("Volumes", volumes)) - fields.append(("Autostart", autostart)) - return [Label("Details For Storage Pool: %s" % self.get_selected_pool()), - self.create_grid_from_fields(fields)] - - -def ListStoragePools(): - screen = ListStoragePoolsConfigScreen() - screen.start() diff --git a/virtManagerTui/mainmenu.py b/virtManagerTui/mainmenu.py deleted file mode 100644 index 95c0ed7d..00000000 --- a/virtManagerTui/mainmenu.py +++ /dev/null @@ -1,56 +0,0 @@ -# mainmenu.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -from newt_syrup.menuscreen import MenuScreen - -from virtManagerTui.nodemenu import NodeMenu -from virtManagerTui.netmenu import NetworkMenu -from virtManagerTui.storagemenu import StoragePoolMenu -from virtManagerTui.hostmenu import HostMenu - -NODE_MENU = 1 -NETWORK_MENU = 2 -STORAGE_MENU = 3 -HOST_MENU = 4 -EXIT_CONSOLE = 99 - - -class MainMenuScreen(MenuScreen): - def __init__(self): - MenuScreen.__init__(self, "Main Menu") - - def get_menu_items(self): - return (("Node Administration", NODE_MENU), - ("Network Administration", NETWORK_MENU), - ("Storage Pool Administration", STORAGE_MENU), - ("Host Administration", HOST_MENU)) - - def handle_selection(self, page): - if page is NODE_MENU: - NodeMenu() - elif page is NETWORK_MENU: - NetworkMenu() - elif page is STORAGE_MENU: - StoragePoolMenu() - elif page is HOST_MENU: - HostMenu() - - -def MainMenu(): - screen = MainMenuScreen() - screen.start() diff --git a/virtManagerTui/migratedomain.py b/virtManagerTui/migratedomain.py deleted file mode 100644 index 1b52db30..00000000 --- a/virtManagerTui/migratedomain.py +++ /dev/null @@ -1,91 +0,0 @@ -# -# migratedomain.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -import snack -from virtManagerTui.domainlistconfigscreen import DomainListConfigScreen - -LIST_DOMAINS = 1 -SELECT_TARGET = 2 -CONFIRM_PAGE = 3 - - -class MigrateDomainConfigScreen(DomainListConfigScreen): - def __init__(self): - DomainListConfigScreen.__init__(self, "Migrate Virtual Machine") - self.__configured = False - self.__confirm = None - self.__targets = None - - def get_elements_for_page(self, screen, page): - if page is LIST_DOMAINS: - return self.get_domain_list_page(screen) - elif page is SELECT_TARGET: - return self.get_target_page(screen) - elif page is CONFIRM_PAGE: - return self.get_confirm_page(screen) - - def page_has_next(self, page): - if page is LIST_DOMAINS: - return self.has_selectable_domains() - else: - return page < CONFIRM_PAGE - - def page_has_back(self, page): - return page < CONFIRM_PAGE - - def page_has_finish(self, page): - return page is CONFIRM_PAGE - - def validate_input(self, page, errors): - if page is LIST_DOMAINS: - return self.get_selected_domain() is not None - elif page is SELECT_TARGET: - if self.__targets.current() is None: - errors.append("Please enter a target hostname or IP address.") - return False - elif page is CONFIRM_PAGE: - if not self.__confirm.value(): - errors.append("You must confirm migrating this virtual machine to proceed.") - return False - return True - - def process_input(self, page): - if page is CONFIRM_PAGE: - self.get_libvirt().migrate_domain(self.get_selected_domain(), self.__targets.current()) - self.set_finished() - - def get_target_page(self, screen): - ignore = screen - self.__targets = snack.Listbox(0) - for connection in self.get_virt_manager_config().get_connection_list(): - self.__targets.append(connection, connection) - return [snack.Label("Select A Target Host"), - self.__targets] - - def get_confirm_page(self, screen): - ignore = screen - self.__confirm = snack.Checkbox("Confirm migrating this virtual machine.") - grid = snack.Grid(1, 1) - grid.setField(self.__confirm, 0, 0) - return [grid] - - -def MigrateDomain(): - screen = MigrateDomainConfigScreen() - screen.start() diff --git a/virtManagerTui/netmenu.py b/virtManagerTui/netmenu.py deleted file mode 100644 index 434d6e61..00000000 --- a/virtManagerTui/netmenu.py +++ /dev/null @@ -1,60 +0,0 @@ -# mainmenu.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -from newt_syrup.menuscreen import MenuScreen - -from virtManagerTui.addnetwork import AddNetwork -from virtManagerTui.startnetwork import StartNetwork -from virtManagerTui.stopnetwork import StopNetwork -from virtManagerTui.removenetwork import RemoveNetwork -from virtManagerTui.listnetworks import ListNetworks - -ADD_NETWORK = 1 -START_NETWORK = 2 -STOP_NETWORK = 3 -REMOVE_NETWORK = 4 -LIST_NETWORKS = 5 - - -class NetworkMenuScreen(MenuScreen): - def __init__(self): - MenuScreen.__init__(self, "Network Administration") - - def get_menu_items(self): - return (("Add A Network", ADD_NETWORK), - ("Start A Network", START_NETWORK), - ("Stop A Network", STOP_NETWORK), - ("Remove A Network", REMOVE_NETWORK), - ("List Networks", LIST_NETWORKS)) - - def handle_selection(self, item): - if item is ADD_NETWORK: - AddNetwork() - elif item is START_NETWORK: - StartNetwork() - elif item is STOP_NETWORK: - StopNetwork() - elif item is REMOVE_NETWORK: - RemoveNetwork() - elif item is LIST_NETWORKS: - ListNetworks() - - -def NetworkMenu(): - screen = NetworkMenuScreen() - screen.start() diff --git a/virtManagerTui/networkconfig.py b/virtManagerTui/networkconfig.py deleted file mode 100644 index 3246ff7d..00000000 --- a/virtManagerTui/networkconfig.py +++ /dev/null @@ -1,112 +0,0 @@ -# networkconfig.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -import ipaddr - - -class NetworkConfig: - def __init__(self): - self.__name = "" - self.__isolated_network = True - self.__physical_device = "" - self.__ipv4_end = None - self.__ipv4_start = None - self.__ipv4_address = None - self.set_ipv4_address("192.168.100.0/24") - - def set_name(self, name): - self.__name = name - - def get_name(self): - return self.__name - - def set_ipv4_address(self, address): - self.__ipv4_address = ipaddr.IPNetwork(address) - start = int(self.__ipv4_address.numhosts / 2) - end = self.__ipv4_address.numhosts - 2 - self.__ipv4_start = self.__ipv4_address.network + start - self.__ipv4_end = self.__ipv4_address.network + end - - def get_ipv4_address(self): - return self.__ipv4_address - - def get_ipv4_address_raw(self): - return self.__ipv4_address - - def get_ipv4_netmask(self): - return self.__ipv4_address.netmask - - def get_ipv4_broadcast(self): - return self.__ipv4_address.broadcast - - def get_ipv4_gateway(self): - return self.__ipv4_address.network + 1 - - def get_ipv4_max_addresses(self): - return self.__ipv4_address.numhosts - - def get_ipv4_network_type(self): - if self.__ipv4_address.is_private: - return "PRIVATE" - if self.__ipv4_address.is_reserved: - return "RESERVED" - return "OTHER" - - def is_public_ipv4_network(self): - if self.__ipv4_address.is_private: - return False - if self.__ipv4_address.is_loopback: - return False - if self.__ipv4_address.is_multicast: - return False - if self.__ipv4_address.is_reserved: - return False - return True - - def set_ipv4_start_address(self, address): - self.__ipv4_start = address - - def get_ipv4_start_address(self): - return self.__ipv4_start - - def set_ipv4_end_address(self, address): - self.__ipv4_end = address - - def get_ipv4_end_address(self): - return self.__ipv4_end - - def is_bad_address(self, address): - return not self.__ipv4_address.overlaps(address) - - def set_isolated_network(self, isolated): - self.__isolated_network = isolated - - def is_isolated_network(self): - return self.__isolated_network - - def set_physical_device(self, device): - self.__physical_device = device - - def get_physical_device(self): - return self.__physical_device - - def get_physical_device_text(self): - if self.__physical_device == "": - return "any physical device" - else: - return "physical device %s" % self.__physical_device diff --git a/virtManagerTui/networklistconfigscreen.py b/virtManagerTui/networklistconfigscreen.py deleted file mode 100644 index b019310d..00000000 --- a/virtManagerTui/networklistconfigscreen.py +++ /dev/null @@ -1,57 +0,0 @@ -# networklistconfigscreen.py - Copyright (C) 2011 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -import snack - -from virtManagerTui.vmmconfigscreen import VmmTuiConfigScreen - - -class NetworkListConfigScreen(VmmTuiConfigScreen): - '''Provides a base class for all config screens that require a network list.''' - - def __init__(self, title): - VmmTuiConfigScreen.__init__(self, title) - self.__has_networks = None - self.__network_list = None - - def get_network_list_page(self, screen, defined=True, started=True): - ignore = screen - uuids = self.get_libvirt().list_networks(defined, started) - result = None - - if len(uuids) > 0: - self.__has_networks = True - self.__network_list = snack.Listbox(0) - for uuid in uuids: - network = self.get_libvirt().get_network(uuid) - self.__network_list.append(uuid, network.get_name()) - result = self.__network_list - else: - self.__has_networks = False - result = snack.Label("There are no networks available.") - grid = snack.Grid(1, 1) - grid.setField(result, 0, 0) - return [snack.Label("Network List"), - grid] - - def get_selected_network(self): - uuid = self.__network_list.current() - return self.get_libvirt().get_network(uuid) - - def has_selectable_networks(self): - return self.__has_networks diff --git a/virtManagerTui/nodeadmin.py b/virtManagerTui/nodeadmin.py deleted file mode 100644 index 721dacff..00000000 --- a/virtManagerTui/nodeadmin.py +++ /dev/null @@ -1,29 +0,0 @@ -# -# node-admin - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -import sys - -from virtManagerTui.mainmenu import MainMenu - - -def NodeAdmin(): - MainMenu() - -if __name__ == "__main__": - sys.exit(NodeAdmin()) diff --git a/virtManagerTui/nodemenu.py b/virtManagerTui/nodemenu.py deleted file mode 100644 index 85d46eab..00000000 --- a/virtManagerTui/nodemenu.py +++ /dev/null @@ -1,75 +0,0 @@ -# mainmenu.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -from newt_syrup.menuscreen import MenuScreen - -from virtManagerTui.adddomain import AddDomain -from virtManagerTui.startdomain import StartDomain -from virtManagerTui.stopdomain import StopDomain -from virtManagerTui.pausedomain import PauseDomain -from virtManagerTui.removedomain import RemoveDomain -from virtManagerTui.listdomains import ListDomains -from virtManagerTui.migratedomain import MigrateDomain -from virtManagerTui.createuser import CreateUser - -ADD_DOMAIN = 1 -START_DOMAIN = 2 -STOP_DOMAIN = 3 -PAUSE_DOMAIN = 4 -REMOVE_DOMAIN = 5 -LIST_DOMAINS = 6 -MIGRATE_DOMAIN = 7 -CREATE_USER = 8 - - -class NodeMenuScreen(MenuScreen): - def __init__(self): - MenuScreen.__init__(self, "Node Administration") - - def get_menu_items(self): - return (("Add A Virtual Machine", ADD_DOMAIN), - ("Start A Virtual Machine", START_DOMAIN), - ("Stop A Virtual Machine", STOP_DOMAIN), - ("Pause A Virtual Machine", PAUSE_DOMAIN), - ("Remove A Virtual Machine", REMOVE_DOMAIN), - ("List All Virtual Machines", LIST_DOMAINS), - ("Migrate Virtual Machine", MIGRATE_DOMAIN), - ("Create A User", CREATE_USER)) - - def handle_selection(self, item): - if item is ADD_DOMAIN: - AddDomain() - elif item is START_DOMAIN: - StartDomain() - elif item is STOP_DOMAIN: - StopDomain() - elif item is PAUSE_DOMAIN: - PauseDomain() - elif item is REMOVE_DOMAIN: - RemoveDomain() - elif item is LIST_DOMAINS: - ListDomains() - elif item is MIGRATE_DOMAIN: - MigrateDomain() - elif item is CREATE_USER: - CreateUser() - - -def NodeMenu(): - screen = NodeMenuScreen() - screen.start() diff --git a/virtManagerTui/pausedomain.py b/virtManagerTui/pausedomain.py deleted file mode 100644 index 6b9d3780..00000000 --- a/virtManagerTui/pausedomain.py +++ /dev/null @@ -1,74 +0,0 @@ -# -# pausedomain.py - Copyright (C) 2011 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -import snack -from virtManagerTui.domainlistconfigscreen import DomainListConfigScreen - - -class PauseDomainConfigScreen(DomainListConfigScreen): - LIST_PAGE = 1 - STOP_PAGE = 2 - - def __init__(self): - DomainListConfigScreen.__init__(self, "Pause A Domain") - - def get_elements_for_page(self, screen, page): - if page is self.LIST_PAGE: - return self.get_domain_list_page(screen, defined=False) - elif page is self.STOP_PAGE: - return self.get_stop_page(screen) - - def page_has_next(self, page): - if page is self.LIST_PAGE: - return self.has_selectable_domains() - return False - - def page_has_back(self, page): - if page is self.STOP_PAGE: - return True - return False - - def validate_input(self, page, errors): - if page is self.LIST_PAGE: - if self.get_selected_domain() is not None: - domain = self.get_selected_domain() - try: - if domain.is_pauseable(): - domain.suspend() - return True - else: - errors.append("%s is not in a pauseable state: state=%s" % (domain.get_name(), domain.run_status())) - except Exception, error: - errors.append("There was an error pausing the domain: %s" % domain) - errors.append(str(error)) - else: - errors.append("You must first select a domain to stop.") - return False - - def get_stop_page(self, screen): - ignore = screen - - grid = snack.Grid(1, 1) - grid.setField(snack.Label("%s was successfully paused." % self.get_selected_domain().get_name()), 0, 0) - return [grid] - - -def PauseDomain(): - screen = PauseDomainConfigScreen() - screen.start() diff --git a/virtManagerTui/poolconfig.py b/virtManagerTui/poolconfig.py deleted file mode 100644 index 47ec7c6f..00000000 --- a/virtManagerTui/poolconfig.py +++ /dev/null @@ -1,154 +0,0 @@ -# poolconfig.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -from virtinst import Storage - -ROOT_TARGET_PATH = "/var/lib/libvirt/images/%s" - - -class PoolConfig: - def __init__(self, libvirt): - self.__libvirt = libvirt - self.__name = "" - self.set_type(None) - self.__format = None - self.__hostname = "" - self.__target_path = "" - self.__source_path = "" - self.__build_pool = False - - self.__needs_source_path = None - self.__needs_target_path = None - self.__pool = None - self.__needs_hostname = None - self.__needs_build_pool = None - self.__needs_format = None - self.__type = None - - def get_pool(self): - return self.__pool - - def set_name(self, name): - self.__name = name - - def get_name(self): - return self.__name - - def set_type(self, pooltype): - self.__type = pooltype - self.__needs_target_path = False - self.__needs_format = False - self.__needs_target_path = False - self.__needs_format = False - self.__needs_hostname = False - self.__needs_source_path = False - self.__needs_build_pool = False - if pooltype is not None: - if pooltype is Storage.StoragePool.TYPE_DIR: - self.__needs_target_path = True - self.__target_path = ROOT_TARGET_PATH % self.__name - self.__build_pool = True - elif pooltype is Storage.StoragePool.TYPE_DISK: - self.__needs_target_path = True - self.__needs_format = True - self.__needs_source_path = True - self.__needs_build_pool = True - elif pooltype is Storage.StoragePool.TYPE_FS: - self.__needs_target_path = True - self.__needs_format = True - self.__needs_source_path = True - self.__build_pool = True - elif pooltype is Storage.StoragePool.TYPE_ISCSI: - self.__needs_target_path = True - self.__needs_hostname = True - self.__needs_source_path = True - self.__build_pool = False - elif pooltype is Storage.StoragePool.TYPE_LOGICAL: - self.__needs_target_path = True - self.__needs_source_path = True - self.__needs_build_pool = True - elif pooltype is Storage.StoragePool.TYPE_NETFS: - self.__needs_target_path = True - self.__needs_format = True - self.__needs_hostname = True - self.__needs_source_path = True - self.__build_pool = True - # create pool - pool_class = Storage.StoragePool.get_pool_class(self.__type) - self.__pool = pool_class(name=self.__name, - conn=self.__libvirt.get_connection()) - if self.__needs_format: - self.__format = self.__pool.formats[0] - else: - self.__type = Storage.StoragePool.get_pool_types()[0] - - def get_type(self): - return self.__type - - def needs_target_path(self): - return self.__needs_target_path - - def needs_format(self): - return self.__needs_format - - def needs_hostname(self): - return self.__needs_hostname - - def source_must_be_absolute(self): - if self.__type is Storage.StoragePool.TYPE_ISCSI: - return False - return True - - def needs_source_path(self): - return self.__needs_source_path - - def needs_build_pool(self): - return self.__needs_build_pool - - def set_target_path(self, path): - self.__target_path = path - - def get_target_path(self): - return self.__target_path - - def get_formats(self): - return self.__pool.formats - - def set_format(self, fmt): - self.__format = fmt - - def get_format(self): - return self.__format - - def set_hostname(self, hostname): - self.__hostname = hostname - - def get_hostname(self): - return self.__hostname - - def set_source_path(self, source_path): - self.__source_path = source_path - - def get_source_path(self): - return self.__source_path - - def set_build_pool(self, build_pool): - self.__build_pool = build_pool - - def get_build_pool(self): - return self.__build_pool diff --git a/virtManagerTui/removedomain.py b/virtManagerTui/removedomain.py deleted file mode 100644 index 148ac871..00000000 --- a/virtManagerTui/removedomain.py +++ /dev/null @@ -1,96 +0,0 @@ -# -# removedomain.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -import snack -from virtManagerTui.domainlistconfigscreen import DomainListConfigScreen - - -class RemoveDomainConfigScreen(DomainListConfigScreen): - LIST_PAGE = 1 - CONFIRM_PAGE = 2 - REMOVE_PAGE = 3 - - def __init__(self): - DomainListConfigScreen.__init__(self, "Remove A Domain") - self.__confirm_remove = None - - def get_elements_for_page(self, screen, page): - if page is self.LIST_PAGE: - return self.get_domain_list_page(screen) - elif page is self.CONFIRM_PAGE: - return self.get_confirm_page(screen) - elif page is self.REMOVE_PAGE: - return self.get_remove_page(screen) - - def page_has_next(self, page): - if page is self.LIST_PAGE: - return self.has_selectable_domains() - elif page is self.CONFIRM_PAGE: - return True - return False - - def page_has_back(self, page): - if page is self.CONFIRM_PAGE: - return True - elif page is self.REMOVE_PAGE: - return True - return False - - def get_back_page(self, page): - if page is self.CONFIRM_PAGE: - return self.LIST_PAGE - elif page is self.REMOVE_PAGE: - return self.LIST_PAGE - - def validate_input(self, page, errors): - if page is self.LIST_PAGE: - if self.get_selected_domain() is not None: - return True - else: - errors.append("You must first select a domain.") - elif page is self.CONFIRM_PAGE: - if self.__confirm_remove.value(): - domain = self.get_selected_domain() - try: - domain.delete() - return True - except Exception, error: - errors.append("Failed to remove %s." % domain) - errors.append(str(error)) - else: - errors.append("You must confirm undefining the domain to proceed.") - return False - - def get_confirm_page(self, screen): - ignore = screen - self.__confirm_remove = snack.Checkbox("Check here to confirm undefining %s." % self.get_selected_domain().get_name(), 0) - grid = snack.Grid(1, 1) - grid.setField(self.__confirm_remove, 0, 0) - return [grid] - - def get_remove_page(self, screen): - ignore = screen - grid = snack.Grid(1, 1) - grid.setField(snack.Label("%s has been removed." % self.get_selected_domain().get_name()), 0, 0) - return [grid] - - -def RemoveDomain(): - screen = RemoveDomainConfigScreen() - screen.start() diff --git a/virtManagerTui/removehost.py b/virtManagerTui/removehost.py deleted file mode 100644 index 23017656..00000000 --- a/virtManagerTui/removehost.py +++ /dev/null @@ -1,73 +0,0 @@ -# removehost.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -import snack - -from virtManagerTui.hostlistconfigscreen import HostListConfigScreen - -SELECT_HOST_PAGE = 1 -CONFIRM_REMOVE_PAGE = 2 - - -class RemoveHostConfigScreen(HostListConfigScreen): - def __init__(self): - HostListConfigScreen.__init__(self, "Remove Host Connection") - self.__confirm = None - - def get_elements_for_page(self, screen, page): - if page is SELECT_HOST_PAGE: - return self.get_connection_list_page(screen) - elif page is CONFIRM_REMOVE_PAGE: - return self.get_confirm_remove_page(screen) - - def page_has_next(self, page): - return page is SELECT_HOST_PAGE and self.has_selectable_connections() - - def page_has_back(self, page): - return page is CONFIRM_REMOVE_PAGE - - def page_has_finish(self, page): - return page is CONFIRM_REMOVE_PAGE - - def validate_input(self, page, errors): - if page is SELECT_HOST_PAGE: - return True - elif page is CONFIRM_REMOVE_PAGE: - if self.__confirm.value(): - return True - else: - errors.append("You must confirm removing the connection.") - return False - - def process_input(self, page): - if page is CONFIRM_REMOVE_PAGE: - self.get_virt_manager_config().remove_connection(self.get_selected_connection()) - self.set_finished() - - def get_confirm_remove_page(self, screen): - ignore = screen - self.__confirm = snack.Checkbox("Remove this connection: %s" % self.get_selected_connection(), 0) - grid = snack.Grid(1, 1) - grid.setField(self.__confirm, 0, 0) - return [snack.Label("Remove Host Connection"), - grid] - - -def RemoveHost(): - screen = RemoveHostConfigScreen() - screen.start() diff --git a/virtManagerTui/removenetwork.py b/virtManagerTui/removenetwork.py deleted file mode 100644 index 6e0f644b..00000000 --- a/virtManagerTui/removenetwork.py +++ /dev/null @@ -1,94 +0,0 @@ -# -# removenetwork.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -from snack import Checkbox -from snack import Label -from virtManagerTui.networklistconfigscreen import NetworkListConfigScreen - -LIST_PAGE = 1 -CONFIRM_PAGE = 2 -REMOVE_PAGE = 3 - - -class RemoveNetworkConfigScreen(NetworkListConfigScreen): - def __init__(self): - NetworkListConfigScreen.__init__(self, "Remove A Network") - self.__deleted_network_name = None - self.__confirm_remove = None - - def get_elements_for_page(self, screen, page): - if page is LIST_PAGE: - return self.get_network_list_page(screen, started=False) - elif page is CONFIRM_PAGE: - return self.get_confirm_page(screen) - elif page is REMOVE_PAGE: - return self.get_remove_network_page(screen) - - def page_has_next(self, page): - if page is LIST_PAGE: - return self.has_selectable_networks() - if page is CONFIRM_PAGE: - return True - return False - - def page_has_back(self, page): - if page is CONFIRM_PAGE: - return True - if page is REMOVE_PAGE: - return True - return False - - def get_back_page(self, page): - if page is CONFIRM_PAGE: - return LIST_PAGE - elif page is REMOVE_PAGE: - return LIST_PAGE - - def validate_input(self, page, errors): - if page is LIST_PAGE: - return True - elif page is CONFIRM_PAGE: - network = self.get_selected_network() - if self.__confirm_remove.value(): - self.__deleted_network_name = network.get_name() - network.delete() - return True - else: - errors.append("You must confirm undefining %s." % network.get_name()) - elif page is REMOVE_PAGE: - return True - return False - - def get_confirm_page(self, screen): - ignore = screen - network = self.get_selected_network() - self.__confirm_remove = Checkbox("Check here to confirm undefining %s." % network.get_name()) - fields = [] - fields.append((self.__confirm_remove, None)) - return [self.create_grid_from_fields(fields)] - - def get_remove_network_page(self, screen): - ignore = screen - network_name = self.__deleted_network_name - return [Label("Network has been removed: %s" % network_name)] - - -def RemoveNetwork(): - screen = RemoveNetworkConfigScreen() - screen.start() diff --git a/virtManagerTui/removepool.py b/virtManagerTui/removepool.py deleted file mode 100644 index fccaa77b..00000000 --- a/virtManagerTui/removepool.py +++ /dev/null @@ -1,98 +0,0 @@ -# -# removepool.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -from snack import Checkbox -from snack import Label - -from virtManagerTui.storagelistconfigscreen import StorageListConfigScreen - -LIST_POOLS_PAGE = 1 -CONFIRM_PAGE = 2 -FINISHED_REMOVING = 3 - - -class RemoveStoragePoolConfigScreen(StorageListConfigScreen): - def __init__(self): - StorageListConfigScreen.__init__(self, "Remove A Storage Pool") - self.__confirm = None - - def get_elements_for_page(self, screen, page): - if page is LIST_POOLS_PAGE: - return self.get_storage_pool_list_page(screen) - elif page is CONFIRM_PAGE: - return self.get_confirm_page(screen) - elif page is FINISHED_REMOVING: - return self.get_finished_removing_page(screen) - - def page_has_next(self, page): - if page is LIST_POOLS_PAGE and self.has_selectable_pools(): - return True - elif page is CONFIRM_PAGE: - return True - return False - - def page_has_finish(self, page): - return page is FINISHED_REMOVING - - def page_has_back(self, page): - ignore = page - return False - - def validate_input(self, page, errors): - if page is LIST_POOLS_PAGE: - if self.get_selected_pool() is not None: - return True - else: - errors.append("Please select a storage pool to be removed.") - elif page is CONFIRM_PAGE: - if self.__confirm.value(): - return True - else: - errors.append("You must confirm removing a storage pool.") - return False - - def process_input(self, page): - if page is CONFIRM_PAGE: - try: - self.get_libvirt().destroy_storage_pool(self.get_selected_pool()) - self.get_libvirt().undefine_storage_pool(self.get_selected_pool()) - except Exception: - pass - - def get_confirm_page(self, screen): - ignore = screen - self.__confirm = Checkbox("Check here to confirm deleting pool: %s" % self.get_selected_pool()) - fields = [] - fields.append((None, self.__confirm)) - return [Label("Remove Selected Storage Pool"), - self.create_grid_from_fields(fields)] - - def get_finished_removing_page(self, page): - ignore = page - self.set_finished() - pool = self.get_selected_pool() - state = "" - if self.get_libvirt().storage_pool_exists(pool): - state = "was not " - return [Label("Storage pool '%s' %sdeleted." % (pool, state))] - - -def RemoveStoragePool(): - screen = RemoveStoragePoolConfigScreen() - screen.start() diff --git a/virtManagerTui/removevolume.py b/virtManagerTui/removevolume.py deleted file mode 100644 index 68f96f1f..00000000 --- a/virtManagerTui/removevolume.py +++ /dev/null @@ -1,84 +0,0 @@ -# removevolume.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -import snack - -from virtManagerTui.storagelistconfigscreen import StorageListConfigScreen -from virtManagerTui.volumeconfig import StorageVolumeConfig - -SELECT_POOL_PAGE = 1 -SELECT_VOLUME_PAGE = 2 -CONFIRM_PAGE = 3 - - -class RemoveVolumeConfigScreen(StorageListConfigScreen): - def __init__(self): - StorageListConfigScreen.__init__(self, "Add A New Storage Volume") - self.__config = StorageVolumeConfig() - self.__confirm = None - - def get_elements_for_page(self, screen, page): - if page is SELECT_POOL_PAGE: - return self.get_storage_pool_list_page(screen) - elif page is SELECT_VOLUME_PAGE: - return self.get_storage_volume_list_page(screen) - elif page is CONFIRM_PAGE: - return self.get_confirm_page(screen) - - def page_has_next(self, page): - if page is SELECT_POOL_PAGE: - return self.has_selectable_pools() - elif page is SELECT_VOLUME_PAGE: - return self.has_selectable_volumes() - return False - - def validate_input(self, page, errors): - if page is SELECT_POOL_PAGE: - return self.get_selected_pool() is not None - elif page is SELECT_VOLUME_PAGE: - return self.get_selected_volume() is not None - elif page is CONFIRM_PAGE: - if self.__confirm.value(): - return True - else: - errors.append("You must confirm deleting a storage volume.") - return False - - def process_input(self, page): - if page is CONFIRM_PAGE: - self.get_libvirt().remove_storage_volume(self.get_selected_pool(), self.get_selected_volume()) - self.set_finished() - - def page_has_back(self, page): - return page > SELECT_POOL_PAGE - - def page_has_finish(self, page): - return page is CONFIRM_PAGE - - def get_confirm_page(self, screen): - ignore = screen - self.__confirm = snack.Checkbox("Check here to confirm deleting volume: %s" % self.get_selected_volume()) - grid = snack.Grid(1, 1) - grid.setField(self.__confirm, 0, 0) - return [snack.Label("Remove Selected Storage Volume"), - grid] - - -def RemoveStorageVolume(): - screen = RemoveVolumeConfigScreen() - screen.start() diff --git a/virtManagerTui/startdomain.py b/virtManagerTui/startdomain.py deleted file mode 100644 index fcd6f6cf..00000000 --- a/virtManagerTui/startdomain.py +++ /dev/null @@ -1,73 +0,0 @@ -# -# startdomain.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -import snack - -from virtManagerTui.domainlistconfigscreen import DomainListConfigScreen - - -class StartDomainConfigScreen(DomainListConfigScreen): - LIST_PAGE = 1 - START_PAGE = 2 - - def __init__(self): - DomainListConfigScreen.__init__(self, "Start A Domain") - - def get_elements_for_page(self, screen, page): - if page is self.LIST_PAGE: - return self.get_domain_list_page(screen, created=False) - elif page is self.START_PAGE: - return self.get_start_domain_page(screen) - - def page_has_next(self, page): - if page is self.LIST_PAGE: - return self.has_selectable_domains() - return False - - def page_has_back(self, page): - if page is self.START_PAGE: - return True - return False - - def validate_input(self, page, errors): - if page is self.LIST_PAGE: - if self.get_selected_domain() is not None: - domain = self.get_selected_domain() - try: - if domain.is_unpauseable(): - domain.resume() - else: - domain.startup() - return True - except Exception, error: - errors.append("There was an error creating the domain: %s" % domain.get_name()) - errors.append(str(error)) - else: - errors.append("You must first select a domain to start.") - - def get_start_domain_page(self, screen): - ignore = screen - grid = snack.Grid(1, 1) - grid.setField(snack.Label("%s was successfully started." % self.get_selected_domain().get_name()), 0, 0) - return [grid] - - -def StartDomain(): - screen = StartDomainConfigScreen() - screen.start() diff --git a/virtManagerTui/startnetwork.py b/virtManagerTui/startnetwork.py deleted file mode 100644 index c19ddc84..00000000 --- a/virtManagerTui/startnetwork.py +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env python -# -# startnetwork.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -from snack import Label -from virtManagerTui.networklistconfigscreen import NetworkListConfigScreen - -LIST_PAGE = 1 -START_PAGE = 2 - - -class StartNetworkConfigScreen(NetworkListConfigScreen): - def __init__(self): - NetworkListConfigScreen.__init__(self, "Start A Network") - - def get_elements_for_page(self, screen, page): - if page is LIST_PAGE: - return self.get_network_list_page(screen, started=False) - elif page is START_PAGE: - return self.get_start_network_page(screen) - - def page_has_next(self, page): - if page is LIST_PAGE: - return self.has_selectable_networks() - - def page_has_back(self, page): - return (page is START_PAGE) - - def validate_input(self, page, errors): - if page is LIST_PAGE: - network = self.get_selected_network() - if network.is_active(): - errors.append("%s is already started." % network.get_name()) - else: - network.start() - return True - - def get_start_network_page(self, screen): - ignore = screen - network = self.get_selected_network() - return [Label("%s was successfully started." % network.get_name())] - - -def StartNetwork(): - screen = StartNetworkConfigScreen() - screen.start() diff --git a/virtManagerTui/startpool.py b/virtManagerTui/startpool.py deleted file mode 100644 index 4907b7c9..00000000 --- a/virtManagerTui/startpool.py +++ /dev/null @@ -1,63 +0,0 @@ -# -# startpool.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -from snack import Label -from virtManagerTui.storagelistconfigscreen import StorageListConfigScreen - -LIST_POOLS_PAGE = 1 -FINAL_PAGE = 2 - - -class StartStoragePoolConfigScreen(StorageListConfigScreen): - def __init__(self): - StorageListConfigScreen.__init__(self, "Start A Storage Pool") - - def get_elements_for_page(self, screen, page): - if page is LIST_POOLS_PAGE: - return self.get_storage_pool_list_page(screen, created=False) - elif page is FINAL_PAGE: - return self.get_final_page(screen) - - def page_has_next(self, page): - return page is LIST_POOLS_PAGE and self.has_selectable_pools() - - def page_has_finish(self, page): - return page is FINAL_PAGE - - def validate_input(self, page, errors): - if page is LIST_POOLS_PAGE: - if self.get_selected_pool() is not None: - return True - else: - errors.append("Please select a storage pool to be started.") - return False - - def process_input(self, page): - if page is LIST_POOLS_PAGE: - self.get_libvirt().create_storage_pool(self.get_selected_pool()) - - def get_final_page(self, screen): - ignore = screen - self.set_finished() - return [Label("Storage pool started: %s" % self.get_selected_pool())] - - -def StartStoragePool(): - screen = StartStoragePoolConfigScreen() - screen.start() diff --git a/virtManagerTui/stopdomain.py b/virtManagerTui/stopdomain.py deleted file mode 100644 index c11f67eb..00000000 --- a/virtManagerTui/stopdomain.py +++ /dev/null @@ -1,73 +0,0 @@ -# -# stopdomain.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -import snack -from virtManagerTui.domainlistconfigscreen import DomainListConfigScreen - - -class StopDomainConfigScreen(DomainListConfigScreen): - LIST_PAGE = 1 - STOP_PAGE = 2 - - def __init__(self): - DomainListConfigScreen.__init__(self, "Stop A Domain") - - def get_elements_for_page(self, screen, page): - if page is self.LIST_PAGE: - return self.get_domain_list_page(screen, defined=False) - elif page is self.STOP_PAGE: - return self.get_stop_page(screen) - - def page_has_next(self, page): - if page is self.LIST_PAGE: - return self.has_selectable_domains() - return False - - def page_has_back(self, page): - if page is self.STOP_PAGE: - return True - return False - - def validate_input(self, page, errors): - if page is self.LIST_PAGE: - if self.get_selected_domain() is not None: - domain = self.get_selected_domain() - try: - if domain.is_stoppable(): - domain.destroy() - return True - else: - errors.append("%s is not in a stoppable state: state=%s" % (domain.get_name(), domain.run_status())) - except Exception, error: - errors.append("There was an error stopping the domain: %s" % domain) - errors.append(str(error)) - else: - errors.append("You must first select a domain to stop.") - return False - - def get_stop_page(self, screen): - ignore = screen - grid = snack.Grid(1, 1) - grid.setField(snack.Label("%s was successfully stopped." % self.get_selected_domain().get_name()), 0, 0) - return [grid] - - -def StopDomain(): - screen = StopDomainConfigScreen() - screen.start() diff --git a/virtManagerTui/stopnetwork.py b/virtManagerTui/stopnetwork.py deleted file mode 100644 index 6fa9173c..00000000 --- a/virtManagerTui/stopnetwork.py +++ /dev/null @@ -1,65 +0,0 @@ -# -# stopnetwork.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -from snack import Label -from virtManagerTui.networklistconfigscreen import NetworkListConfigScreen -import logging - -LIST_PAGE = 1 -STOP_PAGE = 2 - - -class StopNetworkConfigScreen(NetworkListConfigScreen): - def __init__(self): - NetworkListConfigScreen.__init__(self, "Stop A Network") - - def get_elements_for_page(self, screen, page): - if page is LIST_PAGE: - return self.get_network_list_page(screen, defined=False) - elif page is STOP_PAGE: - return self.get_stop_network_page(screen) - - def page_has_next(self, page): - if page is LIST_PAGE: - return self.has_selectable_networks() - return False - - def page_has_back(self, page): - if page is STOP_PAGE: - return True - return False - - def validate_input(self, page, errors): - if page is LIST_PAGE: - network = self.get_selected_network() - try: - network.stop() - except Exception as error: - logging.error(error) - return network.is_active() is not True - - def get_stop_network_page(self, screen): - ignore = screen - network = self.get_selected_network() - return [Label("%s has been stopped." % network.get_name())] - - -def StopNetwork(): - screen = StopNetworkConfigScreen() - screen.start() diff --git a/virtManagerTui/stoppool.py b/virtManagerTui/stoppool.py deleted file mode 100644 index 96391ee9..00000000 --- a/virtManagerTui/stoppool.py +++ /dev/null @@ -1,63 +0,0 @@ -# -# stoppool.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -from snack import Label -from virtManagerTui.storagelistconfigscreen import StorageListConfigScreen - -LIST_POOLS_PAGE = 1 -FINAL_PAGE = 2 - - -class StopStoragePoolConfigScreen(StorageListConfigScreen): - def __init__(self): - StorageListConfigScreen.__init__(self, "Stop A Storage Pool") - - def get_elements_for_page(self, screen, page): - if page is LIST_POOLS_PAGE: - return self.get_storage_pool_list_page(screen, defined=False) - elif page is FINAL_PAGE: - return self.get_final_page(screen) - - def page_has_next(self, page): - return page is LIST_POOLS_PAGE and self.has_selectable_pools() - - def page_has_finish(self, page): - return page is FINAL_PAGE - - def validate_input(self, page, errors): - if page is LIST_POOLS_PAGE: - if self.get_selected_pool() is not None: - return True - else: - errors.append("Please select a storage pool to be stopped.") - return False - - def process_input(self, page): - if page is LIST_POOLS_PAGE: - self.get_libvirt().destroy_storage_pool(self.get_selected_pool()) - - def get_final_page(self, screen): - ignore = screen - self.set_finished() - return [Label("Storage pool stopped: %s" % self.get_selected_pool())] - - -def StopStoragePool(): - screen = StopStoragePoolConfigScreen() - screen.start() diff --git a/virtManagerTui/storagelistconfigscreen.py b/virtManagerTui/storagelistconfigscreen.py deleted file mode 100644 index 97005cdd..00000000 --- a/virtManagerTui/storagelistconfigscreen.py +++ /dev/null @@ -1,80 +0,0 @@ -# storagelistconfigscreen.py - Copyright (C) 2011 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -import snack - -from virtManagerTui.vmmconfigscreen import VmmTuiConfigScreen - - -class StorageListConfigScreen(VmmTuiConfigScreen): - '''Provides a base class for any configuration screen that deals with storage pool lists.''' - - def __init__(self, title): - VmmTuiConfigScreen.__init__(self, title) - self.__has_pools = None - self.__pools_list = None - self.__has_volumes = None - self.__volumes_list = None - - def get_storage_pool_list_page(self, screen, defined=True, created=True): - ignore = screen - pools = self.get_libvirt().list_storage_pools(defined=defined, created=created) - if len(pools) > 0: - self.__has_pools = True - self.__pools_list = snack.Listbox(0) - for pool in pools: - self.__pools_list.append(pool, pool) - result = self.__pools_list - else: - self.__has_pools = False - result = snack.Label("There are no storage pools available.") - grid = snack.Grid(1, 1) - grid.setField(result, 0, 0) - return [snack.Label("Storage Pool List"), - grid] - - def get_selected_pool(self): - return self.__pools_list.current() - - def has_selectable_pools(self): - return self.__has_pools - - def get_storage_volume_list_page(self, screen): - '''Requires that self.__pools_list have a selected element.''' - ignore = screen - pool = self.get_libvirt().get_storage_pool(self.get_selected_pool()) - if len(pool.listVolumes()) > 0: - self.__has_volumes = True - self.__volumes_list = snack.Listbox(0) - for volname in pool.listVolumes(): - volume = pool.storageVolLookupByName(volname) - self.__volumes_list.append("%s (%0.2f GB)" % (volume.name(), volume.info()[2] / (1024 ** 3)), volume.name()) - result = self.__volumes_list - else: - self.__has_volumes = False - result = snack.Label("There are no storage volumes available.") - grid = snack.Grid(1, 1) - grid.setField(result, 0, 0) - return [snack.Label("Storage Volume List"), - grid] - - def get_selected_volume(self): - return self.__volumes_list.current() - - def has_selectable_volumes(self): - return self.__has_volumes diff --git a/virtManagerTui/storagemenu.py b/virtManagerTui/storagemenu.py deleted file mode 100644 index 68dd745e..00000000 --- a/virtManagerTui/storagemenu.py +++ /dev/null @@ -1,70 +0,0 @@ -# storagemenu.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -from newt_syrup.menuscreen import MenuScreen - -from virtManagerTui.addpool import AddStoragePool -from virtManagerTui.startpool import StartStoragePool -from virtManagerTui.stoppool import StopStoragePool -from virtManagerTui.removepool import RemoveStoragePool -from virtManagerTui.addvolume import AddStorageVolume -from virtManagerTui.removevolume import RemoveStorageVolume -from virtManagerTui.listpools import ListStoragePools - -ADD_POOL = 1 -START_POOL = 2 -STOP_POOL = 3 -REMOVE_POOL = 4 -ADD_VOLUME = 5 -REMOVE_VOLUME = 6 -LIST_POOLS = 7 - - -class StoragePoolMenuScreen(MenuScreen): - def __init__(self): - MenuScreen.__init__(self, "Storage Pool Administration") - - def get_menu_items(self): - return (("Add A Storage Pool", ADD_POOL), - ("Start A Storage Pool", START_POOL), - ("Stop A Storage Pool", STOP_POOL), - ("Remove A Storage Pool", REMOVE_POOL), - ("Add A Storage Volume", ADD_VOLUME), - ("Remove A Storage Volume", REMOVE_VOLUME), - ("List Storage Pools", LIST_POOLS)) - - def handle_selection(self, item): - if item is ADD_POOL: - AddStoragePool() - elif item is START_POOL: - StartStoragePool() - elif item is STOP_POOL: - StopStoragePool() - elif item is REMOVE_POOL: - RemoveStoragePool() - elif item is ADD_VOLUME: - AddStorageVolume() - elif item is REMOVE_VOLUME: - RemoveStorageVolume() - elif item is LIST_POOLS: - ListStoragePools() - - -def StoragePoolMenu(): - screen = StoragePoolMenuScreen() - screen.start() diff --git a/virtManagerTui/userworker.py b/virtManagerTui/userworker.py deleted file mode 100644 index 908e4b7a..00000000 --- a/virtManagerTui/userworker.py +++ /dev/null @@ -1,39 +0,0 @@ -# userworker.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -import libuser - - -class UserWorker: - '''Provides APIs for creating, modifying and deleting user accounts.''' - def __init__(self): - self.__admin = libuser.admin() - - def create_user(self, username, password, other_group): - '''Creates a new user account with the provides username, - password. The user is also added to the optional group - if one is specified.''' - user = self.__admin.initUser(username) - user.set('pw_passwd', password) - self.__admin.addUser(user) - if other_group is not None: - group = self.__admin.lookupGroupByName(other_group) - if group is None: - raise Exception("Invalid group specified: %s" % other_group) - user.add('pw_gid', group.get('pw_gid')[0]) - self.__admin.modifyUser(user) diff --git a/virtManagerTui/vmmconfigscreen.py b/virtManagerTui/vmmconfigscreen.py deleted file mode 100644 index bfe19e64..00000000 --- a/virtManagerTui/vmmconfigscreen.py +++ /dev/null @@ -1,77 +0,0 @@ -# vmmconfigscreen.py - Copyright (C) 2011 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -from snack import Grid -from snack import Label - -from types import StringType - -from newt_syrup import configscreen -from virtManagerTui.libvirtworker import LibvirtWorker, VirtManagerConfig - -BACK_BUTTON = "back" -NEXT_BUTTON = "next" -CANCEL_BUTTON = "cancel" -FINISH_BUTTON = "finish" - - -class VmmTuiConfigScreen(configscreen.ConfigScreen): - '''Enables the creation of navigable, multi-paged configuration screens.''' - - def __init__(self, title): - configscreen.ConfigScreen.__init__(self, title) - self.__libvirt = LibvirtWorker() - self.__vm_config = VirtManagerConfig() - - def get_libvirt(self): - return self.__libvirt - - def get_virt_manager_config(self): - return self.__vm_config - - def create_grid_from_fields(self, fields): - ''' - Takes a series of fields names and values and returns a Grid composed - of Labels for that screen. - - If the value element is specified, it can be either a String or else - one of the UI widgets. - - Keyword arguments: - fields -- A two-dimensional array of label and value pairs. - ''' - grid = Grid(2, len(fields)) - row = 0 - for field in fields: - if field[1] is not None: - grid.setField(Label("%s : " % field[0]), 0, row, anchorRight=1) - # if the value is a String, then wrap it in a Label - # otherwise just add it - value = field[1] - if type(value) == StringType: - value = Label(field[1]) - grid.setField(value, 1, row, anchorLeft=1) - else: - # here the label itself might be a string or a widget - value = field[0] - if type(value) == StringType: - value = Label(field[0]) - grid.setField(value, 0, row) - row += 1 - - return grid diff --git a/virtManagerTui/volumeconfig.py b/virtManagerTui/volumeconfig.py deleted file mode 100644 index da5930e3..00000000 --- a/virtManagerTui/volumeconfig.py +++ /dev/null @@ -1,86 +0,0 @@ -# volumeconfig.py - Copyright (C) 2009 Red Hat, Inc. -# Written by Darryl L. Pierce -# -# 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; version 2 of the License. -# -# 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. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -import virtinst -from virtinst import Storage - - -class StorageVolumeConfig: - def __init__(self): - self.__pool = None - self.__name = "" - self.__formats = None - self.__format = None - self.__max_capacity = 10000 - self.__allocation = 0 - self.__pool_type = None - self.__volume_class = None - - def set_pool(self, pool): - self.__pool = pool - self.__formats = None - self.__pool_type = virtinst.util.get_xml_path(self.__pool.XMLDesc(0), '/pool/@type') - self.__volume_class = Storage.StoragePool.get_volume_for_pool(self.__pool_type) - - def get_pool(self): - return self.__pool - - def create_volume(self): - volume = self.__volume_class(name=self.__name + ".img", - allocation=self.__allocation * (1024 ** 2), - capacity=self.__max_capacity * (1024 ** 2), - pool=self.__pool) - volume.pool = self.__pool - if self.needs_format(): - volume.format = self.__format - return volume - - def set_name(self, name): - self.__name = name - - def get_name(self): - return self.__name - - def needs_format(self): - if self.__pool.__dict__.keys().count("get_formats_for_pool") > 0: - return self.__pool.get_formats_for_pool() is not 0 - else: - return False - - def get_formats_for_pool(self): - if self.__formats is None: - self.__formats = self.__volume_class.formats - return self.__formats - - def set_format(self, fmt): - self.__format = fmt - - def get_format(self): - return self.__format - - def set_max_capacity(self, capacity): - self.__max_capacity = capacity - - def get_max_capacity(self): - return self.__max_capacity - - def set_allocation(self, allocation): - self.__allocation = allocation - - def get_allocation(self): - return self.__allocation diff --git a/virtcli/cliconfig.py b/virtcli/cliconfig.py index 77dfe221..5e124a27 100644 --- a/virtcli/cliconfig.py +++ b/virtcli/cliconfig.py @@ -74,8 +74,6 @@ else: asset_dir = install_asset_dir icon_dir = os.path.join(asset_dir, "icons") -with_tui = bool(int(_get_param("with_tui", "1"))) - default_qemu_user = _get_param("default_qemu_user", "root") rhel_enable_unsupported_opts = not bool(int( _get_param("hide_unsupported_rhel_options", "0")))