Пример #1
0
    def createClients(self, host):
        # Run synexec on the controller to allow this to work on any hypervisor
        libsynexec.initialise_master_on_controller(self.jobid)

        # Install 'client00'
        xenrt.TEC().progress("Installing client zero")
        self.clientvms.append(self.createVM(host, "client00"))

        # Copy synexec slave binary to 'client00'
        libsynexec.initialise_slave(self.clientvms[0])

        # Install apache tools on client00
        self.clientvms[0].execguest("apt-get -y --force-yes install apache2-utils")

        # Shutdown client00 for cloning
        self.clientvms[0].shutdown()

        # Install more VMs as appropriate
        for i in range(1, self.numclients):
            xenrt.TEC().progress("Installing client VM %d" % i)

            # Clone original VM
            self.clientvms.append(self.clientvms[0].cloneVM(name="client%02d" % i))
            self.clientvms[i].start()

        # Restart client00
        self.clientvms[0].start()
Пример #2
0
    def clone(self, endpoint, endpoints):
        if endpoint not in endpoints:
            endpoints[endpoint] = [] # list of vms cloned from endpoint
            self.start_endpoint(endpoint) #required state to install iperf
            endpoint.installIperf(version="2.0.5")
            libsynexec.initialise_slave(endpoint)

        # reuse any existing clone
        for g in self.guests:
            g_name = g.getName()
            endpoint_name = endpoint.getName()
            is_clone = g_name.startswith("%s-" % (endpoint_name,))
            self.log(None, "endpoints=%s, endpoint=%s, g=%s, g_name=%s, endpoint_name=%s, is_clone=%s" % (endpoints, endpoint, g, g_name, endpoint_name, is_clone))
            if is_clone and g not in endpoints[endpoint]:
                endpoints[endpoint].append(g)

        self.log(None, "self.nr_vm_pairs=%s, endpoint=%s, endpoints=%s, self.endpoints_of(endpoint)=%s" % (self.nr_vm_pairs, endpoint, endpoints, self.endpoints_of(endpoint)))

        if endpoint.distro.startswith("rhel") or endpoint.distro.startswith("centos") or endpoint.distro.startswith("oel"):
            # When we clone this guest, we don't want it to remember its MAC address
            endpoint.execguest("sed -i /HWADDR/d /etc/sysconfig/network-scripts/ifcfg-eth0")

        # clone as needed
        if self.nr_vm_pairs > len(self.endpoints_of(endpoint)):
            self.shutdown_endpoint(endpoint) #required state for cloning
        for i in range(len(self.endpoints_of(endpoint)), self.nr_vm_pairs):
            new_name = "%s-%d" % (endpoint.getName(), i)
            cloned_endpoint = endpoint.cloneVM(new_name)
            endpoints[endpoint].append(cloned_endpoint)
            endpoint.host.addGuest(cloned_endpoint)
Пример #3
0
    def clone(self, endpoint, endpoints):
        if endpoint not in endpoints:
            endpoints[endpoint] = []  # list of vms cloned from endpoint
            self.start_endpoint(endpoint)  #required state to install iperf
            endpoint.installIperf(version="2.0.5")
            libsynexec.initialise_slave(endpoint)

        # reuse any existing clone
        for g in self.guests:
            g_name = g.getName()
            endpoint_name = endpoint.getName()
            is_clone = g_name.startswith("%s-" % (endpoint_name, ))
            self.log(
                None,
                "endpoints=%s, endpoint=%s, g=%s, g_name=%s, endpoint_name=%s, is_clone=%s"
                % (endpoints, endpoint, g, g_name, endpoint_name, is_clone))
            if is_clone and g not in endpoints[endpoint]:
                endpoints[endpoint].append(g)

        self.log(
            None,
            "self.nr_vm_pairs=%s, endpoint=%s, endpoints=%s, self.endpoints_of(endpoint)=%s"
            % (self.nr_vm_pairs, endpoint, endpoints,
               self.endpoints_of(endpoint)))

        if endpoint.distro.startswith("rhel") or endpoint.distro.startswith(
                "centos") or endpoint.distro.startswith("oel"):
            # When we clone this guest, we don't want it to remember its MAC address
            endpoint.execguest(
                "sed -i /HWADDR/d /etc/sysconfig/network-scripts/ifcfg-eth0")

        # clone as needed
        if self.nr_vm_pairs > len(self.endpoints_of(endpoint)):
            self.shutdown_endpoint(endpoint)  #required state for cloning
        for i in range(len(self.endpoints_of(endpoint)), self.nr_vm_pairs):
            new_name = "%s-%d" % (endpoint.getName(), i)
            cloned_endpoint = endpoint.cloneVM(new_name)
            endpoints[endpoint].append(cloned_endpoint)
            endpoint.host.addGuest(cloned_endpoint)
