From: Thierry Parmentelat Date: Tue, 24 Jan 2012 12:23:50 +0000 (+0100) Subject: Merge branch 'master' into sqlalchemy X-Git-Tag: before-migrate~3 X-Git-Url: http://git.onelab.eu/?p=sfa.git;a=commitdiff_plain;h=6f0a757c5adf47b4d222cec09514dcd688b93457;hp=5870a2bc6732f7d8e02b1aa7ea96535f32ddd656 Merge branch 'master' into sqlalchemy Conflicts: sfa/managers/registry_manager_openstack.py --- diff --git a/sfa/client/sfi.py b/sfa/client/sfi.py index c551a808..ec34f45f 100644 --- a/sfa/client/sfi.py +++ b/sfa/client/sfi.py @@ -323,6 +323,8 @@ class Sfi: help="root registry", metavar="URL", default=None) parser.add_option("-s", "--sliceapi", dest="sm", default=None, metavar="URL", help="slice API - in general a SM URL, but can be used to talk to an aggregate") + parser.add_option("-R", "--raw", dest="raw", action="store_true", default=False, + help="Display raw, unparsed server response") parser.add_option("-d", "--dir", dest="sfi_dir", help="config & working directory - default is %default", metavar="PATH", default=Sfi.default_sfi_dir()) @@ -782,7 +784,10 @@ or version information about sfi itself api_options['call_id']=unique_call_id() result = server.ListSlices(creds, *self.ois(server,api_options)) value = ReturnValue.get_value(result) - display_list(value) + if self.options.raw: + print result + else: + display_list(value) return # show rspec for named slice @@ -832,7 +837,10 @@ or with an slice hrn, shows currently provisioned resources result = server.ListResources (creds, api_options) value = ReturnValue.get_value(result) if options.file is None: - display_rspec(value, options.format) + if self.options.raw: + print result + else: + display_rspec(value, options.format) else: save_rspec_to_file(value, options.file) return @@ -899,7 +907,10 @@ or with an slice hrn, shows currently provisioned resources result = server.CreateSliver(slice_urn, creds, rspec, users, *self.ois(server, api_options)) value = ReturnValue.get_value(result) if options.file is None: - print value + if self.options.raw: + print result + else: + print value else: save_rspec_to_file (value, options.file) return value @@ -925,8 +936,12 @@ or with an slice hrn, shows currently provisioned resources api_options = {} api_options ['call_id'] = unique_call_id() result = server.DeleteSliver(slice_urn, creds, *self.ois(server, api_options ) ) - # xxx no ReturnValue ?? - return result + value = ReturnValue.get_value(result) + if self.options.raw: + print result + else: + print value + return value def status(self, options, args): """ @@ -947,10 +962,13 @@ or with an slice hrn, shows currently provisioned resources # options and call_id when supported api_options = {} - api_options['call_id']=unique_call_id() + api_options['call_id']=unique_call_id() result = server.SliverStatus(slice_urn, creds, *self.ois(server,api_options)) value = ReturnValue.get_value(result) - print value + if self.options.raw: + print result + else: + print value if options.file: save_variable_to_file(value, options.file, options.fileformat) @@ -971,7 +989,13 @@ or with an slice hrn, shows currently provisioned resources delegated_cred = self.delegate_cred(slice_cred, get_authority(self.authority)) creds.append(delegated_cred) # xxx Thierry - does this not need an api_options as well ? - return server.Start(slice_urn, creds) + result = server.Start(slice_urn, creds) + value = ReturnValue.get_value(result) + if self.options.raw: + print result + else: + print value + return value def stop(self, options, args): """ @@ -987,7 +1011,13 @@ or with an slice hrn, shows currently provisioned resources if options.delegate: delegated_cred = self.delegate_cred(slice_cred, get_authority(self.authority)) creds.append(delegated_cred) - return server.Stop(slice_urn, creds) + result = server.Stop(slice_urn, creds) + value = ReturnValue.get_value(result) + if self.options.raw: + print result + else: + print value + return value # reset named slice def reset(self, options, args): @@ -1004,7 +1034,13 @@ or with an slice hrn, shows currently provisioned resources if options.delegate: delegated_cred = self.delegate_cred(slice_cred, get_authority(self.authority)) creds.append(delegated_cred) - return server.reset_slice(creds, slice_urn) + result = server.reset_slice(creds, slice_urn) + value = ReturnValue.get_value(result) + if self.options.raw: + print result + else: + print value + return value def renew(self, options, args): """ @@ -1027,6 +1063,10 @@ or with an slice hrn, shows currently provisioned resources api_options['call_id']=unique_call_id() result = server.RenewSliver(slice_urn, creds, time, *self.ois(server,api_options)) value = ReturnValue.get_value(result) + if self.options.raw: + print result + else: + print value return value @@ -1044,7 +1084,13 @@ or with an slice hrn, shows currently provisioned resources if options.delegate: delegated_cred = self.delegate_cred(slice_cred, get_authority(self.authority)) creds.append(delegated_cred) - return server.Shutdown(slice_urn, creds) + result = server.Shutdown(slice_urn, creds) + value = ReturnValue.get_value(result) + if self.options.raw: + print result + else: + print value + return value def get_ticket(self, options, args): diff --git a/sfa/generic/openstack.py b/sfa/generic/openstack.py new file mode 100644 index 00000000..5c99d235 --- /dev/null +++ b/sfa/generic/openstack.py @@ -0,0 +1,35 @@ +from sfa.generic import Generic + +import sfa.server.sfaapi +import sfa.openstack.openstack_driver +import sfa.managers.registry_manager_openstack +import sfa.managers.slice_manager +import sfa.managers.aggregate_manager_openstack + +class openstack (Generic): + + # use the standard api class + def api_class (self): + return sfa.server.sfaapi.SfaApi + + # the manager classes for the server-side services + def registry_manager_class (self) : + return sfa.managers.registry_manager_openstack.RegistryManager + def slicemgr_manager_class (self) : + return sfa.managers.slice_manager.SliceManager + def aggregate_manager_class (self) : + return sfa.managers.aggregate_manager_openstack.AggregateManager + + # driver class for server-side services, talk to the whole testbed + def driver_class (self): + return sfa.openstack.openstack_driver.OpenstackDriver + + # for the component mode, to be run on board planetlab nodes + # manager class + def component_manager_class (self): + return sfa.managers.component_manager_pl + # driver_class + def component_driver_class (self): + return sfa.plc.plcomponentdriver.PlComponentDriver + + diff --git a/sfa/managers/aggregate_manager_openstack.py b/sfa/managers/aggregate_manager_openstack.py deleted file mode 100644 index 3ed0bbaa..00000000 --- a/sfa/managers/aggregate_manager_openstack.py +++ /dev/null @@ -1,117 +0,0 @@ -from sfa.util.version import version_core -from sfa.util.xrn import Xrn -from sfa.util.callids import Callids -from sfa.managers import aggregate_manager - -class AggregateManager(aggregate_manager.AggregateManager): - - def __init__ (self, config): pass - - # essentially a union of the core version, the generic version (this code) and - # whatever the driver needs to expose - def GetVersion(self, api, options): - - xrn=Xrn(api.hrn) - version = version_core() - version_generic = { - 'interface':'aggregate', - 'sfa': 2, - 'geni_api': 2, - 'geni_api_versions': {'2': 'http://%s:%s' % (api.config.SFA_AGGREGATE_HOST, api.config.SFA_AGGREGATE_PORT)}, - 'hrn':xrn.get_hrn(), - 'urn':xrn.get_urn(), - } - version.update(version_generic) - testbed_version = self.driver.aggregate_version() - version.update(testbed_version) - return version - - def ListSlices(self, api, creds, options): - call_id = options.get('call_id') - if Callids().already_handled(call_id): return [] - return self.driver.list_slices (creds, options) - - def ListResources(self, api, creds, options): - call_id = options.get('call_id') - if Callids().already_handled(call_id): return "" - - # get slice's hrn from options - slice_xrn = options.get('geni_slice_urn', None) - # pass None if no slice is specified - if not slice_xrn: - slice_hrn, slice_urn = None, None - else: - xrn = Xrn(slice_xrn) - slice_urn=xrn.get_urn() - slice_hrn=xrn.get_hrn() - - return self.driver.list_resources (slice_urn, slice_hrn, creds, options) - - def SliverStatus (self, api, xrn, creds, options): - call_id = options.get('call_id') - if Callids().already_handled(call_id): return {} - - xrn = Xrn(xrn) - slice_urn=xrn.get_urn() - slice_hrn=xrn.get_hrn() - return self.driver.sliver_status (slice_urn, slice_hrn) - - def CreateSliver(self, api, xrn, creds, rspec_string, users, options): - """ - Create the sliver[s] (slice) at this aggregate. - Verify HRN and initialize the slice record in PLC if necessary. - """ - call_id = options.get('call_id') - if Callids().already_handled(call_id): return "" - - xrn = Xrn(xrn) - slice_urn=xrn.get_urn() - slice_hrn=xrn.get_hrn() - - return self.driver.create_sliver (slice_urn, slice_hrn, creds, rspec_string, users, options) - - def DeleteSliver(self, api, xrn, creds, options): - call_id = options.get('call_id') - if Callids().already_handled(call_id): return True - - xrn = Xrn(xrn) - slice_urn=xrn.get_urn() - slice_hrn=xrn.get_hrn() - return self.driver.delete_sliver (slice_urn, slice_hrn, creds, options) - - def RenewSliver(self, api, xrn, creds, expiration_time, options): - call_id = options.get('call_id') - if Callids().already_handled(call_id): return True - - xrn = Xrn(xrn) - slice_urn=xrn.get_urn() - slice_hrn=xrn.get_hrn() - return self.driver.renew_sliver (slice_urn, slice_hrn, creds, expiration_time, options) - - ### these methods could use an options extension for at least call_id - def start_slice(self, api, xrn, creds): - xrn = Xrn(xrn) - slice_urn=xrn.get_urn() - slice_hrn=xrn.get_hrn() - return self.driver.start_slice (slice_urn, slice_hrn, creds) - - def stop_slice(self, api, xrn, creds): - xrn = Xrn(xrn) - slice_urn=xrn.get_urn() - slice_hrn=xrn.get_hrn() - return self.driver.stop_slice (slice_urn, slice_hrn, creds) - - def reset_slice(self, api, xrn): - xrn = Xrn(xrn) - slice_urn=xrn.get_urn() - slice_hrn=xrn.get_hrn() - return self.driver.reset_slice (slice_urn, slice_hrn) - - def GetTicket(self, api, xrn, creds, rspec, users, options): - - xrn = Xrn(xrn) - slice_urn=xrn.get_urn() - slice_hrn=xrn.get_hrn() - - return self.driver.get_ticket (slice_urn, slice_hrn, creds, rspec, options) - diff --git a/sfa/managers/registry_manager_openstack.py b/sfa/managers/registry_manager_openstack.py index f409f454..aee536f7 100644 --- a/sfa/managers/registry_manager_openstack.py +++ b/sfa/managers/registry_manager_openstack.py @@ -25,20 +25,6 @@ from sfa.managers.registry_manager import RegistryManager class RegistryManager(RegistryManager): - def __init__ (self, config): pass - - # The GENI GetVersion call - def GetVersion(self, api, options): - peers = dict ( [ (hrn,interface.get_url()) for (hrn,interface) in api.registries.iteritems() - if hrn != api.hrn]) - xrn=Xrn(api.hrn) - return version_core({'interface':'registry', - 'sfa': 2, - 'geni_api': 2, - 'hrn':xrn.get_hrn(), - 'urn':xrn.get_urn(), - 'peers':peers}) - def GetCredential(self, api, xrn, type, is_self=False): # convert xrn to hrn if type: @@ -100,138 +86,6 @@ class RegistryManager(RegistryManager): return new_cred.save_to_string(save_parents=True) - def Resolve(self, api, xrns, type=None, full=True): - - if not isinstance(xrns, types.ListType): - xrns = [xrns] - # try to infer type if not set and we get a single input - if not type: - type = Xrn(xrns).get_type() - hrns = [urn_to_hrn(xrn)[0] for xrn in xrns] - - # load all known registry names into a prefix tree and attempt to find - # the longest matching prefix - # create a dict where key is a registry hrn and its value is a list - # of hrns at that registry (determined by the known prefix tree). - xrn_dict = {} - registries = api.registries - tree = prefixTree() - registry_hrns = registries.keys() - tree.load(registry_hrns) - for xrn in xrns: - registry_hrn = tree.best_match(urn_to_hrn(xrn)[0]) - if registry_hrn not in xrn_dict: - xrn_dict[registry_hrn] = [] - xrn_dict[registry_hrn].append(xrn) - - records = [] - for registry_hrn in xrn_dict: - # skip the hrn without a registry hrn - # XX should we let the user know the authority is unknown? - if not registry_hrn: - continue - - # if the best match (longest matching hrn) is not the local registry, - # forward the request - xrns = xrn_dict[registry_hrn] - if registry_hrn != api.hrn: - credential = api.getCredential() - interface = api.registries[registry_hrn] - server_proxy = api.server_proxy(interface, credential) - peer_records = server_proxy.Resolve(xrns, credential,type) - # pass foreign records as-is - # previous code used to read - # records.extend([SfaRecord(dict=record).as_dict() for record in peer_records]) - # not sure why the records coming through xmlrpc had to be processed at all - records.extend(peer_records) - - # try resolving the remaining unfound records at the local registry - local_hrns = list ( set(hrns).difference([record['hrn'] for record in records]) ) - # - local_records = dbsession.query(RegRecord).filter(RegRecord.hrn.in_(local_hrns)) - if type: - local_records = local_records.filter_by(type=type) - local_records=local_records.all() - logger.info("Resolve: local_records=%s (type=%s)"%(local_records,type)) - local_dicts = [ record.__dict__ for record in local_records ] - - if full: - # in full mode we get as much info as we can, which involves contacting the - # testbed for getting implementation details about the record - self.driver.augment_records_with_testbed_info(local_dicts) - # also we fill the 'url' field for known authorities - # used to be in the driver code, sounds like a poorman thing though - def solve_neighbour_url (record): - if not record.type.startswith('authority'): return - hrn=record.hrn - for neighbour_dict in [ api.aggregates, api.registries ]: - if hrn in neighbour_dict: - record.url=neighbour_dict[hrn].get_url() - return - for record in local_records: solve_neighbour_url (record) - - # convert local record objects to dicts for xmlrpc - # xxx somehow here calling dict(record) issues a weird error - # however record.todict() seems to work fine - # records.extend( [ dict(record) for record in local_records ] ) - records.extend( [ record.todict() for record in local_records ] ) - if not records: - raise RecordNotFound(str(hrns)) - - return records - - def List (self, api, xrn, origin_hrn=None): - hrn, type = urn_to_hrn(xrn) - # load all know registry names into a prefix tree and attempt to find - # the longest matching prefix - registries = api.registries - registry_hrns = registries.keys() - tree = prefixTree() - tree.load(registry_hrns) - registry_hrn = tree.best_match(hrn) - - #if there was no match then this record belongs to an unknow registry - if not registry_hrn: - raise MissingAuthority(xrn) - # if the best match (longest matching hrn) is not the local registry, - # forward the request - record_dicts = [] - if registry_hrn != api.hrn: - credential = api.getCredential() - interface = api.registries[registry_hrn] - server_proxy = api.server_proxy(interface, credential) - record_list = server_proxy.List(xrn, credential) - # same as above, no need to process what comes from through xmlrpc - # pass foreign records as-is - record_dicts = record_list - - # if we still have not found the record yet, try the local registry - if not record_dicts: - if not api.auth.hierarchy.auth_exists(hrn): - raise MissingAuthority(hrn) - records = dbsession.query(RegRecord).filter_by(authority=hrn) - record_dicts=[ record.todict() for record in records ] - - return record_dicts - - - def CreateGid(self, api, xrn, cert): - # get the authority - authority = Xrn(xrn=xrn).get_authority_hrn() - auth_info = api.auth.get_auth_info(authority) - if not cert: - pkey = Keypair(create=True) - else: - certificate = Certificate(string=cert) - pkey = certificate.get_pubkey() - gid = api.auth.hierarchy.create_gid(xrn, create_uuid(), pkey) - return gid.save_to_string(save_parents=True) - - #################### - # utility for handling relationships among the SFA objects - # given that the SFA db does not handle this sort of relationsships - # it will rely on side-effects in the testbed to keep this persistent - # subject_record describes the subject of the relationships # ref_record contains the target values for the various relationships we need to manage # (to begin with, this is just the slice x person relationship) @@ -253,209 +107,3 @@ class RegistryManager(RegistryManager): link_ids = [ tuple.pointer for tuple in link_id_tuples ] self.driver.update_relation (subject_type, target_type, subject_id, link_ids) - def Register(self, api, record_dict): - - hrn, type = record_dict['hrn'], record_dict['type'] - urn = hrn_to_urn(hrn,type) - # validate the type - if type not in ['authority', 'slice', 'node', 'user']: - raise UnknownSfaType(type) - - # check if record_dict already exists - existing_records = dbsession.query(RegRecord).filter_by(type=type,hrn=hrn).all() - if existing_records: - raise ExistingRecord(hrn) - - assert ('type' in record_dict) - # returns the right type of RegRecord according to type in record - record = make_record(dict=record_dict) - record.just_created() - record.authority = get_authority(record.hrn) - auth_info = api.auth.get_auth_info(record.authority) - pub_key = None - # make sure record has a gid - if not record.gid: - uuid = create_uuid() - pkey = Keypair(create=True) - if getattr(record,'keys',None): - pub_key=record.keys - # use only first key in record - if isinstance(record.keys, types.ListType): - pub_key = record.keys[0] - pkey = convert_public_key(pub_key) - - gid_object = api.auth.hierarchy.create_gid(urn, uuid, pkey) - gid = gid_object.save_to_string(save_parents=True) - record.gid = gid - - if type in ["authority"]: - # update the tree - if not api.auth.hierarchy.auth_exists(hrn): - api.auth.hierarchy.create_auth(hrn_to_urn(hrn,'authority')) - - # get the GID from the newly created authority - gid = auth_info.get_gid_object() - record.gid=gid.save_to_string(save_parents=True) - - # update testbed-specific data if needed - pointer = self.driver.register (record.__dict__, hrn, pub_key) - - record.pointer=pointer - dbsession.add(record) - dbsession.commit() - - # update membership for researchers, pis, owners, operators - self.update_relations (record, record) - - return record.get_gid_object().save_to_string(save_parents=True) - - def Update(self, api, record_dict): - assert ('type' in record_dict) - new_record=RegRecord(dict=record_dict) - type = new_record.type - hrn = new_record.hrn - - # make sure the record exists - record = dbsession.query(RegRecord).filter_by(type=type,hrn=hrn).first() - if not record: - raise RecordNotFound("hrn=%s, type=%s"%(hrn,type)) - record.just_updated() - - # validate the type - if type not in ['authority', 'slice', 'node', 'user']: - raise UnknownSfaType(type) - - # Use the pointer from the existing record, not the one that the user - # gave us. This prevents the user from inserting a forged pointer - pointer = record.pointer - - # is the a change in keys ? - new_key=None - if type=='user': - if getattr(new_key,'keys',None): - new_key=new_record.keys - if isinstance (new_key,types.ListType): - new_key=new_key[0] - - # update the PLC information that was specified with the record - if not self.driver.update (record.__dict__, new_record.__dict__, hrn, new_key): - logger.warning("driver.update failed") - - # take new_key into account - if new_key: - # update the openssl key and gid - pkey = convert_public_key(new_key) - uuid = create_uuid() - urn = hrn_to_urn(hrn,type) - gid_object = api.auth.hierarchy.create_gid(urn, uuid, pkey) - gid = gid_object.save_to_string(save_parents=True) - record.gid = gid - dsession.commit() - - # update membership for researchers, pis, owners, operators - self.update_relations (record, new_record) - - return 1 - - # expecting an Xrn instance - def Remove(self, api, xrn, origin_hrn=None): - hrn=xrn.get_hrn() - type=xrn.get_type() - request=dbsession.query(RegRecord).filter_by(hrn=hrn) - if type and type not in ['all', '*']: - request=request.filter_by(type=type) - - record = request.first() - if not record: - msg="Could not find hrn %s"%hrn - if type: msg += " type=%s"%type - raise RecordNotFound(msg) - - type = record.type - if type not in ['slice', 'user', 'node', 'authority'] : - raise UnknownSfaType(type) - - credential = api.getCredential() - registries = api.registries - - # Try to remove the object from the PLCDB of federated agg. - # This is attempted before removing the object from the local agg's PLCDB and sfa table - if hrn.startswith(api.hrn) and type in ['user', 'slice', 'authority']: - for registry in registries: - if registry not in [api.hrn]: - try: - result=registries[registry].remove_peer_object(credential, record, origin_hrn) - except: - pass - - # call testbed callback first - # IIUC this is done on the local testbed TOO because of the refreshpeer link - if not self.driver.remove(record.__dict__): - logger.warning("driver.remove failed") - - # delete from sfa db - dbsession.delete(record) - dbsession.commit() - - return 1 - - # This is a PLC-specific thing, won't work with other platforms - def get_key_from_incoming_ip (self, api): - # verify that the callers's ip address exist in the db and is an interface - # for a node in the db - (ip, port) = api.remote_addr - interfaces = self.driver.shell.GetInterfaces({'ip': ip}, ['node_id']) - if not interfaces: - raise NonExistingRecord("no such ip %(ip)s" % locals()) - nodes = self.driver.shell.GetNodes([interfaces[0]['node_id']], ['node_id', 'hostname']) - if not nodes: - raise NonExistingRecord("no such node using ip %(ip)s" % locals()) - node = nodes[0] - - # look up the sfa record - record=dbsession.query(RegRecord).filter_by(type='node',pointer=node['node_id']).first() - if not record: - raise RecordNotFound("node with pointer %s"%node['node_id']) - - # generate a new keypair and gid - uuid = create_uuid() - pkey = Keypair(create=True) - urn = hrn_to_urn(record.hrn, record.type) - gid_object = api.auth.hierarchy.create_gid(urn, uuid, pkey) - gid = gid_object.save_to_string(save_parents=True) - record.gid = gid - - # update the record - dbsession.commit() - - # attempt the scp the key - # and gid onto the node - # this will only work for planetlab based components - (kfd, key_filename) = tempfile.mkstemp() - (gfd, gid_filename) = tempfile.mkstemp() - pkey.save_to_file(key_filename) - gid_object.save_to_file(gid_filename, save_parents=True) - host = node['hostname'] - key_dest="/etc/sfa/node.key" - gid_dest="/etc/sfa/node.gid" - scp = "/usr/bin/scp" - #identity = "/etc/planetlab/root_ssh_key.rsa" - identity = "/etc/sfa/root_ssh_key" - scp_options=" -i %(identity)s " % locals() - scp_options+="-o StrictHostKeyChecking=no " % locals() - scp_key_command="%(scp)s %(scp_options)s %(key_filename)s root@%(host)s:%(key_dest)s" %\ - locals() - scp_gid_command="%(scp)s %(scp_options)s %(gid_filename)s root@%(host)s:%(gid_dest)s" %\ - locals() - - all_commands = [scp_key_command, scp_gid_command] - - for command in all_commands: - (status, output) = commands.getstatusoutput(command) - if status: - raise Exception, output - - for filename in [key_filename, gid_filename]: - os.unlink(filename) - - return 1 diff --git a/sfa/managers/slice_manager.py b/sfa/managers/slice_manager.py index e9e446ac..b261fe28 100644 --- a/sfa/managers/slice_manager.py +++ b/sfa/managers/slice_manager.py @@ -135,7 +135,7 @@ class SliceManager: # look in cache first cached_requested = options.get('cached', True) - if not xrn and self.cache and cached_request: + if not xrn and self.cache and cached_requested: rspec = self.cache.get(version_string) if rspec: api.logger.debug("SliceManager.ListResources returns cached advertisement") diff --git a/sfa/rspecs/versions/sfav1.py b/sfa/rspecs/versions/sfav1.py index 39bbac5b..ab022df3 100644 --- a/sfa/rspecs/versions/sfav1.py +++ b/sfa/rspecs/versions/sfav1.py @@ -101,7 +101,7 @@ class SFAv1(BaseVersion): sliver_attributes = self.get_sliver_attributes(nodename, network) for sliver_attribute in sliver_attributes: sliver_attribute['node_id'] = nodename - attributes.append(attribute) + attributes.append(sliver_attribute) return attributes diff --git a/sfa/server/sfa-clean-peer-records.py b/sfa/server/sfa-clean-peer-records.py index 3a34fbcc..0e04ecd9 100644 --- a/sfa/server/sfa-clean-peer-records.py +++ b/sfa/server/sfa-clean-peer-records.py @@ -27,9 +27,9 @@ def main(): # Get the path to the sfa server key/cert files from # the sfa hierarchy object sfa_hierarchy = Hierarchy() - sfa_key_path = sfa_hierarchy.basedir - key_file = os.path.join(sfa_key_path, "server.key") - cert_file = os.path.join(sfa_key_path, "server.cert") + auth_info = sfa_hierarchy.get_interface_auth_info() + key_file = auth_info.get_privkey_filename() + cert_file = auth_info.get_gid_filename() key = Keypair(filename=key_file) # get a connection to our local sfa registry diff --git a/sfa/server/sfa-start.py b/sfa/server/sfa-start.py index 8355d1cb..22a80912 100755 --- a/sfa/server/sfa-start.py +++ b/sfa/server/sfa-start.py @@ -40,10 +40,10 @@ from sfa.trust.trustedroots import TrustedRoots from sfa.trust.certificate import Keypair, Certificate from sfa.trust.hierarchy import Hierarchy from sfa.trust.gid import GID - from sfa.server.sfaapi import SfaApi from sfa.server.registry import Registries from sfa.server.aggregate import Aggregates +from sfa.client.return_value import ReturnValue # after http://www.erlenstar.demon.co.uk/unix/faq_2.html def daemon(): @@ -100,7 +100,7 @@ def install_peer_certs(server_key_file, server_cert_file): logger.info("get_trusted_certs: skipping non sfa aggregate: %s" % new_hrn) continue - trusted_gids = interface.get_trusted_certs() + trusted_gids = ReturnValue.get_value(interface.get_trusted_certs()) if trusted_gids: # the gid we want should be the first one in the list, # but lets make sure @@ -109,7 +109,7 @@ def install_peer_certs(server_key_file, server_cert_file): message = "interface: %s\t" % (api.interface) message += "unable to install trusted gid for %s" % \ (new_hrn) - gid = GID(string=trusted_gids[0]) + gid = GID(string=trusted_gid) peer_gids.append(gid) if gid.get_hrn() == new_hrn: gid_filename = os.path.join(trusted_certs_dir, '%s.gid' % new_hrn)