예제 #1
0
파일: host.py 프로젝트: thomassa/xenrt
    def boot(self):
        if self.host.productVersion.endswith("-x64"):
            arch = "amd64"
        else:
            arch = "x86"
        # Construct a PXE target
        pxe1 = xenrt.PXEBoot()
        serport = self.host.lookup("SERIAL_CONSOLE_PORT", "0")
        serbaud = self.host.lookup("SERIAL_CONSOLE_BAUD", "115200")
        pxe1.setSerial(serport, serbaud)
        pxe2 = xenrt.PXEBoot()
        serport = self.host.lookup("SERIAL_CONSOLE_PORT", "0")
        serbaud = self.host.lookup("SERIAL_CONSOLE_BAUD", "115200")
        pxe2.setSerial(serport, serbaud)

        pxe1.addEntry("ipxe", boot="ipxe")
        pxe1.setDefault("ipxe")
        pxe1.writeOut(self.host.machine)

        winpe = pxe2.addEntry("winpe", boot="memdisk")
        winpe.setInitrd("%s/tftp/winpe/winpe-%s.iso" %
                        (xenrt.TEC().lookup("LOCALURL"), arch))
        winpe.setArgs("iso raw")

        pxe2.setDefault("winpe")
        filename = pxe2.writeOut(self.host.machine, suffix="_ipxe")
        ipxescript = """set 209:string pxelinux.cfg/%s
chain tftp://${next-server}/%s
""" % (os.path.basename(filename), xenrt.TEC().lookup("PXELINUX_PATH",
                                                      "pxelinux.0"))
        pxe2.writeIPXEConfig(self.host.machine, ipxescript)

        self.host.machine.powerctl.cycle()
        xenrt.sleep(60)
        self.waitForBoot()
예제 #2
0
    def run(self, arglist):
        pxe = xenrt.PXEBoot()
        pxe.copyIn("%s/%s.c32" % (xenrt.TEC().getWorkdir(), self.TEST))
        entry = pxe.addEntry(self.TEST, boot="linux")
        entry.linuxSetKernel("%s.c32" % (self.TEST))
        pxe.setDefault(self.TEST)
        pxe.writeOut(None, forcemac=self.testmac)

        self.testguest.lifecycleOperation("vm-start")
        self.testguest.poll("UP", pollperiod=5)
        domainid = self.testguest.getDomid()
        xenrt.TEC().logverbose("Waiting for test to complete...")
        time.sleep(30) 
        self.testguest.shutdown(force=True)

        results = {}
        data = self.host.execdom0("cat %s/console.%s.log" % 
                                  (xenrt.TEC().lookup("GUEST_CONSOLE_LOGDIR"),
                                   domainid))
        file("%s/%s.out" % (xenrt.TEC().getLogdir(), self.TEST), "w").write(data)
        data = filter(re.compile("XenTest").search, data.split("boot:"))
        for item in data:
            testname = re.search("XenTest: (?P<test>.*)", item).group("test").strip()
            results[testname] = item.strip()
        for key in results:
            failure = re.search("FAIL .*", results[key])
            if failure:
                raise xenrt.XRTFailure("XenTest subcase %s failed: %s" % 
                                       (key, failure.group()))
예제 #3
0
 def createPXEFileForMac(self, mac):
     pxe = xenrt.PXEBoot(abspath=True, removeOnExit=True)
     pxecfg = pxe.addEntry("cleanrd", default=1, boot="linux")
     barch = self.pool.master.getBasicArch()
     pxecfg.linuxSetKernel("clean/vmlinuz-xenrt-%s" % (barch))
     pxecfg.linuxArgsKernelAdd("root=/dev/ram0")
     pxecfg.linuxArgsKernelAdd("console=tty0")
     pxecfg.linuxArgsKernelAdd("maxcpus=1")
     pxecfg.linuxArgsKernelAdd("console=ttyS0,115200n8")
     pxecfg.linuxArgsKernelAdd("ramdisk_size=%d" % (self.RAMDISK_SIZE))
     pxecfg.linuxArgsKernelAdd("ro")
     pxecfg.linuxArgsKernelAdd("initrd=clean/cleanroot-%s.img.gz" % (barch))
     pxefile = pxe.writeOut(None, forcemac=mac)
