def test_find_endpoint(self): self.assertIsNone(find_endpoint(self.EXAMPLE_IP[0], self.EXAMPLE_IP[0])) end1 = create_endpoint(self.EXAMPLE_IP[0], self.EXAMPLE_IP[0]) end1_find = find_endpoint(self.EXAMPLE_IP[0], self.EXAMPLE_IP[0]) self.assertEqual(end1, end1_find) self.assertIsNone(find_endpoint(self.EXAMPLE_IP[0], self.EXAMPLE_IP[1])) end2 = create_endpoint(self.EXAMPLE_IP[0], self.EXAMPLE_IP[1]) end2_find = find_endpoint(self.EXAMPLE_IP[0], self.EXAMPLE_IP[1]) self.assertEqual(end2, end2_find) self.assertIsNone(find_endpoint(self.EXAMPLE_IP[1], self.EXAMPLE_IP[0]))
def extract_endpoint(src, dst): """ Reads endpoint pair object from user input data. If the endpoint has existing matching endpointpair in UNIS it will be returned instead. @returns: None, L{periscope.topology.models.EndPointPair}, or L{psapi.protocol.EndPointPair} """ if not src and not dst: return None endpoint = find_endpoint(src, dst) if endpoint: return endpoint endpoint = psEndPointPair(src=src, dst=dst) endpoint.src_type = None endpoint.dst_type = None return endpoint