blob: c0361e6f77cb1b24219d9976e433f77433377dc3 [file] [log] [blame]
Murat Parlakisik638c65f2017-05-31 11:10:24 +03001default_attributes = {"sflow_port": SFLOW_PORT, "sflow_api_port": SFLOW_API_PORT}
2
3sync_attributes = ("sflow_port", "sflow_api_port",)
4
5@property
6def sflow_port(self):
7 return self.get_attribute("sflow_port", self.default_attributes["sflow_port"])
8
9@sflow_port.setter
10def sflow_port(self, value):
11 self.set_attribute("sflow_port", value)
12
13@property
14def sflow_api_port(self):
15 return self.get_attribute("sflow_api_port", self.default_attributes["sflow_api_port"])
16
17@sflow_api_port.setter
18def sflow_api_port(self, value):
19 self.set_attribute("sflow_api_port", value)
20
21def get_instance(self):
22 if self.slices.exists():
23 slice = self.slices.all()[0]
24 if slice.instances.exists():
25 return slice.instances.all()[0]
26
27 return None
28
29@property
30def sflow_api_url(self):
31 if not self.get_instance():
32 return None
33 return "http://" + self.get_instance().get_ssh_ip() + ":" + str(self.sflow_api_port) + "/"