Ejemplo n.º 1
0
 def fill_name_tag_in_tn_iface(node, dom, transport_vlans={},
                               force_vlan=None):
     """
     Obtain a random VLAN from the given list of ranges of available VLANs
     obtained from TNRM.
         In case TNRM provides the full list only, the local domain will
         be iteratively examined to minimise possible collisions of VLANs.
         In case restricted sets of VLANs is used, those will be
         taken into account.
     """
     new_node = {}
     idx_vlan = 0
     # num_iter = 0
     vlan = ""
     for k in node.keys():
         if k == "vlan":
             vlans = CommonUtils.process_range_and_set_values(
                 node[k][0]["description"])
             # A) Search for suitable (available) VLANs until found or
             # "all" the range (having randomness in mind) is examined
             # - For this, check slice monitoring info
             # contained = True
             max_iter = int(len(vlans)-1)
             # while contained and num_iter <= max_iter:
             #     idx_vlan = CommonUtils.get_random_list_position(max_iter)
             #     vlan = vlans[idx_vlan]
             #     contained, intersect = TNUtils.check_vlan_is_in_use(vlan)
             #     num_iter += 1
             # B.1) Choose from list of restricted VLANs
             if "enabled" in transport_vlans and\
                 "disabled" in transport_vlans:
                 vlans_enabled = transport_vlans.get("enabled") or set()
                 vlans_disabled = transport_vlans.get("disabled") or set()
                 # VLANs are taken from the intersection of the free VLANs
                 # reported by TN (to only get free VLANs) and those
                 # restricted by configuration (to avoid them, even if free)
                 vlans = set(vlans).intersection(set(vlans_enabled))
                 vlans = set(vlans).difference(set(vlans_disabled))
                 vlans = list(vlans)
                 max_iter = int(len(vlans)-1)
                 idx_vlan = CommonUtils.get_random_list_position(max_iter)
             # B.2) Choose from list of available VLANs from TNRM
             else:
                 idx_vlan = CommonUtils.get_random_list_position(max_iter)
             # C) If explicit VLAN is forced, use that one
             if force_vlan is not None:
                 vlan = force_vlan
             else:
                 vlan = vlans[idx_vlan]
             new_node[k] = [{"tag": str(vlan), "name": "%s+vlan" % dom}]
         else:
             new_node[k] = node[k]
     return new_node
Ejemplo n.º 2
0
 def fill_name_tag_in_tn_iface(node, dom):
     """
     Obtain a random VLAN from the given list of ranges of available VLANs obtained from TNRM.
         In case TNRM provides the full list only, the local domain will be iteratively 
         examined in order to minimise possible collisions of VLANs
     """
     new_node = {}
     num_iter = 0
     vlan = ""
     for k in node.keys():
         if k == "vlan":
             vlans = CommonUtils.process_range_and_set_values(
                 node[k][0]["description"])
             is_contained = True
             max_iter = int(len(vlans) - 1)
             # Search for suitable (available VLANs) until found or "all" the
             # range (having in mind the randomness) has been examined
             while is_contained and num_iter <= max_iter:
                 idx_vlan = CommonUtils.get_random_list_position(max_iter)
                 vlan = vlans[idx_vlan]
                 is_contained, intersect = TNUtils.check_vlan_is_in_use(
                     vlan)
                 num_iter += 1
             new_node[k] = [{"tag": str(vlan), "name": "%s+vlan" % dom}]
         else:
             new_node[k] = node[k]
     return new_node
Ejemplo n.º 3
0
Archivo: tn.py Proyecto: HalasNet/felix
 def fill_name_tag_in_tn_iface(node, dom):
     """
     Obtain a random VLAN from the given list of ranges of available VLANs obtained from TNRM.
         In case TNRM provides the full list only, the local domain will be iteratively 
         examined in order to minimise possible collisions of VLANs
     """
     new_node = {}
     num_iter = 0
     vlan = ""
     for k in node.keys():
         if k == "vlan":
             vlans = CommonUtils.process_range_and_set_values(node[k][0]["description"])
             is_contained = True
             max_iter = int(len(vlans)-1)
             # Search for suitable (available VLANs) until found or "all" the 
             # range (having in mind the randomness) has been examined
             while is_contained and num_iter <= max_iter:
                 idx_vlan = CommonUtils.get_random_list_position(max_iter)
                 vlan = vlans[idx_vlan]
                 is_contained, intersect = TNUtils.check_vlan_is_in_use(vlan)
                 num_iter += 1
             new_node[k] = [{"tag": str(vlan), "name": "%s+vlan" % dom}]
         else:
             new_node[k] = node[k]
     return new_node
