Code

< 40 %
40-60 %
> 60 %
1
"""Most relevant classes to be used on the topology."""
2
3
4 1
__all__ = ('Host', 'Topology')
5
6
7 1
class Topology:
8
    """Represent the topology with links and switches."""
9
10 1
    def __init__(self, switches, links):
11
        """Create a instance of Topology."""
12 1
        self.switches = switches
13 1
        self.links = links
14
15
16 1
class Host:
17
    """Represents the Host."""
18
19 1
    def __init__(self, mac):
20
        """Create a instance of Host."""
21 1
        self.mac = mac
22
23 1
    @property
24 1
    def id(self):  # pylint: disable=invalid-name
25
        """Return the host id."""
26 1
        return self.mac
27
28 1
    def as_dict(self):
29
        """Return a dict representation of a Host."""
30 1
        return {'mac': self.mac,
31
                'type': 'host'}
32