### $Id$
### $URL$
+from sfa.trust.certificate import *
from sfa.trust.gid import *
from sfa.trust.credential import *
from sfa.util.record import *
# @param protocol The ORPC protocol to use. Can be "soap" or "xmlrpc"
def __init__(self, url, key_file, cert_file, protocol="xmlrpc"):
- self.url = url
- self.key_file = key_file
- self.cert_file = cert_file
+ self.url = url
+ self.key_file = key_file
+ self.cert_file = cert_file
+ self.key = Keypair(filename = self.key_file)
+
- if (protocol=="xmlrpc"):
- import xmlrpcprotocol
- self.server = xmlrpcprotocol.get_server(self.url, self.key_file, self.cert_file)
- elif (protocol=="soap"):
- import soapprotocol
- self.server = soapprotocol.get_server(self.url, self.key_file, self.cert_file)
- else:
- raise Exception("Attempted use of undefined protocol %s"%protocol)
+ if (protocol=="xmlrpc"):
+ import xmlrpcprotocol
+ self.server = xmlrpcprotocol.get_server(self.url, self.key_file, self.cert_file)
+ elif (protocol=="soap"):
+ import soapprotocol
+ self.server = soapprotocol.get_server(self.url, self.key_file, self.cert_file)
+ else:
+ raise Exception("Attempted use of undefined protocol %s"%protocol)
# -------------------------------------------------------------------------
#
# @return a GID object
- def get_gid(self, name):
- gid_str_list = self.server.get_gid(name)
- gid_list = []
- for str in gid_str_list:
- gid_list.append(GID(string=str))
- return gid_list
+ #def get_gid(self, name):
+ # gid_str_list = self.server.get_gid(name)
+ # gid_list = []
+ # for str in gid_str_list:
+ # gid_list.append(GID(string=str))
+ # return gid_list
+
+ def get_gid(self, cert, hrn, type, request_hash):
+ cert_string = cert.save_to_string(save_parents=True)
+ gid_str = self.server.get_gid(cert_string, hrn, type, request_hash)
+ return GID(string=gid_str)
##
# Get_self_credential a degenerate version of get_credential used by a
# client to get his initial credential when he doesn't have one. This is
#
# @return list of record objects
- def list(self, cred, auth_hrn):
- result_dict_list = self.server.list(cred.save_to_string(save_parents=True), auth_hrn)
+ def list(self, cred, auth_hrn, caller_cred=None):
+ result_dict_list = self.server.list(cred.save_to_string(save_parents=True), auth_hrn, caller_cred)
result_rec_list = []
for dict in result_dict_list:
result_rec_list.append(GeniRecord(dict=dict))
#
#
# @param cred credential object specifying rights of the caller
- # @return record to register
+ # @param record to register
#
# @return GID object for the newly-registered record
- def register(self, cred, record):
- gid_str = self.server.register(cred.save_to_string(save_parents=True), record.as_dict())
+ def register(self, cred, record, caller_cred=None):
+ gid_str = self.server.register(cred.save_to_string(save_parents=True), record.as_dict(), caller_cred)
return GID(string = gid_str)
+
+ ##
+ # Register a peer object with the registry.
+ #
+ #
+ # @param cred credential object specifying rights of the caller
+ # @param record to register
+ #
+ # @return GID object for the newly-registered record
+
+ def register_peer_object(self, cred, record, caller_cred=None):
+ return self.server.register_peer_object(cred.save_to_string(save_parents=True), record, caller_cred)
+
##
# Remove an object from the registry. If the object represents a PLC object,
# then the PLC records will also be removed.
# @param type
# @param hrn
- def remove(self, cred, type, hrn):
- result = self.server.remove(cred.save_to_string(save_parents=True), type, hrn)
+ def remove(self, cred, type, hrn, caller_cred=None):
+ return self.server.remove(cred.save_to_string(save_parents=True), type, hrn, caller_cred)
+
+ ##
+ # Remove a peer object from the registry. If the object represents a PLC object,
+ # then the PLC records will also be removed.
+ #
+ # @param cred credential object specifying rights of the caller
+ # @param type
+ # @param hrn
+
+ def remove_peer_object(self, cred, record, caller_cred=None):
+ result = self.server.remove_peer_object(cred.save_to_string(save_parents=True), record, caller_cred)
return result
##
# @param cred credential object specifying rights of the caller
# @param name human readable name of object
- def resolve(self, cred, name):
- result_dict_list = self.server.resolve(cred.save_to_string(save_parents=True), name)
+ def resolve(self, cred, name, caller_cred=None):
+ result_dict_list = self.server.resolve(cred.save_to_string(save_parents=True), name, caller_cred)
result_rec_list = []
for dict in result_dict_list:
if dict['type'] in ['authority']:
# @param cred credential object specifying rights of the caller
# @param record a record object to be updated
- def update(self, cred, record):
- result = self.server.update(cred.save_to_string(save_parents=True), record.as_dict())
+ def update(self, cred, record, caller_cred=None):
+ result = self.server.update(cred.save_to_string(save_parents=True), record.as_dict(), caller_cred)
return result
# @param cred a credential
# @param hrn slice hrn
- def get_resources(self, cred, hrn=None):
- result = self.server.get_resources(cred.save_to_string(save_parents=True), hrn)
+ def get_resources(self, cred, hrn=None, caller_cred=None):
+ result = self.server.get_resources(cred.save_to_string(save_parents=True), hrn, caller_cred)
return result
def get_aggregates(self, cred, hrn=None):
- result = self.server.get_resources(cred.save_to_string(save_parents=True), hrn)
+ result = self.server.get_aggregates(cred.save_to_string(save_parents=True), hrn)
return result
+ def get_registries(self, cred, hrn=None):
+ result = self.server.get_registries(cred.save_to_string(save_parents=True), hrn)
+ return result
+
## get policy
#
# @param cred a credential
# @param cred a credential
# @param rspec resource specification defining how to instantiate the slice
- def create_slice(self, cred, hrn, rspec):
- result = self.server.create_slice(cred.save_to_string(save_parents=True), hrn, rspec)
+ def create_slice(self, cred, hrn, rspec, caller_cred=None):
+ result = self.server.create_slice(cred.save_to_string(save_parents=True), hrn, rspec, caller_cred)
return result
#
# @param cred a credential
# @param hrn slice to delete
- def delete_slice(self, cred, hrn):
- result = self.server.delete_slice(cred.save_to_string(save_parents=True), hrn)
+ def delete_slice(self, cred, hrn, caller_cred=None):
+ result = self.server.delete_slice(cred.save_to_string(save_parents=True), hrn, caller_cred)
return result
# ------------------------------------------------------------------------
# @param cred a credential identifying the caller (callerGID) and the slice
# (objectGID)
- def delete_slice(self, cred, hrn):
- result = self.server.delete_slice(cred.save_to_string(save_parents=True), hrn)
+ def delete_slice(self, cred, hrn, caller_cred=None):
+ result = self.server.delete_slice(cred.save_to_string(save_parents=True), hrn, caller_cred)
return result
##
return result
+ def remove_remote_object(self, cred, hrn, record):
+ result = self.server.remove_remote_object(cred.save_to_string(save_parents=True), hrn, record)
+ return result