Quantcast
Viewing all articles
Browse latest Browse all 2

Answer by gongysh for Assuming Quantum doesnt have a mechanism to query and see if a new subnet CIDR that i want to create doesnt overlaps with the existing subnet CIDR's. I want to do this before creating a subnet, i want to find if an overlapping subnet cidr exists. If above is true then.. I know this is not directly related to the Quantum work, I need a Java library or Algorithm to find if 2 CIDR's overlap. Any help is greatly appreciated

this is python one quantum is using: def _validate_subnet_cidr(self, context, network, new_subnet_cidr): """Validate the CIDR for a subnet. Verifies the specified CIDR does not overlap with the ones defined for the other subnets specified for this network, or with any other CIDR if overlapping IPs are disabled. """ new_subnet_ipset = netaddr.IPSet([new_subnet_cidr]) if cfg.CONF.allow_overlapping_ips: subnet_list = network.subnets else: subnet_list = self._get_all_subnets(context) for subnet in subnet_list: if (netaddr.IPSet([subnet.cidr]) & new_subnet_ipset): # don't give out details of the overlapping subnet err_msg = (_("Requested subnet with cidr: %(cidr)s for " "network: %(network_id)s overlaps with another " "subnet") % {'cidr': new_subnet_cidr, 'network_id': network.id}) LOG.error(_("Validation for CIDR: %(new_cidr)s failed - " "overlaps with subnet %(subnet_id)s " "(CIDR: %(cidr)s)"), {'new_cidr': new_subnet_cidr, 'subnet_id': subnet.id, 'cidr': subnet.cidr}) raise q_exc.InvalidInput(error_message=err_msg)

Viewing all articles
Browse latest Browse all 2

Trending Articles