X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fplc%2Fslices.py;h=5cead3bebac361cb1985d303de1e3cfb598c1f3e;hb=a0f6a0a871ca38cbbb60c384ef8c8adf6afb844a;hp=0b2690294cbc17c60b2e8a45f5ed1dc097765b2b;hpb=8e13e7b178d5ffec16cdfa0e3b81f883fca5ec68;p=sfa.git diff --git a/sfa/plc/slices.py b/sfa/plc/slices.py index 0b269029..5cead3be 100644 --- a/sfa/plc/slices.py +++ b/sfa/plc/slices.py @@ -1,17 +1,12 @@ -import datetime -import time -import traceback -import sys - from types import StringTypes -from sfa.util.xrn import Xrn, get_leaf, get_authority, hrn_to_urn, urn_to_hrn -from sfa.util.plxrn import hrn_to_pl_slicename, hrn_to_pl_login_base -from sfa.util.faults import * -from sfa.util.record import SfaRecord +from collections import defaultdict + +from sfa.util.xrn import get_leaf, get_authority, urn_to_hrn +from sfa.util.plxrn import hrn_to_pl_slicename from sfa.util.policy import Policy +from sfa.rspecs.rspec import RSpec from sfa.plc.vlink import VLink -from sfa.util.prefixTree import prefixTree -from collections import defaultdict +from sfa.util.xrn import Xrn MAXINT = 2L**31-1 @@ -189,11 +184,22 @@ class Slices: except: self.api.logger.log_exc('Failed to add/remove slice from nodes') - def verify_slice_links(self, slice, links, peer=None): - if not links or not nodes: + def verify_slice_links(self, slice, links, aggregate): + # nodes is undefined here + if not links: return + for link in links: - topo_rspec = VLink.get_topo_rspec(link) + # get the ip address of the first node in the link + ifname1 = Xrn(link['interface1']['component_id']).get_leaf() + (node, device) = ifname1.split(':') + node_id = int(node.replace('node', '')) + node = aggregate.nodes[node_id] + if1 = aggregate.interfaces[node['interface_ids'][0]] + ipaddr = if1['ip'] + topo_rspec = VLink.get_topo_rspec(link, ipaddr) + self.api.plshell.AddSliceTag(self.api.plauth, slice['name'], 'topo_rspec', str([topo_rspec]), node_id) + def handle_peer(self, site, slice, persons, peer): @@ -541,8 +547,7 @@ class Slices: # add requested_attributes for attribute in added_slice_attributes: try: - name, value, node_id = attribute['name'], attribute['value'], attribute.get('node_id', None) - self.api.plshell.AddSliceTag(self.api.plauth, slice['name'], name, value, node_id) + self.api.plshell.AddSliceTag(self.api.plauth, slice['name'], attribute['name'], attribute['value'], attribute.get('node_id', None)) except Exception, e: self.api.logger.warn('Failed to add sliver attribute. name: %s, value: %s, node_id: %s\nCause:%s'\ % (name, value, node_id, str(e)))