#
-# Geniwrapper XML-RPC and SOAP interfaces
+# SFA XML-RPC and SOAP interfaces
#
### $Id$
### $URL$
from sfa.trust.rights import *
from sfa.trust.credential import *
from sfa.trust.certificate import *
-from sfa.util.misc import *
+from sfa.util.namespace import *
from sfa.util.api import *
from sfa.util.nodemanager import NodeManager
from sfa.util.sfalogging import *
+from sfa.util.table import SfaTable
-class GeniAPI(BaseAPI):
+class SfaAPI(BaseAPI):
# flat list of method names
import sfa.methods
return '4.2'
- def getCredential(self, origin_hrn=None):
+ def getCredential(self):
if self.interface in ['registry']:
- return self.getCredentialFromLocalRegistry(origin_hrn)
+ return self.getCredentialFromLocalRegistry()
else:
- return self.getCredentialFromRegistry(origin_hrn)
+ return self.getCredentialFromRegistry()
- def getCredentialFromRegistry(self, origin_hrn=None):
+ def getCredentialFromRegistry(self):
"""
- Get our credential from a remote registry using a geniclient connection
+ Get our credential from a remote registry
"""
type = 'authority'
path = self.config.SFA_DATA_DIR
registry = registries[self.hrn]
cert_string=self.cert.save_to_string(save_parents=True)
# get self credential
- arg_list = [cert_string,type,self.hrn]
- request_hash=self.key.compute_hash(arg_list)
- self_cred = registry.get_self_credential(cert_string, type, self.hrn, request_hash)
+ self_cred = registry.get_self_credential(cert_string, type, self.hrn)
# get credential
- arg_list = [self_cred,type,self.hrn,origin_hrn]
- request_hash=self.key.compute_hash(arg_list)
- cred = registry.get_credential(self_cred, type, self.hrn, origin_hrn, request_hash)
+ cred = registry.get_credential(self_cred, type, self.hrn)
# save cred to file
Credential(string=cred).save_to_file(cred_filename, save_parents=True)
return cred
- def getCredentialFromLocalRegistry(self, origin_hrn=None):
+ def getCredentialFromLocalRegistry(self):
"""
Get our current credential directly from the local registry.
"""
if not auth_hrn or hrn == self.config.SFA_INTERFACE_HRN:
auth_hrn = hrn
auth_info = self.auth.get_auth_info(auth_hrn)
- from sfa.util.genitable import GeniTable
- table = GeniTable()
+ table = SfaTable()
records = table.findObjects(hrn)
if not records:
raise RecordNotFound
record = records[0]
type = record['type']
object_gid = record.get_gid_object()
-
- # get the origin caller's gid (this is the caller's gid by default)
- if origin_hrn:
- orgin_records = table.find({'hrn': origin_hrn})
- if not origin_records:
- raise RecordNotFound(origin_hrn)
- origin_record = origin_records[0]
- origin_caller_gid_object = GID(string = record['gid'])
- else:
- origin_caller_gid_object = object_gid
-
new_cred = Credential(subject = object_gid.get_subject())
new_cred.set_gid_caller(object_gid)
new_cred.set_gid_object(object_gid)
self.credential = self.getCredentialFromRegistry()
##
- # Convert geni fields to PLC fields for use when registering up updating
+ # Convert SFA fields to PLC fields for use when registering up updating
# registry record in the PLC database
#
# @param type type of record (user, slice, ...)
# @param hrn human readable name
- # @param geni_fields dictionary of geni fields
+ # @param sfa_fields dictionary of SFA fields
# @param pl_fields dictionary of PLC fields (output)
- def geni_fields_to_pl_fields(self, type, hrn, record):
+ def sfa_fields_to_pl_fields(self, type, hrn, record):
def convert_ints(tmpdict, int_fields):
for field in int_fields:
elif type == "node":
if not "hostname" in pl_record:
if not "hostname" in record:
- raise MissingGeniInfo("hostname")
+ raise MissingSfaInfo("hostname")
pl_record["hostname"] = record["hostname"]
if not "model" in pl_record:
pl_record["model"] = "geni"
def fill_record_pl_info(self, record):
"""
- Fill in the planetlab specific fields of a Geni record. This
+ Fill in the planetlab specific fields of a SFA record. This
involves calling the appropriate PLC method to retrieve the
database record for the object.
elif (type == "node"):
pl_res = self.plshell.GetNodes(self.plauth, [pointer])
else:
- raise UnknownGeniType(type)
+ raise UnknownSfaType(type)
if not pl_res:
raise PlanetLabRecordDoesNotExist(record['hrn'])
- def fill_record_geni_info(self, record):
- geni_info = {}
+ def fill_record_sfa_info(self, record):
+ sfa_info = {}
type = record['type']
- from sfa.util.genitable import GeniTable
- table = GeniTable()
+ table = SfaTable()
if (type == "slice"):
person_ids = record.get("person_ids", [])
persons = table.find({'type': 'user', 'pointer': person_ids})
researchers = [person['hrn'] for person in persons]
- geni_info['researcher'] = researchers
+ sfa_info['researcher'] = researchers
elif (type == "authority"):
person_ids = record.get("person_ids", [])
if 'admin' in person['roles']:
admins.append(hrn)
- geni_info['PI'] = pis
- geni_info['operator'] = techs
- geni_info['owner'] = admins
+ sfa_info['PI'] = pis
+ sfa_info['operator'] = techs
+ sfa_info['owner'] = admins
# xxx TODO: OrganizationName
elif (type == "node"):
- geni_info['dns'] = record.get("hostname", "")
+ sfa_info['dns'] = record.get("hostname", "")
# xxx TODO: URI, LatLong, IP, DNS
elif (type == "user"):
- geni_info['email'] = record.get("email", "")
+ sfa_info['email'] = record.get("email", "")
# xxx TODO: PostalAddress, Phone
- record.update(geni_info)
+ record.update(sfa_info)
def fill_record_info(self, record):
"""
- Given a geni record, fill in the PLC specific and Geni specific
+ Given a SFA record, fill in the PLC specific and SFA specific
fields in the record.
"""
self.fill_record_pl_info(record)
- self.fill_record_geni_info(record)
+ self.fill_record_sfa_info(record)
def update_membership_list(self, oldRecord, record, listName, addFunc, delFunc):
# get a list of the HRNs tht are members of the old and new records
# build a list of the new person ids, by looking up each person to get
# their pointer
newIdList = []
- from sfa.util.genitable import GeniTable
- table = GeniTable()
+ table = SfaTable()
records = table.find({'type': 'user', 'hrn': newList})
for rec in records:
newIdList.append(rec['pointer'])