def run(self, arglist=[]): guestname = xenrt.TEC().lookup("RESOURCE_HOST_0") container = xenrt.TEC().lookupHost(guestname, "CONTAINER_HOST") machine = xenrt.PhysicalHost(container) place = xenrt.GenericHost(machine) place.findPassword() place.checkVersion() host = xenrt.lib.xenserver.hostFactory(place.productVersion)( machine, productVersion=place.productVersion) place.populateSubclass(host) host.existing(doguests=False) guest = host.guestFactory()(guestname) guest.existing(host) guest.reservedIP = xenrt.TEC().lookupHost(guestname, "HOST_ADDRESS") guest.shutdown() snapUUID = host.minimalList( "snapshot-list", "uuid", "snapshot-of=%s name-label=clean" % guest.uuid)[0] guest.revert(snapUUID) guest.start() guest.xmlrpcUnpackTarball( "%s/sigcheck.tgz" % (xenrt.TEC().lookup("TEST_TARBALL_BASE")), "c:\\") guest.xmlrpcExec("echo %s > c:\\winversion.txt" % guest.distro) guest.installCarbonWindowsGUI(forceFromCD=True)
def netPortControl(machinename, ethid, enable): machine = xenrt.PhysicalHost(machinename, ipaddr="0.0.0.0") h = xenrt.GenericHost(machine) if enable: h._controlNetPort(h.getNICMACAddress(ethid), "CMD_PORT_ENABLE") else: h._controlNetPort(h.getNICMACAddress(ethid), "CMD_PORT_DISABLE")
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) if not productVersion: productVersion = xenrt.TEC().lookup("HYPERV_DISTRO", "ws12r2-x64") host = HyperVHost(m, productVersion=productVersion, productType=productType) host.cloudstack = extraConfig.get("cloudstack", False) host.install() xenrt.TEC().registry.hostPut(machine, host) xenrt.TEC().registry.hostPut(name, host) if basicNetwork: host.createBasicNetwork() return host
def lookup(self, key): resource_host = "RESOURCE_HOST_0" machine = xenrt.TEC().lookup(resource_host, resource_host) m = xenrt.PhysicalHost(xenrt.TEC().lookup(machine, machine)) hosttype = self.productVersionFromInputDir(xenrt.TEC().getInputDir()) host = xenrt.lib.xenserver.hostFactory(hosttype)( m, productVersion=hosttype) return host.lookup(key, None)
def existingHost(self, hostname): machine = xenrt.PhysicalHost(hostname) place = xenrt.GenericHost(machine) place.findPassword() place.checkVersion() host = xenrt.lib.xenserver.hostFactory(place.productVersion)( machine, productVersion=place.productVersion) place.populateSubclass(host) host.findPassword() host.checkVersion() return host
def prepare(self, arglist=None): # Assume the target host is RESOURCE_HOST_1 self.targethost = self.getHost("RESOURCE_HOST_1") # Install native Linux on the P2V host mname = xenrt.TEC().lookup("RESOURCE_HOST_0") m = xenrt.PhysicalHost(mname) xenrt.GEC().startLogger(m) self.p2vhost = xenrt.lib.native.NativeLinuxHost(m) self.getLogsFrom(self.p2vhost) self.p2vhost.installLinuxVendor(self.DISTRO)
def run(self, arglist): self.host = self.getDefaultHost() if not self.host: m = xenrt.PhysicalHost(xenrt.TEC().lookup("RESOURCE_HOST_0")) self.host = xenrt.lib.xenserver.host.DundeeHost(m) self.host.findPassword() if arglist: tests = map(lambda t: t.split("/", 1), arglist) else: tests = [("Console", "Serial"), ("Power", "IPMI"), ("Power", "PDU"), ("Network", "DHCP"), ("Network", "Ports"), ("FC", "HBA")] for t in tests: self.runSubcase("test%s%s" % (t[0],t[1]), (), t[0], t[1]) self.host.waitForEnabled(1800, desc="Boot after %s/%s test" % (t[0],t[1]))
def prepare(self, arglist): self.machineName = xenrt.PhysicalHost(xenrt.TEC().lookup("RESOURCE_HOST_0")).name self.flags = {} self.updateMachine = False self.updateMachineWithAutoFlaggerTag = "" args = self.parseArgsKeyValue(arglist) if "FLAGSTOCHECK" in args: [ self.flags.update({ flag:self.ALL_FLAGS[flag] }) for flag in args["FLAGSTOCHECK"].split(",") if flag in self.ALL_FLAGS] elif "AllFLAGS" in args: self.flags.update(self.ALL_FLAGS) if "UPDATEMACHINE" in args: self.updateMachine = True if "AUTOFLAGGERTAG" in args: self.updateMachineWithAutoFlaggerTag = args["AUTOFLAGGERTAG"]
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={}, 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) if productVersion: esxVersion = productVersion xenrt.TEC().logverbose("Product version specified, using %s" % esxVersion) elif xenrt.TEC().lookup("ESXI_VERSION", None): esxVersion = xenrt.TEC().lookup("ESXI_VERSION") xenrt.TEC().logverbose("ESXI_VERSION specified, using %s" % esxVersion) else: esxVersion = "5.0.0.update01" xenrt.TEC().logverbose("No version specified, using %s" % esxVersion) host = ESXHost(m) host.esxiVersion = esxVersion host.password = xenrt.TEC().lookup("ROOT_PASSWORD") if not xenrt.TEC().lookup("EXISTING_VMWARE", False, boolean=True): host.install() if extraConfig.get("virconn", True): host.virConn = host._openVirConn() if installSRType != "no": # Add the default SR which is installed by ESX sr = xenrt.lib.esx.EXTStorageRepository(host, host.getDefaultDatastore()) sr.existing() host.addSR(sr) xenrt.TEC().registry.hostPut(machine, host) xenrt.TEC().registry.hostPut(name, host) if extraConfig.has_key("dc") and extraConfig.has_key("cluster"): host.addToVCenter(extraConfig["dc"], extraConfig["cluster"]) if cpufreqgovernor: # Roughly map the Linux cpufreqgovernor names onto ESXi policy names nameMapping = { "performance": "static", "ondemand": "dynamic", "powersave": "low", } if cpufreqgovernor in nameMapping: policy = nameMapping[cpufreqgovernor] else: policy = cpufreqgovernor cur = host.getCurrentPowerPolicy() xenrt.TEC().logverbose("Before changing cpufreq governor: %s" % (cur, )) host.setPowerPolicy(policy) cur = host.getCurrentPowerPolicy() xenrt.TEC().logverbose("After changing cpufreq governor: %s" % (cur, )) return host
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
def run(self, arglist=[]): h = self.getDefaultHost() if not h: m = xenrt.PhysicalHost(xenrt.TEC().lookup("RESOURCE_HOST_0")) h = xenrt.GenericHost(m) h.findPassword() if h.lookup("BMC_ADDRESS", None): defaultDevice = h.execdom0("ip route show | grep default | awk '{print $5}'").strip() gw = h.execdom0("ip route show | grep default | awk '{print $3}'").strip() subnet = IPy.IP(h.execdom0("ip route show | grep -v default | grep ' %s ' | awk '{print $1}'" % defaultDevice).strip()) bmcaddr = xenrt.getHostAddress(h.lookup("BMC_ADDRESS")) if not IPy.IP(bmcaddr) in subnet: raise xenrt.XRTError("BMC Address not on management network") try: h.execdom0("modprobe ipmi_devintf") h.execdom0("modprobe ipmi_msghandler") h.execdom0("modprobe ipmi_poweroff") h.execdom0("modprobe ipmi_si") h.execdom0("modprobe ipmi_watchdog") h.execdom0("ipmitool -I open lan print 1") except: try: h.execdom0("apt-get update") h.execdom0("apt-get install -y --force-yes openipmi ipmitool") except: h.execdom0("yum install -y OpenIPMI OpenIPMI-tools") h.execdom0("modprobe ipmi_devintf") h.execdom0("modprobe ipmi_msghandler") h.execdom0("modprobe ipmi_poweroff") h.execdom0("modprobe ipmi_si") h.execdom0("modprobe ipmi_watchdog") h.execdom0("ipmitool -I open lan print 1") h.execdom0("ipmitool -I open lan set 1 ipsrc static") h.execdom0("ipmitool -I open lan set 1 ipaddr %s" % bmcaddr) h.execdom0("ipmitool -I open lan set 1 netmask %s" % subnet.netmask().strNormal()) h.execdom0("ipmitool -I open lan set 1 defgw ipaddr %s" % gw) h.execdom0("ipmitool -I open lan set 1 access on") try: h.execdom0("ipmitool -I open lan set 1 user") except: xenrt.TEC().logverbose("Warning: could not enable default user for IPMI") try: h.execdom0("ipmitool -I open delloem lcd set mode userdefined %s" % h.getName()) except: xenrt.TEC().logverbose("Warning: could not set Dell LCD") try: if "Dell" in h.execdom0("dmidecode -t 1"): if h.execdom0("test -e /opt/dell/toolkit/bin/syscfg", retval="code"): if h.execdom0("apt-get", retval="code") == 0: distro = h.execdom0("""cat /etc/apt/sources.list | grep "^deb" | awk '{print $3}' | cut -d "-" -f 1 | cut -d "/" -f 1 | head -1""").strip() h.execdom0("rm -f /etc/apt/sources.list.d/linux.dell.com.sources.list") h.execdom0("""echo 'deb http://linux.dell.com/repo/community/ubuntu %s openmanage' | tee -a /etc/apt/sources.list.d/linux.dell.com.sources.list""" % distro) try: h.execdom0("gpg --keyserver hkp://pool.sks-keyservers.net:80 --recv-key 1285491434D8786F") h.execdom0("gpg -a --export 1285491434D8786F | apt-key add -") except: pass h.execdom0("apt-get update") h.execdom0("apt-get install -y --force-yes syscfg") h.execdom0("rm -f /etc/apt/sources.list.d/linux.dell.com.sources.list") h.execdom0("apt-get update") else: try: try: h.execdom0("wget -q -O - http://linux.dell.com/repo/hardware/Linux_Repository_15.07.00/bootstrap.cgi | bash") h.execdom0("yum install -y syscfg") except: h.execdom0("rm -f /etc/yum.repos.d/Citrix.repo") h.execdom0("rm -f /etc/yum.repos.d/CentOS-Base.repo") h.execdom0("wget -q -O - http://linux.dell.com/repo/hardware/Linux_Repository_15.07.00/bootstrap.cgi | bash") h.execdom0("yum install -y syscfg") except: # Older version for Creedence h.execdom0("wget -q -O - http://linux.dell.com/repo/hardware/OMSA_7.4.0/bootstrap.cgi | bash") h.execdom0("yum install -y syscfg") h.reboot() syscfg = h.execdom0("/opt/dell/toolkit/bin/syscfg") if xenrt.TEC().lookup("DELL_SERIAL_PORT_SWAP", False, boolean=True): try: h.execdom0("/opt/dell/toolkit/bin/syscfg --serialportaddrsel=alternate") except: xenrt.TEC().warning("Failed to change serial port config") elif xenrt.TEC().lookup("DELL_SERIAL_PORT_DEFAULT", False, boolean=True): try: h.execdom0("/opt/dell/toolkit/bin/syscfg --serialportaddrsel=default") except: xenrt.TEC().warning("Failed to change serial port config") if "--serialcomm" in syscfg: if h.lookup("SERIAL_CONSOLE_PORT", None) == "1": serial = "com2cr" else: serial = "com1cr" try: h.execdom0("/opt/dell/toolkit/bin/syscfg --serialcomm=%s" % serial) except: xenrt.TEC().warning("Failed to configure serial output") if "--acpower" in syscfg: try: h.execdom0("/opt/dell/toolkit/bin/syscfg --acpower=on") except: xenrt.TEC().warning("Failed to change AC power config") if "--f1f2promptonerror" in syscfg: try: h.execdom0("/opt/dell/toolkit/bin/syscfg --f1f2promptonerror=disable") except: xenrt.TEC().warning("Failed to change F1/F2 prompt config") if "--sriov" in syscfg: try: h.execdom0("/opt/dell/toolkit/bin/syscfg --sriov=enable") except: xenrt.TEC().warning("Failed to enable SRIOV") if "--inteltxt" in syscfg: try: h.execdom0("/opt/dell/toolkit/bin/syscfg --inteltxt=enable") except: xenrt.TEC().warning("Failed to enable TXT") try: h.execdom0("/opt/dell/toolkit/bin/syscfg tpm --tpmsecurity=onwithpbm") except: xenrt.TEC().warning("Failed to enable TPM security") try: h.execdom0("/opt/dell/toolkit/bin/syscfg tpm --tpmactivation=enabled") except: xenrt.TEC().warning("Failed to activate TPM") if h.lookup("ASSET_TAG", None) and "--asset" in syscfg: try: h.execdom0("/opt/dell/toolkit/bin/syscfg --asset=%s" % (h.lookup("ASSET_TAG"))) except: xenrt.TEC().warning("Failed to enable TXT") if "--virtualization" in syscfg: try: h.execdom0("/opt/dell/toolkit/bin/syscfg --virtualization=enable") except: xenrt.TEC().warning("Failed to enable TXT") if "--memtest" in syscfg: try: h.execdom0("/opt/dell/toolkit/bin/syscfg --memtest=disable") except: xenrt.TEC().warning("Failed to disable memtest") except: raise
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) if not productVersion: productVersion = xenrt.TEC().lookup("ORACLEVM_VERSION", "3.2.8") host = hostFactory(m, productVersion=productVersion, productType=productType) host.install() 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