Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions neutron/db/rbac_db_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,14 @@ class SecurityGroupRBAC(RBACColumns, model_base.BASEV2):
@staticmethod
def get_valid_actions():
return (ACCESS_SHARED,)


class SubnetPoolRBAC(RBACColumns, model_base.BASEV2):
"""RBAC table for security groups."""

object_id = _object_id_column('subnetpool.id')
object_type = 'subnet_pool'

@staticmethod
def get_valid_actions():
return (ACCESS_SHARED,)
44 changes: 43 additions & 1 deletion neutron/objects/subnetpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,46 @@
from oslo_versionedobjects import fields as obj_fields

from neutron.db import models_v2 as models
from neutron.db import rbac_db_models
from neutron.objects import base
from neutron.objects import common_types
from neutron.objects import rbac
from neutron.objects import rbac_db


@base.NeutronObjectRegistry.register
class SubnetPool(base.NeutronDbObject):
class SubnetPoolRBAC(rbac.RBACBaseObject):
# Version 1.0: Initial version
VERSION = '1.0'

db_model = rbac_db_models.SubnetPoolRBAC

@classmethod
def get_projects(cls, context, object_id=None, action=None,
target_tenant=None):
clauses = []
if object_id:
clauses.append(rbac_db_models.SubnetPoolRBAC.object_id == object_id)
if action:
clauses.append(rbac_db_models.SubnetPoolRBAC.action == action)
if target_tenant:
clauses.append(rbac_db_models.SubnetPoolRBAC.target_tenant ==
target_tenant)
query = context.session.query(
rbac_db_models.SubnetPoolRBAC.target_tenant)
if clauses:
query = query.filter(sa.and_(*clauses))
return [data[0] for data in query]


@base.NeutronObjectRegistry.register
class SubnetPool(base.NeutronDbObject):
# Version 1.0: Initial version
# Version 1.1: Add RBAC support
VERSION = '1.1'

# required by RbacNeutronMetaclass
rbac_db_cls = SubnetPoolRBAC
db_model = models.SubnetPool

fields = {
Expand Down Expand Up @@ -83,6 +114,17 @@ def update(self):
if 'prefixes' in fields:
self._attach_prefixes(fields['prefixes'])

def obj_make_compatible(self, primitive, target_version):
_target_version = versionutils.convert_version_to_tuple(target_version)
if _target_version < (1, 1):
primitive.pop('shared')

@classmethod
def get_bound_tenant_ids(cls, context, obj_id):
port_objs = ports.Port.get_objects(context,
security_group_ids=[obj_id])
return {port.tenant_id for port in port_objs}


@base.NeutronObjectRegistry.register
class SubnetPoolPrefix(base.NeutronDbObject):
Expand Down