示例#1
0
    def prepare(self, arglist):

        self.memory = None
        self.postInstallMemory = None
        self.vcpus = None
        self.cps = None
        self.template = None

        self.host = self.getDefaultHost()
        if self.DISTRO:
            # Workaroun CA-165205
            if self.DISTRO == "generic-linux" and self.host.lookup(
                    "GENERIC_LINUX_OS") in ("etch", "debian60"):
                self.DISTRO = "rhel5x"
            (self.distro, self.arch) = xenrt.getDistroAndArch(self.DISTRO)
        elif self.tcsku.endswith("_XenApp"):
            distroarch = self.tcsku.replace("_XenApp", "")
            (self.distro, self.arch) = xenrt.getDistroAndArch(distroarch)
            self.template = self.getXenAppTemplate(self.distro)
        else:
            (self.distro, self.arch) = xenrt.getDistroAndArch(self.tcsku)

        (self.installDistro,
         self.special) = self.host.resolveDistroName(self.distro)

        self.assertHardware()
        self.getGuestParams()

        # Workaround NOV-1 - set memory back to something sensible after install
        if self.installDistro == "sles112":
            if not self.memory:
                self.postInstallMemory = self.getTemplateParams().defaultMemory
            elif self.memory < 4096:
                self.postInstallMemory = self.memory
示例#2
0
    def prepare(self, arglist):

        self.memory = None
        self.postInstallMemory = None
        self.vcpus = None
        self.cps = None
        self.template = None
        

        self.host = self.getDefaultHost()
        if self.DISTRO:
            # Workaroun CA-165205
            if self.DISTRO == "generic-linux" and self.host.lookup("GENERIC_LINUX_OS") in ("etch", "debian60"):
                self.DISTRO = "rhel5x"
            (self.distro, self.arch) = xenrt.getDistroAndArch(self.DISTRO)
        elif self.tcsku.endswith("_XenApp"):
            distroarch = self.tcsku.replace("_XenApp", "")
            (self.distro, self.arch) = xenrt.getDistroAndArch(distroarch)
            self.template = self.getXenAppTemplate(self.distro)
        else:
            (self.distro, self.arch) = xenrt.getDistroAndArch(self.tcsku)

        (self.installDistro, self.special) = self.host.resolveDistroName(self.distro)
        
        self.assertHardware()
        self.getGuestParams()

        # Workaround NOV-1 - set memory back to something sensible after install
        if self.installDistro == "sles112":
            if not self.memory:
                self.postInstallMemory = self.getTemplateParams().defaultMemory
            elif self.memory < 4096:
                self.postInstallMemory = self.memory
示例#3
0
 def run(self, arglist):
     m = xenrt.rootops.MountNFS(xenrt.TEC().lookup("SHARED_VHD_PATH_NFS"))
     h = self.getDefaultHost()
     for a in arglist:
         if a[0] in ("v", "w"):
             args = {"distro": a}
             fulldistro = a
         else:
             (distro, arch) = xenrt.getDistroAndArch(a)
             args = {"distro": distro, "arch": arch}
             fulldistro = "%s_%s" % (distro, arch)
         g = h.createBasicGuest(notools=True, nodrivers=True, **args)
         if g.windows:
             g.installWICIfRequired()
             g.installDotNet35()
             g.installDotNet4()
             g.installPowerShell()
         g.prepareForTemplate()
         vdiuuid = h.minimalList("vbd-list", args="vm-uuid=%s userdevice=0" % g.getUUID(), params="vdi-uuid")[0]
         cfg = "%s/%s.cfg" % (m.getMount(), fulldistro)
         if os.path.exists(cfg):
             with open(cfg) as f:
                 u = f.read().strip()
         else:
             u = str(uuid.uuid4())
         xenrt.rootops.sudo("sh -c 'echo %s > %s.part'" % (u, cfg))
         vhd = "%s/%s.vhd" % (m.getMount(), u)
         xenrt.rootops.sudo("wget -O %s.part 'http://%s/export_raw_vdi?vdi=%s&format=vhd' --user=root --password=%s" % (vhd, h.getIP(), vdiuuid, h.password))
         xenrt.rootops.sudo("mv %s.part %s" % (vhd, vhd))
         xenrt.rootops.sudo("mv %s.part %s" % (cfg, cfg))
         g.uninstall()
示例#4
0
    def prepare(self, arglist):
        (self.distro, self.arch) = xenrt.getDistroAndArch(self.tcsku)
        self.host = self.getDefaultHost()

        if self.METHOD == "CDROM":
            self.repository = "cdrom"
        else:
            r = xenrt.getLinuxRepo(self.distro, self.arch, self.METHOD)
            self.repository = string.split(r)[0]
