build.tracing.trace_msg   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 88.24%

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 47
ccs 15
cts 17
cp 0.8824
rs 10
c 0
b 0
f 0
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A TraceMsg.request_id() 0 4 3
A TraceMsg._instantiate_vars() 0 8 1
A TraceMsg.__init__() 0 3 1
1
""" This module creates the TraceID message to be used as the
2
Ethernet payload of the PacketOut. This msg is important to
3
differentiate parallel traces.
4
"""
5
6
7 1
class TraceMsg(object):
8
    """ This class will be used to create, retrieve and update the
9
    payload message sent through the trace process
10
11
    Basically the msg is a dictionary:
12
13
    {"trace": {
14
            "request_id": "number to identify this trace"
15
        }
16
    }
17
    """
18
19 1
    def __init__(self, r_id='0'):
20 1
        self._request_id = None
21 1
        self._instantiate_vars(r_id)
22
23 1
    def _instantiate_vars(self, r_id):
24
        """ Attributes in the TraceMsg are processed as
25
        Getter and Setters.
26
27
        Args:
28
            r_id: request ID
29
        """
30 1
        self.request_id = r_id
31
32 1
    @property
33 1
    def request_id(self):
34
        """ Getter: Request ID """
35 1
        return self._request_id
36
37 1
    @request_id.setter
38 1
    def request_id(self, r_id):
39
        """ Setter: Request ID """
40 1
        try:
41 1
            if isinstance(r_id, int):
42 1
                self._request_id = r_id
43
            else:
44 1
                self._request_id = int(r_id)
45
        except ValueError:
46
            raise ValueError("Invalid ID provided: %s" % r_id)
47