From: smbaker Date: Tue, 4 Oct 2011 20:05:46 +0000 (-0700) Subject: ability for sliceview to display user slices instead of authority slices X-Git-Tag: sface-0.1-20~20 X-Git-Url: http://git.onelab.eu/?p=sface.git;a=commitdiff_plain;h=37dfde8c6c59f3c33d1225d3c73cb5ec11c12306 ability for sliceview to display user slices instead of authority slices --- diff --git a/sface/config.py b/sface/config.py index c475e76..b8b1872 100644 --- a/sface/config.py +++ b/sface/config.py @@ -187,10 +187,11 @@ class Config: def getSliceRecordFile(self): return self.fullpath ("%s.record" % self.getSlice()) + def getUserRecordFile(self): return self.fullpath ("%s.record" % self.getUser()) + def getAuthorityRecordFile(self): return self.fullpath ("%s/%s.record" % self.getAuthority()) - def getAuthorityListFile(self): - return self.fullpath ("%s_list.xml" % self.getAuthority()) + def getAuthorityListFile(self): return self.fullpath ("%s_list.xml" % self.getAuthority()) # configuration singleton diff --git a/sface/sfidata.py b/sface/sfidata.py index 315fddc..fb98ac5 100644 --- a/sface/sfidata.py +++ b/sface/sfidata.py @@ -3,7 +3,7 @@ from PyQt4.QtCore import * from PyQt4.QtGui import * from lxml import etree -from sfa.util.record import SfaRecord, SliceRecord, AuthorityRecord +from sfa.util.record import SfaRecord, SliceRecord, AuthorityRecord, UserRecord from sfa.rspecs.rspec_parser import parse_rspec from sface.config import config @@ -35,6 +35,22 @@ class SfiData: return rec return None + def getUserRecord(self): + rec_file = config.getUserRecordFile() + if os.path.exists(rec_file): + xml = open(rec_file).read() + rec = UserRecord() + rec.load_from_string(xml) + return rec + return None + + def getUserSliceHrns(self): + rec = self.getUserRecord() + if rec: + return rec.get_field("slices") + + return [] + def purgeNonSliceResources(self, rspec): # This can probably go away once the new slice manager is fully # deployed. diff --git a/sface/sliceview.py b/sface/sliceview.py index 65b6572..d9850bb 100644 --- a/sface/sliceview.py +++ b/sface/sliceview.py @@ -112,14 +112,21 @@ class SliceView(QTableView): node_index = model.index(current.row(), 0, current.parent()) node_data = node_index.data().toString() +MODE_AUTHORITY_SLICES = 1 +MODE_USER_SLICES = 2 + class SliceModel(QStandardItemModel): - def __init__(self, rows=0, columns=4, parent=None): + def __init__(self, rows=0, columns=4, parent=None, mode=MODE_AUTHORITY_SLICES): QStandardItemModel.__init__(self, rows, columns, parent) + self.mode = mode def updateModel(self): self.clear() - slice_names = SfiData().getAuthorityHrns(type="slice") + if (self.mode == MODE_AUTHORITY_SLICES): + slice_names = SfiData().getAuthorityHrns(type="slice") + else: # MODE_USER_SLICES + slice_names = SfiData().getUserSliceHrns() rootItem = self.invisibleRootItem()