示例#5
0
    def test_distroparsing(self):
        """
        Test that we get the correct distro/arch for distro text
        """
        tests = {"rhel64-x64": ("rhel64", "x86-64"),
                 "rhel64-x86": ("rhel64", "x86-32"),
                 "rhel64-x32": ("rhel64", "x86-32"),
                 "rhel64_x86-32": ("rhel64", "x86-32"),
                 "rhel64_x86-64": ("rhel64", "x86-64"),
                 "rhel64": ("rhel64", "x86-32")}

        for t in tests.keys():
            self.assertEqual(tests[t], xenrt.getDistroAndArch(t))
                 
示例#6
0
    def test_distroparsing(self):
        """
        Test that we get the correct distro/arch for distro text
        """
        tests = {
            "rhel64-x64": ("rhel64", "x86-64"),
            "rhel64-x86": ("rhel64", "x86-32"),
            "rhel64-x32": ("rhel64", "x86-32"),
            "rhel64_x86-32": ("rhel64", "x86-32"),
            "rhel64_x86-64": ("rhel64", "x86-64"),
            "rhel64": ("rhel64", "x86-32"),
        }

        for t in tests.keys():
            self.assertEqual(tests[t], xenrt.getDistroAndArch(t))
示例#7
0
文件: maint.py 项目: thomassa/xenrt
 def run(self, arglist):
     m = xenrt.rootops.MountNFS(xenrt.TEC().lookup("SHARED_VHD_PATH_NFS"))
     h = self.getDefaultHost()
     for a in arglist:
         if a[0] in ("v", "w"):
             args = {"distro": a}
             fulldistro = a
         else:
             (distro, arch) = xenrt.getDistroAndArch(a)
             args = {"distro": distro, "arch": arch}
             fulldistro = "%s_%s" % (distro, arch)
         g = h.createBasicGuest(notools=True, nodrivers=True, **args)
         if g.windows:
             g.installWICIfRequired()
             g.installDotNet35()
             g.installDotNet4()
             g.installPowerShell()
         g.prepareForTemplate()
         vdiuuid = h.minimalList("vbd-list",
                                 args="vm-uuid=%s userdevice=0" %
                                 g.getUUID(),
                                 params="vdi-uuid")[0]
         cfg = "%s/%s.cfg" % (m.getMount(), fulldistro)
         if os.path.exists(cfg):
             with open(cfg) as f:
                 u = f.read().strip()
         else:
             u = str(uuid.uuid4())
         xenrt.rootops.sudo("sh -c 'echo %s > %s.part'" % (u, cfg))
         vhd = "%s/%s.vhd" % (m.getMount(), u)
         xenrt.rootops.sudo(
             "wget -O %s.part 'http://%s/export_raw_vdi?vdi=%s&format=vhd' --user=root --password=%s"
             % (vhd, h.getIP(), vdiuuid, h.password))
         xenrt.rootops.sudo("mv %s.part %s" % (vhd, vhd))
         xenrt.rootops.sudo("mv %s.part %s" % (cfg, cfg))
         g.uninstall()
示例#8
0
def createHost(id=0,
               version=None,
               pool=None,
               name=None,
               dhcp=True,
               license=True,
               diskid=0,
               diskCount=1,
               productVersion=None,
               productType=None,
               withisos=False,
               noisos=None,
               overlay=None,
               installSRType=None,
               suppackcds=None,
               addToLogCollectionList=False,
               disablefw=False,
               cpufreqgovernor=None,
               defaultlicense=True,
               ipv6=None,
               enableAllPorts=True,
               noipv4=False,
               basicNetwork=True,
               extraConfig=None,
               containerHost=None,
               vHostName=None,
               vHostCpus=2,
               vHostMemory=4096,
               vHostDiskSize=50,
               vHostSR=None,
               vNetworks=None,
               **kwargs):

    if containerHost != None:
        raise xenrt.XRTError("Nested hosts not supported for this host type")

    # noisos isn't used here, it is present in the arg list to
    # allow its use as a flag in PrepareNode in sequence.py

    machine = str("RESOURCE_HOST_%s" % (id))
    mname = xenrt.TEC().lookup(machine)
    m = xenrt.PhysicalHost(mname)

    xenrt.GEC().startLogger(m)

    (distro, arch) = xenrt.getDistroAndArch(productVersion)

    host = xenrt.lib.native.NativeLinuxHost(m, version)
    host.installLinuxVendor(distro, arch=arch)

    if cpufreqgovernor:
        output = host.execcmd(
            "head /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor || true"
        )
        xenrt.TEC().logverbose("Before changing cpufreq governor: %s" %
                               (output, ))

        # For each CPU, set the scaling_governor. This command will fail if the host does not support cpufreq scaling (e.g. BIOS power regulator is not in OS control mode)
        # TODO also make this persist across reboots
        host.execcmd(
            "for cpu in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do echo %s > $cpu; done"
            % (cpufreqgovernor, ))

        output = host.execcmd(
            "head /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor || true"
        )
        xenrt.TEC().logverbose("After changing cpufreq governor: %s" %
                               (output, ))

    xenrt.TEC().registry.hostPut(machine, host)
    xenrt.TEC().registry.hostPut(name, host)

    return host
