1 from sfa.util.misc import *
2 from types import StringTypes
4 def get_peer(api, hrn):
5 # Becaues of myplc federation, we first need to determine if this
6 # slice belongs to out local plc or a myplc peer. We will assume it
7 # is a local site, unless we find out otherwise
10 # get this slice's authority (site)
11 slice_authority = get_authority(hrn)
13 # get this site's authority (sfa root authority or sub authority)
14 site_authority = get_authority(slice_authority).lower()
15 # check if we are already peered with this site_authority, if so
16 peers = api.plshell.GetPeers(api.plauth, {}, \
17 ['peer_id', 'peername', 'shortname', 'hrn_root'])
18 for peer_record in peers:
19 names = [name.lower() for name in peer_record.values() if isinstance(name, StringTypes)]
20 if site_authority in names:
21 peer = peer_record['shortname']
26 def get_sfa_peer(api, hrn):
27 # return the authority for this hrn or None if we are the authority
29 slice_authority = get_authority(hrn)
30 site_authority = get_authority(slice_authority)
32 if site_authority != api.hrn:
33 sfa_peer = site_authority