Ejemplo n.º 4
0
    def identify_tn_from_sdn_and_vl(dpid_port_ids, request_stps,
                                    sdn_utils, transport_vlans={}):
        # TN resources
        nodes = []
        links = []
        logger.debug("Identifying TN STPs from Virtual Links + SDN resources")
        logger.debug("Request STPs=%s" % str(request_stps))

        for stp in request_stps:
            paths = TNUtils.find_interdomain_paths_from_stps_and_dpids(
                stp, dpid_port_ids)

            # A path is chosen from the mapping taking into account the
            # restrictions defined implicitly by the DPIDs within the flowspace
            # Note: an empty list will be returned if none fits
            # path = sdn_utils.find_path_containing_all(dpid_port_ids, paths)
            # Thus, path is either the previously returned (or all, if empty)
            # path = path or paths

            # Getting the only element of list (path) or random element (paths)
            rnd_path_idx = CommonUtils.get_random_list_position(len(paths))
            path = paths[0] if len(paths) == 1 else paths[rnd_path_idx]

            # Whatever the search space (i.e. the path) is, this is fed to the
            # methods that identify how to extend the SDN flowspace to be able
            # to bind the SDN domain with the stitching (virtual) domain
            items, links_constraints = \
                sdn_utils.analyze_mapped_path(dpid_port_ids, [path])

            src_dom, dst_dom = path["src"]["tn"], path["dst"]["tn"]
            node = TNUtils.generate_tn_node(
                src_dom, dst_dom, transport_vlans)
            src_vlan = node["interfaces"][0]["vlan"][0]["tag"]
            dst_vlan = node["interfaces"][1]["vlan"][0]["tag"]
            if node is None:
                break
            nodes.append(node)
            link = TNUtils.generate_tn_link(
                src_dom, src_vlan, dst_dom, dst_vlan)
            links.append(link)
        logger.debug("Implicit retrieval of TN STPs has concluded: \
            %s" % str(links))
        return (nodes, links)
Ejemplo n.º 5
0
    def identify_tn_from_sdn_and_vl(dpid_port_ids, request_stps, sdn_utils):
        # TN resources
        nodes = []
        links = []
        logger.debug(
            "Identifying TN STPs from Virtual Links and SDN resources")
        logger.debug("Request STPs=%s" % str(request_stps))

        for stp in request_stps:
            paths = TNUtils.find_interdomain_paths_from_stps_and_dpids(
                stp, dpid_port_ids)

            # A path is chosen from the mapping taking into account the
            # restrictions defined implicitly by the DPIDs within the flowspace
            # Note: an empty list will be returned if none fits
            #path = sdn_utils.find_path_containing_all(dpid_port_ids, paths)
            # Thus, path is either the previously returned (or all, if empty)
            #path = path or paths

            # Getting the only element of list (path) or random element (paths)
            rnd_path_idx = CommonUtils.get_random_list_position(len(paths))
            path = paths[0] if len(paths) == 1 else paths[rnd_path_idx]

            # Whatever the search space (i.e. the path) is, this is fed to the
            # methods that identify how to extend the SDN flowspace to be able
            # to bind the SDN domain with the stitching (virtual) domain
            items, links_constraints = sdn_utils.analyze_mapped_path(
                dpid_port_ids, [path])

            src_dom, dst_dom = path["src"]["tn"], path["dst"]["tn"]
            node = TNUtils.generate_tn_node(src_dom, dst_dom)
            src_vlan = node["interfaces"][0]["vlan"][0]["tag"]
            dst_vlan = node["interfaces"][1]["vlan"][0]["tag"]
            if node is None:
                break
            nodes.append(node)
            link = TNUtils.generate_tn_link(src_dom, src_vlan, dst_dom,
                                            dst_vlan)
            links.append(link)
        logger.debug("Implicit retrieval of TN STPs has concluded: %s" %
                     str(links))
        return (nodes, links)