from sfa.rspecs.rspec import RSpec
from sfa.planetlab.vlink import VLink
from sfa.planetlab.topology import Topology
-from sfa.planetlab.plxrn import PlXrn, hrn_to_pl_slicename, xrn_to_hostname
+from sfa.planetlab.plxrn import PlXrn, hrn_to_pl_slicename, xrn_to_hostname, xrn_to_ext_slicename, hrn_to_ext_loginbase, top_auth
from sfa.storage.model import SliverAllocation
from sfa.storage.alchemy import dbsession
requested_leases = []
for lease in rspec_requested_leases:
requested_lease = {}
- slice_name = hrn_to_pl_slicename(lease['slice_id'])
+ slice_hrn, _ = urn_to_hrn(lease['slice_id'])
+ top_auth_hrn = top_auth(slice_hrn)
+ if top_auth_hrn == self.driver.hrn:
+ slice_name = hrn_to_pl_slicename(lease['slice_id'])
+ else:
+ slice_name = xrn_to_ext_slicename(lease['slice_id'])
if slice_name != slice['name']:
continue
elif Xrn(lease['component_id']).get_authority_urn().split(':')[0] != self.driver.hrn:
for link in requested_links:
# get the ip address of the first node in the link
ifname1 = Xrn(link['interface1']['component_id']).get_leaf()
- ifname_parts = ifname1.split(':')
- node_raw = ifname_parts[0]
- device = None
- if len(ifname_parts) > 1:
- device = ifname_parts[1]
- node_id = int(node_raw.replace('node', ''))
- node = nodes_dict[node_id]
- if1 = interfaces_dict[node['interface_ids'][0]]
- ipaddr = if1['ip']
- topo_rspec = VLink.get_topo_rspec(link, ipaddr)
- # set topo_rspec tag
- slice_tags.append({'name': 'topo_rspec', 'value': str([topo_rspec]), 'node_id': node_id})
- # set vini_topo tag
- slice_tags.append({'name': 'vini_topo', 'value': 'manual', 'node_id': node_id})
- #self.driver.shell.AddSliceTag(slice['name'], 'topo_rspec', str([topo_rspec]), node_id)
+ if ifname1:
+ ifname_parts = ifname1.split(':')
+ node_raw = ifname_parts[0]
+ device = None
+ if len(ifname_parts) > 1:
+ device = ifname_parts[1]
+ node_id = int(node_raw.replace('node', ''))
+ node = nodes_dict[node_id]
+ if1 = interfaces_dict[node['interface_ids'][0]]
+ ipaddr = if1['ip']
+ topo_rspec = VLink.get_topo_rspec(link, ipaddr)
+ # set topo_rspec tag
+ slice_tags.append({'name': 'topo_rspec', 'value': str([topo_rspec]), 'node_id': node_id})
+ # set vini_topo tag
+ slice_tags.append({'name': 'vini_topo', 'value': 'manual', 'node_id': node_id})
+ #self.driver.shell.AddSliceTag(slice['name'], 'topo_rspec', str([topo_rspec]), node_id)
self.verify_slice_attributes(slice, slice_tags, {'append': True}, admin=True)
def verify_site(self, slice_xrn, slice_record={}, peer=None, sfa_peer=None, options={}):
(slice_hrn, type) = urn_to_hrn(slice_xrn)
- site_hrn = get_authority(slice_hrn)
- top_auth_hrn = site_hrn.split('.')[0]
+ top_auth_hrn = top_auth(slice_hrn)
if top_auth_hrn == self.driver.hrn:
# login base can't be longer than 20 characters
slicename = hrn_to_pl_slicename(slice_hrn)
authority_name = slicename.split('_')[0]
login_base = authority_name[:20]
else:
- login_base = '8'.join(site_hrn.split('.'))[:20]
+ login_base = hrn_to_ext_loginbase(slice_hrn)
authority_name = login_base
sites = self.driver.shell.GetSites(login_base)
def verify_slice(self, slice_hrn, slice_record, peer, sfa_peer, expiration, options={}):
- site_hrn = get_authority(slice_hrn)
- top_auth_hrn = site_hrn.split('.')[0]
+ top_auth_hrn = top_auth(slice_hrn)
if top_auth_hrn == self.driver.hrn:
slicename = hrn_to_pl_slicename(slice_hrn)
parts = slicename.split("_")
login_base = parts[0]
else:
- login_base = '8'.join(site_hrn.split('.'))
- slice_name = '_'.join([login_base, slice_hrn.split('.')[-1]])
+ login_base = hrn_to_ext_loginbase(slice_hrn)
+ slicename = xrn_to_ext_slicename(slice_hrn)
slices = self.driver.shell.GetSlices([slicename])
expires = int(datetime_to_epoch(utcparse(expiration)))
#def get_existing_persons(self, users):
def verify_persons(self, slice_hrn, slice_record, users, peer, sfa_peer, options={}):
-
- site_hrn = get_authority(slice_hrn)
- top_auth_hrn = site_hrn.split('.')[0]
- if top_auth_hrn == self.driver.hrn:
- slicename = hrn_to_pl_slicename(slice_hrn)
- parts = slicename.split("_")
- login_base = parts[0]
- else:
- login_base = '8'.join(site_hrn.split('.'))
- slice_name = '_'.join([login_base, slice_hrn.split('.')[-1]])
-
-
-
users_by_email = {}
users_by_site = defaultdict(list)
users_dict = {}
username = get_leaf(hrn)
user['username'] = username
- site_hrn = get_authority(hrn)
- top_auth_hrn = site_hrn.split('.')[0]
+ top_auth_hrn = top_auth(hrn)
if top_auth_hrn == self.driver.hrn:
login_base = PlXrn(xrn=user['urn']).pl_login_base()
else:
- login_base = '8'.join(site_hrn.split('.'))
+ login_base = hrn_to_ext_loginbase(hrn)
user['site'] = login_base
if 'email' in user: