installer: Remove --location nfs support

Removal was discussed here:
https://www.redhat.com/archives/virt-tools-list/2018-May/msg00011.html

Basically I don't think many people use this, the feature is very
inflexible, it's hard to test, and users can essentially do it
themselves with a bit more effort.
This commit is contained in:
Cole Robinson 2018-06-12 13:49:25 -04:00
parent 8e150901f4
commit 7a2abb5abf
8 changed files with 23 additions and 211 deletions

View File

@ -19,8 +19,9 @@ VNC or SPICE, as well as text mode installs over serial console. The guest
can be configured to use one or more virtual disks, network interfaces,
audio devices, physical USB or PCI devices, among others.
The installation media can be held locally or remotely on NFS, HTTP, FTP
servers. In the latter case C<virt-install> will fetch the minimal files
The installation media can be local ISO or CDROM media, or a distro install
tree hosted remotely over HTTP, FTP, or in a local directory. In the install
tree case C<virt-install> will fetch the minimal files
necessary to kick off the installation process, allowing the guest
to fetch the rest of the OS distribution as needed. PXE booting, and importing
an existing disk image (thus skipping the install phase) are also supported.
@ -397,10 +398,6 @@ An HTTP server location containing an installable distribution image.
An FTP server location containing an installable distribution image.
=item nfs:host:/path or nfs://host/path
An NFS server location containing an installable distribution image. This requires running virt-install as root.
=item DIRECTORY
Path to a local directory containing an installable distribution image. Note that the directory will not be accessible by the guest after initial boot, so the OS installer will need another way to access the rest of the install media.

View File

@ -10,8 +10,6 @@ import os
# Need to do this before any tests or virtinst import
os.environ["VIRTINST_TEST_SUITE"] = "1"
os.environ["VIRTINST_TEST_URL_DIR"] = os.path.abspath(
"tests/cli-test-xml/fakefedoratree/")
# pylint: disable=wrong-import-position
from virtcli import cliconfig

View File

@ -1,119 +0,0 @@
<domain type="kvm">
<name>foobar</name>
<uuid>00000000-1111-2222-3333-444444444444</uuid>
<memory>65536</memory>
<currentMemory>65536</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch="x86_64">hvm</type>
<kernel>/tmp/virtinst-vmlinuz.</kernel>
<initrd>/tmp/virtinst-initrd.img.</initrd>
<cmdline>method=nfs:example.com/fake</cmdline>
</os>
<features>
<acpi/>
<apic/>
<vmport state="off"/>
</features>
<cpu mode="custom" match="exact">
<model>Opteron_G4</model>
</cpu>
<clock offset="utc">
<timer name="rtc" tickpolicy="catchup"/>
<timer name="pit" tickpolicy="delay"/>
<timer name="hpet" present="no"/>
</clock>
<on_reboot>destroy</on_reboot>
<pm>
<suspend-to-mem enabled="no"/>
<suspend-to-disk enabled="no"/>
</pm>
<devices>
<emulator>/usr/bin/qemu-kvm</emulator>
<controller type="usb" index="0" model="ich9-ehci1"/>
<controller type="usb" index="0" model="ich9-uhci1">
<master startport="0"/>
</controller>
<controller type="usb" index="0" model="ich9-uhci2">
<master startport="2"/>
</controller>
<controller type="usb" index="0" model="ich9-uhci3">
<master startport="4"/>
</controller>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>
</channel>
<input type="tablet" bus="usb"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<sound model="ich6"/>
<video>
<model type="qxl"/>
</video>
<redirdev bus="usb" type="spicevmc"/>
<redirdev bus="usb" type="spicevmc"/>
<rng model="virtio">
<backend model="random">/dev/urandom</backend>
</rng>
</devices>
</domain>
<domain type="kvm">
<name>foobar</name>
<uuid>00000000-1111-2222-3333-444444444444</uuid>
<memory>65536</memory>
<currentMemory>65536</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch="x86_64">hvm</type>
<boot dev="hd"/>
</os>
<features>
<acpi/>
<apic/>
<vmport state="off"/>
</features>
<cpu mode="custom" match="exact">
<model>Opteron_G4</model>
</cpu>
<clock offset="utc">
<timer name="rtc" tickpolicy="catchup"/>
<timer name="pit" tickpolicy="delay"/>
<timer name="hpet" present="no"/>
</clock>
<pm>
<suspend-to-mem enabled="no"/>
<suspend-to-disk enabled="no"/>
</pm>
<devices>
<emulator>/usr/bin/qemu-kvm</emulator>
<controller type="usb" index="0" model="ich9-ehci1"/>
<controller type="usb" index="0" model="ich9-uhci1">
<master startport="0"/>
</controller>
<controller type="usb" index="0" model="ich9-uhci2">
<master startport="2"/>
</controller>
<controller type="usb" index="0" model="ich9-uhci3">
<master startport="4"/>
</controller>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>
</channel>
<input type="tablet" bus="usb"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<image compression="off"/>
</graphics>
<sound model="ich6"/>
<video>
<model type="qxl"/>
</video>
<redirdev bus="usb" type="spicevmc"/>
<redirdev bus="usb" type="spicevmc"/>
<rng model="virtio">
<backend model="random">/dev/urandom</backend>
</rng>
</devices>
</domain>

