コード例 #1
0
class DeviceTest(unittest.TestCase):
    def setUp(self):
        self.driver = OptinDriver()
        self.devices = self.driver.get_all_devices()

    def test_should_get_dpids(self):
        dpids = self.filter_device(DPID)
        self.assertEquals(5, len(dpids))

    def test_should_get_links(self):
        links = self.filter_device(Link)
        print("LINKS:---", len(links))
        for link in links:
            print("Link: SRC:",
                  link.get_src_dpid().get_datapath(), "port:",
                  link.get_src_port().get_num(), "DST:",
                  link.get_dst_dpid().get_datapath(), "port:",
                  link.get_dst_port().get_num())

    def filter_device(self, instance):
        devices = list()
        for device in self.devices:
            if isinstance(device, instance):
                devices.append(device)
        return devices
コード例 #2
0
ファイル: listresources.py プロジェクト: HalasNet/felix
class ListResourcesTest(unittest.TestCase):

    def setUp(self):
        self.driver = OptinDriver()
        self.devices = self.driver.get_all_devices()
        self.manager = OpenFlowRSpecManager()

    def test_should_list_resources(self):
        print(self.manager.compose_advertisement(self.devices))
コード例 #3
0
ファイル: devicetest.py プロジェクト: HalasNet/felix
class DeviceTest(unittest.TestCase):

    def setUp(self):
        self.driver = OptinDriver()
        self.devices = self.driver.get_all_devices()

    def test_should_get_dpids(self):
        dpids = self.filter_device(DPID)
        self.assertEquals(5, len(dpids))

    def test_should_get_links(self):
        links = self.filter_device(Link)
        print("LINKS:---",len(links))
        for link in links:
            print("Link: SRC:", link.get_src_dpid().get_datapath(),"port:", link.get_src_port().get_num(), "DST:", link.get_dst_dpid().get_datapath(),"port:", link.get_dst_port().get_num())

    def filter_device(self, instance):
        devices = list()
        for device in self.devices:
            if isinstance(device, instance):
                devices.append(device)
        return devices
コード例 #4
0
 def __init__(self):
     self.__driver = OptinDriver()
     self.START_ACTION = "START"
     self.STOP_ACTION = "STOP"
     self.REBOOT_ACTION = "REBOOT"
     self.DELETE_ACTION = "DELETE"
コード例 #5
0
class OptinRM(ResourceManagerBase):
    def __init__(self):
        self.__driver = OptinDriver()
        self.START_ACTION = "START"
        self.STOP_ACTION = "STOP"
        self.REBOOT_ACTION = "REBOOT"
        self.DELETE_ACTION = "DELETE"

    def get_version(self):
        return self.__driver.get_version()

    def get_resources(self, urns=None, geni_available=True):
        if urns:
            slivers = list()
            for urn in urns:
                slivers.append(
                    self.__driver.get_specific_devices(urn, geni_available))
            return slivers[0]
        else:
            return self.__driver.get_all_devices(geni_available)

    def create_resources(self,
                         urns,
                         expiration=None,
                         users=list(),
                         geni_best_effort=True):
        flowspaces = list()
        for urn in urns:
            flowspaces.append(
                self.__driver.create_flowspace(urn, expiration, users,
                                               geni_best_effort))
        return flowspaces[0]

    def reserve_resources(self,
                          slice_urn,
                          reservation,
                          expiration=None,
                          users=list()):
        return self.__driver.reserve_flowspace(slice_urn, reservation, users)

    def start_resources(self, urns, geni_best_effort=True):
        return self.__crud_resources(urns, geni_best_effort, self.START_ACTION)

    def stop_resources(self, urns, geni_best_effort):
        return self.__crud_resources(urns, geni_best_effort, self.STOP_ACTION)

    def reboot_resources(self, urns, geni_best_effort):
        return self.__crud_resources(urns, geni_best_effort,
                                     self.REBOOT_ACTION)

    def delete_resources(self, urns, geni_best_effort):
        return self.__crud_resources(urns, geni_best_effort,
                                     self.DELETE_ACTION)

    def renew_resources(self, urns, expiration, geni_best_effort=False):
        resources = list()
        self.__driver.set_geni_best_effort_mode(geni_best_effort)
        for urn in urns:
            try:
                resource = self.__driver.renew_fs(urn, expiration)
            except Exception as e:
                raise e
            if type(resource) == list:
                resources.extend(resource)
            else:
                resources.append(resource)
        return resources

    def __crud_resources(self, urns, geni_best_effort, action):
        self.__driver.set_geni_best_effort_mode(geni_best_effort)
        resources = list()
        for urn in urns:
            if action == self.START_ACTION:
                resource = self.__driver.start_flow_space(urn)
            elif action == self.STOP_ACTION:
                resource = self.__driver.stop_flow_space(urn)
            elif action == self.REBOOT_ACTION:
                resource = self.__driver.reboot_flow_space(urn)
            elif action == self.DELETE_ACTION:
                resource = self.__driver.delete_flow_space(urn)
            if type(resource) == list:
                resources.extend(resource)
            else:
                resources.append(resource)
        return resources

    def get_driver(self):
        return self.__driver

    def set_driver(self, value):
        self.__driver = value
