From: Thierry Parmentelat Date: Tue, 19 Oct 2010 11:01:54 +0000 (+0300) Subject: Merge branch 'master' of ssh://git.onelab.eu/git/sfa X-Git-Tag: sfa-1.0-5~11 X-Git-Url: http://git.onelab.eu/?p=sfa.git;a=commitdiff_plain;h=ba2aaa438f939a4b5c697052e37b1c3218901319 Merge branch 'master' of ssh://git.onelab.eu/git/sfa Conflicts: sfa/managers/aggregate_manager_max.py sfa/util/xrn.py --- ba2aaa438f939a4b5c697052e37b1c3218901319 diff --cc sfa/managers/aggregate_manager_max.py index 2a46cb5a,949e241f..e586ffb9 --- a/sfa/managers/aggregate_manager_max.py +++ b/sfa/managers/aggregate_manager_max.py @@@ -3,8 -3,8 +3,9 @@@ from sfa.util.rspec import RSpec import sys import pdb -from sfa.util.namespace import hrn_to_pl_slicename, hrn_to_urn --from sfa.util.xrn import urn_to_hrn, get_authority ++from sfa.util.xrn import urn_to_hrn, hrn_to_urn, get_authority ++from sfa.util.plxrn import hrn_to_pl_slicename +from sfa.util.plxrn import hrn_to_pl_slicename from sfa.util.rspec import * from sfa.util.specdict import * from sfa.util.faults import * diff --cc sfa/util/xrn.py index eb0d39e4,c00dcef4..a503e713 --- a/sfa/util/xrn.py +++ b/sfa/util/xrn.py @@@ -53,50 -54,34 +53,54 @@@ class Xrn def urn_split (urn): return Xrn.urn_meaningful(urn).split('+') + #################### + # the local fields that are kept consistent + # self.urn + # self.hrn + # self.type + # self.path # provide either urn, or (hrn + type) def __init__ (self, xrn=None, urn=None, hrn=None, type=None): - if not xrn: - if urn: - xrn = urn - elif hrn: - xrn = hrn ++ # user has specified xrn : guess if urn or hrn + if xrn is not None: + if xrn.startswith(Xrn.URN_PREFIX): + self.urn=xrn + self.urn_to_hrn() else: - raise SfaAPIError,"Xrn.__init__" - - if xrn.startswith(Xrn.URN_PREFIX): - self.urn=xrn + self.hrn=xrn + self.type=type + self.hrn_to_urn() ++ # user has specified urn, let's use it + elif urn is not None: + self.urn=urn self.urn_to_hrn() - else: - self.hrn=xrn ++ # user has specified hrn and type + elif hrn is not None and type is not None: + self.hrn=hrn self.type=type self.hrn_to_urn() - - if not type: - sfa_logger().debug("type-less Xrn's are not safe") ++ # what should we do ? + else: + raise SfaAPIError,"Xrn.__init__" +# happens all the time .. +# if not type: +# sfa_logger().debug("type-less Xrn's are not safe") def get_urn(self): return self.urn - def get_hrn(self): return (self.hrn, self.type) + def get_hrn(self): return self.hrn + def get_type(self): return self.type + def get_hrn_type(self): return (self.hrn, self.type) - def get_leaf(self): - if not self.hrn: raise SfaAPIError, "Xrn.get_leaf" + def _normalize(self): + if self.hrn is None: raise SfaAPIError, "Xrn._normalize" if not hasattr(self,'leaf'): self.leaf=Xrn.hrn_split(self.hrn)[-1] + # self.authority keeps a list + if not hasattr(self,'authority'): + self.authority=Xrn.hrn_auth_list(self.hrn) + + def get_leaf(self): + self._normalize() return self.leaf def get_authority_hrn(self):