Example #1
0
File: RHL.py Project: helgi/oz
    def _modify_iso(self):
        """
        Method to modify the ISO for autoinstallation.
        """
        self.log.debug("Putting the kickstart in place")

        outname = join(self.iso_contents, "ks.cfg")

        if self.auto is None:
            def _kssub(line):
                """
                Method that is called back from oz.ozutil.copy_modify_file() to
                modify kickstart files as appropriate for RHL-9.
                """
                # because we need to do this URL substitution here, we can't use
                # the generic "copy_kickstart()" method
                if re.match("^url", line):
                    return "url --url " + self.url + "\n"
                elif re.match("^rootpw", line):
                    return "rootpw " + self.rootpw + "\n"
                else:
                    return line

            copy_modify_file(generate_full_auto_path(self.stock_ks), outname, _kssub)
        else:
            shutil.copy(self.auto, outname)

        initrdline = "  append initrd=initrd.img ks=cdrom:/ks.cfg method=" + self.url + "\n"
        self._modify_isolinux(initrdline)
Example #2
0
File: Debian.py Project: helgi/oz
    def __init__(self, tdl, config, auto, output_disk, netdev, diskbus,
                 macaddress):
        oz.Guest.CDGuest.__init__(self, tdl, config, output_disk, netdev,
                                  None, None, diskbus, True, False, macaddress)

        self.preseed_file = auto
        if self.preseed_file is None:
            self.preseed_file = generate_full_auto_path("debian-" + self.tdl.update + "-jeos.preseed")
Example #3
0
File: Ubuntu.py Project: helgi/oz
    def __init__(self, tdl, config, auto, output_disk, initrd, nicmodel,
                 diskbus, macaddress):
        if tdl.update in ["6.06", "6.06.1", "6.06.2"]:
            tdl.update = "6.06"
        elif tdl.update in ["8.04", "8.04.1", "8.04.2", "8.04.3", "8.04.4"]:
            tdl.update = "8.04"
        elif tdl.update in ["10.04", "10.04.1", "10.04.2", "10.04.3"]:
            tdl.update = "10.04"
        elif tdl.update in ["12.04", "12.04.1", "12.04.2"]:
            tdl.update = "12.04"

        oz.Guest.CDGuest.__init__(self, tdl, config, output_disk, nicmodel,
                                  None, None, diskbus, True, True, macaddress)

        self.sshprivkey = join('/etc', 'oz', 'id_rsa-icicle-gen')
        self.crond_was_active = False
        self.sshd_was_active = False
        self.sshd_config = """\
SyslogFacility AUTHPRIV
PasswordAuthentication yes
ChallengeResponseAuthentication no
GSSAPIAuthentication yes
GSSAPICleanupCredentials yes
UsePAM yes
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS
X11Forwarding yes
Subsystem       sftp    /usr/libexec/openssh/sftp-server
"""

        self.casper_initrd = initrd

        self.preseed_file = auto
        if self.preseed_file is None:
            self.preseed_file = generate_full_auto_path("ubuntu-" + self.tdl.update + "-jeos.preseed")
        self.tunnels = {}

        self.ssh_startuplink = None
        self.cron_startuplink = None

        self.debarch = self.tdl.arch
        if self.debarch == "x86_64":
            self.debarch = "amd64"

        self.kernelfname = join(self.output_dir, self.tdl.name + "-kernel")
        self.initrdfname = join(self.output_dir, self.tdl.name + "-ramdisk")
        self.kernelcache = join(self.data_dir, "kernels",
                                self.tdl.distro + self.tdl.update + self.tdl.arch + "-kernel")
        self.initrdcache = join(self.data_dir, "kernels",
                                self.tdl.distro + self.tdl.update + self.tdl.arch + "-ramdisk")

        self.cmdline = "priority=critical locale=en_US"

        self.reboots = 0
        if self.tdl.update in ["5.04", "5.10"]:
            self.reboots = 1
Example #4
0
File: Windows.py Project: helgi/oz
    def __init__(self, tdl, config, auto, output_disk, netdev, diskbus, macaddress):
        Windows.__init__(self, tdl, config, output_disk, netdev, diskbus, macaddress)

        self.unattendfile = auto
        if self.unattendfile is None:
            self.unattendfile = generate_full_auto_path("windows-" + self.tdl.update + "-jeos.xml")

        self.winarch = "x86"
        if self.tdl.arch == "x86_64":
            self.winarch = "amd64"
