Repository navigation
Expand file tree
/
Copy pathHostTrackerAPI.py
More file actions
50 lines (42 loc) · 2 KB
/
Copy pathHostTrackerAPI.py
File metadata and controls
50 lines (42 loc) · 2 KB
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
43
44
45
46
47
48
49
50
"""
"""
from BasicAPI import *
from RequestData import *
class HostTrackerAPI(BasicAPI):
def __init__(self, format):
BasicAPI.__init__(self, format, app='hosttracker')
def retrieve_host_by_address(self, networkAddress, container):
self.uri = '/' + self.app + '/' + \
container + '/address/' + networkAddress
self.methd = 'GET'
self.data = None
self.headers = {'Accept': 'application/' + self.format}
return RequestData(uri=self.uri, method=self.method, data=self.data, headers=self.headers)
def add_host(self, hostConfig, container):
self.uri = '/' + self.app + '/' + \
container + '/address/' + hostConfig['networkAddress']
self.method = 'PUT'
self.data = hostConfig
self.headers = {'Accept': 'application/' + self.format,
'Content-type': 'application/' +self.format
}
return RequestData(uri=self.uri, method=self.method, data=self.data, headers=self.headers)
def del_host(self, networkAddress, container):
self.uri = '/' + self.app + '/' + \
container + '/address/' + networkAddress
self.method = 'DELETE'
self.data = None
self.headers = {'Accept': 'application/' + self.format}
return RequestData(uri=self.uri, method=self.method, data=self.data, headers=self.headers)
def retrieve_active_hosts(self, container):
self.uri = '/' + self.app + '/' + container + '/hosts/active'
self.method = 'GET'
self.data = None
self.headers = {'Accept': 'application/' + self.format}
return RequestData(uri=self.uri, method=self.method, data=self.data, headers=self.headers)
def retrieve_inactive_hosts(self, container):
self.uri = '/' + self.app + '/' + container + '/hosts/inactive'
self.method = 'GET'
self.data = None
self.headers = {'Accept': 'application/' + self.format}
return RequestData(uri=self.uri, method=self.method, data=self.data, headers=self.headers)