git://git.onelab.eu
/
sfa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
minor bug-fix
[sfa.git]
/
sfa
/
methods
/
remove_peer_object.py
diff --git
a/sfa/methods/remove_peer_object.py
b/sfa/methods/remove_peer_object.py
index
67fa56a
..
ed46ea7
100644
(file)
--- 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.method import Method
from sfa.util.parameter import Parameter, Mixed
from sfa.trust.auth import Auth
-from sfa.util.record import
Geni
Record
-from sfa.util.
genitable import Geni
Table
+from sfa.util.record import
Sfa
Record
+from sfa.util.
table import Sfa
Table
from sfa.util.debug import log
from sfa.trust.credential import Credential
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):
from types import StringTypes
class remove_peer_object(Method):
@@
-26,29
+25,34
@@
class remove_peer_object(Method):
accepts = [
Parameter(str, "Credential string"),
accepts = [
Parameter(str, "Credential string"),
- Parameter(dict, "Record dictionary")
+ Parameter(dict, "Record dictionary"),
+ Mixed(Parameter(str, "Human readable name of the original caller"),
+ Parameter(None, "Origin hrn not specified"))
]
returns = Parameter(int, "1 if successful")
]
returns = Parameter(int, "1 if successful")
- def call(self, cred, record,
caller_cred
=None):
- if caller_cred==None:
- caller_cred=cred
+ def call(self, cred, record,
origin_hrn
=None):
+ user_cred = Credential(string=cred)
+
#log the call
#log the call
- self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, Credential(string=caller_cred).get_gid_caller().get_hrn(), hrn, self.name))
-
+ 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, record['hrn'], self.name))
+
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)
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 =
Geni
Table()
- hrn, type
, peer_auth
= record['hrn'], record['type']
+ table =
Sfa
Table()
+ hrn, type = record['hrn'], record['type']
records = table.find({'hrn': hrn, 'type': type })
for record in records:
records = table.find({'hrn': hrn, 'type': type })
for record in records:
- self.remove_plc_record(record)
- table.remove(record)
+ if record['peer_authority']:
+ self.remove_plc_record(record)
+ table.remove(record)
return 1
return 1
@@
-66,12
+70,12
@@
class remove_peer_object(Method):
elif type == "slice":
slices=self.api.plshell.GetSlices(self.api.plauth, {'slice_id' : record['pointer']})
elif type == "slice":
slices=self.api.plshell.GetSlices(self.api.plauth, {'slice_id' : record['pointer']})
-
if not slices:
+ if not slices:
return 1
return 1
-
slice=slices[0]
+ slice=slices[0]
if slice['peer_id']:
peer = self.get_peer_name(slice['peer_id'])
if slice['peer_id']:
peer = self.get_peer_name(slice['peer_id'])
-
self.api.plshell.UnBindObjectFromPeer(self.api.plauth, 'slice', slice['slice_id'], peer)
+ self.api.plshell.UnBindObjectFromPeer(self.api.plauth, 'slice', slice['slice_id'], peer)
self.api.plshell.DeleteSlice(self.api.plauth, slice['slice_id'])
elif type == "authority":
sites=self.api.plshell.GetSites(self.api.plauth, {'site_id' : record['pointer']})
self.api.plshell.DeleteSlice(self.api.plauth, slice['slice_id'])
elif type == "authority":
sites=self.api.plshell.GetSites(self.api.plauth, {'site_id' : record['pointer']})
@@
-84,16
+88,16
@@
class remove_peer_object(Method):
self.api.plshell.DeleteSite(self.api.plauth, site['site_id'])
else:
self.api.plshell.DeleteSite(self.api.plauth, site['site_id'])
else:
- raise Unknown
Geni
Type(type)
+ raise Unknown
Sfa
Type(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:
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
Geni
InvalidArgument, "No such peer"
+ raise
Sfa
InvalidArgument, "No such peer"
peer = peers[0]
peer = peers[0]
- return peer['
peer
name']
+ return peer['
short
name']