Example #5
0
File: Mandrake.py Project: helgi/oz
    def __init__(self, tdl, config, auto, output_disk, netdev, diskbus,
                 macaddress):
        oz.Guest.CDGuest.__init__(self, tdl, config, output_disk, netdev,
                                  None, None, diskbus, True, False, macaddress)

        if self.tdl.arch != "i386":
            raise OzException("Mandrake only supports i386 architecture")

        self.auto = auto
        if self.auto is None:
            self.auto = generate_full_auto_path("mandrake-" + self.tdl.update + "-jeos.cfg")
Example #6
0
File: Mandriva.py Project: helgi/oz
    def __init__(self, tdl, config, auto, output_disk, netdev, diskbus,
                 macaddress):
        oz.Guest.CDGuest.__init__(self, tdl, config, output_disk, netdev,
                                  None, None, diskbus, True, False, macaddress)

        self.auto = auto
        if self.auto is None:
            self.auto = generate_full_auto_path("mandriva-" + self.tdl.update + "-jeos.cfg")

        self.mandriva_arch = self.tdl.arch
        if self.mandriva_arch == "i386":
            self.mandriva_arch = "i586"
Example #7
0
File: Windows.py Project: helgi/oz
    def __init__(self, tdl, config, auto, output_disk, netdev, diskbus, macaddress):
        Windows.__init__(self, tdl, config, output_disk, netdev, diskbus, macaddress)

        if self.tdl.update == "2000" and self.tdl.arch != "i386":
            raise OzException("Windows 2000 only supports i386 architecture")

        self.siffile = auto
        if self.siffile is None:
            self.siffile = generate_full_auto_path("windows-" + self.tdl.update + "-jeos.sif")

        self.winarch = self.tdl.arch
        if self.winarch == "x86_64":
            self.winarch = "amd64"
Example #8
0
File: OpenSUSE.py Project: helgi/oz
    def __init__(self, tdl, config, auto, output_disk, nicmodel, diskbus,
                 macaddress):
        oz.Guest.CDGuest.__init__(self, tdl, config, output_disk, nicmodel,
                                  None, None, diskbus, True, False, macaddress)

        self.reboots = 1
        if self.tdl.update in ["10.3"]:
            # for 10.3 we don't have a 2-stage install process so don't reboot
            self.reboots = 0

        self.autoyast = auto
        if self.autoyast is None:
            self.autoyast = generate_full_auto_path("opensuse-" + self.tdl.update + "-jeos.xml")

        self.sshprivkey = join('/etc', 'oz', 'id_rsa-icicle-gen')