Пример #4
0
    def run(self, arglist=None):
        self.changeNrDom0vcpus(self.host, self.dom0vcpus)
        self.loadKernelModule()
        self.host.execdom0("iptables -F")

        guests = self.host.guests.values()

        if self.isNameinGuests(guests, "vm00"):
            # reuse any existing vms
            self.vm = guests
            self.rvms = len(self.vm)
            self.vbds = len(self.vm) * 2
        else:
            # Install 'vm00'
            xenrt.TEC().progress("Installing VM zero")
            self.vm.append(xenrt.lib.xenserver.guest.createVM(\
                    host=self.host,
                    guestname="vm00",
                    distro=self.distro,
                    arch=self.arch,
                    vifs=xenrt.lib.xenserver.Guest.DEFAULT,
                    disks=[ self.edisk ]))
            self.rvms += 1
            self.vbds += 2

            # Copy bins to 'vm00'
            sftp = self.vm[0].sftpClient()
            sftp.copyTo("/home/xenrtd/felipef/latency", "/root/latency")
            libsynexec.initialise_slave(self.vm[0])

            # Copy bins to dom0
            sftp = self.host.sftpClient()
            libsynexec.initialise_master_in_dom0(self.host)

            # Populate the extra disk
            if (self.writefirst == "true"):
                self.vm[0].execguest("dd if=/dev/zero of=/dev/xvdb bs=1M oflag=direct || true")

        if len(self.vm) > self.vms:
            # Shutdown unnecessary VMs
            for i in range(self.vms, len(self.vm)):
                self.backendDetach(self.vm[i]) #must detach any out-of-xapi devices before shutdown
                self.shutdown_vm(self.vm[i])

        if len(self.vm) < self.vms:
            # Shutdown VM for cloning
            self.backendDetach(self.vm[0]) #must detach any out-of-xapi devices before shutdown
            self.shutdown_vm(self.vm[0])

            # Install more VMs as appropriate
            for i in range(len(self.vm), self.vms):
                xenrt.TEC().progress("Installing VM %d" % i)

                # Copies original VM (much quicker than installing another one)
                cloned_vm = self.vm[0].copyVM(name="vm%02d" % i)
                self.vm.append(cloned_vm)
                self.host.addGuest(cloned_vm)
                self.vm[i].start()

                # Populate the extra disk
                if (self.writefirst == "true"):
                    self.vm[i].execguest("dd if=/dev/zero of=/dev/xvdb bs=1M oflag=direct || true")

                # At this point, we added one VM and plugged two more VBDs to the host
                self.rvms += 1
                self.vbds += 2

        # Make sure all VMs are running and have synexec on
        for i in range(0, self.vms):
            self.start_vm(self.vm[i])
            self.backendAttach(self.vm[i])
            libsynexec.start_slave(self.vm[i], self.jobid)

        # Change scheduler of the SRs where the VMs' VBDs are on
        for i in range(0, self.vms):
            sr_uuid = self.getSRofGuest(self.vm[i], self.userdevice)
            self.changeDiskScheduler(self.host, sr_uuid, self.scheduler)

        # Run synexec master
        libsynexec.start_master_in_dom0(self.host, self.latcmd, self.jobid, self.vms)

        # Fetch results from slaves
        for i in range (0, self.vms):
            results = libsynexec.get_slave_log(self.vm[i])
            for line in results.splitlines():
                self.log("concurrent", "%d %d" % (i, int(line)))

        # Fetch log from master
        results = libsynexec.get_master_log(self.host)
        self.log("synexec_master", "%s" % results)
