X-Git-Url: http://git.onelab.eu/?p=sface.git;a=blobdiff_plain;f=sface%2Fsfiprocess.py;h=35f0ca9d8650f7a8df42ffd12390bf6e1641e221;hp=b6c5f046676ee2c952f5bcd1ac490ff43fb65dc4;hb=d7a2606ffd441335cd25b0185cb077c6cb91e795;hpb=95ffcc9a39b6df94c6296cc42511c0140fd8a388 diff --git a/sface/sfiprocess.py b/sface/sfiprocess.py index b6c5f04..35f0ca9 100644 --- a/sface/sfiprocess.py +++ b/sface/sfiprocess.py @@ -1,11 +1,12 @@ import os +import pickle import sys import time from PyQt4.QtCore import * from sface.config import config -from sface.xmlrpcwindow import XmlrpcTracker, XmlrpcReader +from sface.xmlrpcwindow import get_tracker, XmlrpcReader def find_executable(exec_name): """find the given executable in $PATH""" @@ -29,7 +30,6 @@ class SfiProcess(QObject): self.processFinished) self.xmlrpcreader = XmlrpcReader() # this one is for parsing XMLRPC responses - self.xmlrpctracker = XmlrpcTracker() # this one is for the debug window # holds aggregate output from processStandardOutput(); used by xmlrpc # tracker. @@ -64,7 +64,15 @@ class SfiProcess(QObject): output = self.process.readAllStandardOutput() self.output = self.output + output if config.debug: - print output + try: + print output + except IOError, e: + if (e.errno == 4): + # XXX why is this happening?? + print "*** caught EINTR" + else: + raise + def processStandardError(self): print self.process.readAllStandardError() @@ -97,10 +105,17 @@ class SfiProcess(QObject): self.trace_end() self.emit(SIGNAL("finished()")) - def __getRSpec(self, mgr): + def getFaultString(self): + if self.faults == []: + return None + + return self.faults[0].get("faultString","") + " (" + self.faults[0].get("faultCode","") + ")" + + def retrieveRspec(self): slice = config.getSlice() - # Write RSpec to file for testing. - filename = os.path.expanduser("~/.sfi/" + slice + ".rspec") + mgr = config.getSlicemgr() + # Write RSpec to file + filename = config.fullpath ("%s.rspec"%slice) try: os.remove(filename) except: @@ -113,25 +128,38 @@ class SfiProcess(QObject): self.start() return filename - def getRSpecFromSM(self): - return self.__getRSpec(config.getSlicemgr()) + def retrieveResources(self): + mgr = config.getSlicemgr() + # Write RSpec to file + filename = config.getResourcesRSpecFile() + try: + os.remove(filename) + except: + pass + args = ["-u", config.getUser(), "-a", config.getAuthority(), + "-r", config.getRegistry(), "-s", mgr, "resources", + "-o", filename] + + self.__init_command(args) + self.start() + return filename -# def getRSpecFromAM(self): -# return self.__getRSpec(config.getAggmgr()) def listRecords(self, hrn, rectype=None, filename=None): args = ["-u", config.getUser(), "-a", config.getAuthority(), - "-r", config.getRegistry(), "-s", config.getSlicemgr(), "list", hrn] + "-r", config.getRegistry(), "-s", config.getSlicemgr(), "list", "-F", "xmllist", hrn] - if filename: - # we can't tell whether SFI will create one file or many, so delete - # leftovers from last time, then we'll know what we got, after we get it. - if os.path.exists(filename): - os.remove(filename) - if os.path.exists(filename + ".1"): - os.remove(filename + ".1") - args.append("-o") - args.append(filename) + if not filename: + filename = config.getAuthorityListFile() + + # we can't tell whether SFI will create one file or many, so delete + # leftovers from last time, then we'll know what we got, after we get it. + if os.path.exists(filename): + os.remove(filename) + if os.path.exists(filename + ".1"): + os.remove(filename + ".1") + args.append("-o") + args.append(filename) if rectype: args.append("-t") @@ -155,15 +183,41 @@ class SfiProcess(QObject): def getAuthorityRecord(self): self.getRecord(config.getAuthority(), config.getAuthorityRecordFile()) - def applyRSpec(self, rspec): - filename = config.getSliceRSpecFile() + "_new" - rspec.save(filename) + def applyRSpec(self, rspec, aggAddr=None, aggPort=None, saveObtained=True): + # that's what we pass, like in what we'd like to get + requested = config.getSliceRSpecFile() + "_new" + # that's what we actually receive + # just overwrite the slice file as if we'd used 'resources' + obtained = config.getSliceRSpecFile() + rspec.save(requested) args = ["-u", config.getUser(), "-a", config.getAuthority(), - "-r", config.getRegistry(), "-s", config.getSlicemgr(), "create", - config.getSlice(), filename] + "-r", config.getRegistry(), "-s", config.getSlicemgr(), "create"] + + if saveObtained: + args = args + ["-o", obtained] + + if aggAddr: + args = args + ["-a", aggAddr, "-p", str(aggPort)] + + args = args + [config.getSlice(), requested] + + self.__init_command(args) + self.start() + + def deleteSlivers(self, slice=None, aggAddr=None, aggPort=None): + if not slice: + slice = config.getSlice() + + args = ["-u", config.getUser(), "-a", config.getAuthority(), + "-r", config.getRegistry(), "-s", config.getSlicemgr(), "delete"] + + if aggAddr: + args = args + ["-a", aggAddr, "-p", str(aggPort)] + + args = args + [slice] + self.__init_command(args) self.start() - return filename def updateRecord(self, filename): args = ["-u", config.getUser(), "-a", config.getAuthority(), @@ -177,10 +231,42 @@ class SfiProcess(QObject): self.__init_command(args) self.start() - def renewSlivers(self, expiration): + def removeRecord(self, hrn): + args = ["-u", config.getUser(), "-a", config.getAuthority(), + "-r", config.getRegistry(), "-s", config.getSlicemgr(), "remove", hrn] + self.__init_command(args) + self.start() + + def renewSlivers(self, expiration, slice=None): + if not slice: + slice = config.getSlice() + args = ["-u", config.getUser(), "-a", config.getAuthority(), "-r", config.getRegistry(), "-s", config.getSlicemgr(), "renew", - config.getSlice(), expiration] + slice, expiration] + self.__init_command(args) + self.start() + + def sliverStatus(self, slice=None, filename=None): + if not slice: + slice = config.getSlice() + + if not filename: + filename = config.fullpath(slice+".sliverstatus") + + args = ["-u", config.getUser(), "-a", config.getAuthority(), + "-r", config.getRegistry(), "-s", config.getSlicemgr(), "status", + "-o", filename, "-F", "pickled", slice] + self.__init_command(args) + self.start() + + def getSliceMgrVersion(self, filename=None): + if not filename: + filename = config.fullpath("slicemgr.version") + + args = ["-u", config.getUser(), "-a", config.getAuthority(), + "-r", config.getRegistry(), "-s", config.getSlicemgr(), "version", + "-o", filename, "-F", "pickled",] self.__init_command(args) self.start() @@ -206,5 +292,5 @@ class SfiProcess(QObject): # command = "%s %s" % (self.exe, self.args.join(" ")) print time.strftime('%H:%M:%S'),"Done [%.3f s]"%(time.time()-self._trace) if config.debug: - self.xmlrpctracker.getAndPrint(self.output) + get_tracker().getAndPrint(self.output)