X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fmethods%2Fremove_peer_object.py;h=32b756ac6ea700122e5c8abc3151f9532c5f3c43;hb=3d7237fa0b5f2b4a60cb97c7fb3b6aecfd94558a;hp=ab55ed874d99b18c1c60f28d91be19b2bdbae49e;hpb=6987653677f806729ff39aefa77cc8d9ab3e2a52;p=sfa.git diff --git a/sfa/methods/remove_peer_object.py b/sfa/methods/remove_peer_object.py index ab55ed87..32b756ac 100644 --- a/sfa/methods/remove_peer_object.py +++ b/sfa/methods/remove_peer_object.py @@ -2,11 +2,10 @@ from sfa.util.faults import * from sfa.util.method import Method from sfa.util.parameter import Parameter, Mixed from sfa.trust.auth import Auth -from sfa.util.record import GeniRecord -from sfa.util.genitable import GeniTable +from sfa.util.record import SfaRecord +from sfa.util.table import SfaTable from sfa.util.debug import log from sfa.trust.credential import Credential -from sfa.util.misc import * from types import StringTypes class remove_peer_object(Method): @@ -27,28 +26,27 @@ class remove_peer_object(Method): accepts = [ Parameter(str, "Credential string"), Parameter(dict, "Record dictionary"), - Mixed(Parameter(str, "Request hash"), - Parameter(None, "Request hash not specified")) + Mixed(Parameter(str, "Human readable name of the original caller"), + Parameter(None, "Origin hrn not specified")) ] returns = Parameter(int, "1 if successful") - def call(self, cred, record, request_hash=None): + def call(self, cred, record, origin_hrn=None): user_cred = Credential(string=cred) #log the call - gid_origin_caller = user_cred.get_gid_origin_caller() - origin_hrn = gid_origin_caller.get_hrn() + if not origin_hrn: + origin_hrn = user_cred.get_gid_caller().get_hrn() self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrn, self.name)) - self.api.auth.authenticateCred(cred, [cred], request_hash) self.api.auth.check(cred, "remove") # Only allow the local interface or record owner to delete peer_records try: self.api.auth.verify_object_permission(record['hrn']) except: self.api.auth.verify_cred_is_me(cred) - table = GeniTable() + table = SfaTable() hrn, type = record['hrn'], record['type'] records = table.find({'hrn': hrn, 'type': type }) for record in records: @@ -90,14 +88,14 @@ class remove_peer_object(Method): self.api.plshell.DeleteSite(self.api.plauth, site['site_id']) else: - raise UnknownGeniType(type) + raise UnknownSfaType(type) return 1 def get_peer_name(self, peer_id): peers = self.api.plshell.GetPeers(self.api.plauth, [peer_id], ['peername', 'shortname', 'hrn_root']) if not peers: - raise GeniInvalidArgument, "No such peer" + raise SfaInvalidArgument, "No such peer" peer = peers[0] return peer['shortname']