from xenrt.lib.opsys.rhel import *
from xenrt.lib.opsys.sles import *
from xenrt.lib.opsys.xs import *
+from xenrt.lib.opsys.coreos import *
--- /dev/null
+import xenrt
+import os.path
+import os
+import shutil
+import re
+from xenrt.lib.opsys import LinuxOS, registerOS, OSNotDetected
+from zope.interface import implements
+
+
+__all__ = ["CoreOSLinux"]
+
+
+class CoreOSLinux(LinuxOS):
+ """CoreOS Linux (cannot be installed through OS class)"""
+
+ def __init__(self, distro, parent, password=None):
+ super(CoreOSLinux, self).__init__(distro, parent, password)
+ self.distro = distro
+ self.arch = "x86-64"
+
+ @property
+ def canonicalDistroName(self):
+ return "%s_%s" % (self.distro, self.arch)
+
+ @property
+ def _maindisk(self):
+ if self.parent._osParent_hypervisorType == xenrt.HypervisorType.xen:
+ return "xvda"
+ else:
+ return "sda"
+
+ @property
+ def isoRepo(self):
+ return "linux"
+
+ @property
+ def defaultRootdisk(self):
+ return 5 * xenrt.GIGA
+
+ @property
+ def defaultMemory(self):
+ return 1024
+
+ def waitForBoot(self, timeout):
+ # We consider boot of a CoreOS guest complete once it responds to SSH
+ startTime = xenrt.util.timenow()
+ self.getIP(trafficType="SSH", timeout=timeout)
+ # Reduce the timeout by however long it took to get the IP
+ timeout -= (xenrt.util.timenow() - startTime)
+ # Now wait for an SSH response in the remaining time
+ self.waitForSSH(timeout)
+
+ @staticmethod
+ def knownDistro(distro):
+ return distro.startswith("coreos")
+
+ @staticmethod
+ def testInit(parent):
+ return CoreOSLinux("coreos", parent)
+
+ @classmethod
+ def detect(cls, parent, detectionState):
+ obj=cls("testcoreos", parent, detectionState.password)
+ if obj.execSSH("grep NAME=CoreOS /etc/os-release", retval="code") == 0:
+ return cls("coreos_x86-64", parent, obj.password)
+ else:
+ raise OSNotDetected("OS it not CoreOS")
+
+registerOS(CoreOSLinux)
from zope.interface import implements
-__all__ = ["RHELLinux", "CentOSLinux", "OELLinux"]
+__all__ = ["RHELLinux", "CentOSLinux", "OELLinux", "SciLinux"]
class RHELBasedLinux(LinuxOS):
raise OSNotDetected("OS is CentOS")
if obj.execSSH("test -e /etc/oracle-release", retval="code") == 0:
raise OSNotDetected("OS is Oracle Linux")
+ if obj.execSSH("test -e /etc/sl-release", retval="code") == 0:
+ raise OSNotDetected("OS is Scientific Linux")
distro = obj.execSSH("cat /etc/redhat-release | "
"sed 's/Red Hat Enterprise Linux Server release /rhel/' | "
"sed 's/Red Hat Enterprise Linux Client release /rheld/' | "
else:
raise OSNotDetected("Could not determine Oracle Linux version")
+class SciLinux(RHELBasedLinux):
+ implements(xenrt.interfaces.InstallMethodPV,
+ xenrt.interfaces.InstallMethodIsoWithAnswerFile)
+
+ @staticmethod
+ def knownDistro(distro):
+ return distro.startswith("sl")
+
+ @staticmethod
+ def testInit(parent):
+ return SciLinux("sl66", parent)
+
+ @property
+ def isoName(self):
+ if not SciLinux.knownDistro(self.distro):
+ return None
+ return self._defaultIsoName
+
+ @classmethod
+ def detect(cls, parent, detectionState):
+ obj=cls("testscilinux", parent, detectionState.password)
+ if obj.execSSH("test -e /etc/sl-release", retval="code") != 0:
+ raise OSNotDetected("OS is not Scientific Linux")
+ distro = obj.execSSH("cat /etc/sl-release | "
+ "sed 's/Scientific Linux release /scilinux/' | "
+ "awk '{print $1}'").strip()
+ dd = distro.split(".")
+ distro = dd[0]
+ if dd[1] != "0":
+ distro += dd[1]
+ if re.match("^scilinux(\d+)$", distro):
+ return cls("%s_%s" % (distro, obj.getArch()), parent, obj.password)
+ else:
+ raise OSNotDetected("Could not determine Scientific Linux version")
+
+
+
registerOS(RHELLinux)
registerOS(CentOSLinux)
registerOS(OELLinux)
+registerOS(SciLinux)