-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDevice.py
42 lines (34 loc) · 1.18 KB
/
Device.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class Device(object):
def __init__(self):
self.statistics = {
'downspeed': 0,
'upspeed': 0
}
self.qos = {
'downspeed': 0,
'upspeed': 0
}
self.details = []
def from_response(self, response_device):
self.ip = response_device['ip']
self.hostname = response_device['name']
self.mac = response_device['mac']
self.statistics['downspeed'] = response_device['statistics']['downspeed']
self.statistics['upspeed'] = response_device['statistics']['upspeed']
self.qos['downspeed'] = response_device['qos']['downmax']
self.qos['upspeed'] = response_device['qos']['upmax']
def to_dict(self):
return {
'ip': self.ip,
'mac': self.mac,
'hostname': self.hostname,
'statistics': {
'downspeed': self.statistics['downspeed'],
'upspeed': self.statistics['upspeed']
},
'qos': {
'downspeed': self.qos['downspeed'],
'upspeed': self.qos['upspeed']
},
'details': self.details
}