示例#9
0
 def run(self, arglist):
     (distro, arch) = xenrt.getDistroAndArch(self.tcsku)
     host = self.getHost("RESOURCE_HOST_0")
     g = host.createBasicGuest(distro=distro, arch=arch, sr="Melio") 
     g.uninstall()
示例#10
0
文件: host.py 项目: johnmdilley/xenrt
def createHost(id=0,
               version=None,
               pool=None,
               name=None,
               dhcp=True,
               license=True,
               diskid=0,
               diskCount=1,
               productType=None,
               productVersion=None,
               withisos=False,
               noisos=None,
               overlay=None,
               installSRType=None,
               suppackcds=None,
               addToLogCollectionList=False,
               noAutoPatch=False,
               disablefw=False,
               cpufreqgovernor=None,
               defaultlicense=True,
               ipv6=None,
               noipv4=False,
               basicNetwork=True,
               extraConfig=None,
               containerHost=None,
               vHostName=None,
               vHostCpus=2,
               vHostMemory=4096,
               vHostDiskSize=50,
               vHostSR=None,
               vNetworks=None,
               **kwargs):

    if containerHost != None:
        raise xenrt.XRTError("Nested hosts not supported for this host type")

    machine = str("RESOURCE_HOST_%s" % (id))

    m = xenrt.PhysicalHost(xenrt.TEC().lookup(machine, machine))
    xenrt.GEC().startLogger(m)

    xenrt.TEC().logverbose("KVM.createHost: productType='%s' productVersion='%s' version='%s'" % (productType, productVersion, version))
    if productVersion:
        (distro, arch) = xenrt.getDistroAndArch(productVersion)
    else:
        distro = "centos64"
        arch = "x86-64"

    xenrt.TEC().logverbose("KVM.createHost: using distro '%s' (%s)" % (distro, arch))

    host = KVMHost(m, productVersion=productVersion, productType=productType)
    extrapackages = []
    extrapackages.append("libvirt")
    rhel7 = False
    if re.search(r"rhel7", distro) or re.search(r"centos7", distro) or re.search(r"oel7", distro) or re.search(r"sl7", distro):
        rhel7 = True
        extrapackages.append("ntp")
        extrapackages.append("wget")
        extrapackages.append("virt-install")
        extrapackages.append("qemu-kvm")
    else:
        extrapackages.append("python-virtinst")
        extrapackages.append("kvm")
    extrapackages.append("bridge-utils")
    host.installLinuxVendor(distro, arch=arch, extrapackages=extrapackages, options={"ossvg":True})
    host.checkVersion()

    host.execdom0("sed -i 's/\\#listen_tcp = 1/listen_tcp = 1/' /etc/libvirt/libvirtd.conf")
    host.execdom0("sed -i 's/\\#listen_tls = 0/listen_tls = 0/' /etc/libvirt/libvirtd.conf")
    host.execdom0("sed -i 's/\\#auth_tcp = \"sasl\"/auth_tcp = \"none\"/' /etc/libvirt/libvirtd.conf")
    host.execdom0("sed -i 's/\\#LIBVIRTD_ARGS=\"--listen\"/LIBVIRTD_ARGS=\"--listen\"/' /etc/sysconfig/libvirtd")
    host.execdom0("service libvirtd restart")
    try:
        host.execdom0("service firewalld stop")
    except:
        host.execdom0("service iptables stop")

    if rhel7:
        # NetworkManager doesn't support bridging and must be disabled
        host.execdom0("chkconfig NetworkManager off")
        host.execdom0("chkconfig network on")
        host.execdom0("service NetworkManager stop")

    host.virConn = host._openVirConn()

    host.execvirt("virsh net-destroy default")
    host.execvirt("virsh net-undefine default")
    host.createNetwork("cloudbr0", useDHCP=True)

    networkConfig  = "<network>"
    networkConfig += "<name>cloudbr0</name>"
    networkConfig += "<forward mode='bridge'/>"
    networkConfig += "<bridge name='cloudbr0'/>"
    networkConfig += "</network>"
    host.execvirt("virsh net-define /dev/stdin <<< \"%s\"" % (networkConfig, ))

    # Sometimes the networking changes can break our virConn, needed for the
    # SR creation step. As a quick fix lets just reestablish it and let the old
    # one be GC'd
    # TODO: Optimise the libvirt support so this is automatic
    host.virConn = host._openVirConn()

    # Create local storage with type EXT
    if installSRType != "no":
        host.execdom0("lvcreate VGXenRT -l 100%FREE --name lv_storage")
        sr = xenrt.lib.kvm.EXTStorageRepository(host, "LocalStorage")
        sr.createOn("/dev/VGXenRT/lv_storage")
        host.addSR(sr, default=True)

    # SELinux support for NFS SRs on KVM (eg. for ISO files)
    # https://bugzilla.redhat.com/show_bug.cgi?id=589922
    try:
        host.execdom0("getsebool virt_use_nfs")
        host.execdom0("setsebool virt_use_nfs on")
    except:
        # In RHEL7 these commands throw an exception if SELinux is disabled.
        pass

    if cpufreqgovernor:
        output = host.execcmd("head /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor || true")
        xenrt.TEC().logverbose("Before changing cpufreq governor: %s" % (output,))

        # For each CPU, set the scaling_governor. This command will fail if the host does not support cpufreq scaling (e.g. BIOS power regulator is not in OS control mode)
        # TODO also make this persist across reboots
        host.execcmd("for cpu in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do echo %s > $cpu; done" % (cpufreqgovernor,))

        output = host.execcmd("head /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor || true")
        xenrt.TEC().logverbose("After changing cpufreq governor: %s" % (output,))

    xenrt.TEC().registry.hostPut(machine, host)
    xenrt.TEC().registry.hostPut(name, host)

    return host
