from sfa.util.table import SfaTable
from sfa.util.record import SfaRecord
from sfa.trust.gid import GID
-from sfa.util.namespace import hrn_to_pl_login_base
from sfa.util.xrn import Xrn, get_leaf, get_authority, hrn_to_urn, urn_to_hrn
+from sfa.util.plxrn import hrn_to_pl_login_base
from sfa.trust.credential import Credential
from sfa.trust.certificate import Certificate, Keypair
from sfa.trust.gid import create_uuid
+from sfa.util.version import version_core
+# Thierry - turning this off, it's a slice interface not a registry one ?!?
+#from sfa.managers.aggregate_manager_pl import SliverStatus
-def get_version(api):
- version = {}
- version['geni_api'] = 1
- version['sfa'] = 1
- return version
+# The GENI GetVersion call
+def GetVersion(api):
+ peers =dict ([ (peername,v._ServerProxy__host) for (peername,v) in api.registries.iteritems()
+ if peername != api.hrn])
+ xrn=Xrn(api.hrn)
+ return version_core({'interface':'registry',
+ 'hrn':xrn.get_hrn(),
+ 'urn':xrn.get_urn(),
+ 'peers':peers})
def get_credential(api, xrn, type, is_self=False):
# convert xrn to hrn
return new_cred.save_to_string(save_parents=True)
-# The GENI GetVersion call
-def GetVersion():
- version = {}
- version['geni_api'] = 1
- return version
-
def resolve(api, xrns, type=None, full=True):
- # load all know registry names into a prefix tree and attempt to find
+ # load all known registry names into a prefix tree and attempt to find
# the longest matching prefix
if not isinstance(xrns, types.ListType):
+ if not type:
+ type = Xrn(xrns).get_type()
xrns = [xrns]
hrns = [urn_to_hrn(xrn)[0] for xrn in xrns]
- # create a dict whre key is an registry hrn and its value is a
+ # create a dict where key is a registry hrn and its value is a
# hrns at that registry (determined by the known prefix tree).
xrn_dict = {}
registries = api.registries
records = []
if registry_hrn != api.hrn:
credential = api.getCredential()
- record_list = registries[registry_hrn].list(credential, xrn, origin_hrn)
+ record_list = registries[registry_hrn].List(xrn, credential)
records = [SfaRecord(dict=record).as_dict() for record in record_list]
# if we still have not found the record yet, try the local registry
return 1
-# being PL specific it sounds right to expect a hrn+type (not a xrn)
-def remove(api, hrn, type, origin_hrn=None):
-# # convert xrn to hrn
-# if type:
-# hrn = urn_to_hrn(xrn)[0]
-# else:
-# hrn, type = urn_to_hrn(xrn)
+# expecting an Xrn instance
+def remove(api, xrn, origin_hrn=None):
table = SfaTable()
- filter = {'hrn': hrn}
+ filter = {'hrn': xrn.get_hrn()}
+ hrn=xrn.get_hrn()
+ type=xrn.get_type()
if type and type not in ['all', '*']:
filter['type'] = type
+
records = table.find(filter)
- if not records:
- raise RecordNotFound(hrn)
+ if not records: raise RecordNotFound(hrn)
record = records[0]
type = record['type']