View File

@ -734,7 +734,6 @@ c.add_compare("--connect " + utils.URIs.kvm_session + " --disk size=8 --os-varia
# misc KVM config tests
c.add_compare("--disk none --location %(EXISTIMG3)s --nonetworks", "location-iso", skip_check=not find_executable("isoinfo")) # Using --location iso mounting
c.add_compare("--disk none --location nfs:example.com/fake --nonetworks", "location-nfs") # Using --location nfs
c.add_compare("--disk %(EXISTIMG1)s --pxe --os-variant rhel6.4", "kvm-rhel6") # RHEL6 defaults
c.add_compare("--disk %(EXISTIMG1)s --pxe --os-variant rhel7.0", "kvm-rhel7") # RHEL7 defaults
c.add_compare("--disk %(EXISTIMG1)s --pxe --os-variant centos7.0", "kvm-centos7") # Centos 7 defaults
@ -748,6 +747,7 @@ c.add_valid("--arch aarch64 --nodisks --pxe --connect " + utils.URIs.kvm_nodomca
c.add_invalid("--disk none --boot network --machine foobar") # Unknown machine type
c.add_invalid("--nodisks --boot network --arch mips --virt-type kvm") # Invalid domain type for arch
c.add_invalid("--nodisks --boot network --paravirt --arch mips") # Invalid arch/virt combo
c.add_invalid("--disk none --location nfs:example.com/fake --nonetworks") # Using --location nfs, no longer supported
c = vinst.add_category("kvm-q35", "--noautoconsole --connect " + utils.URIs.kvm_q35, compare_check=support.SUPPORT_CONN_VMPORT)
c.add_compare("--boot uefi --disk none", "boot-uefi")

View File

@ -280,7 +280,7 @@
</child>
<child>
<object class="GtkRadioButton" id="method-tree">
<property name="label" translatable="yes">Network _Install (HTTP, FTP, or NFS)</property>
<property name="label" translatable="yes">Network _Install (HTTP, HTTPS, or FTP)</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>

View File

@ -824,8 +824,8 @@ def parse_args():
insg.add_argument("-c", dest="cdrom_short", help=argparse.SUPPRESS)
insg.add_argument("--cdrom", help=_("CD-ROM installation media"))
insg.add_argument("-l", "--location",
help=_("Installation source (eg, nfs:host:/path, "
"https://host/path, ftp://host/path)"))
help=_("Distro install URL, eg. https://host/path. See man "
"page for specific distro examples."))
insg.add_argument("--pxe", action="store_true",
help=_("Boot from the network using the PXE protocol"))
insg.add_argument("--import", action="store_true", dest="import_install",

View File

@ -20,33 +20,14 @@ from .osdict import OSDB
def _is_url(conn, url):
"""
Check if passed string is a (pseudo) valid http, ftp, or nfs url.
Check if passed string is an http or ftp URL
"""
if not conn.is_remote() and os.path.exists(url):
return os.path.isdir(url)
return (url.startswith("http://") or url.startswith("https://") or
url.startswith("ftp://") or url.startswith("nfs:"))
def _sanitize_url(url):
"""
Do nothing for http or ftp, but make sure nfs is in the expected format
"""
if url.startswith("nfs://"):
# Convert RFC compliant NFS nfs://server/path/to/distro
# to what mount/anaconda expect nfs:server:/path/to/distro
# and carry the latter form around internally
url = "nfs:" + url[6:]
# If we need to add the : after the server
index = url.find("/", 4)
if index == -1:
raise ValueError(_("Invalid NFS format: No path specified."))
if url[index - 1] != ":":
url = url[:index] + ":" + url[index:]
return url
return (url.startswith("http://") or
url.startswith("https://") or
url.startswith("ftp://"))
# Enum of the various install media types we can have
@ -160,14 +141,14 @@ class DistroInstaller(Installer):
1) it can be a local file (ex. boot.iso), directory (ex. distro
tree) or physical device (ex. cdrom media)
2) http, ftp, or nfs path for an install tree
2) http, https, or ftp for an install tree
"""
self._cached_store = None
self._cached_fetcher = None
if _is_url(self.conn, val):
logging.debug("DistroInstaller location is a network source.")
return _sanitize_url(val)
return val
try:
dev = DeviceDisk(self.conn)
@ -178,6 +159,12 @@ class DistroInstaller(Installer):
val = dev.path
except Exception as e:
logging.debug("Error validating install location", exc_info=True)
if val.startswith("nfs:"):
logging.warning("NFS URL installs are no longer supported. "
"Access your install media over an alternate transport "
"like HTTP, or manually mount the NFS share and install "
"from the local directory mount point.")
raise ValueError(_("Validating install media '%s' failed: %s") %
(str(val), e))

View File

@ -16,14 +16,14 @@ import urllib
import requests
#########################################################################
# Backends for the various URL types we support (http, ftp, nfs, local) #
#########################################################################
###########################################################################
# Backends for the various URL types we support (http, https, ftp, local) #
###########################################################################
class _URLFetcher(object):
"""
This is a generic base class for fetching/extracting files from
a media source, such as CD ISO, NFS server, or HTTP/FTP server
a media source, such as CD ISO, or HTTP/HTTPS/FTP server
"""
_block_size = 16384
@ -286,55 +286,6 @@ class _LocalURLFetcher(_URLFetcher):
return urlobj, size
class _MountedURLFetcher(_LocalURLFetcher):
"""
Fetcher capable of extracting files from a NFS server
or loopback mounted file, or local CDROM device
"""
_in_test_suite = bool("VIRTINST_TEST_SUITE" in os.environ)
_mounted = False
def prepareLocation(self):
if self._mounted:
return
if self._in_test_suite:
self._srcdir = os.environ["VIRTINST_TEST_URL_DIR"]
else:
self._srcdir = tempfile.mkdtemp(prefix="virtinstmnt.",
dir=self.scratchdir)
mountcmd = "/bin/mount"
logging.debug("Preparing mount at %s", self._srcdir)
cmd = [mountcmd, "-o", "ro", self.location[4:], self._srcdir]
logging.debug("mount cmd: %s", cmd)
if not self._in_test_suite:
ret = subprocess.call(cmd)
if ret != 0:
self.cleanupLocation()
raise ValueError(_("Mounting location '%s' failed") %
(self.location))
self._mounted = True
def cleanupLocation(self):
if not self._mounted:
return
logging.debug("Cleaning up mount at %s", self._srcdir)
try:
if not self._in_test_suite:
cmd = ["/bin/umount", self._srcdir]
subprocess.call(cmd)
try:
os.rmdir(self._srcdir)
except Exception:
pass
finally:
self._mounted = False
class _ISOURLFetcher(_URLFetcher):
_cache_file_list = None
@ -375,8 +326,6 @@ def fetcherForURI(uri, *args, **kwargs):
fclass = _HTTPURLFetcher
elif uri.startswith("ftp://"):
fclass = _FTPURLFetcher
elif uri.startswith("nfs:"):
fclass = _MountedURLFetcher
elif os.path.isdir(uri):
# Pointing to a local tree
fclass = _LocalURLFetcher