Exemple #1
0
    def verify_slice_links(self, slice, requested_links, nodes):
         
        if not requested_links:
            return

        # exit if links are not supported here
        topology = Topology()
        if not topology:
            return 

        # build dict of nodes 
        nodes_dict = {}
        interface_ids = []
        for node in nodes:
            nodes_dict[node['node_id']] = node
            interface_ids.extend(node['interface_ids'])
        # build dict of interfaces
        interfaces = self.driver.shell.GetInterfaces(interface_ids)
        interfaces_dict = {}
        for interface in interfaces:
            interfaces_dict[interface['interface_id']] = interface 

        slice_tags = []
        
        # set egre key
        slice_tags.append({'name': 'egre_key', 'value': self.free_egre_key()})
    
        # set netns
        slice_tags.append({'name': 'netns', 'value': '1'})

        # set cap_net_admin 
        # need to update the attribute string?
        slice_tags.append({'name': 'capabilities', 'value': 'CAP_NET_ADMIN'}) 
        
        for link in requested_links:
            # get the ip address of the first node in the link
            ifname1 = Xrn(link['interface1']['component_id']).get_leaf()

            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)
Exemple #2
0
    def verify_slice_links(self, slice, requested_links, nodes):

        if not requested_links:
            return

        # exit if links are not supported here
        topology = Topology()
        if not topology:
            return

        # build dict of nodes
        nodes_dict = {}
        interface_ids = []
        for node in nodes:
            nodes_dict[node['node_id']] = node
            interface_ids.extend(node['interface_ids'])
        # build dict of interfaces
        interfaces = self.driver.shell.GetInterfaces(interface_ids)
        interfaces_dict = {}
        for interface in interfaces:
            interfaces_dict[interface['interface_id']] = interface

        slice_tags = []

        # set egre key
        slice_tags.append({'name': 'egre_key', 'value': self.free_egre_key()})

        # set netns
        slice_tags.append({'name': 'netns', 'value': '1'})

        # set cap_net_admin
        # need to update the attribute string?
        slice_tags.append({'name': 'capabilities', 'value': 'CAP_NET_ADMIN'})

        for link in requested_links:
            # get the ip address of the first node in the link
            ifname1 = Xrn(link['interface1']['component_id']).get_leaf()

            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)
Exemple #3
0
 def get_interface_id(interface):
     if_name = Xrn(interface['component_id']).get_leaf()
     node, dev = if_name.split(":")
     node_id = int(node.replace("node", ""))
     return node_id