def processVm(self, session, vm, snapshot): xenrt.TEC().logverbose("shutdownwatcher processing VM %s" % vm) xenrt.TEC().logverbose( "vm %s has power_state=%s and seenrunning=%s and seenshutdown=%s" % (vm, snapshot['power_state'], vm in self.seenrunning, vm in self.seenshutdown)) if snapshot['power_state'] == "Running": self.seenrunning[vm] = True self.seenshutdown[vm] = False xenrt.TEC().logverbose("vm %s is running" % vm) elif snapshot[ 'power_state'] == "Halted" and vm in self.seenrunning and not self.seenshutdown[ vm]: xenrt.TEC().logverbose( "vm %s is halted and was previously running and not previously shut down" % vm) t = libperf.formattime(libperf.timenow()) name = snapshot['name_label'] line = "%s %s" % (name, t) xenrt.TEC().logverbose("SHUTDOWN %s" % line) libperf.outputToResultsFile(self.logFile, line) self.previousShutdownTime = time.time() self.seenshutdown[vm] = True self.num_seen_shutdowns = self.num_seen_shutdowns + 1 if self.num_seen_shutdowns == self.num_expected_shutdowns: self.complete = True xenrt.TEC().logverbose( "seen %d shutdowns of %d expected, hence complete=%s" % (self.num_seen_shutdowns, self.num_expected_shutdowns, self.complete))
def run(self): xenrt.TEC().logverbose("shutdownwatcher running") n = libperf.formattime(libperf.timenow()) zero = "zero" line = "%s %s %s" % (zero, n, n) xenrt.TEC().logverbose("SHUTDOWN %s" % line) libperf.outputToResultsFile(self.logFile, line) session = self.host.getAPISession(secure=False) try: self.watchEventsOnVm(session) finally: self.host.logoutAPISession(session)
def run(self, arglist=None): self.vm = self.prepareVM() # Create a logfile for the downtimes migrateLogfile = libperf.createLogName("downtime") xenrt.TEC().comment("downtime logfile: %s" % migrateLogfile) libperf.outputToResultsFile(migrateLogfile, "# iter pingable running total-duration") for i in range(0, self.numiters): xenrt.TEC().logverbose("migration iteration %d of %d" % (i, self.numiters)) timesStr = self.timeMigrate() line = "%d %s" % (i, timesStr) libperf.outputToResultsFile(migrateLogfile, line)
def run(self, arglist=None): # Create the clones, recording how long it takes to do so self.clones = self.createMPSVMs(self.numdesktops, self.goldvm) self.configureAllVMs() # Set up log files for REQ226 bootwatcherLogfile = libperf.createLogName("bootwatcher") starterLogfile = libperf.createLogName("starter") shutdownwatcherLogfile = libperf.createLogName("shutdownwatcher") xenrt.TEC().comment("bootwatcher logfile: %s" % bootwatcherLogfile) xenrt.TEC().comment("starter logfile: %s" % starterLogfile) xenrt.TEC().comment("shutdownwatcher logfile: %s" % shutdownwatcherLogfile) # Begin to collect stats from NetApp, for REQ246,248 self.startNetAppStatGather() # Start watching for shutdowns sdw = ShutdownWatcher(self, len(self.clones), shutdownwatcherLogfile) sdw.start() xenrt.TEC().logverbose("started shutdownwatcher") # Now start the VMs, for REQ226 numthreads = len(self.normalHosts) self.timeStartVMs( numthreads, self.clones, starterLogfile, bootwatcherLogfile, awaitParam=None) # awaitParam=None -> don't use a BootWatcher # Wait for all the VMs to shut down # TODO this is broken sdw.join() xenrt.TEC().logverbose("shutdownwatcher has completed") if sdw.error: raise xenrt.XRTError("shutdownwatcher completed with error") # Now gather the final stats from the NetApp, for REQ246,248 stats = self.finishNetAppStatGather() netappLogFile = libperf.createLogName("netapp") libperf.outputToResultsFile(netappLogFile, stats)
def run(self, arglist=None): # Create the clones, recording how long it takes to do so self.clones = self.createMPSVMs(self.numdesktops, self.goldvm) self.configureAllVMs() # Set up log files for REQ226 bootwatcherLogfile = libperf.createLogName("bootwatcher") starterLogfile = libperf.createLogName("starter") xenrt.TEC().comment("bootwatcher logfile: %s" % bootwatcherLogfile) xenrt.TEC().comment("starter logfile: %s" % starterLogfile) # Begin to collect stats from NetApp, for REQ246,248 self.startNetAppStatGather() # Now start the VMs, for REQ226 numthreads = len(self.normalHosts) self.timeStartVMs(numthreads, self.clones, starterLogfile, bootwatcherLogfile) # Now gather the final stats from the NetApp, for REQ246,248 stats = self.finishNetAppStatGather() netappLogFile = libperf.createLogName("netapp") libperf.outputToResultsFile(netappLogFile, stats)
def processVm(self, session, vm, snapshot): xenrt.TEC().logverbose("shutdownwatcher processing VM %s" % vm) xenrt.TEC().logverbose("vm %s has power_state=%s and seenrunning=%s and seenshutdown=%s" % (vm, snapshot['power_state'], vm in self.seenrunning, vm in self.seenshutdown)) if snapshot['power_state'] == "Running": self.seenrunning[vm] = True self.seenshutdown[vm] = False xenrt.TEC().logverbose("vm %s is running" % vm) elif snapshot['power_state'] == "Halted" and vm in self.seenrunning and not self.seenshutdown[vm]: xenrt.TEC().logverbose("vm %s is halted and was previously running and not previously shut down" % vm) t = libperf.formattime(libperf.timenow()) name = snapshot['name_label'] line = "%s %s" % (name, t) xenrt.TEC().logverbose("SHUTDOWN %s" % line) libperf.outputToResultsFile(self.logFile, line) self.previousShutdownTime = time.time() self.seenshutdown[vm] = True self.num_seen_shutdowns = self.num_seen_shutdowns + 1 if self.num_seen_shutdowns == self.num_expected_shutdowns: self.complete = True xenrt.TEC().logverbose("seen %d shutdowns of %d expected, hence complete=%s" % (self.num_seen_shutdowns, self.num_expected_shutdowns, self.complete))
def run(self, arglist=None): # Create the clones, recording how long it takes to do so self.clones = self.createMPSVMs(self.numdesktops, self.goldvm) self.configureAllVMs() # Set up log files for REQ226 bootwatcherLogfile = libperf.createLogName("bootwatcher") starterLogfile = libperf.createLogName("starter") shutdownwatcherLogfile = libperf.createLogName("shutdownwatcher") xenrt.TEC().comment("bootwatcher logfile: %s" % bootwatcherLogfile) xenrt.TEC().comment("starter logfile: %s" % starterLogfile) xenrt.TEC().comment("shutdownwatcher logfile: %s" % shutdownwatcherLogfile) # Begin to collect stats from NetApp, for REQ246,248 self.startNetAppStatGather() # Start watching for shutdowns sdw = ShutdownWatcher(self, len(self.clones), shutdownwatcherLogfile) sdw.start() xenrt.TEC().logverbose("started shutdownwatcher") # Now start the VMs, for REQ226 numthreads = len(self.normalHosts) self.timeStartVMs(numthreads, self.clones, starterLogfile, bootwatcherLogfile, awaitParam=None) # awaitParam=None -> don't use a BootWatcher # Wait for all the VMs to shut down # TODO this is broken sdw.join() xenrt.TEC().logverbose("shutdownwatcher has completed") if sdw.error: raise xenrt.XRTError("shutdownwatcher completed with error") # Now gather the final stats from the NetApp, for REQ246,248 stats = self.finishNetAppStatGather() netappLogFile = libperf.createLogName("netapp") libperf.outputToResultsFile(netappLogFile, stats)
def run(self, arglist=None): self.xenhost = self.host.getIP() xenrt.TEC().logverbose("hostname is [%s]" % self.xenhost) # Restart the 'Citrix Pool Management service' on the DDC. This clears out any previous state about which hosts were in which pools. if self.useXenDesktop: self.restartPoolManagementService(self.ddc) # Clean up if self.startwithcleanslate: xenrt.TEC().logverbose("Deleting all existing desktop groups") self.deleteAllDesktopGroups() rundirpath = None # Register the VMs in a new desktop group with the DDC groupname = "xenrt%s" % self.randomid try: if self.useXenDesktop: xenrt.TEC().logverbose("Registering VMs with DDC in desktop group %s" % groupname) self.registerVMsWithDDC(groupname, self.clones) hostobjs = [self.tec.gec.registry.hostGet(h) for h in self.normalHosts] # Use the master for the host for the launchers launcherhostobj = hostobjs.pop(0) xenrt.TEC().logverbose("Nominated host %s as the launcher host" % launcherhostobj.getName()) numthreads = self.numhostsfordesktops # Select the relevant number of hosts for desktops hostobjsfordesktops = hostobjs[0:self.numhostsfordesktops] hostnamesfordesktops = [h.getName() for h in hostobjsfordesktops] xenrt.TEC().logverbose("Names of hosts for desktop VMs are %s" % hostnamesfordesktops) # Now spin up the VMs xenrt.TEC().logverbose("Starting VMs") bootwatcherLogfile = libperf.createLogName("bootwatcher") starterLogfile = libperf.createLogName("starter") self.timeStartVMs(numthreads, self.clones, starterLogfile, bootwatcherLogfile, queueHosts=hostnamesfordesktops, awaitParam="PV_drivers_version", awaitKey="major") # Now make some launcher VMs numlaunchers = int(math.ceil(self.numdesktops / self.vmsperlauncher)) xenrt.TEC().logverbose("VMs per launcher is %d; number of desktops is %d; hence using %d launcher VMs" % (self.vmsperlauncher, self.numdesktops, numlaunchers)) launchers = [] for i in range(0, numlaunchers): launchername = "mylauncher%d" % i xenrt.TEC().logverbose("Making launcher VM %d on host %s..." % (i, launcherhostobj.getName())) # TODO could import the first and then clone the rest? launchervmobj = self.makeLauncherVM(launchername, useICA=self.useXenDesktop, host=launcherhostobj) launchers.append(launchervmobj) # Create a 'run' directory. The returned path is valid on self.guest. rundirpath = self.createFreshResultsDir() # Now tell the launcher to start ICA sessions to the VMs. # The VMs then log in and LoginVSI kicks in. # (We assume that by this stage the VMs' VDAs have registered with the DDC.) refbasedir = self.mountRefBase(self.guest.execguest) # Begin to collect stats from NetApp, for REQ247,249 self.startNetAppStatGather() for i in range(0, self.numdesktops): launcherindex = i % numlaunchers if self.useXenDesktop: user = "******" % (i+1) xenrt.TEC().logverbose("Logging in to desktop group %s with user %s on launcher %d" % (groupname, user, launcherindex)) self.logInToVMsWfica(refbasedir, launchers[launcherindex], groupname, user, "xenroot!!1!") else: # Get the IP address of the ith desktop VM xenrt.TEC().logverbose("Finding IP of %dth desktop VM..." % i) # We need to know the host that the ith desktop VM is running on # TODO Temporary hack: assume it's the second host in self.normalHosts! h = self.normalHosts[1] xenrt.TEC().logverbose("host is [%s]" % h) vmuuid = self.clones[i].getUUID() ip = self.getVMIP(h, vmuuid) xenrt.TEC().logverbose("IP of %dth VM is %s" % (i, ip)) xenrt.TEC().logverbose("Logging in to %dth VM with on launcher %d" % (i, launcherindex)) self.logInToVMsRdesktop(refbasedir, launchers[launcherindex], ip, "Administrator", xenrt.TEC().lookup(["WINDOWS_INSTALL_ISOS", "ADMINISTRATOR_PASSWORD"])) xenrt.TEC().logverbose("Started all %d sessions!" % self.numdesktops) # Wait for the sessions to complete latestTime = time.time() + 50*60 # allow 50 mins for all sessions to complete for i in range(1, self.numdesktops+1): xenrt.TEC().logverbose("Waiting for the %dth session of %d to complete..." % (i, self.numdesktops)) self.waitForResultsToAppear(rundirpath, i, self.numreadings, latestTime) xenrt.TEC().logverbose("All %d sessions have completed (or timed out)!" % self.numdesktops) # Now gather the final stats from the NetApp, for REQ247,249 stats = self.finishNetAppStatGather() netappLogFile = libperf.createLogName("netapp") libperf.outputToResultsFile(netappLogFile, stats) xenrt.TEC().logverbose("All good.") finally: xenrt.TEC().logverbose("FINALLY") if not rundirpath is None: # Get the results. xenrt.TEC().logverbose("Copying logs from %s..." % rundirpath) self.copyRunDirToLogs(rundirpath) if self.useXenDesktop: # Clean up if self.cleanup: xenrt.TEC().logverbose("Deleting desktop group %s" % groupname) self.deleteDesktopGroup(groupname)
def log(self, filename, msg): """Logs to a file and console""" xenrt.TEC().logverbose(msg) if filename is not None: libperf.outputToResultsFile(libperf.createLogName(filename), msg)