moved address type constants to ip_types file
This commit is contained in:
@@ -1,3 +0,0 @@
|
|||||||
SHARED = 'shared'
|
|
||||||
FIXED = 'fixed'
|
|
||||||
FLOATING = 'floating'
|
|
||||||
|
|||||||
3
quark/db/ip_types.py
Normal file
3
quark/db/ip_types.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
SHARED = 'shared'
|
||||||
|
FIXED = 'fixed'
|
||||||
|
FLOATING = 'floating'
|
||||||
@@ -25,9 +25,7 @@ from sqlalchemy.ext import hybrid
|
|||||||
from sqlalchemy import orm
|
from sqlalchemy import orm
|
||||||
|
|
||||||
from quark.db import custom_types
|
from quark.db import custom_types
|
||||||
from quark.db import FIXED
|
from quark.db import ip_types
|
||||||
from quark.db import FLOATING
|
|
||||||
from quark.db import SHARED
|
|
||||||
# NOTE(mdietz): This is the only way to actually create the quotas table,
|
# NOTE(mdietz): This is the only way to actually create the quotas table,
|
||||||
# regardless if we need it. This is how it's done upstream.
|
# regardless if we need it. This is how it's done upstream.
|
||||||
# NOTE(jhammond): If it isn't obvious quota_driver is unused and that's ok.
|
# NOTE(jhammond): If it isn't obvious quota_driver is unused and that's ok.
|
||||||
@@ -159,7 +157,8 @@ class IPAddress(BASEV2, models.HasId):
|
|||||||
# Legacy data
|
# Legacy data
|
||||||
used_by_tenant_id = sa.Column(sa.String(255))
|
used_by_tenant_id = sa.Column(sa.String(255))
|
||||||
|
|
||||||
address_type = sa.Column(sa.Enum(FIXED, FLOATING, SHARED,
|
address_type = sa.Column(sa.Enum(ip_types.FIXED, ip_types.FLOATING,
|
||||||
|
ip_types.SHARED,
|
||||||
name="quark_ip_address_types"))
|
name="quark_ip_address_types"))
|
||||||
associations = orm.relationship(PortIpAssociation, backref="ip_address")
|
associations = orm.relationship(PortIpAssociation, backref="ip_address")
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ from oslo.config import cfg
|
|||||||
from oslo.db import exception as db_exception
|
from oslo.db import exception as db_exception
|
||||||
|
|
||||||
from quark.db import api as db_api
|
from quark.db import api as db_api
|
||||||
from quark.db import FIXED
|
from quark.db import ip_types
|
||||||
from quark.db import models
|
from quark.db import models
|
||||||
from quark import exceptions as q_exc
|
from quark import exceptions as q_exc
|
||||||
from quark import utils
|
from quark import utils
|
||||||
@@ -300,7 +300,7 @@ class QuarkIpam(object):
|
|||||||
allocated_at=timeutils.utcnow(),
|
allocated_at=timeutils.utcnow(),
|
||||||
port_id=port_id,
|
port_id=port_id,
|
||||||
address_type=kwargs.get('address_type',
|
address_type=kwargs.get('address_type',
|
||||||
FIXED))
|
ip_types.FIXED))
|
||||||
return [updated_address]
|
return [updated_address]
|
||||||
else:
|
else:
|
||||||
# Make sure we never find it again
|
# Make sure we never find it again
|
||||||
@@ -350,7 +350,7 @@ class QuarkIpam(object):
|
|||||||
deallocated=0, version=subnet["ip_version"],
|
deallocated=0, version=subnet["ip_version"],
|
||||||
network_id=net_id,
|
network_id=net_id,
|
||||||
port_id=port_id,
|
port_id=port_id,
|
||||||
address_type=kwargs.get('address_type', FIXED))
|
address_type=kwargs.get('address_type', ip_types.FIXED))
|
||||||
address["deallocated"] = 0
|
address["deallocated"] = 0
|
||||||
except Exception:
|
except Exception:
|
||||||
# NOTE(mdietz): Our version of sqlalchemy incorrectly raises None
|
# NOTE(mdietz): Our version of sqlalchemy incorrectly raises None
|
||||||
@@ -433,7 +433,8 @@ class QuarkIpam(object):
|
|||||||
deallocated_at=None,
|
deallocated_at=None,
|
||||||
used_by_tenant_id=context.tenant_id,
|
used_by_tenant_id=context.tenant_id,
|
||||||
allocated_at=timeutils.utcnow(),
|
allocated_at=timeutils.utcnow(),
|
||||||
address_type=kwargs.get('address_type', FIXED))
|
address_type=kwargs.get('address_type',
|
||||||
|
ip_types.FIXED))
|
||||||
|
|
||||||
# This triggers when the IP is allocated to another tenant,
|
# This triggers when the IP is allocated to another tenant,
|
||||||
# either because we missed it due to our filters above, or
|
# either because we missed it due to our filters above, or
|
||||||
@@ -444,7 +445,8 @@ class QuarkIpam(object):
|
|||||||
context, address=ip_address,
|
context, address=ip_address,
|
||||||
subnet_id=subnet["id"],
|
subnet_id=subnet["id"],
|
||||||
version=subnet["ip_version"], network_id=net_id,
|
version=subnet["ip_version"], network_id=net_id,
|
||||||
address_type=kwargs.get('address_type', FIXED))
|
address_type=kwargs.get('address_type',
|
||||||
|
ip_types.FIXED))
|
||||||
except db_exception.DBDuplicateEntry:
|
except db_exception.DBDuplicateEntry:
|
||||||
LOG.info("{0} exists but was already "
|
LOG.info("{0} exists but was already "
|
||||||
"allocated".format(str(ip_address)))
|
"allocated".format(str(ip_address)))
|
||||||
|
|||||||
@@ -19,8 +19,7 @@ from oslo.config import cfg
|
|||||||
import webob
|
import webob
|
||||||
|
|
||||||
from quark.db import api as db_api
|
from quark.db import api as db_api
|
||||||
from quark.db import FIXED
|
from quark.db import ip_types
|
||||||
from quark.db import SHARED
|
|
||||||
from quark import exceptions as quark_exceptions
|
from quark import exceptions as quark_exceptions
|
||||||
from quark import ipam
|
from quark import ipam
|
||||||
from quark import plugin_views as v
|
from quark import plugin_views as v
|
||||||
@@ -78,7 +77,8 @@ def _can_be_shared(address_model):
|
|||||||
|
|
||||||
def create_ip_address(context, body):
|
def create_ip_address(context, body):
|
||||||
LOG.info("create_ip_address for tenant %s" % context.tenant_id)
|
LOG.info("create_ip_address for tenant %s" % context.tenant_id)
|
||||||
address_type = SHARED if _shared_ip_request(body) else FIXED
|
address_type = (ip_types.SHARED if _shared_ip_request(body)
|
||||||
|
else ip_types.FIXED)
|
||||||
ip_dict = body.get("ip_address")
|
ip_dict = body.get("ip_address")
|
||||||
port_ids = ip_dict.get('port_ids', [])
|
port_ids = ip_dict.get('port_ids', [])
|
||||||
network_id = ip_dict.get('network_id')
|
network_id = ip_dict.get('network_id')
|
||||||
|
|||||||
Reference in New Issue
Block a user