예제 #4
0
파일: host.py 프로젝트: thomassa/xenrt
    def install(self,
                cd=None,
                primarydisk=None,
                guestdisks=["sda"],
                source="url",
                timezone="UTC",
                interfaces=[(None, "yes", "dhcp", None, None, None)],
                ntpserver=None,
                nameserver=None,
                hostname=None,
                installSRType=None,
                bootloader=None,
                overlay=None,
                suppackcds=None):

        xenrt.TEC().progress("Installing ESXi %s" % self.esxiVersion)

        workdir = xenrt.TEC().getWorkdir()

        # Get a PXE directory to put boot files in
        pxe = xenrt.PXEBoot()

        # Create an NFS directory for images, signals, etc.
        nfsdir = xenrt.NFSDirectory()

        isoname = "/usr/groups/xenrt/esx/ESXi-%s.iso" % self.esxiVersion
        esxiso = xenrt.TEC().getFile(isoname)
        if not esxiso:
            raise xenrt.XRTError("Couldn't find ISO %s" % (isoname))

        mount = xenrt.rootops.MountISO(esxiso)
        mountpoint = mount.getMount()
        pxe.copyIn("%s/*" % (mountpoint))

        # create kickstart file
        ksname = "kickstart-%s.cfg" % (self.getName())
        kspath = "%s/%s" % (workdir, ksname)
        ks = file(kspath, "w")
        kstext = """
vmaccepteula
rootpw %s
clearpart --alldrives --overwritevmfs
install --firstdisk --overwritevmfs
network --bootproto=dhcp --device=vmnic0

%%firstboot --interpreter=busybox
vim-cmd hostsvc/enable_ssh
vim-cmd hostsvc/start_ssh
vim-cmd hostsvc/enable_esx_shell
vim-cmd hostsvc/start_esx_shell
esxcli system settings advanced set -o /UserVars/SuppressShellWarning -i 1

esxcli network firewall set --enabled false
esxcli network vswitch standard policy security set --allow-promiscuous true -v vSwitch0
esxcli system settings advanced set -i 1 -o /Misc/LogToSerial
esxcli system settings advanced set -i 115200 -o /Misc/SerialBaudRate
esxcli system settings advanced set -i 1 -o /Misc/DebugLogToSerial
esxcli system settings advanced set -s NONE -o /Misc/LogPort
esxcli system settings advanced set -s COM1 -o /Misc/LogPort

%%post --interpreter=busybox
exec < /dev/console > /dev/console 2> /dev/console
touch /vmfs/volumes/remote-install-location/.xenrtsuccess
sleep 30
reboot
""" % xenrt.TEC().lookup("ROOT_PASSWORD")
        ks.write(kstext)
        ks.close()
        nfsdir.copyIn(kspath)
        xenrt.TEC().copyToLogDir(kspath, target=ksname)

        # tweak mboot config file
        origbootcfg = file("%s/%s" % (mountpoint, "boot.cfg"), "r")
        bootcfgpath = "%s/%s" % (workdir, "boot.cfg")
        bootcfg = file(bootcfgpath, "w")
        bootcfgtext = origbootcfg.read()
        bootcfgtext = re.sub(r"/", r"",
                             bootcfgtext)  # get rid of all absolute paths...
        bootcfgtext += "prefix=%s" % pxe.makeBootPath(
            "")  # ... and use our PXE path as a prefix instead
        bootcfgtext = re.sub(
            r"--- useropts\.gz", r"", bootcfgtext
        )  # this file seems to cause only trouble, and getting rid of it seems to have no side effects...
        bootcfgtext = re.sub(r"--- jumpstrt\.gz", r"",
                             bootcfgtext)  # this file (in ESXi 5.5) is similar
        if self.esxiVersion < "5.5":
            deferToolsPackInstallation = False
        else:
            bootcfgtext2 = re.sub(
                r"--- tools.t00", r"", bootcfgtext
            )  # this file is too large to get over netboot from atftpd (as used in CBGLAB01), so we will install it after host-installation
            deferToolsPackInstallation = (bootcfgtext2 <> bootcfgtext)
            bootcfgtext = bootcfgtext2
        bootcfgtext = re.sub(
            r"(kernelopt=.*)", r"\1 debugLogToSerial=1 logPort=com1 ks=%s" %
            ("nfs://%s%s" % (nfsdir.getHostAndPath(ksname))), bootcfgtext)
        bootcfg.write(bootcfgtext)
        bootcfg.close()
        origbootcfg.close()
        # remove the old boot.cfg (as it is read-only, it won't let you update in place)
        os.remove(os.path.join(pxe.path(), "boot.cfg"))
        pxe.copyIn(bootcfgpath)
        xenrt.TEC().copyToLogDir(bootcfgpath,
                                 target="bootcfg-%s.cfg" % (self.getName()))

        # add boot entry
        # NB: we are not actually booting a linux kernel
        pxecfg = pxe.addEntry("esx", default=1, boot="linux")
        pxecfg.linuxSetKernel("mboot.c32")
        pxecfg.linuxArgsKernelAdd("-c %s" % pxe.makeBootPath("boot.cfg"))

        chain = self.getChainBoot()
        if chain:
            pxe.addEntry("local", boot="chainlocal", options=chain)
        else:
            pxe.addEntry("local", boot="local")

        # Set up PXE for installer boot
        pxefile = pxe.writeOut(self.machine)
        pfname = os.path.basename(pxefile)
        xenrt.TEC().copyToLogDir(pxefile, target="%s.pxe.txt" % (pfname))

        # Reboot the host into the installer
        self.machine.powerctl.cycle()
        xenrt.TEC().progress("Rebooted host to start installation.")

        # Monitor for installation complete
        xenrt.waitForFile("%s/.xenrtsuccess" % (nfsdir.path()),
                          1800,
                          desc="Installer boot on !%s" % (self.getName()))

        # Boot the local disk - we need to update this before the machine
        # reboots after setting the signal flag.
        pxe.setDefault("local")
        pxe.writeOut(self.machine)

        xenrt.sleep(30)
        self.waitForSSH(900, desc="Host boot (!%s)" % (self.getName()))

        # If we skipped tools.t00 above due to tftp issues, install it now. It's just a .tar.gz file.
        if deferToolsPackInstallation:
            xenrt.TEC().progress("Manually installing tools.t00")

            toolsFile = "%s/tools.t00" % (mountpoint)

            # Use the first-named datastore to temporarily dump the file. (Alternatively, could use /tardisks?)
            firstDatastore = self.getDefaultDatastore()
            destFilePath = "/vmfs/volumes/%s/tools.t00" % (firstDatastore)
            sftp = self.sftpClient()
            try:
                sftp.copyTo(toolsFile, destFilePath)
            finally:
                sftp.close()

            self.execdom0("tar xvfz %s -C /locker/packages" % (destFilePath))
            self.execdom0("rm -f %s" % (destFilePath))

        # We're done with the ISO now
        mount.unmount()

        nfsdir.remove()

        self.installSRType = installSRType

        xenrt.TEC().progress("Completed installation of ESXi host")
