X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Futil%2Fgeniclient.py;h=d591daca26221ff7db90470fb7abed941ef42532;hb=9d71cdfbd3a8bee73e19c4baedb46bf97061382d;hp=3bc00126db18310e00ac1be2840ef0a6dd78626f;hpb=9f59853888b1649c74f7acb15d8828ad6da7dba9;p=sfa.git diff --git a/sfa/util/geniclient.py b/sfa/util/geniclient.py index 3bc00126..d591daca 100644 --- a/sfa/util/geniclient.py +++ b/sfa/util/geniclient.py @@ -9,6 +9,7 @@ ### $Id$ ### $URL$ +from sfa.trust.certificate import * from sfa.trust.gid import * from sfa.trust.credential import * from sfa.util.record import * @@ -35,18 +36,20 @@ class GeniClient: # @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) # ------------------------------------------------------------------------- @@ -78,13 +81,18 @@ class GeniClient: # # @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 @@ -145,7 +153,7 @@ class GeniClient: # # # @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 @@ -153,6 +161,19 @@ class GeniClient: 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. @@ -162,7 +183,18 @@ class GeniClient: # @param hrn def remove(self, cred, type, hrn, caller_cred=None): - result = self.server.remove(cred.save_to_string(save_parents=True), type, hrn, caller_cred) + 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 ##