2018-03-15 21:04:29 +00:00
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns = "http://www.w3.org/1999/xhtml" >
< head >
< meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" / >
2018-05-16 23:23:14 +00:00
< title > pylorax.installer — Lorax 19.7.15 documentation< / title >
2018-03-15 21:04:29 +00:00
< link rel = "stylesheet" href = "../../_static/default.css" type = "text/css" / >
< link rel = "stylesheet" href = "../../_static/pygments.css" type = "text/css" / >
< script type = "text/javascript" >
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../../',
2018-05-16 23:23:14 +00:00
VERSION: '19.7.15',
2018-03-15 21:04:29 +00:00
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
< / script >
< script type = "text/javascript" src = "../../_static/jquery.js" > < / script >
< script type = "text/javascript" src = "../../_static/underscore.js" > < / script >
< script type = "text/javascript" src = "../../_static/doctools.js" > < / script >
2018-05-16 23:23:14 +00:00
< link rel = "top" title = "Lorax 19.7.15 documentation" href = "../../index.html" / >
2018-03-16 23:41:16 +00:00
< link rel = "up" title = "pylorax" href = "../pylorax.html" / >
2018-03-15 21:04:29 +00:00
< / head >
< body >
< div class = "related" >
< h3 > Navigation< / h3 >
< ul >
< li class = "right" style = "margin-right: 10px" >
< a href = "../../genindex.html" title = "General Index"
accesskey="I">index< / a > < / li >
< li class = "right" >
< a href = "../../py-modindex.html" title = "Python Module Index"
>modules< / a > |< / li >
2018-05-16 23:23:14 +00:00
< li > < a href = "../../index.html" > Lorax 19.7.15 documentation< / a > » < / li >
2018-03-16 23:41:16 +00:00
< li > < a href = "../index.html" > Module code< / a > » < / li >
< li > < a href = "../pylorax.html" accesskey = "U" > pylorax< / a > » < / li >
2018-03-15 21:04:29 +00:00
< / ul >
< / div >
< div class = "document" >
< div class = "documentwrapper" >
< div class = "bodywrapper" >
< div class = "body" >
< h1 > Source code for pylorax.installer< / h1 > < div class = "highlight" > < pre >
< span class = "c" > #< / span >
< span class = "c" > # Copyright (C) 2011-2017 Red Hat, Inc.< / span >
< span class = "c" > #< / span >
< span class = "c" > # This program is free software; you can redistribute it and/or modify< / span >
< span class = "c" > # it under the terms of the GNU General Public License as published by< / span >
< span class = "c" > # the Free Software Foundation; either version 2 of the License, or< / span >
< span class = "c" > # (at your option) any later version.< / span >
< span class = "c" > #< / span >
< span class = "c" > # This program is distributed in the hope that it will be useful,< / span >
< span class = "c" > # but WITHOUT ANY WARRANTY; without even the implied warranty of< / span >
< span class = "c" > # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the< / span >
< span class = "c" > # GNU General Public License for more details.< / span >
< span class = "c" > #< / span >
< span class = "c" > # You should have received a copy of the GNU General Public License< / span >
< span class = "c" > # along with this program. If not, see < http://www.gnu.org/licenses/> .< / span >
< span class = "c" > #< / span >
< span class = "kn" > import< / span > < span class = "nn" > logging< / span >
< span class = "n" > log< / span > < span class = "o" > =< / span > < span class = "n" > logging< / span > < span class = "o" > .< / span > < span class = "n" > getLogger< / span > < span class = "p" > (< / span > < span class = "s" > " pylorax" < / span > < span class = "p" > )< / span >
< span class = "kn" > import< / span > < span class = "nn" > os< / span >
< span class = "kn" > import< / span > < span class = "nn" > shutil< / span >
< span class = "kn" > import< / span > < span class = "nn" > sys< / span >
< span class = "kn" > import< / span > < span class = "nn" > subprocess< / span >
< span class = "kn" > import< / span > < span class = "nn" > tempfile< / span >
< span class = "kn" > from< / span > < span class = "nn" > time< / span > < span class = "kn" > import< / span > < span class = "n" > sleep< / span >
< span class = "kn" > import< / span > < span class = "nn" > uuid< / span >
< span class = "kn" > from< / span > < span class = "nn" > pylorax.executils< / span > < span class = "kn" > import< / span > < span class = "n" > execWithRedirect< / span > < span class = "p" > ,< / span > < span class = "n" > execWithCapture< / span >
< span class = "kn" > from< / span > < span class = "nn" > pylorax.imgutils< / span > < span class = "kn" > import< / span > < span class = "n" > get_loop_name< / span > < span class = "p" > ,< / span > < span class = "n" > dm_detach< / span > < span class = "p" > ,< / span > < span class = "n" > mount< / span > < span class = "p" > ,< / span > < span class = "n" > umount< / span >
< span class = "kn" > from< / span > < span class = "nn" > pylorax.imgutils< / span > < span class = "kn" > import< / span > < span class = "n" > PartitionMount< / span > < span class = "p" > ,< / span > < span class = "n" > mksparse< / span > < span class = "p" > ,< / span > < span class = "n" > mkext4img< / span > < span class = "p" > ,< / span > < span class = "n" > loop_detach< / span >
< span class = "kn" > from< / span > < span class = "nn" > pylorax.imgutils< / span > < span class = "kn" > import< / span > < span class = "n" > mktar< / span > < span class = "p" > ,< / span > < span class = "n" > mkdiskfsimage< / span > < span class = "p" > ,< / span > < span class = "n" > mkqcow2< / span >
< span class = "kn" > from< / span > < span class = "nn" > pylorax.logmonitor< / span > < span class = "kn" > import< / span > < span class = "n" > LogMonitor< / span >
< span class = "kn" > from< / span > < span class = "nn" > pylorax.sysutils< / span > < span class = "kn" > import< / span > < span class = "n" > joinpaths< / span >
< span class = "kn" > from< / span > < span class = "nn" > pylorax.treebuilder< / span > < span class = "kn" > import< / span > < span class = "n" > udev_escape< / span >
< span class = "n" > ROOT_PATH< / span > < span class = "o" > =< / span > < span class = "s" > " /mnt/sysimage/" < / span >
< span class = "c" > # no-virt mode doesn' t need libvirt, so make it optional< / span >
< span class = "k" > try< / span > < span class = "p" > :< / span >
< span class = "kn" > import< / span > < span class = "nn" > libvirt< / span >
< span class = "k" > except< / span > < span class = "ne" > ImportError< / span > < span class = "p" > :< / span >
< span class = "n" > libvirt< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span >
< div class = "viewcode-block" id = "InstallError" > < a class = "viewcode-back" href = "../../pylorax.html#pylorax.installer.InstallError" > [docs]< / a > < span class = "k" > class< / span > < span class = "nc" > InstallError< / span > < span class = "p" > (< / span > < span class = "ne" > Exception< / span > < span class = "p" > ):< / span >
< span class = "k" > pass< / span >
< / div >
< div class = "viewcode-block" id = "IsoMountpoint" > < a class = "viewcode-back" href = "../../pylorax.html#pylorax.installer.IsoMountpoint" > [docs]< / a > < span class = "k" > class< / span > < span class = "nc" > IsoMountpoint< / span > < span class = "p" > (< / span > < span class = "nb" > object< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " < / span >
< span class = "sd" > Mount the iso on a temporary directory and check to make sure the< / span >
< span class = "sd" > vmlinuz and initrd.img files exist< / span >
< span class = "sd" > Check the iso for a LiveOS directory and set a flag.< / span >
< span class = "sd" > Extract the iso' s label.< / span >
< span class = "sd" > initrd_path can be used to point to a boot.iso tree with a newer< / span >
< span class = "sd" > initrd.img than the iso has. The iso is still used for stage2.< / span >
< span class = "sd" > " " " < / span >
< span class = "k" > def< / span > < span class = "nf" > __init__< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "p" > ,< / span > < span class = "n" > iso_path< / span > < span class = "p" > ,< / span > < span class = "n" > initrd_path< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " iso_path is the path to a boot.iso< / span >
< span class = "sd" > initrd_path overrides mounting the iso for access to< / span >
< span class = "sd" > initrd and vmlinuz.< / span >
< span class = "sd" > " " " < / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > label< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > iso_path< / span > < span class = "o" > =< / span > < span class = "n" > iso_path< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > initrd_path< / span > < span class = "o" > =< / span > < span class = "n" > initrd_path< / span >
< span class = "k" > if< / span > < span class = "ow" > not< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > initrd_path< / span > < span class = "p" > :< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > mount_dir< / span > < span class = "o" > =< / span > < span class = "n" > mount< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > iso_path< / span > < span class = "p" > ,< / span > < span class = "n" > opts< / span > < span class = "o" > =< / span > < span class = "s" > " loop" < / span > < span class = "p" > )< / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > mount_dir< / span > < span class = "o" > =< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > initrd_path< / span >
< span class = "n" > kernel_list< / span > < span class = "o" > =< / span > < span class = "p" > [(< / span > < span class = "s" > " /isolinux/vmlinuz" < / span > < span class = "p" > ,< / span > < span class = "s" > " /isolinux/initrd.img" < / span > < span class = "p" > ),< / span >
< span class = "p" > (< / span > < span class = "s" > " /ppc/ppc64/vmlinuz" < / span > < span class = "p" > ,< / span > < span class = "s" > " /ppc/ppc64/initrd.img" < / span > < span class = "p" > )]< / span >
< span class = "k" > if< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > isdir< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > mount_dir< / span > < span class = "o" > +< / span > < span class = "s" > " /repodata" < / span > < span class = "p" > ):< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > repo< / span > < span class = "o" > =< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > mount_dir< / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > repo< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > liveos< / span > < span class = "o" > =< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > isdir< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > mount_dir< / span > < span class = "o" > +< / span > < span class = "s" > " /LiveOS" < / span > < span class = "p" > )< / span >
< span class = "k" > try< / span > < span class = "p" > :< / span >
< span class = "k" > for< / span > < span class = "n" > kernel< / span > < span class = "p" > ,< / span > < span class = "n" > initrd< / span > < span class = "ow" > in< / span > < span class = "n" > kernel_list< / span > < span class = "p" > :< / span >
< span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > isfile< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > mount_dir< / span > < span class = "o" > +< / span > < span class = "n" > kernel< / span > < span class = "p" > )< / span > < span class = "ow" > and< / span >
< span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > isfile< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > mount_dir< / span > < span class = "o" > +< / span > < span class = "n" > initrd< / span > < span class = "p" > )):< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > kernel< / span > < span class = "o" > =< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > mount_dir< / span > < span class = "o" > +< / span > < span class = "n" > kernel< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > initrd< / span > < span class = "o" > =< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > mount_dir< / span > < span class = "o" > +< / span > < span class = "n" > initrd< / span >
< span class = "k" > break< / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
< span class = "k" > raise< / span > < span class = "ne" > Exception< / span > < span class = "p" > (< / span > < span class = "s" > " Missing kernel and initrd file in iso, failed" < / span >
< span class = "s" > " to search under: {0}" < / span > < span class = "o" > .< / span > < span class = "n" > format< / span > < span class = "p" > (< / span > < span class = "n" > kernel_list< / span > < span class = "p" > ))< / span >
< span class = "k" > except< / span > < span class = "p" > :< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > umount< / span > < span class = "p" > ()< / span >
< span class = "k" > raise< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > get_iso_label< / span > < span class = "p" > ()< / span >
< div class = "viewcode-block" id = "IsoMountpoint.umount" > < a class = "viewcode-back" href = "../../pylorax.html#pylorax.installer.IsoMountpoint.umount" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > umount< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "p" > ):< / span >
< span class = "k" > if< / span > < span class = "ow" > not< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > initrd_path< / span > < span class = "p" > :< / span >
< span class = "n" > umount< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > mount_dir< / span > < span class = "p" > )< / span >
< / div >
< div class = "viewcode-block" id = "IsoMountpoint.get_iso_label" > < a class = "viewcode-back" href = "../../pylorax.html#pylorax.installer.IsoMountpoint.get_iso_label" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > get_iso_label< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " < / span >
< span class = "sd" > Get the iso' s label using isoinfo< / span >
< span class = "sd" > " " " < / span >
< span class = "n" > isoinfo_output< / span > < span class = "o" > =< / span > < span class = "n" > execWithCapture< / span > < span class = "p" > (< / span > < span class = "s" > " isoinfo" < / span > < span class = "p" > ,< / span > < span class = "p" > [< / span > < span class = "s" > " -d" < / span > < span class = "p" > ,< / span > < span class = "s" > " -i" < / span > < span class = "p" > ,< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > iso_path< / span > < span class = "p" > ])< / span >
< span class = "n" > log< / span > < span class = "o" > .< / span > < span class = "n" > debug< / span > < span class = "p" > (< / span > < span class = "n" > isoinfo_output< / span > < span class = "p" > )< / span >
< span class = "k" > for< / span > < span class = "n" > line< / span > < span class = "ow" > in< / span > < span class = "n" > isoinfo_output< / span > < span class = "o" > .< / span > < span class = "n" > splitlines< / span > < span class = "p" > ():< / span >
< span class = "k" > if< / span > < span class = "n" > line< / span > < span class = "o" > .< / span > < span class = "n" > startswith< / span > < span class = "p" > (< / span > < span class = "s" > " Volume id: " < / span > < span class = "p" > ):< / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > label< / span > < span class = "o" > =< / span > < span class = "n" > line< / span > < span class = "p" > [< / span > < span class = "mi" > 11< / span > < span class = "p" > :]< / span >
< span class = "k" > return< / span >
< / div > < / div >
< div class = "viewcode-block" id = "VirtualInstall" > < a class = "viewcode-back" href = "../../pylorax.html#pylorax.installer.VirtualInstall" > [docs]< / a > < span class = "k" > class< / span > < span class = "nc" > VirtualInstall< / span > < span class = "p" > (< / span > < span class = "nb" > object< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " < / span >
< span class = "sd" > Run virt-install using an iso and kickstart(s)< / span >
< span class = "sd" > " " " < / span >
< span class = "k" > def< / span > < span class = "nf" > __init__< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "p" > ,< / span > < span class = "n" > iso< / span > < span class = "p" > ,< / span > < span class = "n" > ks_paths< / span > < span class = "p" > ,< / span > < span class = "n" > disk_img< / span > < span class = "p" > ,< / span > < span class = "n" > img_size< / span > < span class = "o" > =< / span > < span class = "mi" > 2< / span > < span class = "p" > ,< / span >
< span class = "n" > kernel_args< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span > < span class = "p" > ,< / span > < span class = "n" > memory< / span > < span class = "o" > =< / span > < span class = "mi" > 1024< / span > < span class = "p" > ,< / span > < span class = "n" > vnc< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span > < span class = "p" > ,< / span > < span class = "n" > arch< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span > < span class = "p" > ,< / span >
< span class = "n" > log_check< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span > < span class = "p" > ,< / span > < span class = "n" > virtio_host< / span > < span class = "o" > =< / span > < span class = "s" > " 127.0.0.1" < / span > < span class = "p" > ,< / span > < span class = "n" > virtio_port< / span > < span class = "o" > =< / span > < span class = "mi" > 6080< / span > < span class = "p" > ,< / span >
< span class = "n" > qcow2< / span > < span class = "o" > =< / span > < span class = "bp" > False< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " < / span >
< span class = "sd" > iso is an instance of IsoMountpoint< / span >
< span class = "sd" > ks_paths is a list of paths to a kickstart files. All are injected, the< / span >
< span class = "sd" > first one is the one executed.< / span >
< span class = "sd" > disk_img is the path to a disk image (doesn' t need to exist)< / span >
< span class = "sd" > img_size is the size, in GiB, of the image if it doesn' t exist< / span >
< span class = "sd" > kernel_args are extra arguments to pass on the kernel cmdline< / span >
< span class = "sd" > memory is the amount of ram to assign to the virt< / span >
< span class = "sd" > vnc is passed to the --graphics command verbatim< / span >
< span class = "sd" > arch is the optional architecture to use in the virt< / span >
< span class = "sd" > log_check is a method that returns True of the log indicates an error< / span >
< span class = "sd" > virtio_host and virtio_port are used to communicate with the log monitor< / span >
< span class = "sd" > " " " < / span >
< span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > virt_name< / span > < span class = "o" > =< / span > < span class = "s" > " LiveOS-" < / span > < span class = "o" > +< / span > < span class = "nb" > str< / span > < span class = "p" > (< / span > < span class = "n" > uuid< / span > < span class = "o" > .< / span > < span class = "n" > uuid4< / span > < span class = "p" > ())< / span >
< span class = "c" > # add --graphics none later< / span >
< span class = "c" > # add whatever serial cmds are needed later< / span >
< span class = "n" > args< / span > < span class = "o" > =< / span > < span class = "p" > [< / span > < span class = "s" > " -n" < / span > < span class = "p" > ,< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > virt_name< / span > < span class = "p" > ,< / span >
< span class = "s" > " -r" < / span > < span class = "p" > ,< / span > < span class = "nb" > str< / span > < span class = "p" > (< / span > < span class = "n" > memory< / span > < span class = "p" > ),< / span >
< span class = "s" > " --noreboot" < / span > < span class = "p" > ,< / span >
< span class = "s" > " --noautoconsole" < / span > < span class = "p" > ]< / span >
< span class = "n" > args< / span > < span class = "o" > .< / span > < span class = "n" > append< / span > < span class = "p" > (< / span > < span class = "s" > " --graphics" < / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "n" > vnc< / span > < span class = "p" > :< / span >
< span class = "n" > args< / span > < span class = "o" > .< / span > < span class = "n" > append< / span > < span class = "p" > (< / span > < span class = "n" > vnc< / span > < span class = "p" > )< / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
< span class = "n" > args< / span > < span class = "o" > .< / span > < span class = "n" > append< / span > < span class = "p" > (< / span > < span class = "s" > " none" < / span > < span class = "p" > )< / span >
< span class = "k" > for< / span > < span class = "n" > ks< / span > < span class = "ow" > in< / span > < span class = "n" > ks_paths< / span > < span class = "p" > :< / span >
< span class = "n" > args< / span > < span class = "o" > .< / span > < span class = "n" > append< / span > < span class = "p" > (< / span > < span class = "s" > " --initrd-inject" < / span > < span class = "p" > )< / span >
< span class = "n" > args< / span > < span class = "o" > .< / span > < span class = "n" > append< / span > < span class = "p" > (< / span > < span class = "n" > ks< / span > < span class = "p" > )< / span >
< span class = "n" > disk_opts< / span > < span class = "o" > =< / span > < span class = "s" > " path={0}" < / span > < span class = "o" > .< / span > < span class = "n" > format< / span > < span class = "p" > (< / span > < span class = "n" > disk_img< / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "n" > qcow2< / span > < span class = "p" > :< / span >
< span class = "n" > disk_opts< / span > < span class = "o" > +=< / span > < span class = "s" > " ,format=qcow2" < / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
< span class = "n" > disk_opts< / span > < span class = "o" > +=< / span > < span class = "s" > " ,format=raw" < / span >
< span class = "k" > if< / span > < span class = "ow" > not< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > isfile< / span > < span class = "p" > (< / span > < span class = "n" > disk_img< / span > < span class = "p" > ):< / span >
< span class = "n" > disk_opts< / span > < span class = "o" > +=< / span > < span class = "s" > " ,size={0}" < / span > < span class = "o" > .< / span > < span class = "n" > format< / span > < span class = "p" > (< / span > < span class = "n" > img_size< / span > < span class = "p" > )< / span >
< span class = "n" > args< / span > < span class = "o" > .< / span > < span class = "n" > append< / span > < span class = "p" > (< / span > < span class = "s" > " --disk" < / span > < span class = "p" > )< / span >
< span class = "n" > args< / span > < span class = "o" > .< / span > < span class = "n" > append< / span > < span class = "p" > (< / span > < span class = "n" > disk_opts< / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "n" > iso< / span > < span class = "o" > .< / span > < span class = "n" > liveos< / span > < span class = "p" > :< / span >
< span class = "n" > disk_opts< / span > < span class = "o" > =< / span > < span class = "s" > " path={0},device=cdrom" < / span > < span class = "o" > .< / span > < span class = "n" > format< / span > < span class = "p" > (< / span > < span class = "n" > iso< / span > < span class = "o" > .< / span > < span class = "n" > iso_path< / span > < span class = "p" > )< / span >
< span class = "n" > args< / span > < span class = "o" > .< / span > < span class = "n" > append< / span > < span class = "p" > (< / span > < span class = "s" > " --disk" < / span > < span class = "p" > )< / span >
< span class = "n" > args< / span > < span class = "o" > .< / span > < span class = "n" > append< / span > < span class = "p" > (< / span > < span class = "n" > disk_opts< / span > < span class = "p" > )< / span >
< span class = "n" > extra_args< / span > < span class = "o" > =< / span > < span class = "s" > " ks=file:/{0}" < / span > < span class = "o" > .< / span > < span class = "n" > format< / span > < span class = "p" > (< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > basename< / span > < span class = "p" > (< / span > < span class = "n" > ks_paths< / span > < span class = "p" > [< / span > < span class = "mi" > 0< / span > < span class = "p" > ]))< / span >
< span class = "k" > if< / span > < span class = "ow" > not< / span > < span class = "n" > vnc< / span > < span class = "p" > :< / span >
< span class = "n" > extra_args< / span > < span class = "o" > +=< / span > < span class = "s" > " inst.cmdline console=ttyS0" < / span >
< span class = "k" > if< / span > < span class = "n" > kernel_args< / span > < span class = "p" > :< / span >
< span class = "n" > extra_args< / span > < span class = "o" > +=< / span > < span class = "s" > " " < / span > < span class = "o" > +< / span > < span class = "n" > kernel_args< / span >
< span class = "k" > if< / span > < span class = "n" > iso< / span > < span class = "o" > .< / span > < span class = "n" > liveos< / span > < span class = "p" > :< / span >
< span class = "n" > extra_args< / span > < span class = "o" > +=< / span > < span class = "s" > " stage2=hd:LABEL={0}" < / span > < span class = "o" > .< / span > < span class = "n" > format< / span > < span class = "p" > (< / span > < span class = "n" > udev_escape< / span > < span class = "p" > (< / span > < span class = "n" > iso< / span > < span class = "o" > .< / span > < span class = "n" > label< / span > < span class = "p" > ))< / span >
< span class = "n" > args< / span > < span class = "o" > .< / span > < span class = "n" > append< / span > < span class = "p" > (< / span > < span class = "s" > " --extra-args" < / span > < span class = "p" > )< / span >
< span class = "n" > args< / span > < span class = "o" > .< / span > < span class = "n" > append< / span > < span class = "p" > (< / span > < span class = "n" > extra_args< / span > < span class = "p" > )< / span >
< span class = "n" > args< / span > < span class = "o" > .< / span > < span class = "n" > append< / span > < span class = "p" > (< / span > < span class = "s" > " --location" < / span > < span class = "p" > )< / span >
< span class = "n" > args< / span > < span class = "o" > .< / span > < span class = "n" > append< / span > < span class = "p" > (< / span > < span class = "n" > iso< / span > < span class = "o" > .< / span > < span class = "n" > mount_dir< / span > < span class = "p" > )< / span >
< span class = "n" > channel_args< / span > < span class = "o" > =< / span > < span class = "s" > " tcp,host={0}:{1},mode=connect,target_type=virtio" < / span > \
< span class = "s" > " ,name=org.fedoraproject.anaconda.log.0" < / span > < span class = "o" > .< / span > < span class = "n" > format< / span > < span class = "p" > (< / span >
< span class = "n" > virtio_host< / span > < span class = "p" > ,< / span > < span class = "n" > virtio_port< / span > < span class = "p" > )< / span >
< span class = "n" > args< / span > < span class = "o" > .< / span > < span class = "n" > append< / span > < span class = "p" > (< / span > < span class = "s" > " --channel" < / span > < span class = "p" > )< / span >
< span class = "n" > args< / span > < span class = "o" > .< / span > < span class = "n" > append< / span > < span class = "p" > (< / span > < span class = "n" > channel_args< / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "n" > arch< / span > < span class = "p" > :< / span >
< span class = "n" > args< / span > < span class = "o" > .< / span > < span class = "n" > append< / span > < span class = "p" > (< / span > < span class = "s" > " --arch" < / span > < span class = "p" > )< / span >
< span class = "n" > args< / span > < span class = "o" > .< / span > < span class = "n" > append< / span > < span class = "p" > (< / span > < span class = "n" > arch< / span > < span class = "p" > )< / span >
< span class = "n" > rc< / span > < span class = "o" > =< / span > < span class = "n" > execWithRedirect< / span > < span class = "p" > (< / span > < span class = "s" > " virt-install" < / span > < span class = "p" > ,< / span > < span class = "n" > args< / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "n" > rc< / span > < span class = "p" > :< / span >
< span class = "k" > raise< / span > < span class = "ne" > Exception< / span > < span class = "p" > (< / span > < span class = "s" > " Problem starting virtual install" < / span > < span class = "p" > )< / span >
< span class = "n" > conn< / span > < span class = "o" > =< / span > < span class = "n" > libvirt< / span > < span class = "o" > .< / span > < span class = "n" > openReadOnly< / span > < span class = "p" > (< / span > < span class = "bp" > None< / span > < span class = "p" > )< / span >
< span class = "n" > dom< / span > < span class = "o" > =< / span > < span class = "n" > conn< / span > < span class = "o" > .< / span > < span class = "n" > lookupByName< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > virt_name< / span > < span class = "p" > )< / span >
< span class = "c" > # TODO: If vnc has been passed, we should look up the port and print that< / span >
< span class = "c" > # for the user at this point< / span >
< span class = "k" > while< / span > < span class = "n" > dom< / span > < span class = "o" > .< / span > < span class = "n" > isActive< / span > < span class = "p" > ()< / span > < span class = "ow" > and< / span > < span class = "ow" > not< / span > < span class = "n" > log_check< / span > < span class = "p" > ():< / span >
< span class = "n" > sys< / span > < span class = "o" > .< / span > < span class = "n" > stdout< / span > < span class = "o" > .< / span > < span class = "n" > write< / span > < span class = "p" > (< / span > < span class = "s" > " ." < / span > < span class = "p" > )< / span >
< span class = "n" > sys< / span > < span class = "o" > .< / span > < span class = "n" > stdout< / span > < span class = "o" > .< / span > < span class = "n" > flush< / span > < span class = "p" > ()< / span >
< span class = "n" > sleep< / span > < span class = "p" > (< / span > < span class = "mi" > 10< / span > < span class = "p" > )< / span >
< span class = "k" > print< / span >
< span class = "k" > if< / span > < span class = "n" > log_check< / span > < span class = "p" > ():< / span >
< span class = "n" > log< / span > < span class = "o" > .< / span > < span class = "n" > info< / span > < span class = "p" > (< / span > < span class = "s" > " Installation error detected. See logfile." < / span > < span class = "p" > )< / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
< span class = "n" > log< / span > < span class = "o" > .< / span > < span class = "n" > info< / span > < span class = "p" > (< / span > < span class = "s" > " Install finished. Or at least virt shut down." < / span > < span class = "p" > )< / span >
< div class = "viewcode-block" id = "VirtualInstall.destroy" > < a class = "viewcode-back" href = "../../pylorax.html#pylorax.installer.VirtualInstall.destroy" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > destroy< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " < / span >
< span class = "sd" > Make sure the virt has been shut down and destroyed< / span >
< span class = "sd" > Could use libvirt for this instead.< / span >
< span class = "sd" > " " " < / span >
< span class = "n" > log< / span > < span class = "o" > .< / span > < span class = "n" > info< / span > < span class = "p" > (< / span > < span class = "s" > " Shutting down < / span > < span class = "si" > %s< / span > < span class = "s" > " < / span > < span class = "p" > ,< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > virt_name< / span > < span class = "p" > )< / span >
< span class = "n" > subprocess< / span > < span class = "o" > .< / span > < span class = "n" > call< / span > < span class = "p" > ([< / span > < span class = "s" > " virsh" < / span > < span class = "p" > ,< / span > < span class = "s" > " destroy" < / span > < span class = "p" > ,< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > virt_name< / span > < span class = "p" > ])< / span >
< span class = "n" > subprocess< / span > < span class = "o" > .< / span > < span class = "n" > call< / span > < span class = "p" > ([< / span > < span class = "s" > " virsh" < / span > < span class = "p" > ,< / span > < span class = "s" > " undefine" < / span > < span class = "p" > ,< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > virt_name< / span > < span class = "p" > ])< / span >
< / div > < / div >
< div class = "viewcode-block" id = "novirt_install" > < a class = "viewcode-back" href = "../../pylorax.html#pylorax.installer.novirt_install" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > novirt_install< / span > < span class = "p" > (< / span > < span class = "n" > opts< / span > < span class = "p" > ,< / span > < span class = "n" > disk_img< / span > < span class = "p" > ,< / span > < span class = "n" > disk_size< / span > < span class = "p" > ,< / span > < span class = "n" > repo_url< / span > < span class = "p" > ,< / span > < span class = "n" > callback_func< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " < / span >
< span class = "sd" > Use Anaconda to install to a disk image< / span >
< span class = "sd" > " " " < / span >
< span class = "kn" > import< / span > < span class = "nn" > selinux< / span >
< span class = "c" > # Set selinux to Permissive if it is Enforcing< / span >
< span class = "n" > selinux_enforcing< / span > < span class = "o" > =< / span > < span class = "bp" > False< / span >
< span class = "k" > if< / span > < span class = "n" > selinux< / span > < span class = "o" > .< / span > < span class = "n" > is_selinux_enabled< / span > < span class = "p" > ()< / span > < span class = "ow" > and< / span > < span class = "n" > selinux< / span > < span class = "o" > .< / span > < span class = "n" > security_getenforce< / span > < span class = "p" > ():< / span >
< span class = "n" > selinux_enforcing< / span > < span class = "o" > =< / span > < span class = "bp" > True< / span >
< span class = "n" > selinux< / span > < span class = "o" > .< / span > < span class = "n" > security_setenforce< / span > < span class = "p" > (< / span > < span class = "mi" > 0< / span > < span class = "p" > )< / span >
< span class = "c" > # Clean up /tmp/ from previous runs to prevent stale info from being used< / span >
2018-04-25 20:25:07 +00:00
< span class = "k" > for< / span > < span class = "n" > path< / span > < span class = "ow" > in< / span > < span class = "p" > [< / span > < span class = "s" > " /tmp/yum.repos.d/" < / span > < span class = "p" > ,< / span > < span class = "s" > " /tmp/yum.cache/" < / span > < span class = "p" > ,< / span > < span class = "s" > " /tmp/yum.root/" < / span > < span class = "p" > ,< / span > < span class = "s" > " /tmp/yum.pluginconf.d/" < / span > < span class = "p" > ]:< / span >
2018-03-15 21:04:29 +00:00
< span class = "k" > if< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > isdir< / span > < span class = "p" > (< / span > < span class = "n" > path< / span > < span class = "p" > ):< / span >
< span class = "n" > shutil< / span > < span class = "o" > .< / span > < span class = "n" > rmtree< / span > < span class = "p" > (< / span > < span class = "n" > path< / span > < span class = "p" > )< / span >
< span class = "n" > args< / span > < span class = "o" > =< / span > < span class = "p" > [< / span > < span class = "s" > " --kickstart" < / span > < span class = "p" > ,< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > ks< / span > < span class = "p" > [< / span > < span class = "mi" > 0< / span > < span class = "p" > ],< / span > < span class = "s" > " --cmdline" < / span > < span class = "p" > ,< / span > < span class = "s" > " --repo" < / span > < span class = "p" > ,< / span > < span class = "n" > repo_url< / span > < span class = "p" > ]< / span >
< span class = "k" > if< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > anaconda_args< / span > < span class = "p" > :< / span >
< span class = "k" > for< / span > < span class = "n" > arg< / span > < span class = "ow" > in< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > anaconda_args< / span > < span class = "p" > :< / span >
< span class = "n" > args< / span > < span class = "o" > +=< / span > < span class = "n" > arg< / span > < span class = "o" > .< / span > < span class = "n" > split< / span > < span class = "p" > (< / span > < span class = "s" > " " < / span > < span class = "p" > ,< / span > < span class = "mi" > 1< / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > proxy< / span > < span class = "p" > :< / span >
< span class = "n" > args< / span > < span class = "o" > +=< / span > < span class = "p" > [< / span > < span class = "s" > " --proxy" < / span > < span class = "p" > ,< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > proxy< / span > < span class = "p" > ]< / span >
< span class = "k" > if< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > armplatform< / span > < span class = "p" > :< / span >
< span class = "n" > args< / span > < span class = "o" > +=< / span > < span class = "p" > [< / span > < span class = "s" > " --armplatform" < / span > < span class = "p" > ,< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > armplatform< / span > < span class = "p" > ]< / span >
< span class = "k" > if< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > make_iso< / span > < span class = "ow" > or< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > make_fsimage< / span > < span class = "p" > :< / span >
< span class = "c" > # Make a blank fs image< / span >
< span class = "n" > args< / span > < span class = "o" > +=< / span > < span class = "p" > [< / span > < span class = "s" > " --dirinstall" < / span > < span class = "p" > ]< / span >
< span class = "n" > mkext4img< / span > < span class = "p" > (< / span > < span class = "bp" > None< / span > < span class = "p" > ,< / span > < span class = "n" > disk_img< / span > < span class = "p" > ,< / span > < span class = "n" > label< / span > < span class = "o" > =< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > fs_label< / span > < span class = "p" > ,< / span > < span class = "n" > size< / span > < span class = "o" > =< / span > < span class = "n" > disk_size< / span > < span class = "o" > *< / span > < span class = "mi" > 1024< / span > < span class = "o" > **< / span > < span class = "mi" > 3< / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "ow" > not< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > isdir< / span > < span class = "p" > (< / span > < span class = "n" > ROOT_PATH< / span > < span class = "p" > ):< / span >
< span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > mkdir< / span > < span class = "p" > (< / span > < span class = "n" > ROOT_PATH< / span > < span class = "p" > )< / span >
< span class = "n" > mount< / span > < span class = "p" > (< / span > < span class = "n" > disk_img< / span > < span class = "p" > ,< / span > < span class = "n" > opts< / span > < span class = "o" > =< / span > < span class = "s" > " loop" < / span > < span class = "p" > ,< / span > < span class = "n" > mnt< / span > < span class = "o" > =< / span > < span class = "n" > ROOT_PATH< / span > < span class = "p" > )< / span >
< span class = "k" > elif< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > make_tar< / span > < span class = "p" > :< / span >
< span class = "n" > args< / span > < span class = "o" > +=< / span > < span class = "p" > [< / span > < span class = "s" > " --dirinstall" < / span > < span class = "p" > ]< / span >
< span class = "c" > # Install directly into ROOT_PATH, make sure it starts clean< / span >
< span class = "k" > if< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > exists< / span > < span class = "p" > (< / span > < span class = "n" > ROOT_PATH< / span > < span class = "p" > ):< / span >
< span class = "n" > shutil< / span > < span class = "o" > .< / span > < span class = "n" > rmtree< / span > < span class = "p" > (< / span > < span class = "n" > ROOT_PATH< / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "ow" > not< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > isdir< / span > < span class = "p" > (< / span > < span class = "n" > ROOT_PATH< / span > < span class = "p" > ):< / span >
< span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > mkdir< / span > < span class = "p" > (< / span > < span class = "n" > ROOT_PATH< / span > < span class = "p" > )< / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
< span class = "n" > args< / span > < span class = "o" > +=< / span > < span class = "p" > [< / span > < span class = "s" > " --image" < / span > < span class = "p" > ,< / span > < span class = "n" > disk_img< / span > < span class = "p" > ]< / span >
< span class = "c" > # Create the sparse image< / span >
< span class = "n" > mksparse< / span > < span class = "p" > (< / span > < span class = "n" > disk_img< / span > < span class = "p" > ,< / span > < span class = "n" > disk_size< / span > < span class = "o" > *< / span > < span class = "mi" > 1024< / span > < span class = "o" > **< / span > < span class = "mi" > 3< / span > < span class = "p" > )< / span >
< span class = "c" > # Make sure anaconda has the right product and release< / span >
< span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > environ< / span > < span class = "p" > [< / span > < span class = "s" > " ANACONDA_PRODUCTNAME" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > project< / span >
< span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > environ< / span > < span class = "p" > [< / span > < span class = "s" > " ANACONDA_PRODUCTVERSION" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > releasever< / span >
< span class = "n" > rc< / span > < span class = "o" > =< / span > < span class = "n" > execWithRedirect< / span > < span class = "p" > (< / span > < span class = "s" > " anaconda" < / span > < span class = "p" > ,< / span > < span class = "n" > args< / span > < span class = "p" > ,< / span > < span class = "n" > callback_func< / span > < span class = "o" > =< / span > < span class = "n" > callback_func< / span > < span class = "p" > )< / span >
< span class = "c" > # Move the anaconda logs over to a log directory< / span >
< span class = "n" > log_dir< / span > < span class = "o" > =< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > abspath< / span > < span class = "p" > (< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > dirname< / span > < span class = "p" > (< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > logfile< / span > < span class = "p" > ))< / span >
< span class = "n" > log_anaconda< / span > < span class = "o" > =< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "n" > log_dir< / span > < span class = "p" > ,< / span > < span class = "s" > " anaconda" < / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "ow" > not< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > isdir< / span > < span class = "p" > (< / span > < span class = "n" > log_anaconda< / span > < span class = "p" > ):< / span >
< span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > mkdir< / span > < span class = "p" > (< / span > < span class = "n" > log_anaconda< / span > < span class = "p" > )< / span >
< span class = "k" > for< / span > < span class = "n" > l< / span > < span class = "ow" > in< / span > < span class = "p" > [< / span > < span class = "s" > " anaconda.log" < / span > < span class = "p" > ,< / span > < span class = "s" > " ifcfg.log" < / span > < span class = "p" > ,< / span > < span class = "s" > " program.log" < / span > < span class = "p" > ,< / span > < span class = "s" > " storage.log" < / span > < span class = "p" > ,< / span >
< span class = "s" > " packaging.log" < / span > < span class = "p" > ,< / span > < span class = "s" > " yum.log" < / span > < span class = "p" > ]:< / span >
< span class = "k" > if< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > exists< / span > < span class = "p" > (< / span > < span class = "s" > " /tmp/" < / span > < span class = "o" > +< / span > < span class = "n" > l< / span > < span class = "p" > ):< / span >
< span class = "n" > shutil< / span > < span class = "o" > .< / span > < span class = "n" > copy2< / span > < span class = "p" > (< / span > < span class = "s" > " /tmp/" < / span > < span class = "o" > +< / span > < span class = "n" > l< / span > < span class = "p" > ,< / span > < span class = "n" > log_anaconda< / span > < span class = "p" > )< / span >
< span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > unlink< / span > < span class = "p" > (< / span > < span class = "s" > " /tmp/" < / span > < span class = "o" > +< / span > < span class = "n" > l< / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > make_iso< / span > < span class = "ow" > or< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > make_fsimage< / span > < span class = "p" > :< / span >
< span class = "n" > umount< / span > < span class = "p" > (< / span > < span class = "n" > ROOT_PATH< / span > < span class = "p" > )< / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
< span class = "c" > # If anaconda failed the disk image may still be in use by dm< / span >
< span class = "n" > execWithRedirect< / span > < span class = "p" > (< / span > < span class = "s" > " anaconda-cleanup" < / span > < span class = "p" > ,< / span > < span class = "p" > [])< / span >
< span class = "k" > if< / span > < span class = "n" > disk_img< / span > < span class = "p" > :< / span >
< span class = "n" > dm_name< / span > < span class = "o" > =< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > splitext< / span > < span class = "p" > (< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > basename< / span > < span class = "p" > (< / span > < span class = "n" > disk_img< / span > < span class = "p" > ))[< / span > < span class = "mi" > 0< / span > < span class = "p" > ]< / span >
< span class = "n" > dm_path< / span > < span class = "o" > =< / span > < span class = "s" > " /dev/mapper/" < / span > < span class = "o" > +< / span > < span class = "n" > dm_name< / span >
< span class = "k" > if< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > exists< / span > < span class = "p" > (< / span > < span class = "n" > dm_path< / span > < span class = "p" > ):< / span >
< span class = "n" > dm_detach< / span > < span class = "p" > (< / span > < span class = "n" > dm_path< / span > < span class = "p" > )< / span >
< span class = "n" > loop_detach< / span > < span class = "p" > (< / span > < span class = "n" > get_loop_name< / span > < span class = "p" > (< / span > < span class = "n" > disk_img< / span > < span class = "p" > ))< / span >
< span class = "k" > if< / span > < span class = "n" > selinux_enforcing< / span > < span class = "p" > :< / span >
< span class = "n" > selinux< / span > < span class = "o" > .< / span > < span class = "n" > security_setenforce< / span > < span class = "p" > (< / span > < span class = "mi" > 1< / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "n" > rc< / span > < span class = "p" > :< / span >
< span class = "k" > raise< / span > < span class = "n" > InstallError< / span > < span class = "p" > (< / span > < span class = "s" > " novirt_install failed" < / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > make_tar< / span > < span class = "p" > :< / span >
< span class = "n" > compress_args< / span > < span class = "o" > =< / span > < span class = "p" > []< / span >
< span class = "k" > for< / span > < span class = "n" > arg< / span > < span class = "ow" > in< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > compress_args< / span > < span class = "p" > :< / span >
< span class = "n" > compress_args< / span > < span class = "o" > +=< / span > < span class = "n" > arg< / span > < span class = "o" > .< / span > < span class = "n" > split< / span > < span class = "p" > (< / span > < span class = "s" > " " < / span > < span class = "p" > ,< / span > < span class = "mi" > 1< / span > < span class = "p" > )< / span >
< span class = "n" > rc< / span > < span class = "o" > =< / span > < span class = "n" > mktar< / span > < span class = "p" > (< / span > < span class = "n" > ROOT_PATH< / span > < span class = "p" > ,< / span > < span class = "n" > disk_img< / span > < span class = "p" > ,< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > compression< / span > < span class = "p" > ,< / span > < span class = "n" > compress_args< / span > < span class = "p" > )< / span >
< span class = "n" > shutil< / span > < span class = "o" > .< / span > < span class = "n" > rmtree< / span > < span class = "p" > (< / span > < span class = "n" > ROOT_PATH< / span > < span class = "p" > )< / span >
< span class = "n" > log< / span > < span class = "o" > .< / span > < span class = "n" > info< / span > < span class = "p" > (< / span > < span class = "s" > " tar finished with rc=< / span > < span class = "si" > %d< / span > < span class = "s" > " < / span > < span class = "p" > ,< / span > < span class = "n" > rc< / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "n" > rc< / span > < span class = "p" > :< / span >
< span class = "k" > raise< / span > < span class = "n" > InstallError< / span > < span class = "p" > (< / span > < span class = "s" > " novirt_install failed" < / span > < span class = "p" > )< / span >
< span class = "k" > elif< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > qcow2< / span > < span class = "p" > :< / span >
< span class = "n" > log< / span > < span class = "o" > .< / span > < span class = "n" > info< / span > < span class = "p" > (< / span > < span class = "s" > " Converting < / span > < span class = "si" > %s< / span > < span class = "s" > to qcow2" < / span > < span class = "p" > ,< / span > < span class = "n" > disk_img< / span > < span class = "p" > )< / span >
< span class = "n" > qcow2_args< / span > < span class = "o" > =< / span > < span class = "p" > []< / span >
< span class = "k" > for< / span > < span class = "n" > arg< / span > < span class = "ow" > in< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > qcow2_args< / span > < span class = "p" > :< / span >
< span class = "n" > qcow2_args< / span > < span class = "o" > +=< / span > < span class = "n" > arg< / span > < span class = "o" > .< / span > < span class = "n" > split< / span > < span class = "p" > (< / span > < span class = "s" > " " < / span > < span class = "p" > ,< / span > < span class = "mi" > 1< / span > < span class = "p" > )< / span >
< span class = "c" > # convert the image to qcow2 format< / span >
< span class = "k" > if< / span > < span class = "s" > " -O" < / span > < span class = "ow" > not< / span > < span class = "ow" > in< / span > < span class = "n" > qcow2_args< / span > < span class = "p" > :< / span >
< span class = "n" > qcow2_args< / span > < span class = "o" > .< / span > < span class = "n" > extend< / span > < span class = "p" > ([< / span > < span class = "s" > " -O" < / span > < span class = "p" > ,< / span > < span class = "s" > " qcow2" < / span > < span class = "p" > ])< / span >
< span class = "n" > qcow2_img< / span > < span class = "o" > =< / span > < span class = "n" > tempfile< / span > < span class = "o" > .< / span > < span class = "n" > mktemp< / span > < span class = "p" > (< / span > < span class = "n" > prefix< / span > < span class = "o" > =< / span > < span class = "s" > " disk" < / span > < span class = "p" > ,< / span > < span class = "n" > suffix< / span > < span class = "o" > =< / span > < span class = "s" > " .img" < / span > < span class = "p" > )< / span >
< span class = "n" > execWithRedirect< / span > < span class = "p" > (< / span > < span class = "s" > " qemu-img" < / span > < span class = "p" > ,< / span > < span class = "p" > [< / span > < span class = "s" > " convert" < / span > < span class = "p" > ]< / span > < span class = "o" > +< / span > < span class = "n" > qcow2_args< / span > < span class = "o" > +< / span > < span class = "p" > [< / span > < span class = "n" > disk_img< / span > < span class = "p" > ,< / span > < span class = "n" > qcow2_img< / span > < span class = "p" > ],< / span > < span class = "n" > raise_err< / span > < span class = "o" > =< / span > < span class = "bp" > True< / span > < span class = "p" > )< / span >
< span class = "n" > execWithRedirect< / span > < span class = "p" > (< / span > < span class = "s" > " mv" < / span > < span class = "p" > ,< / span > < span class = "p" > [< / span > < span class = "s" > " -f" < / span > < span class = "p" > ,< / span > < span class = "n" > qcow2_img< / span > < span class = "p" > ,< / span > < span class = "n" > disk_img< / span > < span class = "p" > ],< / span > < span class = "n" > raise_err< / span > < span class = "o" > =< / span > < span class = "bp" > True< / span > < span class = "p" > )< / span >
< / div >
< div class = "viewcode-block" id = "virt_install" > < a class = "viewcode-back" href = "../../pylorax.html#pylorax.installer.virt_install" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > virt_install< / span > < span class = "p" > (< / span > < span class = "n" > opts< / span > < span class = "p" > ,< / span > < span class = "n" > install_log< / span > < span class = "p" > ,< / span > < span class = "n" > disk_img< / span > < span class = "p" > ,< / span > < span class = "n" > disk_size< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " < / span >
< span class = "sd" > Use virt-install to install to a disk image< / span >
< span class = "sd" > install_log is the path to write the log from virt-install< / span >
< span class = "sd" > disk_img is the full path to the final disk or filesystem image< / span >
< span class = "sd" > disk_size is the size of the disk to create in GiB< / span >
< span class = "sd" > " " " < / span >
< span class = "n" > iso_mount< / span > < span class = "o" > =< / span > < span class = "n" > IsoMountpoint< / span > < span class = "p" > (< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > iso< / span > < span class = "p" > ,< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > location< / span > < span class = "p" > )< / span >
< span class = "n" > log_monitor< / span > < span class = "o" > =< / span > < span class = "n" > LogMonitor< / span > < span class = "p" > (< / span > < span class = "n" > install_log< / span > < span class = "p" > )< / span >
< span class = "n" > kernel_args< / span > < span class = "o" > =< / span > < span class = "s" > " " < / span >
< span class = "k" > if< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > kernel_args< / span > < span class = "p" > :< / span >
< span class = "n" > kernel_args< / span > < span class = "o" > +=< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > kernel_args< / span >
< span class = "k" > if< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > proxy< / span > < span class = "p" > :< / span >
< span class = "n" > kernel_args< / span > < span class = "o" > +=< / span > < span class = "s" > " proxy=" < / span > < span class = "o" > +< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > proxy< / span >
< span class = "k" > if< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > qcow2< / span > < span class = "ow" > and< / span > < span class = "ow" > not< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > make_fsimage< / span > < span class = "p" > :< / span >
< span class = "c" > # virt-install can' t take all the qcow2 options so create the image first< / span >
< span class = "n" > qcow2_args< / span > < span class = "o" > =< / span > < span class = "p" > []< / span >
< span class = "k" > for< / span > < span class = "n" > arg< / span > < span class = "ow" > in< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > qcow2_args< / span > < span class = "p" > :< / span >
< span class = "n" > qcow2_args< / span > < span class = "o" > +=< / span > < span class = "n" > arg< / span > < span class = "o" > .< / span > < span class = "n" > split< / span > < span class = "p" > (< / span > < span class = "s" > " " < / span > < span class = "p" > ,< / span > < span class = "mi" > 1< / span > < span class = "p" > )< / span >
< span class = "n" > mkqcow2< / span > < span class = "p" > (< / span > < span class = "n" > disk_img< / span > < span class = "p" > ,< / span > < span class = "n" > disk_size< / span > < span class = "o" > *< / span > < span class = "mi" > 1024< / span > < span class = "o" > **< / span > < span class = "mi" > 3< / span > < span class = "p" > ,< / span > < span class = "n" > qcow2_args< / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > make_fsimage< / span > < span class = "ow" > or< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > make_tar< / span > < span class = "p" > :< / span >
< span class = "n" > diskimg_path< / span > < span class = "o" > =< / span > < span class = "n" > tempfile< / span > < span class = "o" > .< / span > < span class = "n" > mktemp< / span > < span class = "p" > (< / span > < span class = "n" > prefix< / span > < span class = "o" > =< / span > < span class = "s" > " disk" < / span > < span class = "p" > ,< / span > < span class = "n" > suffix< / span > < span class = "o" > =< / span > < span class = "s" > " .img" < / span > < span class = "p" > )< / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
< span class = "n" > diskimg_path< / span > < span class = "o" > =< / span > < span class = "n" > disk_img< / span >
< span class = "n" > virt< / span > < span class = "o" > =< / span > < span class = "n" > VirtualInstall< / span > < span class = "p" > (< / span > < span class = "n" > iso_mount< / span > < span class = "p" > ,< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > ks< / span > < span class = "p" > ,< / span > < span class = "n" > diskimg_path< / span > < span class = "p" > ,< / span > < span class = "n" > disk_size< / span > < span class = "p" > ,< / span >
< span class = "n" > kernel_args< / span > < span class = "p" > ,< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > ram< / span > < span class = "p" > ,< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > vnc< / span > < span class = "p" > ,< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > arch< / span > < span class = "p" > ,< / span >
< span class = "n" > log_check< / span > < span class = "o" > =< / span > < span class = "n" > log_monitor< / span > < span class = "o" > .< / span > < span class = "n" > server< / span > < span class = "o" > .< / span > < span class = "n" > log_check< / span > < span class = "p" > ,< / span >
< span class = "n" > virtio_host< / span > < span class = "o" > =< / span > < span class = "n" > log_monitor< / span > < span class = "o" > .< / span > < span class = "n" > host< / span > < span class = "p" > ,< / span >
< span class = "n" > virtio_port< / span > < span class = "o" > =< / span > < span class = "n" > log_monitor< / span > < span class = "o" > .< / span > < span class = "n" > port< / span > < span class = "p" > ,< / span >
< span class = "n" > qcow2< / span > < span class = "o" > =< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > qcow2< / span > < span class = "p" > )< / span >
< span class = "n" > virt< / span > < span class = "o" > .< / span > < span class = "n" > destroy< / span > < span class = "p" > ()< / span >
< span class = "n" > log_monitor< / span > < span class = "o" > .< / span > < span class = "n" > shutdown< / span > < span class = "p" > ()< / span >
< span class = "n" > iso_mount< / span > < span class = "o" > .< / span > < span class = "n" > umount< / span > < span class = "p" > ()< / span >
< span class = "k" > if< / span > < span class = "n" > log_monitor< / span > < span class = "o" > .< / span > < span class = "n" > server< / span > < span class = "o" > .< / span > < span class = "n" > log_check< / span > < span class = "p" > ():< / span >
< span class = "k" > raise< / span > < span class = "n" > InstallError< / span > < span class = "p" > (< / span > < span class = "s" > " virt_install failed" < / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > make_fsimage< / span > < span class = "p" > :< / span >
< span class = "n" > mkdiskfsimage< / span > < span class = "p" > (< / span > < span class = "n" > diskimg_path< / span > < span class = "p" > ,< / span > < span class = "n" > disk_img< / span > < span class = "p" > ,< / span > < span class = "n" > label< / span > < span class = "o" > =< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > fs_label< / span > < span class = "p" > )< / span >
< span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > unlink< / span > < span class = "p" > (< / span > < span class = "n" > diskimg_path< / span > < span class = "p" > )< / span >
< span class = "k" > elif< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > make_tar< / span > < span class = "p" > :< / span >
< span class = "n" > compress_args< / span > < span class = "o" > =< / span > < span class = "p" > []< / span >
< span class = "k" > for< / span > < span class = "n" > arg< / span > < span class = "ow" > in< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > compress_args< / span > < span class = "p" > :< / span >
< span class = "n" > compress_args< / span > < span class = "o" > +=< / span > < span class = "n" > arg< / span > < span class = "o" > .< / span > < span class = "n" > split< / span > < span class = "p" > (< / span > < span class = "s" > " " < / span > < span class = "p" > ,< / span > < span class = "mi" > 1< / span > < span class = "p" > )< / span >
< span class = "k" > with< / span > < span class = "n" > PartitionMount< / span > < span class = "p" > (< / span > < span class = "n" > diskimg_path< / span > < span class = "p" > )< / span > < span class = "k" > as< / span > < span class = "n" > img_mount< / span > < span class = "p" > :< / span >
< span class = "k" > if< / span > < span class = "n" > img_mount< / span > < span class = "ow" > and< / span > < span class = "n" > img_mount< / span > < span class = "o" > .< / span > < span class = "n" > mount_dir< / span > < span class = "p" > :< / span >
< span class = "n" > rc< / span > < span class = "o" > =< / span > < span class = "n" > mktar< / span > < span class = "p" > (< / span > < span class = "n" > img_mount< / span > < span class = "o" > .< / span > < span class = "n" > mount_dir< / span > < span class = "p" > ,< / span > < span class = "n" > disk_img< / span > < span class = "p" > ,< / span > < span class = "n" > opts< / span > < span class = "o" > .< / span > < span class = "n" > compression< / span > < span class = "p" > ,< / span > < span class = "n" > compress_args< / span > < span class = "p" > )< / span >
< span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > unlink< / span > < span class = "p" > (< / span > < span class = "n" > diskimg_path< / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "n" > rc< / span > < span class = "p" > :< / span >
< span class = "k" > raise< / span > < span class = "n" > InstallError< / span > < span class = "p" > (< / span > < span class = "s" > " virt_install failed" < / span > < span class = "p" > )< / span > < / div >
< / pre > < / div >
< / div >
< / div >
< / div >
< div class = "sphinxsidebar" >
< div class = "sphinxsidebarwrapper" >
< div id = "searchbox" style = "display: none" >
< h3 > Quick search< / h3 >
< form class = "search" action = "../../search.html" method = "get" >
< input type = "text" name = "q" / >
< input type = "submit" value = "Go" / >
< input type = "hidden" name = "check_keywords" value = "yes" / >
< input type = "hidden" name = "area" value = "default" / >
< / form >
< p class = "searchtip" style = "font-size: 90%" >
Enter search terms or a module, class or function name.
< / p >
< / div >
< script type = "text/javascript" > $ ( '#searchbox' ) . show ( 0 ) ; < / script >
< / div >
< / div >
< div class = "clearer" > < / div >
< / div >
< div class = "related" >
< h3 > Navigation< / h3 >
< ul >
< li class = "right" style = "margin-right: 10px" >
< a href = "../../genindex.html" title = "General Index"
>index< / a > < / li >
< li class = "right" >
< a href = "../../py-modindex.html" title = "Python Module Index"
>modules< / a > |< / li >
2018-05-16 23:23:14 +00:00
< li > < a href = "../../index.html" > Lorax 19.7.15 documentation< / a > » < / li >
2018-03-16 23:41:16 +00:00
< li > < a href = "../index.html" > Module code< / a > » < / li >
< li > < a href = "../pylorax.html" > pylorax< / a > » < / li >
2018-03-15 21:04:29 +00:00
< / ul >
< / div >
< div class = "footer" >
2018-03-16 23:41:16 +00:00
© Copyright 2018, Red Hat, Inc..
2018-03-15 21:04:29 +00:00
Created using < a href = "http://sphinx.pocoo.org/" > Sphinx< / a > 1.1.3.
< / div >
< / body >
< / html >