from sfa.plc.sfaImport import sfaImport
def process_options():
- global hrn
(options, args) = getopt.getopt(sys.argv[1:], '', [])
for opt in options:
if config.SFA_API_DEBUG: sfaImporter.logger.setLevel(logging.DEBUG)
shell = sfaImporter.shell
plc_auth = sfaImporter.plc_auth
- AuthHierarchy = sfaImporter.AuthHierarchy
- TrustedRoots = sfaImporter.TrustedRoots
table = SfaTable()
if not table.exists():
sfaImporter.create_top_level_auth_records(interface_hrn)
sfaImporter.logger.info("Import: adding " + interface_hrn + " to trusted list")
- authority = AuthHierarchy.get_auth_info(interface_hrn)
- TrustedRoots.add_gid(authority.get_gid_object())
+ authority = sfaImporter.AuthHierarchy.get_auth_info(interface_hrn)
+ sfaImporter.TrustedRoots.add_gid(authority.get_gid_object())
if ".vini" in interface_hrn and interface_hrn.endswith('vini'):
# create a fake internet2 site first
def create_top_level_auth_records(self, hrn):
- AuthHierarchy = self.AuthHierarchy
urn = hrn_to_urn(hrn, 'authority')
# make sure parent exists
parent_hrn = get_authority(hrn)
self.create_top_level_auth_records(parent_hrn)
# create the authority if it doesnt already exist
- if not AuthHierarchy.auth_exists(urn):
+ if not self.AuthHierarchy.auth_exists(urn):
self.logger.info("Import: creating top level authorites")
- AuthHierarchy.create_auth(urn)
+ self.AuthHierarchy.create_auth(urn)
# create the db record if it doesnt already exist
- auth_info = AuthHierarchy.get_auth_info(hrn)
+ auth_info = self.AuthHierarchy.get_auth_info(hrn)
table = SfaTable()
auth_record = table.find({'type': 'authority', 'hrn': hrn})
def import_person(self, parent_hrn, person):
- AuthHierarchy = self.AuthHierarchy
hrn = email_to_hrn(parent_hrn, person['email'])
# ASN.1 will have problems with hrn's longer than 64 characters
# create the gid
urn = hrn_to_urn(hrn, 'user')
- person_gid = AuthHierarchy.create_gid(urn, create_uuid(), pkey)
+ person_gid = self.AuthHierarchy.create_gid(urn, create_uuid(), pkey)
table = SfaTable()
person_record = SfaRecord(hrn=hrn, gid=person_gid, type="user", pointer=person['person_id'])
person_record['authority'] = get_authority(person_record['hrn'])
table.update(person_record)
def import_slice(self, parent_hrn, slice):
- AuthHierarchy = self.AuthHierarchy
slicename = slice['name'].split("_",1)[-1]
slicename = _cleanup_string(slicename)
pkey = Keypair(create=True)
urn = hrn_to_urn(hrn, 'slice')
- slice_gid = AuthHierarchy.create_gid(urn, create_uuid(), pkey)
+ slice_gid = self.AuthHierarchy.create_gid(urn, create_uuid(), pkey)
slice_record = SfaRecord(hrn=hrn, gid=slice_gid, type="slice", pointer=slice['slice_id'])
slice_record['authority'] = get_authority(slice_record['hrn'])
table = SfaTable()
table.update(slice_record)
def import_node(self, parent_hrn, node):
- AuthHierarchy = self.AuthHierarchy
nodename = node['hostname'].split(".")[0]
nodename = _cleanup_string(nodename)
node_record = table.find({'type': 'node', 'hrn': hrn})
pkey = Keypair(create=True)
urn = hrn_to_urn(hrn, 'node')
- node_gid = AuthHierarchy.create_gid(urn, create_uuid(), pkey)
+ node_gid = self.AuthHierarchy.create_gid(urn, create_uuid(), pkey)
node_record = SfaRecord(hrn=hrn, gid=node_gid, type="node", pointer=node['node_id'])
node_record['authority'] = get_authority(node_record['hrn'])
existing_records = table.find({'hrn': hrn, 'type': 'node', 'pointer': node['node_id']})
def import_site(self, parent_hrn, site):
- AuthHierarchy = self.AuthHierarchy
shell = self.shell
plc_auth = self.plc_auth
sitename = site['login_base']
self.logger.info("Import: importing site " + hrn)
# create the authority
- if not AuthHierarchy.auth_exists(urn):
- AuthHierarchy.create_auth(urn)
+ if not self.AuthHierarchy.auth_exists(urn):
+ self.AuthHierarchy.create_auth(urn)
- auth_info = AuthHierarchy.get_auth_info(urn)
+ auth_info = self.AuthHierarchy.get_auth_info(urn)
table = SfaTable()
auth_record = SfaRecord(hrn=hrn, gid=auth_info.get_gid_object(), type="authority", pointer=site['site_id'])
from ApiExceptionCodes import *
-VerboseExceptions = False
-
-def EnableVerboseExceptions(x=True):
- global VerboseExceptions
- VerboseExceptions = x
-
class ExceptionUnmarshaller(xmlrpclib.Unmarshaller):
def close(self):
try:
if "\nFAULT_TRACEBACK:" in e.faultString:
parts = e.faultString.split("\nFAULT_TRACEBACK:")
e.faultString = parts[0]
- if VerboseExceptions:
+ if BaseClient.VerboseExceptions:
print "\n|Server Traceback:", "\n|".join(parts[1].split("\n"))
raise e
return parser, unmarshaller
class BaseClient():
+
+ VerboseExceptions = False
+
def __init__(self, url):
self.url = url
self.server = xmlrpclib.ServerProxy(self.url, ExceptionReportingTransport())
def noop(self, value):
return self.server.noop(value)
+
+ @staticmethod
+ def EnableVerboseExceptions(x=True):
+ BaseClient.VerboseExceptions = x
+
##
# TCP ports for the three servers
-registry_port=12345
-aggregate_port=12346
-slicemgr_port=12347
+#registry_port=12345
+#aggregate_port=12346
+#slicemgr_port=12347
+### xxx todo not in the config yet
component_port=12346
import os, os.path
import sys
aggregates.sync_interfaces()
def main():
- # xxx get rid of globals - name consistently CamelCase or under_score
- global AuthHierarchy
- global TrustedRoots
- global registry_port
- global aggregate_port
- global slicemgr_port
-
# Generate command line parser
parser = OptionParser(usage="sfa-server [options]")
parser.add_option("-r", "--registry", dest="registry", action="store_true",
# start registry server
if (options.registry):
from sfa.server.registry import Registry
- r = Registry("", registry_port, server_key_file, server_cert_file)
+ r = Registry("", config.SFA_REGISTRY_PORT, server_key_file, server_cert_file)
r.start()
# start aggregate manager
if (options.am):
from sfa.server.aggregate import Aggregate
- a = Aggregate("", aggregate_port, server_key_file, server_cert_file)
+ a = Aggregate("", config.SFA_AGGREGATE_PORT, server_key_file, server_cert_file)
a.start()
# start slice manager
if (options.sm):
from sfa.server.slicemgr import SliceMgr
- s = SliceMgr("", slicemgr_port, server_key_file, server_cert_file)
+ s = SliceMgr("", config.SFA_SM_PORT, server_key_file, server_cert_file)
s.start()
if (options.cm):
from sfa.server.component import Component
- c = Component("", component_port, server_key_file, server_cert_file)
+ c = Component("", config.component_port, server_key_file, server_cert_file)
+# c = Component("", config.SFA_COMPONENT_PORT, server_key_file, server_cert_file)
c.start()
if __name__ == "__main__":