def set_flow(self, chosen_paths):
        self.flows = {}
        # print "chosen_paths: ", chosen_paths

        # Create Flow Objects
        for cp in self.comm_pattern:
            fl = Flow(cp[0], cp[1], cp[2])
            self.flows[fl.get_end_points()] = fl

        for p in chosen_paths:
            path = p[1]

            link_list = []
            for i in range(len(path)-1):
                l = self.links[Link.get_id(path[i], path[i+1])]
                link_list.append(l)

            fl = self.flows[Flow.get_id(path[0], path[-1])]
            fl.set_path(link_list)

        for link in self.get_links().values():
            link.adjust_flow_bandwidths()
    def set_flow(self, chosen_paths):
        self.flows = {}
        # print "chosen_paths: ", chosen_paths

        # Create Flow Objects
        for cp in self.comm_pattern:
            fl = Flow(cp[0], cp[1], cp[2])
            self.flows[fl.get_end_points()] = fl

        for p in chosen_paths:
            path = p[1]

            link_list = []
            for i in range(len(path) - 1):
                l = self.links[Link.get_id(path[i], path[i + 1])]
                link_list.append(l)

            fl = self.flows[Flow.get_id(path[0], path[-1])]
            fl.set_path(link_list)

        for link in self.get_links().values():
            link.adjust_flow_bandwidths()
Esempio n. 3
0
 def test_flow(self):
     flow1 = Flow('host1', 'host2', 1000)
     self.assert_(flow1.get_requested_bandwidth() == 1000)
     self.assert_(flow1.get_end_points() == ('host1', 'host2'))
     self.assert_(not flow1.get_path())
 def test_flow(self):
     flow1 = Flow('host1', 'host2', 1000)
     self.assert_(flow1.get_requested_bandwidth() == 1000)
     self.assert_(flow1.get_end_points() == ('host1', 'host2'))
     self.assert_(not flow1.get_path())