def test_mininet_conversion_to_logical():
    """Test the conversion from a mininet logical network to a logical one."""

    import networkx as nx
    from distriopt import VirtualNetwork
    from mininet.topo import Topo

    virt_topo_mn = Topo()

    # Add nodes
    u = virt_topo_mn.addHost("u", cores=2, memory=1000)
    v = virt_topo_mn.addHost("v", cores=2, memory=1000)
    z = virt_topo_mn.addSwitch("z", cores=2, memory=1000)
    # Add links
    virt_topo_mn.addLink(u, v, rate=1000)
    virt_topo_mn.addLink(v, z, rate=1000)
    virt_topo_mn.addLink(u, z, rate=1000)

    virtual_topo = VirtualNetwork.from_mininet(virt_topo_mn)

    assert virtual_topo.number_of_nodes() == 3
    assert len(virtual_topo.edges()) == 3
    assert nx.is_connected(virtual_topo.g)

    for node in virtual_topo.nodes():
        assert virtual_topo.req_cores(node) == 2
        assert virtual_topo.req_memory(node) == 1000
    for i, j in virtual_topo.edges():
        assert virtual_topo.req_rate(i, j) == 1000
예제 #2
0
 def __init__(self, virtual, physical):
     """"""
     self.virtual = (VirtualNetwork.from_mininet(virtual) if isinstance(
         virtual, Topo) else virtual)
     self.physical = physical
     self.solution = None
     self.status = NotSolved
     self.lb = 0
예제 #3
0
파일: mapper.py 프로젝트: helllb/Distrinet
    def __init__(self, virtual_topo, physical_topo, solver=EmbedGreedy):
        """ virtual_topo: virtual topology to map
            physical_topo: physical topology to map on
            solver: solver class to use to solve the mapping"""
        self.virtual_topo = VirtualNetwork.from_mininet(virtual_topo)
        self.mininet_virtual = virtual_topo
        self.physical_topo = PhysicalNetwork.from_files(physical_topo)
        self.prob = None
        self.solver = solver
        self.solve()

        self.places = self.__places()
예제 #4
0
파일: mapper.py 프로젝트: helllb/Distrinet
    def __init__(self, virtual_topo, cloud_prices, solver=BestFitDopProduct):
        """ virtual_topo: virtual topology to map
            physical_topo: physical topology to map on
            solver: solver class to use to solve the mapping"""
        self.virtual_topo = VirtualNetwork.from_mininet(virtual_topo)
        self.cloud = CloudInstance.read_ec2_instances(vm_type=cloud_prices)
        self.mininet_virtual = virtual_topo
        self.prob = None

        self.solver = solver

        self.places = self.__places()