Beispiel #1
0
    def node_id(self, node_id):
        """
        Setter for the `Node` associated
        with the device

        Parameters
        ----------
        node : str
            The id of the node where the device is to be installed
        """
        self._traffic_control_handler.node_id = node_id
        if node_id is not None:
            TopologyMap.add_interface(self.node_id, self._id, self._name)
Beispiel #2
0
    def _add_interface(self, interface):
        """
        Add `interface` to `Node`

        Parameters
        ----------
        interface: Interface
            `Interface` to be added to `Node`
        """
        self._interfaces.append(interface)
        interface.node = self
        engine.add_int_to_ns(self.id, interface.id)
        TopologyMap.add_interface(self.id, interface.id, interface.name)
Beispiel #3
0
    def setUp(self):
        # Define namespace id and names
        self.ns_id1 = "ns_id1"
        self.ns_id2 = "ns_id2"
        self.ns_name1 = "ns_name1"
        self.ns_name2 = "ns_name2"

        # Add namespaces
        TopologyMap.add_namespace(self.ns_id1, self.ns_name1)
        TopologyMap.add_namespace(self.ns_id2, self.ns_name2)

        # Define interface id and names
        self.int_id1 = "int_id1"
        self.int_id2 = "int_id2"
        self.int_name1 = "int_name1"
        self.int_name2 = "int_name2"

        # Add interfaces
        TopologyMap.add_interface(self.ns_id1, self.int_id1, self.int_name1)
        TopologyMap.add_interface(self.ns_id1, self.int_id2, self.int_name2)
Beispiel #4
0
    def __init__(self, name, node_id):
        """
        Constructore for a device

        Parameters
        ----------
        name : str
            User given name for the device
        node_id : str
            This is the id of the node that the device belongs to
        """

        if config.get_value("assign_random_names") is False:
            if len(name) > MAX_CUSTOM_NAME_LEN:
                raise ValueError(
                    f"Device name {name} is too long. Device names "
                    f"should not exceed 15 characters")

        self._name = name
        self._id = IdGen.get_id(name)
        self._traffic_control_handler = TrafficControlHandler(
            node_id, self._id)
        if node_id is not None:
            TopologyMap.add_interface(self.node_id, self._id, self._name)
Beispiel #5
0
 def test_add_same_entity_again(self):
     with self.assertRaises(ValueError):
         TopologyMap.add_namespace(self.ns_id1, self.ns_name1)
     with self.assertRaises(ValueError):
         TopologyMap.add_interface(self.ns_id1, self.int_id1,
                                   self.int_name1)