예제 #5
0
    def installWindows(self, version, build, arch):
        self.windows = True

        if not os.path.exists(
                "%s/%s/%s/autoinstall-%s.zip" %
            (xenrt.TEC().lookup("IMAGES_ROOT"), version, build, arch)):
            if not os.path.exists(
                    "%s/%s/%s/autoinstall-%s.tar" %
                (xenrt.TEC().lookup("IMAGES_ROOT"), version, build, arch)):
                raise xenrt.XRTError("No install files found for %s build %s" %
                                     (version, build))

        if version == "longhorn" or version[0:7] == "vistaee":
            method = "longhorn"
        else:
            method = "normal"
        self.distro = version

        xenrt.TEC().progress("Preparing TFTP...")
        tftp = "%s/xenrt/native" % (xenrt.TEC().lookup("TFTP_BASE"))
        if not os.path.exists(tftp):
            xenrt.sudo("mkdir -p %s" % (tftp))
        xenrt.getTestTarball("native", extract=True)
        xenrt.sudo("rsync -avxl %s/winpe32.wim %s/winpe.wim" %
                   (xenrt.TEC().lookup("IMAGES_ROOT"), tftp))

        # Get a PXE directory to put boot files in.
        xenrt.TEC().progress("Preparing PXE...")
        serport = xenrt.TEC().lookup("SERIAL_CONSOLE_PORT", "0")
        serbaud = xenrt.TEC().lookup("SERIAL_CONSOLE_BAUD", "115200")
        pxe = xenrt.PXEBoot()
        pxe.copyIn("%s/native/pxe/pxeboot.0" % (xenrt.TEC().getWorkdir()))
        xenrt.sudo("rsync -avxl %s/native/pxe/32/BCD %s/BCD" %
                   (xenrt.TEC().getWorkdir(), tftp))
        xenrt.sudo("rsync -avxl %s/native/pxe/boot.sdi %s/boot.sdi" %
                   (xenrt.TEC().getWorkdir(), tftp))
        xenrt.sudo("rsync -avxl %s/native/pxe/bootmgr.exe %s/bootmgr.exe" %
                   (xenrt.TEC().getWorkdir(), tftp))

        # Set the boot files and options for PXE
        pxe.setSerial(serport, serbaud)
        pxe.addEntry("local", boot="local")
        pxecfg = pxe.addEntry("winpe", default=1, boot="linux")
        pxecfg.linuxSetKernel("pxeboot.0")

        xenrt.TEC().progress("Preparing web directory")
        w = xenrt.WebDirectory()

        f = file("%s/native/pe/perun.cmd" % (xenrt.TEC().getWorkdir()), "r")
        perun = f.read()
        f.close()

        if method == "longhorn":
            t = xenrt.TempDirectory()

            xenrt.command("tar xf %s/%s/%s/autoinstall-%s.tar -C %s" %
                          (xenrt.TEC().lookup("IMAGES_ROOT"), version, build,
                           arch, t.path()))

            w.copyIn("%s/install/unattend.xml" % (t.path()))
            perun += "wget %FILES%/unattend.xml\n"

            # Count the number of install.wim fragments.
            catcmd = "cat "
            partpath = "%s/install/install.part" % (t.path())
            numparts = len(glob.glob("%s*" % (partpath)))
            for i in range(1, numparts + 1):
                # Download install.wim fragment.
                perun += "wget %%FILES%%/%s%d\n" % (os.path.basename(partpath),
                                                    i)
                # Make sure fragments get recombined.
                catcmd += "%s%d " % (os.path.basename(partpath), i)
                # Make fragment available over the network.
                w.copyIn("%s%d" % (partpath, i))
            catcmd += "> c:\\win\\sources\\install.wim\n"
            perun += catcmd
            w.copyIn("%s/install/install.zip" % (t.path()), target="win.zip")

            t.remove()

            # 32-bit installs just require the one stage.
            if arch == "x86-32":
                perun += "c:\\win\\sources\\setup.exe /unattend:c:\\unattend.xml"
        else:
            t = xenrt.TempDirectory()

            xenrt.command(
                "unzip %s/%s/%s/autoinstall-%s.zip unattend.txt -d %s" %
                (xenrt.TEC().lookup("IMAGES_ROOT"), version, build, arch,
                 t.path()))
            try:
                xenrt.command(
                    "unzip %s/%s/%s/autoinstall-%s.zip runonce.cmd -d %s" %
                    (xenrt.TEC().lookup("IMAGES_ROOT"), version, build, arch,
                     t.path()))
            except:
                try:
                    xenrt.command(
                        "unzip %s/%s/%s/autoinstall-%s.zip win/i386/runonce.cmd -d %s"
                        % (xenrt.TEC().lookup("IMAGES_ROOT"), version, build,
                           arch, t.path()))
                except:
                    xenrt.command(
                        "unzip %s/%s/%s/autoinstall-%s.zip win/I386/runonce.cmd -d %s"
                        % (xenrt.TEC().lookup("IMAGES_ROOT"), version, build,
                           arch, t.path()))
                xenrt.command("mv %s/win/?386/runonce.cmd %s/runonce.cmd" %
                              (t.path(), t.path()))
            xenrt.command("chmod a+rwx %s/runonce.cmd" % (t.path()))

            perun += """
wget %FILES%/runonce.cmd
wget %FILES%/unattend.txt
bootsect /nt52 c: /force
c:\win\i386\winnt32.exe /makelocalsource /syspart:c: /s:c:\win\i386 /unattend:c:\unattend.txt /cmd:c:\runonce.cmd
wpeutil reboot
"""
            f = file("%s/runonce.cmd" % (t.path()), "r")
            data = f.read()
            f.close()
            # HACK to support Broadcom NICs on those machines that have them.
            if xenrt.TEC().lookup("BROADCOM_POSTINSTALL", False, boolean=True):
                data = string.replace(data, "EXIT", "")
                data = data + 'REG ADD %KEY%\\050 /VE /D "Broadcom Driver" /f\n'
                data = data + 'REG ADD %KEY%\\050 /V 1 /D ' \
                       '"%systemdrive%\\win\\post\\Broadcom\\setup.exe ' \
                       '/s /v/qn" /f\n'
                data = data + "EXIT\n"

            xenrt.TEC().copyToLogDir("%s/runonce.cmd" % (t.path()))
            f = file("%s/runonce.cmd" % (t.path()), "w")
            f.write(data)
            f.close()
            w.copyIn("%s/unattend.txt" % (t.path()))
            w.copyIn("%s/runonce.cmd" % (t.path()))
            w.copyIn("%s/%s/%s/autoinstall-%s.zip" %
                     (xenrt.TEC().lookup("IMAGES_ROOT"), version, build, arch),
                     target="win.zip")
            t.remove()

        # Copy common files.
        w.copyIn("%s/native/pe/makepart.txt" % (xenrt.TEC().getWorkdir()))

        perun_dir = os.path.dirname(xenrt.TEC().lookup("WINPE_START_FILE"))
        if not os.path.exists(perun_dir):
            xenrt.sudo("mkdir -p %s" % (perun_dir))
        # Replace variables in perun.cmd.
        perun = string.replace(perun, "%FILES%", "%s" % (w.getURL("/")))
        f = file("%s/perun.cmd" % (xenrt.TEC().getWorkdir()), "w")
        f.write(perun)
        f.close()
        xenrt.TEC().copyToLogDir("%s/perun.cmd" % (xenrt.TEC().getWorkdir()))
        # Put perun.cmd where WinPE expects it.
        lock = xenrt.resources.CentralResource()
        for i in range(10):
            try:
                lock.acquire("WINPE_START_FILE")
                break
            except:
                if i == 9:
                    raise xenrt.XRTError("Couldn't get lock on WINPE "
                                         "bootstrap file.")
                xenrt.sleep(60)
        xenrt.sudo(
            "cp %s/perun.cmd %s" %
            (xenrt.TEC().getWorkdir(), xenrt.TEC().lookup("WINPE_START_FILE")))

        # Start install.
        xenrt.TEC().progress("Starting installation")
        pxefile = pxe.writeOut(self.machine)
        pfname = os.path.basename(pxefile)
        xenrt.TEC().copyToLogDir(pxefile, target="%s.pxe.txt" % (pfname))
        self.machine.powerctl.cycle()
        xenrt.TEC().progress("Rebooted host to start installation.")

        xenrt.sleep(120)

        lock.release()

        # 64-bit requires a two-stage installation.
        if arch == "x86-64":
            # Wait for first stage to complete.
            xenrt.sleep(360)
            xenrt.TEC().progress("Preparing TFTP for second stage.")
            xenrt.sudo("rsync -avxl %s/native/pxe/64/ %s/" %
                       (xenrt.TEC().getWorkdir(), tftp))
            xenrt.sudo("rsync -avxl %s/winpe64.wim %s/winpe.wim" %
                       (xenrt.TEC().lookup("IMAGES_ROOT"), tftp))
            self.machine.powerctl.cycle()
            xenrt.TEC().progress(
                "Rebooted host into second installation stage.")

        # Wait for PXE boot.
        xenrt.sleep(120)
        pxe.setDefault("local")
        pxe.writeOut(self.machine)

        # Wait for Windows to boot.
        xenrt.TEC().progress("Waiting for host to boot")
        self.waitforxmlrpc(7200)

        w.remove()

        if method == "longhorn":
            self.winRegAdd(
                "HKLM", "SYSTEM\\CurrentControlSet\\Control\\Terminal Server",
                "fDenyTSConnections", "DWORD", 0)
            self.winRegAdd("HKLM", "SYSTEM\\CurrentControlSet\\Control\\Lsa",
                           "LMCompatibilityLevel", "DWORD", 1)

        if not method == "longhorn":
            bootini = self.xmlrpcReadFile("c:\\boot.ini").strip()
            if self.memory:
                bootini += " /MAXMEM=%d" % (self.memory)
            if self.vcpus:
                bootini += " /NUMPROC=%d" % (self.vcpus)
            self.xmlrpcRemoveFile("c:\\boot.ini")
            self.xmlrpcCreateFile("c:\\boot.ini", xmlrpclib.Binary(bootini))
            self.xmlrpcReboot()
            xenrt.sleep(180)
            self.waitforxmlrpc(300)

            self.tailor()
