def get_request(cls, context, subnet, subnetpool): LOG.info("BCN: get_request subnet: %s" % subnet) cidr = subnet.get('cidr') name = None if 'name' in subnet.keys(): name = subnet.get('name') LOG.info("BCN: Request - set subnet.name : %s" % (name)) subnet_id = subnet.get('id', uuidutils.generate_uuid()) is_any_subnetpool_request = not validators.is_attr_set(cidr) if is_any_subnetpool_request: prefixlen = subnet['prefixlen'] if not validators.is_attr_set(prefixlen): prefixlen = int(subnetpool['default_prefixlen']) LOG.info("BCN: returning AnySubnetRequest, name=%s" % (name)) return AnySubnetRequest( subnet['tenant_id'], subnet_id, common_utils.ip_version_from_int(subnetpool['ip_version']), prefixlen, None, None, name) else: LOG.info("BCN: returning SpecificSubnetRequest") return SpecificSubnetRequest(subnet['tenant_id'], subnet_id, cidr, subnet.get('gateway_ip'), subnet.get('allocation_pools'), name)
def get_request(cls, context, subnet, subnetpool): cidr = subnet.get('cidr') cidr = cidr if validators.is_attr_set(cidr) else None gateway_ip = subnet.get('gateway_ip') gateway_ip = gateway_ip if validators.is_attr_set(gateway_ip) else None subnet_id = subnet.get('id', uuidutils.generate_uuid()) is_any_subnetpool_request = not (cidr or gateway_ip) if is_any_subnetpool_request: prefixlen = subnet['prefixlen'] if not validators.is_attr_set(prefixlen): prefixlen = int(subnetpool['default_prefixlen']) return AnySubnetRequest( subnet['tenant_id'], subnet_id, common_utils.ip_version_from_int(subnetpool['ip_version']), prefixlen) else: alloc_pools = subnet.get('allocation_pools') alloc_pools = (alloc_pools if validators.is_attr_set(alloc_pools) else None) if not cidr and gateway_ip: prefixlen = subnet['prefixlen'] if not validators.is_attr_set(prefixlen): prefixlen = int(subnetpool['default_prefixlen']) gw_ip_net = netaddr.IPNetwork('%s/%s' % (gateway_ip, prefixlen)) cidr = gw_ip_net.cidr return SpecificSubnetRequest(subnet['tenant_id'], subnet_id, cidr, gateway_ip=gateway_ip, allocation_pools=alloc_pools)
def _make_subnet_request(self, tenant_id, subnet, subnetpool): cidr = subnet.get('cidr') subnet_id = subnet.get('id', uuidutils.generate_uuid()) is_any_subnetpool_request = not attributes.is_attr_set(cidr) if is_any_subnetpool_request: prefixlen = subnet['prefixlen'] if not attributes.is_attr_set(prefixlen): prefixlen = int(subnetpool['default_prefixlen']) return ipam.AnySubnetRequest( tenant_id, subnet_id, utils.ip_version_from_int(subnetpool['ip_version']), prefixlen) else: return ipam.SpecificSubnetRequest(tenant_id, subnet_id, cidr)
def get_request(cls, context, subnet, subnetpool): cidr = subnet.get('cidr') subnet_id = subnet.get('id', uuidutils.generate_uuid()) is_any_subnetpool_request = not attributes.is_attr_set(cidr) if is_any_subnetpool_request: prefixlen = subnet['prefixlen'] if not attributes.is_attr_set(prefixlen): prefixlen = int(subnetpool['default_prefixlen']) return AnySubnetRequest( subnet['tenant_id'], subnet_id, common_utils.ip_version_from_int(subnetpool['ip_version']), prefixlen) else: return SpecificSubnetRequest(subnet['tenant_id'], subnet_id, cidr)
def get_request(cls, context, subnet, subnetpool): cidr = subnet.get("cidr") subnet_id = subnet.get("id", uuidutils.generate_uuid()) is_any_subnetpool_request = not attributes.is_attr_set(cidr) if is_any_subnetpool_request: prefixlen = subnet["prefixlen"] if not attributes.is_attr_set(prefixlen): prefixlen = int(subnetpool["default_prefixlen"]) return AnySubnetRequest( subnet["tenant_id"], subnet_id, common_utils.ip_version_from_int(subnetpool["ip_version"]), prefixlen ) else: return SpecificSubnetRequest( subnet["tenant_id"], subnet_id, cidr, subnet.get("gateway_ip"), subnet.get("allocation_pools") )
def get_request(cls, context, subnet, subnetpool): """Return RomanaAnySubnetRequest.""" LOG.debug("RomanaSubnetRequestFactory.get_request()") cidr = subnet.get('cidr') subnet_id = subnet.get('id', uuidutils.generate_uuid()) is_any_subnetpool_request = not attributes.is_attr_set(cidr) if is_any_subnetpool_request: prefixlen = subnet['prefixlen'] if not attributes.is_attr_set(prefixlen): prefixlen = int(subnetpool['default_prefixlen']) return RomanaAnySubnetRequest( subnet['tenant_id'], subnet_id, common_utils.ip_version_from_int(subnetpool['ip_version']), prefixlen) else: return ipam_req.SpecificSubnetRequest( subnet['tenant_id'], subnet_id, cidr, subnet.get('gateway_ip'), subnet.get('allocation_pools'))
def get_request(cls, context, subnet, subnetpool): """Return RomanaAnySubnetRequest.""" LOG.debug("RomanaSubnetRequestFactory.get_request()") cidr = subnet.get('cidr') subnet_id = subnet.get('id', uuidutils.generate_uuid()) is_any_subnetpool_request = not attributes.is_attr_set(cidr) if is_any_subnetpool_request: prefixlen = subnet['prefixlen'] if not attributes.is_attr_set(prefixlen): prefixlen = int(subnetpool['default_prefixlen']) return RomanaAnySubnetRequest( subnet['tenant_id'], subnet_id, common_utils.ip_version_from_int(subnetpool['ip_version']), prefixlen) else: return ipam_req.SpecificSubnetRequest(subnet['tenant_id'], subnet_id, cidr, subnet.get('gateway_ip'), subnet.get( 'allocation_pools'))
def test_ip_version_from_int_ipv6(self): self.assertEqual(utils.ip_version_from_int(6), constants.IPv6)
def test_ip_version_from_int_ipv6(self): self.assertEqual(constants.IPv6, utils.ip_version_from_int(constants.IP_VERSION_6))
def test_ip_version_from_int_ipv4(self): self.assertEqual(constants.IPv4, utils.ip_version_from_int(4))