コード例 #1
0
    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)
コード例 #2
0
    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)
コード例 #3
0
    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)
コード例 #4
0
    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)
コード例 #5
0
ファイル: requests.py プロジェクト: walterleonardo/neutron
    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")
            )
コード例 #6
0
ファイル: __init__.py プロジェクト: rajeshmohan/neutron
    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)
コード例 #7
0
ファイル: db_base_plugin_v2.py プロジェクト: tealover/neutron
    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)
コード例 #8
0
    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'))
コード例 #9
0
    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'))
コード例 #10
0
ファイル: test_utils.py プロジェクト: cisco-openstack/neutron
 def test_ip_version_from_int_ipv6(self):
     self.assertEqual(utils.ip_version_from_int(6),
                      constants.IPv6)
コード例 #11
0
 def test_ip_version_from_int_ipv6(self):
     self.assertEqual(constants.IPv6,
                      utils.ip_version_from_int(constants.IP_VERSION_6))
コード例 #12
0
 def test_ip_version_from_int_ipv6(self):
     self.assertEqual(utils.ip_version_from_int(6), constants.IPv6)
コード例 #13
0
ファイル: test_utils.py プロジェクト: TakeshiTseng/neutron
 def test_ip_version_from_int_ipv4(self):
     self.assertEqual(constants.IPv4,
                      utils.ip_version_from_int(4))
コード例 #14
0
ファイル: test_utils.py プロジェクト: weizai118/neutron
 def test_ip_version_from_int_ipv4(self):
     self.assertEqual(constants.IPv4, utils.ip_version_from_int(4))
コード例 #15
0
ファイル: test_utils.py プロジェクト: igordcard/neutron
 def test_ip_version_from_int_ipv6(self):
     self.assertEqual(constants.IPv6,
                      utils.ip_version_from_int(constants.IP_VERSION_6))