コード例 #6
0
ファイル: devicetest.py プロジェクト: HalasNet/felix
 def setUp(self):
     self.driver = OptinDriver()
     self.devices = self.driver.get_all_devices()
コード例 #7
0
ファイル: optin.py プロジェクト: HalasNet/felix
 def get_optin_driver():
     driver = OptinDriver()
     driver.set_config(OptinConfig)
     return driver
コード例 #8
0
ファイル: optin.py プロジェクト: HalasNet/felix
 def __init__(self):
     self.__driver = OptinDriver()
     self.START_ACTION = "START"
     self.STOP_ACTION = "STOP"
     self.REBOOT_ACTION = "REBOOT"
     self.DELETE_ACTION = "DELETE"
コード例 #9
0
ファイル: optin.py プロジェクト: HalasNet/felix
class OptinRM(ResourceManagerBase):

    def __init__(self):
        self.__driver = OptinDriver()
        self.START_ACTION = "START"
        self.STOP_ACTION = "STOP"
        self.REBOOT_ACTION = "REBOOT"
        self.DELETE_ACTION = "DELETE"
 
    def get_version(self):
        return self.__driver.get_version()

    def get_resources(self, urns=None, geni_available=True):
        if urns:
            slivers = list()
            for urn in urns:
                 slivers.append(self.__driver.get_specific_devices(urn, geni_available))
            return slivers[0]
        else:
            return self.__driver.get_all_devices(geni_available)
    
    def create_resources(self, urns, expiration=None, users=list(), geni_best_effort=True):
        flowspaces = list()
        for urn in urns:
            flowspaces.append(self.__driver.create_flowspace(urn,expiration,users, geni_best_effort))
        return flowspaces[0]
    
    def reserve_resources(self, slice_urn, reservation, expiration=None, users=list()):
        return self.__driver.reserve_flowspace(slice_urn, reservation, users)

    def start_resources(self, urns, geni_best_effort=True):
        return self.__crud_resources(urns, geni_best_effort, self.START_ACTION)
    
    def stop_resources(self, urns, geni_best_effort):
        return self.__crud_resources(urns, geni_best_effort, self.STOP_ACTION) 
    
    def reboot_resources(self, urns, geni_best_effort):
        return self.__crud_resources(urns, geni_best_effort, self.REBOOT_ACTION)

    def delete_resources(self, urns, geni_best_effort):
        return self.__crud_resources(urns, geni_best_effort, self.DELETE_ACTION)

    def renew_resources(self, urns, expiration, geni_best_effort=False):
        resources = list()
        self.__driver.set_geni_best_effort_mode(geni_best_effort)
        for urn in urns:
            try:
                resource = self.__driver.renew_fs(urn, expiration)
            except Exception as e:
                raise e
            if type(resource) == list:
                resources.extend(resource)
            else:
                resources.append(resource)
        return resources

    def __crud_resources(self, urns, geni_best_effort, action):
        self.__driver.set_geni_best_effort_mode(geni_best_effort)
        resources = list()
        for urn in urns:
            if action == self.START_ACTION:
                resource = self.__driver.start_flow_space(urn)
            elif action == self.STOP_ACTION:
                resource = self.__driver.stop_flow_space(urn)
            elif action == self.REBOOT_ACTION:
                resource = self.__driver.reboot_flow_space(urn)
            elif action == self.DELETE_ACTION:
                resource = self.__driver.delete_flow_space(urn)
            if type(resource) == list:
                resources.extend(resource)
            else:
                resources.append(resource)
        return resources

    def get_driver(self):
        return self.__driver

    def set_driver(self, value):
        self.__driver = value     
コード例 #10
0
ファイル: listresources.py プロジェクト: HalasNet/felix
 def setUp(self):
     self.driver = OptinDriver()
     self.devices = self.driver.get_all_devices()
     self.manager = OpenFlowRSpecManager()
コード例 #11
0
 def get_optin_driver():
     driver = OptinDriver()
     driver.set_config(OptinConfig)
     return driver
コード例 #12
0
 def setUp(self):
     self.driver = OptinDriver()
     self.devices = self.driver.get_all_devices()