Passed
Pull Request — master (#96)
by
unknown
01:59
created

build.models.Status.as_dict()   A

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 1
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
"""Most relevant classes to be used on the topology."""
2
3
4
__all__ = ('Host', 'Topology')
5
6
7
class Topology:
8
    """Represent the topology with links and switches."""
9
10
    def __init__(self, switches, links):
11
        """Create a instance of Topology."""
12
        self.switches = switches
13
        self.links = links
14
15
16
class Host:
17
    """Represents the Host."""
18
19
    def __init__(self, mac):
20
        """Create a instance of Host."""
21
        self.mac = mac
22
23
    @property
24
    def id(self):  # pylint: disable=invalid-name
25
        """Return the host id."""
26
        return self.mac
27
28
    def as_dict(self):
29
        """Return a dict representation of a Host."""
30
        return {'mac': self.mac,
31
                'type': 'host'}
32
33
34
class Status:
35
    """Represents the administratively the network status."""
36
37
    def __init__(self, status_id, status):
38
        """Create a instance the network status."""
39
        self.status = status
40
        self.status_id = status_id
41
42
    @property
43
    def id(self):  # pylint: disable=invalid-name
44
        """Return the status id."""
45
        return self.status_id
46
47
    def as_dict(self):
48
        """Return a dict."""
49
        return {'id': self.status_id,
50
                'status': self.status}
51