1 from sfa.util.xrn import get_authority
3 def get_peer(pldriver, hrn):
4 # Because of myplc native federation, we first need to determine if this
5 # slice belongs to out local plc or a myplc peer. We will assume it
6 # is a local site, unless we find out otherwise
9 # get this slice's authority (site)
10 slice_authority = get_authority(hrn)
12 # get this site's authority (sfa root authority or sub authority)
13 site_authority = get_authority(slice_authority).lower()
14 # check if we are already peered with this site_authority, if so
15 peers = pldriver.shell.GetPeers(
16 {}, ['peer_id', 'peername', 'shortname', 'hrn_root'])
17 for peer_record in peers:
18 names = [name.lower() for name in list(peer_record.values())
19 if isinstance(name, str)]
20 if site_authority in names:
21 peer = peer_record['shortname']
26 # def get_sfa_peer(pldriver, 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 != pldriver.hrn:
33 # sfa_peer = site_authority