Beispiel #1
0
def get_slices(n=256):
    p_topo = nxtopo.NXTopo()
    nodes = {}

    # add all the "owned" nodes
    for i in range(n):
        nodes[i] = set()
        for j in range(n):
            if i == j:
                next
            else:
                nodes[i].add(j)
                p_topo.add_switch(id_of_node(i, j))

    # add all the edges
    for i in range(n):
        for j in nodes[i]:
            p_topo.add_link(id_of_node(i, j), id_of_node(j, i))

    p_topo.finalize()

    # Construct the slices
    slices = set()
    for i in range(n):
        slice_nodes = set()
        # owned nodes
        slice_nodes.update([id_of_node(i, j) for j in nodes[i]])
        # foreign nodes
        slice_nodes.update([id_of_node(j, i) for j in nodes[i]])

        l_topo = p_topo.subgraph(slice_nodes)
        switch_map = util.id_map(slice_nodes)
        port_map = util.id_map(util.ports_of_topo(l_topo))
        predicate = util.build_external_predicate(l_topo)
        slices.add(Slice(l_topo, p_topo, switch_map, port_map, predicate))

    return p_topo, slices
Beispiel #2
0
def ident_map_slice(topo, edge_policy, map_end_hosts=False):
    """Build a slice using topo as both the physical and logical topology."""
    node_map = util.id_map(topo.nodes() if map_end_hosts else topo.switches())
    port_map = util.id_map(util.ports_of_topo(topo))
    return Slice(topo, topo, node_map, port_map, edge_policy, map_end_hosts)
Beispiel #3
0
def get_slices():
    p_topo = nxtopo.NXTopo()
    # The triangular core
    p_topo.add_switch("PI1")
    p_topo.add_switch("PI2")
    p_topo.add_switch("PI3")
    p_topo.add_link("PI1","PI2")
    p_topo.add_link("PI1","PI3")
    p_topo.add_link("PI2","PI3")

    # An external-facing switch for each switch in the core
    p_topo.add_switch("PE1")
    p_topo.add_switch("PE2")
    p_topo.add_switch("PE3")
    p_topo.add_link("PI1", "PE1")
    p_topo.add_link("PI2", "PE2")
    p_topo.add_link("PI3", "PE3")

    # For each slice, two endpoints attached appropriately.
    # R    \ /     G
    #       1
    #      / \
    #   --3---2--
    #    /     \
    #       B
    p_topo.add_host("GH1")
    p_topo.add_link("GH1", "PE1")
    p_topo.add_host("GH2")
    p_topo.add_link("GH2", "PE2")
    p_topo.add_host("BH1")
    p_topo.add_link("BH1", "PE2")
    p_topo.add_host("BH2")
    p_topo.add_link("BH2", "PE3")
    p_topo.add_host("RH1")
    p_topo.add_link("RH1", "PE3")
    p_topo.add_host("RH2")
    p_topo.add_link("RH2", "PE1")

    p_topo.finalize()

    green_switches = ("PE1", "PI1", "PI2", "PE2")
    blue_switches  = ("PE2", "PI2", "PI3", "PE3")
    red_switches   = ("PE3", "PI3", "PI1", "PE1")

    green_hosts = ("GH1", "GH2")
    blue_hosts  = ("BH1", "BH2")
    red_hosts   = ("RH1", "RH2")

    green_nodes = green_switches + green_hosts
    blue_nodes  = blue_switches  + blue_hosts
    red_nodes   = red_switches   + red_hosts

    green_topo = p_topo.subgraph(green_nodes)
    blue_topo  = p_topo.subgraph(blue_nodes)
    red_topo   = p_topo.subgraph(red_nodes)

    green_ports = util.ports_of_topo(green_topo)
    blue_ports  = util.ports_of_topo(blue_topo)
    red_ports   = util.ports_of_topo(red_topo)

    g_s_map = util.id_map(green_topo.switches())
    b_s_map = util.id_map(blue_topo.switches())
    r_s_map = util.id_map(red_topo.switches())

    g_p_map = util.id_map(green_ports)
    b_p_map = util.id_map(blue_ports)
    r_p_map = util.id_map(red_ports)

    g_preds = util.build_external_predicate(green_topo)
    b_preds = util.build_external_predicate(blue_topo)
    r_preds = util.build_external_predicate(red_topo)

    green_slice = slicing.Slice(green_topo, p_topo, g_s_map, g_p_map, g_preds)
    blue_slice  = slicing.Slice(blue_topo,  p_topo, b_s_map, b_p_map, b_preds)
    red_slice   = slicing.Slice(red_topo,   p_topo, r_s_map, r_p_map, r_preds)

    return p_topo, (green_slice, blue_slice, red_slice)