from sfa.trust.credential import *
from sfa.util.misc import *
+from sfa.util.sfalogging import *
+
# See "2.2 Characters" in the XML specification:
#
# #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD]
self.plshell_version = self.getPLCShellVersion()
self.hrn = self.config.SFA_INTERFACE_HRN
self.time_format = "%Y-%m-%d %H:%M:%S"
-
+ self.logger=get_sfa_logger()
def getPLCShell(self):
self.plauth = {'Username': self.config.SFA_PLC_USER,
"""
Handle an XML-RPC or SOAP request from the specified source.
"""
-
# Parse request into method name and arguments
try:
interface = xmlrpclib
data = buildSOAP(kw = {'%sResponse' % method: {'Result': result}}, encoding = self.encoding)
return data
+
class Nodes(SimpleStorage):
- def __init__(self, api, ttl = 1):
+ def __init__(self, api, ttl = 1, caller_cred=None):
self.api = api
self.ttl = ttl
self.threshold = None
SimpleStorage.__init__(self, self.nodes_file)
self.policy = Policy(api)
self.load()
+ self.caller_cred=caller_cred
def refresh(self):
elif self.api.interface in ['slicemgr']:
self.refresh_nodes_smgr()
-
def refresh_nodes_aggregate(self):
rspec = Rspec()
rspec.parseString(self.get_rspec())
for aggregate in aggregates:
try:
# get the rspec from the aggregate
- agg_rspec = aggregates[aggregate].get_resources(credential, hrn)
+ agg_rspec = aggregates[aggregate].get_resources(credential, hrn, caller_cred=self.caller_cred)
# extract the netspec from each aggregates rspec
rspec.parseString(agg_rspec)
networks.extend([{'NetSpec': rspec.getDictsByTagName('NetSpec')}])
class Slices(SimpleStorage):
- def __init__(self, api, ttl = .5):
+ def __init__(self, api, ttl = .5, caller_cred=None):
self.api = api
self.ttl = ttl
self.threshold = None
SimpleStorage.__init__(self, self.slices_file)
self.policy = Policy(self.api)
self.load()
+ self.caller_cred=caller_cred
def get_peer(self, hrn):
aggregates = Aggregates(self.api)
for aggregate in aggregates:
try:
- aggregates[aggregate].delete_slice(credential, hrn)
+ aggregates[aggregate].delete_slice(credential, hrn, caller_cred=self.caller_cred)
except:
print >> log, "Error calling list nodes at aggregate %s" % aggregate
traceback.print_exc(log)
try:
# send the whloe rspec to the local aggregate
if aggregate in [self.api.hrn]:
- aggregates[aggregate].create_slice(credential, hrn, rspec)
+ aggregates[aggregate].create_slice(credential, hrn, rspec, caller_cred=self.caller_cred)
else:
- aggregates[aggregate].create_slice(credential, hrn, rspecs[aggregate])
+ aggregates[aggregate].create_slice(credential, hrn, rspecs[aggregate], caller_cred=self.caller_cred)
except:
print >> log, "Error creating slice %(hrn)s at aggregate %(aggregate)s" % locals()
traceback.print_exc()
#
# @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 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
- ## list info about all known aggregates
-
def get_aggregates(self, cred, hrn=None):
- result = self.server.get_aggregates(cred.save_to_string(save_parents=True), hrn)
- return result
-
-
- ## list info about all known registries
-
- def get_registries(self, cred, hrn=None):
- result = self.server.get_registries(cred.save_to_string(save_parents=True), hrn)
+ result = self.server.get_resources(cred.save_to_string(save_parents=True), hrn)
return result
## get policy
# @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
##
--- /dev/null
+import logging
+
+#SFA access log initialization
+
+SFA_ACCESS_LOGFILE='/var/log/sfa_access.log'
+logger=logging.getLogger()
+logger.setLevel(logging.INFO)
+logfile=logging.FileHandler(SFA_ACCESS_LOGFILE)
+formatter = logging.Formatter("%(asctime)s - %(message)s")
+logfile.setFormatter(formatter)
+logger.addHandler(logfile)
+
+def get_sfa_logger():
+ return logger