示例#11
0
文件: melio.py 项目: thomassa/xenrt
 def run(self, arglist):
     (distro, arch) = xenrt.getDistroAndArch(self.tcsku)
     host = self.getHost("RESOURCE_HOST_0")
     g = host.createBasicGuest(distro=distro, arch=arch, sr="Melio")
     g.uninstall()
示例#12
0
def createHost(id=0,
               version=None,
               pool=None,
               name=None,
               dhcp=True,
               license=True,
               diskid=0,
               diskCount=1,
               productVersion=None,
               productType=None,
               withisos=False,
               noisos=None,
               overlay=None,
               installSRType=None,
               suppackcds=None,
               addToLogCollectionList=False,
               disablefw=False,
               cpufreqgovernor=None,
               defaultlicense=True,
               ipv6=None,
               enableAllPorts=True,
               noipv4=False,
               basicNetwork=True,
               extraConfig=None,
               containerHost=None,
               vHostName=None,
               vHostCpus=2,
               vHostMemory=4096,
               vHostDiskSize=50,
               vHostSR=None,
               vNetworks=None,
               **kwargs):

    if containerHost != None:
        raise xenrt.XRTError("Nested hosts not supported for this host type")

    # noisos isn't used here, it is present in the arg list to
    # allow its use as a flag in PrepareNode in sequence.py

    machine = str("RESOURCE_HOST_%s" % (id))
    mname = xenrt.TEC().lookup(machine)
    m = xenrt.PhysicalHost(mname)

    xenrt.GEC().startLogger(m)

    (distro, arch) = xenrt.getDistroAndArch(productVersion)

    host = xenrt.lib.native.NativeLinuxHost(m, version)
    host.installLinuxVendor(distro, arch=arch)

    if cpufreqgovernor:
        output = host.execcmd("head /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor || true")
        xenrt.TEC().logverbose("Before changing cpufreq governor: %s" % (output,))

        # For each CPU, set the scaling_governor. This command will fail if the host does not support cpufreq scaling (e.g. BIOS power regulator is not in OS control mode)
        # TODO also make this persist across reboots
        host.execcmd("for cpu in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do echo %s > $cpu; done" % (cpufreqgovernor,))

        output = host.execcmd("head /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor || true")
        xenrt.TEC().logverbose("After changing cpufreq governor: %s" % (output,))

    xenrt.TEC().registry.hostPut(machine, host)
    xenrt.TEC().registry.hostPut(name, host)

    return host