예제 #6
0
파일: host.py 프로젝트: thomassa/xenrt
    def installWindows(self):
        # Set up the ISO
        mount = xenrt.mountStaticISO(self.productVersion)
        nfsdir = xenrt.NFSDirectory()
        xenrt.command("ln -sfT %s %s/iso" % (mount, nfsdir.path()))

        os.makedirs("%s/custom" % nfsdir.path())
        shutil.copy("%s/iso/Autounattend.xml" % nfsdir.path(),
                    "%s/custom/Autounattend.xml" % nfsdir.path())

        xenrt.command(
            """sed -i "s#<CommandLine>.*</CommandLine>#<CommandLine>c:\\\\\\\\install\\\\\\\\runonce.cmd</CommandLine>#" %s/custom/Autounattend.xml"""
            % nfsdir.path())
        shutil.copytree("%s/iso/$OEM$" % nfsdir.path(),
                        "%s/custom/oem" % nfsdir.path())
        xenrt.command("chmod u+w %s/custom/oem/\\$1/install" % nfsdir.path())

        with open("%s/custom/oem/$1/install/runonce.cmd" % nfsdir.path(),
                  "w") as f:
            f.write("%systemdrive%\install\python\python.cmd\r\n")
            f.write("EXIT\r\n")

        # First boot into winpe
        winpe = WinPE(self)
        winpe.boot()

        xenrt.TEC().logverbose("WinPE booted, wiping disk")
        # Wipe the disks and reboot
        winpe.xmlrpc.write_file("x:\\diskpart.txt",
                                "list disk\nselect disk 0\nclean\nexit")
        winpe.xmlrpc.exec_shell("diskpart.exe /s x:\\diskpart.txt")
        xenrt.TEC().logverbose("Rebooting WinPE")
        winpe.reboot()

        xenrt.TEC().logverbose("WinPE rebooted, mounting shares")

        winpe.xmlrpc.exec_shell("net use y: %s\\iso" % nfsdir.getCIFSPath())
        winpe.xmlrpc.exec_shell("net use z: %s\\custom" % nfsdir.getCIFSPath())

        xenrt.TEC().logverbose("Starting installer")
        # Mount the install share and start the installer
        winpe.xmlrpc.start_shell(
            "y:\\setup.exe /unattend:z:\\autounattend.xml /m:z:\\oem")

        # Now Construct a PXE target for local boot
        pxe = xenrt.PXEBoot()
        serport = self.lookup("SERIAL_CONSOLE_PORT", "0")
        serbaud = self.lookup("SERIAL_CONSOLE_BAUD", "115200")
        pxe.setSerial(serport, serbaud)
        chain = self.getChainBoot()
        if chain:
            pxe.addEntry("local", boot="chainlocal", options=chain)
        else:
            pxe.addEntry("local", boot="local")

        pxe.setDefault("local")
        pxe.writeOut(self.machine)

        # Wait for Windows to be ready
        self.waitForDaemon(7200)

        try:
            self.xmlrpcUpdate()
        except:
            xenrt.TEC().logverbose("Warning - could not update XML/RPC daemon")

        if self.xmlrpcFileExists("c:\\xenrtinstalled.stamp"):
            raise xenrt.XRTFailure(
                "Installation stamp file already exists, this must be a previous installation"
            )
        self.xmlrpcWriteFile("c:\\xenrtinstalled.stamp", "Installed")

        self.xmlrpcWriteFile("c:\\onboot.cmd",
                             "echo Booted > c:\\booted.stamp")
        self.winRegAdd("HKLM", "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
                       "Run", "Booted", "SZ", "c:\\onboot.cmd")
        self.installAdditionalNICDrivers()
        # Disable NLA requirement for RDP
        self.xmlrpcExec(
            """(Get-WmiObject -class "Win32_TSGeneralSetting" -Namespace root\\cimv2\\terminalservices -ComputerName $env:ComputerName -Filter "TerminalName='RDP-tcp'").SetUserAuthenticationRequired(0)""",
            powershell=True)
