def get_service_endpoints(self): """ Get all service endpoints. This information will feed information from the ServicePathEnpdoint model. Model for this table is as follows: class ServicePathEndpoints(BaseModel): id = IntegerField(primary_key=True) cpu_uti_last_one_min = IntegerField(null=True) hostname = CharField(null=True) ip = CharField(unique=True) model = CharField(null=True) snmp_contact = CharField(null=True) snmp_location = CharField(null=True) sysuptime = IntegerField(null=True) tunnel_count = IntegerField(null=True) class Meta: db_table = 'service_path_endpoints' """ endpoint_out = ServicePathEndpoints.select() return endpoint_out
def update_service_endpoint( self, ip, hostname, snmp_location, snmp_contact, model, sysuptime, tunnel_count, cpu_uti_last_one_min): """ Get all service endpoints. This information will feed information from the ServicePathEnpdoint model. Model for this table is as follows: class ServicePathEndpoints(BaseModel): id = IntegerField(primary_key=True) cpu_uti_last_one_min = IntegerField(null=True) hostname = CharField(null=True) ip = CharField(unique=True) model = CharField(null=True) snmp_contact = CharField(null=True) snmp_location = CharField(null=True) sysuptime = IntegerField(null=True) tunnel_count = IntegerField(null=True) class Meta: db_table = 'service_path_endpoints' """ best_ip = ip endpoint_out = ServicePathEndpoints.update(hostname=hostname, snmp_location=snmp_location, snmp_contact=snmp_contact, model=model, sysuptime=sysuptime, tunnel_count=tunnel_count, cpu_uti_last_one_min=cpu_uti_last_one_min).where(ServicePathEndpoints.ip == best_ip) endpoint_out.execute() return endpoint_out
def get_or_create_service_endpoint(self, ip): """ Get a service endpoint, if it does not exist, create it. This information will feed information into the background ServicePathSNMP tool to provide snmp data for best path endpoint. Model for this table is as follows: class ServicePathEndpoints(BaseModel): id = IntegerField(primary_key=True) cpu_uti_last_one_min = IntegerField(null=True) hostname = CharField(null=True) ip = CharField(unique=True) model = CharField(null=True) snmp_contact = CharField(null=True) snmp_location = CharField(null=True) sysuptime = IntegerField(null=True) tunnel_count = IntegerField(null=True) class Meta: db_table = 'service_path_endpoints' """ endpoint_out = ServicePathEndpoints.get_or_create(ip=ip) return endpoint_out