Murat Parlakisik | 638c65f | 2017-05-31 11:10:24 +0300 | [diff] [blame^] | 1 | default_attributes = {"sflow_port": SFLOW_PORT, "sflow_api_port": SFLOW_API_PORT} |
| 2 | |
| 3 | sync_attributes = ("sflow_port", "sflow_api_port",) |
| 4 | |
| 5 | @property |
| 6 | def sflow_port(self): |
| 7 | return self.get_attribute("sflow_port", self.default_attributes["sflow_port"]) |
| 8 | |
| 9 | @sflow_port.setter |
| 10 | def sflow_port(self, value): |
| 11 | self.set_attribute("sflow_port", value) |
| 12 | |
| 13 | @property |
| 14 | def sflow_api_port(self): |
| 15 | return self.get_attribute("sflow_api_port", self.default_attributes["sflow_api_port"]) |
| 16 | |
| 17 | @sflow_api_port.setter |
| 18 | def sflow_api_port(self, value): |
| 19 | self.set_attribute("sflow_api_port", value) |
| 20 | |
| 21 | def 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 |
| 30 | def 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) + "/" |