def test_Endpoint(): """ Tests Endpoint """ endpoint = endpoint_factory('foo') b = endpoint.encode() c = EndpointDecoder(b).get_endpoint() a = {'tenant': 'foo', 'mac': '00:00:00:00:00:00'} hashed_val = Endpoint.make_hash(a)
def get_stored_endpoints(self): # load existing endpoints if any if self.r: try: p_endpoints = self.r.get('p_endpoints') if p_endpoints: p_endpoints = ast.literal_eval(p_endpoints.decode('ascii')) self.endpoints = [] for endpoint in p_endpoints: self.endpoints.append( EndpointDecoder(endpoint).get_endpoint()) except Exception as e: # pragma: no cover self.logger.error( 'Unable to get existing endpoints from Redis because {0}'.format(str(e))) return
def get_stored_endpoints(self): ''' load existing endpoints from Redis. ''' if self.r: try: p_endpoints = self.r.get('p_endpoints') if p_endpoints: new_endpoints = {} p_endpoints = ast.literal_eval(p_endpoints.decode('ascii')) for p_endpoint in p_endpoints: endpoint = EndpointDecoder(p_endpoint).get_endpoint() new_endpoints[endpoint.name] = endpoint return new_endpoints except Exception as e: # pragma: no cover self.logger.error( 'Unable to get existing endpoints from Redis because {0}'. format(str(e))) return {}