예제 #7
0
파일: host.py 프로젝트: thomassa/xenrt
    def install(self):
        f = xenrt.TEC().getFile("/usr/groups/xenrt/oraclevm/%s/ovm.iso" %
                                (self.productVersion))
        d = xenrt.NFSDirectory()
        m = xenrt.MountISO(f)
        d.copyIn("%s/*" % m.getMount())
        m.unmount()

        host, path = d.getHostAndPath("")

        pw = crypt.crypt(xenrt.TEC().lookup("ROOT_PASSWORD"), "Xa")

        ksd = xenrt.NFSDirectory()

        ks = """lang en_US
#langsupport en_US
eula Accepted
keyboard us
#mouse genericusb
timezone --utc America/Los_Angeles
rootpw --iscrypted %s
zerombr
bootloader --location=mbr
install
nfs --server %s --dir %s
clearpart --all
part /boot --fstype ext3 --size 512 --ondisk sda
part  swap --size 4096 --ondisk sda
part / --fstype ext3 --size 1 --grow --ondisk sda
network --bootproto dhcp --device eth0
ovsagent --iscrypted %s
ovsmgmntif eth0
auth  --useshadow  --enablemd5
firewall --disabled
#Do not configure the X Window System
skipx
text

%%packages
@Everything

%%pre
dd if=/dev/zero of=/dev/sda bs=1024 count=1024

%%post --nochroot

%%post
mkdir /tmp/xenrttmpmount
mount -onolock -t nfs %s /tmp/xenrttmpmount
touch /tmp/xenrttmpmount/.xenrtsuccess
umount /tmp/xenrttmpmount

""" % (pw, host, path, pw, ksd.getMountURL(""))

        with open("%s/ks.cfg" % ksd.path(), "w") as f:
            f.write(ks)

        pxe = xenrt.PXEBoot()
        pxe.addEntry("local", boot="local")
        serport = self.lookup("SERIAL_CONSOLE_PORT", "0")
        serbaud = self.lookup("SERIAL_CONSOLE_BAUD", "115200")
        comport = str(int(serport) + 1)

        if self.lookup("PXE_NO_SERIAL", False, boolean=True):
            pxe.setSerial(None, None)
        else:
            pxe.setSerial(serport, serbaud)

        chain = self.getChainBoot()
        if chain:
            pxe.addEntry("local", boot="chainlocal", options=chain)
        else:
            pxe.addEntry("local", boot="local")

        pxe.copyIn("%s/isolinux/xen.gz" % d.path())
        pxe.copyIn("%s/isolinux/vmlinuz" % d.path())
        pxe.copyIn("%s/isolinux/initrd.img" % d.path())

        install = pxe.addEntry("ovminstall", boot="mboot")
        install.mbootSetKernel("%s/xen.gz" % pxe.path())
        install.mbootSetModule1("%s/vmlinuz" % pxe.path())
        install.mbootSetModule2("%s/initrd.img" % pxe.path())

        install.mbootArgsModule1Add("ks=nfs:%sks.cfg" % ksd.getMountURL(""))
        install.mbootArgsModule1Add("ksdevice=eth0")
        install.mbootArgsModule1Add("ip=dhcp")
        #install.mbootArgsKernelAdd("com%s=%s,8n1" % (comport, serbaud))
        #install.mbootArgsModule1Add("console=tty0")
        #install.mbootArgsModule1Add("console=ttyS%s,%sn8" % (serport, serbaud))
        pxe.setDefault("ovminstall")
        pxe.writeOut(self.machine)

        self.machine.powerctl.cycle()

        xenrt.waitForFile("%s/.xenrtsuccess" % ksd.path(),
                          3600,
                          desc="Installer boot on !%s" % (self.getName()))
        xenrt.sleep(30)
        pxe.setDefault("local")
        pxe.writeOut(self.machine)
        self.machine.powerctl.cycle()

        self.waitForSSH(1800, desc="Host boot (!%s)" % (self.getName()))