Example #9
0
File: Debian.py Project: helgi/oz
    def _modify_iso(self):
        """
        Method to make the boot ISO auto-boot with appropriate parameters.
        """
        self.log.debug("Modifying ISO")

        self.log.debug("Copying preseed file")
        mkdir_p(join(self.iso_contents, "preseed"))

        outname = join(self.iso_contents, "preseed", "customiso.seed")

        if self.preseed_file == generate_full_auto_path("debian-" + self.tdl.update + "-jeos.preseed"):

            def _preseed_sub(line):
                """
                Method that is called back from oz.ozutil.copy_modify_file() to
                modify preseed files as appropriate for Debian.
                """
                if re.match('d-i passwd/root-password password', line):
                    return 'd-i passwd/root-password password ' + self.rootpw + '\n'
                elif re.match('d-i passwd/root-password-again password', line):
                    return 'd-i passwd/root-password-again password ' + self.rootpw + '\n'
                else:
                    return line

            copy_modify_file(self.preseed_file, outname, _preseed_sub)
        else:
            shutil.copy(self.preseed_file, outname)

        if self.tdl.arch == "x86_64":
            installdir = "/install.amd"
        else:
            # arch == i386
            installdir = "/install.386"

        self.log.debug("Modifying isolinux.cfg")
        isolinuxcfg = join(self.iso_contents, "isolinux", "isolinux.cfg")
        with open(isolinuxcfg, 'w') as f:
            f.write("""\
default customiso
timeout 1
prompt 0
label customiso
  menu label ^Customiso
  menu default
  kernel %s/vmlinuz\
  append file=/cdrom/preseed/customiso.seed %sdebian-installer/locale=en_US console-setup/layoutcode=us netcfg/choose_interface=auto priority=critical initrd=%s/initrd.gz --
""" % (installdir, extra, installdir))
Example #10
0
File: Mandriva.py Project: helgi/oz
    def _modify_iso(self):
        """
        Method to make the boot ISO auto-boot with appropriate parameters.
        """
        self.log.debug("Modifying ISO")
        self.log.debug("Copying cfg file")

        if self.tdl.update in ["2007.0", "2008.0"]:
            pathdir = join(self.iso_contents, self.mandriva_arch)
        else:
            pathdir = self.iso_contents

        outname = join(pathdir, "auto_inst.cfg")

        if self.auto == generate_full_auto_path("mandriva-" + self.tdl.update + "-jeos.cfg"):
            def _cfg_sub(line):
                """
                Method that is called back from oz.ozutil.copy_modify_file() to
                modify preseed files as appropriate for Mandriva.
                """
                if re.search("'password' =>", line):
                    return "			'password' => '" + self.rootpw + "',\n"
                else:
                    return line

            copy_modify_file(self.auto, outname, _cfg_sub)
        else:
            shutil.copy(self.auto, outname)

        self.log.debug("Modifying isolinux.cfg")
        isolinuxcfg = join(pathdir, "isolinux", "isolinux.cfg")
        with open(isolinuxcfg, 'w') as f:
            f.write("""\
default customiso
timeout 1
prompt 0
label customiso
  kernel alt0/vmlinuz
  append initrd=alt0/all.rdz ramdisk_size=128000 root=/dev/ram3 acpi=ht vga=788 automatic=method:cdrom kickstart=auto_inst.cfg
""")
Example #11
0
File: Windows.py Project: helgi/oz
    def _modify_iso(self):
        """
        Method to make the boot ISO auto-boot with appropriate parameters.
        """
        self.log.debug("Modifying ISO")

        os.mkdir(os.path.join(self.iso_contents, "cdboot"))
        self._geteltorito(self.orig_iso, join(self.iso_contents, "cdboot", "boot.bin"))

        outname = join(self.iso_contents, "autounattend.xml")

        if self.unattendfile == generate_full_auto_path("windows-" + self.tdl.update + "-jeos.xml"):
            # if this is the oz default unattend file, we modify certain
            # parameters to make installation succeed
            doc = libxml2.parseFile(self.unattendfile)
            xp = doc.xpathNewContext()
            xp.xpathRegisterNs("ms", "urn:schemas-microsoft-com:unattend")

            for component in xp.xpathEval("/ms:unattend/ms:settings/ms:component"):
                component.setProp("processorArchitecture", self.winarch)

            keys = xp.xpathEval("/ms:unattend/ms:settings/ms:component/ms:ProductKey")
            keys[0].setContent(self.tdl.key)

            adminpw = xp.xpathEval(
                "/ms:unattend/ms:settings/ms:component/ms:UserAccounts/ms:AdministratorPassword/ms:Value"
            )
            adminpw[0].setContent(self.rootpw)

            autologinpw = xp.xpathEval("/ms:unattend/ms:settings/ms:component/ms:AutoLogon/ms:Password/ms:Value")
            autologinpw[0].setContent(self.rootpw)

            doc.saveFile(outname)
        else:
            # if the user provided their own unattend file, do not override
            # their choices; the user gets to keep both pieces if something
            # breaks
            shutil.copy(self.unattendfile, outname)
Example #12
0
File: OpenSUSE.py Project: helgi/oz
    def _modify_iso(self):
        """
        Method to make the boot ISO auto-boot with appropriate parameters.
        """
        self.log.debug("Putting the autoyast in place")

        outname = join(self.iso_contents, "autoinst.xml")

        if self.autoyast == generate_full_auto_path("opensuse-" + self.tdl.update + "-jeos.xml"):
            doc = libxml2.parseFile(self.autoyast)

            xp = doc.xpathNewContext()
            xp.xpathRegisterNs("suse", "http://www.suse.com/1.0/yast2ns")

            pw = xp.xpathEval('/suse:profile/suse:users/suse:user/suse:user_password')
            pw[0].setContent(self.rootpw)

            doc.saveFile(outname)
        else:
            shutil.copy(self.autoyast, outname)

        self.log.debug("Modifying the boot options")
        isolinux_cfg = join(self.iso_contents, "boot", self.tdl.arch, "loader", "isolinux.cfg")
        f = open(isolinux_cfg, "r")
        lines = f.readlines()
        f.close()
        for index, line in enumerate(lines):
            if re.match("timeout", line):
                lines[index] = "timeout 1\n"
            elif re.match("default", line):
                lines[index] = "default customiso\n"
        lines.append("label customiso\n")
        lines.append("  kernel linux\n")
        lines.append("  append initrd=initrd splash=silent instmode=cd autoyast=default")

        f = open(isolinux_cfg, "w")
        f.writelines(lines)
        f.close()