Пример #5
0
    def installTemplate(self, guests):
        # Install 'vm-template'
        if not self.isNameinGuests(guests, "vm-template"):
            xenrt.TEC().progress("Installing VM template")

            postinstall = [] if self.postinstall is None else self.postinstall.split(",")

            if self.vm_image:
                disturl = xenrt.TEC().lookup("EXPORT_DISTFILES_HTTP", "")
                vmurl = "%s/performance/base/%s" % (disturl, self.vm_image)
                xenrt.TEC().logverbose("Getting vm from %s" % (vmurl))

                self.template = xenrt.productLib(host=self.host).guest.createVMFromFile(
                        host=self.host,
                        guestname=self.vm_image,
                        filename=vmurl)

                if self.vcpus_per_vm:
                    self.template.cpuset(self.vcpus_per_vm)

                if self.vm_ram:
                    self.template.memset(self.vm_ram)

                self.template.removeCD()
                self.template.start()
            else:
                self.template = xenrt.productLib(host=self.host).guest.createVM(\
                        host=self.host,
                        guestname="vm-template",
                        vcpus=self.vcpus_per_vm,
                        memory=self.vm_ram,
                        distro=self.distro,
                        arch=self.arch,
                        postinstall=postinstall,
                        vifs=self.host.guestFactory().DEFAULT)

            if self.template.windows:
                if not isinstance(self.template, xenrt.lib.esx.Guest):
                    self.template.installDrivers(extrareboot=True)

                # Use pvsoptimize to reduce background tasks and IO
                urlperf = xenrt.TEC().lookup("EXPORT_DISTFILES_HTTP", "")
                pvsexe = "TargetOSOptimizer.exe"
                pvsurl = "%s/performance/support-files/%s" % (urlperf, pvsexe)
                xenrt.TEC().logverbose("Getting pvsfile from %s" % (pvsurl))
                pvsfile = xenrt.TEC().getFile(pvsurl,pvsurl)
                cpath = "c:\\%s" % pvsexe
                self.template.xmlrpcSendFile(pvsfile, cpath)
                self.template.xmlrpcExec("%s /s" % cpath)

                if self.bench == "fio":
                    self.template.installFioWin()
                else:
                    self.template.installIOMeter()

                # Reboot once more to ensure everything is quiescent
                self.template.reboot()
            else:
                if isinstance(self.template, xenrt.lib.esx.Guest):
                    self.template.installTools()

                if self.bench == "fio":
                    self.installFioOnLinuxGuest()
                else:
                    self.template.installLatency()

                libsynexec.initialise_slave(self.template)

            if self.distro.startswith("rhel") or self.distro.startswith("centos") or self.distro.startswith("oel"):
                # When we clone this guest, we don't want it to remember its MAC address
                self.template.execguest("sed -i /HWADDR/d /etc/sysconfig/network-scripts/ifcfg-eth0")

            # Shutdown VM for cloning
            self.shutdown_vm(self.template)
        else:
            for vm in guests:
                if vm.getName() == "vm-template":
                    self.template = vm

        self.windows = self.template.windows
Пример #6
0
    def installTemplate(self, guests):
        # Install 'vm-template'
        if not self.isNameinGuests(guests, "vm-template"):
            xenrt.TEC().progress("Installing VM template")

            postinstall = [] if self.postinstall is None else self.postinstall.split(
                ",")

            if self.vm_image:
                disturl = xenrt.TEC().lookup("EXPORT_DISTFILES_HTTP", "")
                vmurl = "%s/performance/base/%s" % (disturl, self.vm_image)
                xenrt.TEC().logverbose("Getting vm from %s" % (vmurl))

                self.template = xenrt.productLib(
                    host=self.host).guest.createVMFromFile(
                        host=self.host,
                        guestname=self.vm_image,
                        filename=vmurl)

                if self.vcpus_per_vm:
                    self.template.cpuset(self.vcpus_per_vm)

                if self.vm_ram:
                    self.template.memset(self.vm_ram)

                self.template.removeCD()
                self.template.start()
            else:
                self.template = xenrt.productLib(host=self.host).guest.createVM(\
                        host=self.host,
                        guestname="vm-template",
                        vcpus=self.vcpus_per_vm,
                        memory=self.vm_ram,
                        distro=self.distro,
                        arch=self.arch,
                        postinstall=postinstall,
                        vifs=self.host.guestFactory().DEFAULT)

            if self.template.windows:
                if not isinstance(self.template, xenrt.lib.esx.Guest):
                    self.template.installDrivers(extrareboot=True)

                # Use pvsoptimize to reduce background tasks and IO
                urlperf = xenrt.TEC().lookup("EXPORT_DISTFILES_HTTP", "")
                pvsexe = "TargetOSOptimizer.exe"
                pvsurl = "%s/performance/support-files/%s" % (urlperf, pvsexe)
                xenrt.TEC().logverbose("Getting pvsfile from %s" % (pvsurl))
                pvsfile = xenrt.TEC().getFile(pvsurl, pvsurl)
                cpath = "c:\\%s" % pvsexe
                self.template.xmlrpcSendFile(pvsfile, cpath)
                self.template.xmlrpcExec("%s /s" % cpath)

                if self.bench == "fio":
                    self.template.installFioWin()
                else:
                    self.template.installIOMeter()

                # Reboot once more to ensure everything is quiescent
                self.template.reboot()
            else:
                if isinstance(self.template, xenrt.lib.esx.Guest):
                    self.template.installTools()

                if self.bench == "fio":
                    self.installFioOnLinuxGuest()
                else:
                    self.template.installLatency()

                libsynexec.initialise_slave(self.template)

            if self.distro.startswith("rhel") or self.distro.startswith(
                    "centos") or self.distro.startswith("oel"):
                # When we clone this guest, we don't want it to remember its MAC address
                self.template.execguest(
                    "sed -i /HWADDR/d /etc/sysconfig/network-scripts/ifcfg-eth0"
                )

            # Shutdown VM for cloning
            self.shutdown_vm(self.template)
        else:
            for vm in guests:
                if vm.getName() == "vm-template":
                    self.template = vm

        self.windows = self.template.windows