-
Notifications
You must be signed in to change notification settings - Fork 7
/
instance.py
88 lines (64 loc) · 2.01 KB
/
instance.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Copyright (c) 2019, Substratum LLC (https://substratum.net) and/or its affiliates. All rights reserved.
BINARIES = [
"MASQNode",
"dns_utility",
]
class Instance:
def __init__(self, node_id, instance_api):
self._index_name = make_index_name(node_id)
self._machine_name = instance_api.machine_name()
self.node_id = node_id
self.instance_api = instance_api
self.dns = self.instance_api.dns
self.traffic = self.instance_api.traffic
self.node = self.instance_api.node
self.attributes = {}
self.binaries_version = None
def start(self):
self.instance_api.start_instance()
return self
def kill(self):
return self.instance_api.stop_instance()
def restart(self):
return self.instance_api.restart_instance()
def index_name(self):
return self._index_name
def machine_name(self):
return self._machine_name
def get_ip(self):
return self.instance_api.get_external_ip()
def shell(self):
self.node.shell()
def update(self):
self.node.update()
def start_node(self, neighbor_info=""):
return self.node.start(self.get_ip(), neighbor_info)
def stop_node(self):
self.dns.revert()
self.traffic.stop()
self.node.shutdown()
def retrieve_logs(self, to_dir="/tmp"):
self.node.retrieve_logs(to_dir)
def tail(self):
self.node.tail()
def inspect(self):
self.node.display_neighborhood()
def inbound(self):
self.node.gossip_received()
def outbound(self):
self.node.gossip_produced()
def subvert(self):
self.dns.subvert()
def revert(self):
self.traffic.stop()
self.dns.revert()
def verify(self):
self.traffic.verify()
def curl(self):
self.dns.subvert()
self.traffic.curl()
def wget(self):
self.dns.subvert()
self.traffic.wget()
def make_index_name(node_id):
return "node-%s" % int(node_id)