Beispiel #1
0
    def tailorForCloudStack(self, isCCP, isLXC=False, isBasic=False):
        """Tailor this host for use with ACS/CCP"""

        # Check that we haven't already tailored the host
        if self.execdom0("ls /var/lib/xenrt/cloudTailored", retval="code") == 0:
            return

        if isBasic:
            self.execdom0("echo 1 > /proc/sys/net/bridge/bridge-nf-call-iptables")
            self.execdom0("echo 1 > /proc/sys/net/bridge/bridge-nf-call-arptables")
            self.execdom0("sed -i '/net.bridge.bridge-nf-call-iptables/d' /etc/sysctl.conf")
            self.execdom0("sed -i '/net.bridge.bridge-nf-call-arptables/d' /etc/sysctl.conf")
            self.execdom0("echo 'net.bridge.bridge-nf-call-iptables = 1' >> /etc/sysctl.conf")
            self.execdom0("echo 'net.bridge.bridge-nf-call-arptables = 1' >> /etc/sysctl.conf")

        # Common operations
        # hostname --fqdn must give a response
        self.execdom0("echo '%s %s.%s %s' >> /etc/hosts" %
                      (self.getIP(),
                       self.getName(),
                       self.lookup("DNS_DOMAIN", "xenrt"),
                       self.getName()))

        # Start NTP
        self.execdom0("service ntpd start")
        self.execdom0("chkconfig ntpd on")

        self.addExtraLogFile("/var/log/cloudstack")

        if isCCP:
            # Citrix CloudPlatform specific operations

            self.execdom0("yum erase -y qemu-kvm")
            # Install CloudPlatform packages
            cloudInputDir = xenrt.getCCPInputs(self.distro)
            if not cloudInputDir:
                raise xenrt.XRTError("No CLOUDINPUTDIR specified")
            xenrt.TEC().logverbose("Downloading %s" % cloudInputDir)
            ccpTar = xenrt.TEC().getFile(cloudInputDir)
            xenrt.TEC().logverbose("Got %s" % ccpTar)
            webdir = xenrt.WebDirectory()
            webdir.copyIn(ccpTar)
            ccpUrl = webdir.getURL(os.path.basename(ccpTar))
            self.execdom0('wget %s -O /tmp/cp.tar.gz' % (ccpUrl))
            webdir.remove()
            self.installJSVC()
            self.execdom0("cd /tmp && mkdir cloudplatform && tar -xvzf cp.tar.gz -C /tmp/cloudplatform")
            installDir = os.path.dirname(self.execdom0('find /tmp/cloudplatform/ -type f -name install.sh'))
            result = self.execdom0("cd %s && ./install.sh -a" % (installDir))
            # CS-20675 - install.sh can exit with 0 even if the install fails!
            if "You could try using --skip-broken to work around the problem" in result:
                raise xenrt.XRTError("Dependency failure installing CloudPlatform")

            # NFS services
            self.execdom0("service rpcbind start")
            self.execdom0("service nfs start")
            self.execdom0("chkconfig rpcbind on")
            try:
                self.execdom0("chkconfig nfs on")
            except:
                self.execdom0("systemctl enable nfs-server.service") # RHEL7
        else:
            # Apache CloudStack specific operations

            # Install cloudstack-agent
            self.installJSVC()
            self.execdom0("yum install -y ipset jna")
            artifactDir = xenrt.lib.cloud.getACSArtifacts(self, ["cloudstack-common-", "cloudstack-agent-"])
            self.execdom0("rpm -ivh %s/cloudstack-*.rpm" % artifactDir)

            # Modify /etc/libvirt/qemu.conf
            self.execdom0("sed -i 's/\\# vnc_listen = \"0.0.0.0\"/vnc_listen = \"0.0.0.0\"/' /etc/libvirt/qemu.conf")
            self.execdom0("service libvirtd restart")

            # Ensure SELinux is in permissive mode
            self.execdom0("sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config")
            self.execdom0("/usr/sbin/setenforce permissive")

        if (re.search(r"rhel7", self.distro) or re.search(r"centos7", self.distro) or re.search(r"oel7", self.distro) or re.search(r"sl7", self.distro)) \
            and xenrt.TEC().lookup("WORKAROUND_CS21359", False, boolean=True):
            self.execdom0("yum install -y libcgroup-tools") # CS-21359
            self.execdom0("echo kvmclock.disable=true >> /etc/cloudstack/agent/agent.properties") # CLOUDSTACK-7472

            self.execdom0("umount /sys/fs/cgroup/cpu,cpuacct /sys/fs/cgroup/cpuset /sys/fs/cgroup/memory /sys/fs/cgroup/devices /sys/fs/cgroup/freezer /sys/fs/cgroup/net_cls /sys/fs/cgroup/blkio")
            self.execdom0("rm -f /sys/fs/cgroup/cpu /sys/fs/cgroup/cpuacct")
            self.execdom0("""cat >> /etc/cgconfig.conf <<EOF
mount {
           cpuset = /sys/fs/cgroup/cpuset;
           cpu = /sys/fs/cgroup/cpu;
           cpuacct = /sys/fs/cgroup/cpuacct;
           memory = /sys/fs/cgroup/memory;
           devices = /sys/fs/cgroup/devices;
           freezer = /sys/fs/cgroup/freezer;
           net_cls = /sys/fs/cgroup/net_cls;
           blkio = /sys/fs/cgroup/blkio;
}
EOF
""")
            self.execdom0("service cgconfig stop")
            self.execdom0("service cgconfig start")

        try:
            # Set up /etc/cloudstack/agent/agent.properties
            self.execdom0("echo 'public.network.device=cloudbr0' >> /etc/cloudstack/agent/agent.properties")
            self.execdom0("echo 'private.network.device=cloudbr0' >> /etc/cloudstack/agent/agent.properties")
        except:
            self.execdom0("echo 'public.network.device=cloudbr0' >> /etc/cloud/agent/agent.properties")
            self.execdom0("echo 'private.network.device=cloudbr0' >> /etc/cloud/agent/agent.properties")

        # Log the commit
        commit = None
        try:
            commit = self.execdom0("cloudstack-sccs").strip()
            xenrt.TEC().logverbose("ACS/CCP agent was built from commit %s" % commit)
        except:
            xenrt.TEC().warning("Error when trying to identify agent version")
        if commit:
            expectedCommit = xenrt.getCCPCommit(self.distro)
            if expectedCommit and commit != expectedCommit:
                raise xenrt.XRTError("ACS/CCP agent commit %s does not match expected commit %s" % (commit, expectedCommit))

        # Ensure NFS mounts use v3 by default
        self.execdom0("echo 'Defaultvers=3' >> /etc/nfsmount.conf") 

        # Write the stamp file to record this has already been done
        self.execdom0("mkdir -p /var/lib/xenrt")
        self.execdom0("touch /var/lib/xenrt/cloudTailored")
Beispiel #2
0
 def getCCPInputs(self):
     return xenrt.getCCPInputs(self.primaryManagementServer.distro)
Beispiel #3
0
 def getCCPInputs(self):
     return xenrt.getCCPInputs(self.primaryManagementServer.distro)