Example #13
0
File: Ubuntu.py Project: helgi/oz
    def _copy_preseed(self, outname):
        """
        Method to copy and modify an Ubuntu style preseed file.
        """
        self.log.debug("Putting the preseed file in place")

        if self.preseed_file == generate_full_auto_path("ubuntu-" + self.tdl.update + "-jeos.preseed"):

            def _preseed_sub(line):
                """
                Method that is called back from oz.ozutil.copy_modify_file() to
                modify preseed files as appropriate for Ubuntu.
                """
                if re.match('d-i passwd/root-password password', line):
                    return 'd-i passwd/root-password password ' + self.rootpw + '\n'
                elif re.match('d-i passwd/root-password-again password', line):
                    return 'd-i passwd/root-password-again password ' + self.rootpw + '\n'
                else:
                    return line

            copy_modify_file(self.preseed_file, outname, _preseed_sub)
        else:
            shutil.copy(self.preseed_file, outname)
Example #14
0
File: Windows.py Project: helgi/oz
    def _modify_iso(self):
        """
        Method to make the boot ISO auto-boot with appropriate parameters.
        """
        self.log.debug("Modifying ISO")

        os.mkdir(join(self.iso_contents, "cdboot"))
        self._geteltorito(self.orig_iso, join(self.iso_contents, "cdboot", "boot.bin"))

        outname = join(self.iso_contents, self.winarch, "winnt.sif")

        if self.siffile == generate_full_auto_path("windows-" + self.tdl.update + "-jeos.sif"):
            # if this is the oz default siffile, we modify certain parameters
            # to make installation succeed
            computername = "OZ" + str(random.randrange(1, 900000))

            def _sifsub(line):
                """
                Method that is called back from oz.ozutil.copy_modify_file() to
                modify sif files as appropriate for Windows 2000/XP/2003.
                """
                if re.match(" *ProductKey", line):
                    return "    ProductKey=" + self.tdl.key + "\n"
                elif re.match(" *ProductID", line):
                    return "    ProductID=" + self.tdl.key + "\n"
                elif re.match(" *ComputerName", line):
                    return "    ComputerName=" + computername + "\n"
                elif re.match(" *AdminPassword", line):
                    return "    AdminPassword="******"\n"
                else:
                    return line

            copy_modify_file(self.siffile, outname, _sifsub)
        else:
            # if the user provided their own siffile, do not override their
            # choices; the user gets to keep both pieces if something breaks
            shutil.copy(self.siffile, outname)
Example #15
0
File: Mandrake.py Project: helgi/oz
    def _modify_iso(self):
        """
        Method to make the boot ISO auto-boot with appropriate parameters.
        """
        self.log.debug("Modifying ISO")

        outname = join(self.iso_contents, "auto_inst.cfg")
        if self.auto == generate_full_auto_path("mandrake-" + self.tdl.update + "-jeos.cfg"):

            def _cfg_sub(line):
                """
                Method that is called back from oz.ozutil.copy_modify_file() to
                modify preseed files as appropriate for Mandrake.
                """
                if re.search("'password' =>", line):
                    return "			'password' => '" + self.rootpw + "',\n"
                else:
                    return line

            copy_modify_file(self.auto, outname, _cfg_sub)
        else:
            shutil.copy(self.auto, outname)

        syslinux = join(self.icicle_tmp, 'syslinux.cfg')
        with open(syslinux, 'w') as f:
            f.write("""\
default customiso
timeout 1
prompt 0
label customiso
  kernel vmlinuz
  append initrd=cdrom.rdz ramdisk_size=32000 root=/dev/ram3 automatic=method:cdrom vga=788 auto_install=auto_inst.cfg
""")

        cdromimg = join(self.iso_contents, "Boot", "cdrom.img")
        subprocess_check_output(["mcopy", "-n", "-o", "-i", cdromimg, syslinux, "::SYSLINUX.CFG"])