]> xenbits.xensource.com Git - xenrt-citrix/xenrt.git/commitdiff
Add support for Scientific Linux and CoreOS
authorAlex Brett <alex.brett@citrix.com>
Tue, 17 Nov 2015 18:35:35 +0000 (18:35 +0000)
committerAlex Brett <alex.brett@citrix.com>
Tue, 17 Nov 2015 18:35:35 +0000 (18:35 +0000)
exec/xenrt/lib/opsys/__init__.py
exec/xenrt/lib/opsys/coreos.py [new file with mode: 0644]
exec/xenrt/lib/opsys/rhel.py

index 9669730f257eb39dae5b909a5621d074ae8f0687..2156f04ce571690bf06b74a682b394bcd8d67d3b 100644 (file)
@@ -192,3 +192,4 @@ from xenrt.lib.opsys.windowspackages import *
 from xenrt.lib.opsys.rhel import *
 from xenrt.lib.opsys.sles import *
 from xenrt.lib.opsys.xs import *
+from xenrt.lib.opsys.coreos import *
diff --git a/exec/xenrt/lib/opsys/coreos.py b/exec/xenrt/lib/opsys/coreos.py
new file mode 100644 (file)
index 0000000..3531f11
--- /dev/null
@@ -0,0 +1,69 @@
+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)
index e5235a2d29ae89053563c45dc81f7cee9ee824cb..d341ce1e857bacfb2d0e7380d22e18a4965fb6b4 100644 (file)
@@ -8,7 +8,7 @@ from xenrt.linuxanswerfiles import RHELKickStartFile
 from zope.interface import implements
 
 
-__all__ = ["RHELLinux", "CentOSLinux", "OELLinux"]
+__all__ = ["RHELLinux", "CentOSLinux", "OELLinux", "SciLinux"]
 
 
 class RHELBasedLinux(LinuxOS):
@@ -203,6 +203,8 @@ class RHELLinux(RHELBasedLinux):
             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/' | "
@@ -293,6 +295,44 @@ class OELLinux(RHELBasedLinux):
         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)