sfaImporter.AuthHierarchy.create_auth(urn)
auth_info = sfaImporter.AuthHierarchy.get_auth_info(urn)
auth_record = RegAuthority()
+ auth_record.type='authority'
auth_record.hrn=site_hrn
auth_record.gid=auth_info.get_gid_object()
auth_record.pointer=site['site_id']
sfaImporter.AuthHierarchy.create_auth(urn)
auth_info = sfaImporter.AuthHierarchy.get_auth_info(urn)
auth_record = RegAuthority()
+ auth_record.type='authority'
auth_record.hrn=site_hrn
auth_record.gid=auth_info.get_gid_object()
auth_record.pointer=site['site_id']
urn = hrn_to_urn(hrn, 'node')
node_gid = sfaImporter.AuthHierarchy.create_gid(urn, create_uuid(), pkey)
node_record = RegNode ()
+ node_record.type='node'
node_record.hrn=hrn
node_record.gid=node_gid
node_record.pointer =node['node_id']
urn = hrn_to_urn(hrn, 'slice')
slice_gid = sfaImporter.AuthHierarchy.create_gid(urn, create_uuid(), pkey)
slice_record = RegSlice ()
+ slice_record.type='slice'
slice_record.hrn=hrn
slice_record.gid=slice_gid
slice_record.pointer=slice['slice_id']
urn = hrn_to_urn(hrn, 'user')
person_gid = sfaImporter.AuthHierarchy.create_gid(urn, create_uuid(), pkey)
person_record = RegUser ()
+ person_record.type='user'
person_record.hrn=hrn
person_record.gid=person_gid
person_record.pointer=person['person_id']
from sfa.trust.hierarchy import Hierarchy
from sfa.trust.gid import create_uuid
from sfa.storage.persistentobjs import RegRecord, RegAuthority, RegUser
-from sfa.storage.persistentobjs import RegAuthoritySa, RegAuthorityAm, RegAuthoritySm
from sfa.storage.alchemy import dbsession
def _un_unicode(str):
# create the db record if it doesnt already exist
auth_info = self.AuthHierarchy.get_auth_info(hrn)
auth_record = RegAuthority()
+ auth_record.type='authority'
auth_record.hrn=hrn
auth_record.gid=auth_info.get_gid_object()
auth_record.authority=get_authority(hrn)
auth_info = self.AuthHierarchy.get_auth_info(hrn)
user_record = RegUser()
+ user_record.type='user'
user_record.hrn=hrn
user_record.gid=auth_info.get_gid_object()
user_record.authority=get_authority(hrn)
# just create certs for all sfa interfaces even if they
# aren't enabled
hrn = self.config.SFA_INTERFACE_HRN
- reg_classes_info = [ (RegAuthoritySa, 'authority+sa'),
- (RegAuthorityAm, 'authority+am'),
- (RegAuthoritySm, 'authority+sm'), ]
auth_info = self.AuthHierarchy.get_auth_info(hrn)
pkey = auth_info.get_pkey_object()
- for (reg_class, type) in reg_classes_info:
+ for type in [ 'authority+sa', 'authority+am', 'authority+sm', ]:
urn = hrn_to_urn(hrn, type)
gid = self.AuthHierarchy.create_gid(urn, create_uuid(), pkey)
# xxx this should probably use a RegAuthority, or a to-be-defined RegPeer object
# but for now we have to preserve the authority+<> stuff
- interface_record = reg_class()
+ interface_record = RegAuthority()
+ interface_record.type=type
interface_record.hrn=hrn
interface_record.gid= gid
interface_record.authority=get_authority(hrn)
##############################
# various kinds of records are implemented as an inheritance hierarchy
# RegRecord is the base class for all actual variants
+# a first draft was using 'type' as the discriminator for the inheritance
+# but we had to define another more internal column (classtype) so we
+# accomodate variants in types like authority+am and the like
class RegRecord (Base,AlchemyObj):
# xxx tmp would be 'records'
__tablename__ = 'records'
record_id = Column (Integer, primary_key=True)
# this is the discriminator that tells which class to use
-# classtype = Column (String)
+ classtype = Column (String)
type = Column (String)
hrn = Column (String)
gid = Column (String)
date_created = Column (DateTime)
last_updated = Column (DateTime)
# use the 'type' column to decide which subclass the object is of
- __mapper_args__ = { 'polymorphic_on' : type }
+ __mapper_args__ = { 'polymorphic_on' : classtype }
fields = [ 'type', 'hrn', 'gid', 'authority', 'peer_authority' ]
- def __init__ (self, type='unknown', hrn=None, gid=None, authority=None, peer_authority=None,
+ def __init__ (self, type=None, hrn=None, gid=None, authority=None, peer_authority=None,
pointer=None, dict=None):
-# managed by alchemy's polymorphic stuff
-# self.type=type
+ if type: self.type=type
if hrn: self.hrn=hrn
if gid:
if isinstance(gid, StringTypes): self.gid=gid
def __repr__ (self):
return RegRecord.__repr__(self).replace("Record","Node")
-# because we use 'type' as the discriminator here, the only way to have type set to
-# e.g. authority+sa is to define a separate class
-# this currently is not used at all though, just to check if all this stuff really is useful
-# if so it would make more sense to store that in the authorities table instead
-class RegAuthoritySa (RegRecord):
- __tablename__ = 'authorities_sa'
- __mapper_args__ = { 'polymorphic_identity' : 'authority+sa' }
- record_id = Column (Integer, ForeignKey ("records.record_id"), primary_key=True)
-
-class RegAuthorityAm (RegRecord):
- __tablename__ = 'authorities_am'
- __mapper_args__ = { 'polymorphic_identity' : 'authority+am' }
- record_id = Column (Integer, ForeignKey ("records.record_id"), primary_key=True)
-
-class RegAuthoritySm (RegRecord):
- __tablename__ = 'authorities_sm'
- __mapper_args__ = { 'polymorphic_identity' : 'authority+sm' }
- record_id = Column (Integer, ForeignKey ("records.record_id"), primary_key=True)
-
##############################
def init_tables(dbsession):
logger.info("Initializing db schema and builtin types")
xml_dict = xml_record.todict()
logger.info("load from xml, keys=%s"%xml_dict.keys())
return make_record_dict (xml_dict)
-
-