Пример #1
0
    def _check_peer_endpoint_ip_versions(self, group_id, peer_cidrs):
        """Ensure all CIDRs in endpoint group have the same IP version.

        Will return the IP version, so it can be used for inter-group testing.
        """
        if len(peer_cidrs) == 1:
            return netaddr.IPNetwork(peer_cidrs[0]).version
        ip_versions = set([netaddr.IPNetwork(pc).version for pc in peer_cidrs])
        if len(ip_versions) > 1:
            raise vpnaas.MixedIPVersionsForIPSecEndpoints(group=group_id)
        return ip_versions.pop()
Пример #2
0
    def _check_local_endpoint_ip_versions(self, group_id, local_subnets):
        """Ensure all subnets in endpoint group have the same IP version.

        Will return the IP version, so it can be used for inter-group testing.
        """
        if len(local_subnets) == 1:
            return local_subnets[0]['ip_version']
        ip_versions = set([subnet['ip_version'] for subnet in local_subnets])
        if len(ip_versions) > 1:
            raise vpnaas.MixedIPVersionsForIPSecEndpoints(group=group_id)
        return ip_versions.pop()