DB models
This commit is contained in:
parent
9fcdf7db82
commit
41f73e2327
@ -2,7 +2,7 @@
|
||||
# Show debugging output in log (sets DEBUG log level output)
|
||||
# debug = False
|
||||
|
||||
[WANQOS]
|
||||
[WANTC]
|
||||
lan_port_name = 'enp1s0f0'
|
||||
lan_max_rate = '100mbit'
|
||||
wan_port_name = 'enp1s0f1'
|
||||
|
@ -13,6 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
WANQOS = 'WANQOS'
|
||||
WAN_QOS = 'wan_tc'
|
||||
WAN_QOS_PATH = 'wan-tcs'
|
||||
WANTC = 'WANTC'
|
||||
WAN_TC = 'wan_tc'
|
||||
WAN_TC_PATH = 'wan-tcs'
|
0
wan_qos/db/models/__init__.py
Normal file
0
wan_qos/db/models/__init__.py
Normal file
48
wan_qos/db/models/wan_tc.py
Normal file
48
wan_qos/db/models/wan_tc.py
Normal file
@ -0,0 +1,48 @@
|
||||
# Copyright 2016 Huawei corp.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.db import model_base
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
class WanTcClass(model_base.BASEV2,
|
||||
model_base.HasId, model_base.HasProject):
|
||||
__tablename__ = 'wan_tc_class'
|
||||
class_ext_id = sa.Column(sa.Integer)
|
||||
parent_class = sa.Column(sa.String(36),
|
||||
sa.ForeignKey('wan_tc_class.id',
|
||||
ondelete='CASCADE'),
|
||||
nullable=True)
|
||||
network_id = sa.Column(sa.String(36),
|
||||
sa.ForeignKey('networks.id',
|
||||
ondelete='CASCADE'),
|
||||
nullable=False,
|
||||
unique=True,
|
||||
primary_key=True)
|
||||
min_rate = sa.Column(sa.String(15), nullable=False)
|
||||
max_rate = sa.Column(sa.String(15))
|
||||
|
||||
|
||||
class WanTcSelector(model_base.BASEV2,
|
||||
model_base.HasId, model_base.HasProject):
|
||||
__tablename__ = 'wan_tc_selector'
|
||||
class_id = sa.Column(sa.String(36),
|
||||
sa.ForeignKey('wan_tc_class.id',
|
||||
ondelete='CASCADE'),
|
||||
nullable=False,
|
||||
primary_key=True)
|
||||
protocol = sa.Column(sa.String(15))
|
||||
match = sa.Column(sa.String(15))
|
||||
|
24
wan_qos/db/wan_qos_db.py
Normal file
24
wan_qos/db/wan_qos_db.py
Normal file
@ -0,0 +1,24 @@
|
||||
# Copyright 2016 Huawei corp.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from wan_qos.db.models import wan_tc as model
|
||||
from wan_qos.common import constants
|
||||
|
||||
|
||||
class WanTcDb():
|
||||
def create_wan_tc_class(self, context, wan_qos_class):
|
||||
pass
|
@ -21,7 +21,7 @@ from neutron.api.v2 import resource_helper
|
||||
from wan_qos.common import constants
|
||||
|
||||
RESOURCE_ATTRIBUTE_MAP = {
|
||||
constants.WAN_QOS_PATH: {
|
||||
constants.WAN_TC_PATH: {
|
||||
'id': {'allow_post': False, 'allow_put': False,
|
||||
'is_visible': True},
|
||||
'max_rate': {'allow_post': True, 'allow_put': False,
|
||||
@ -45,7 +45,7 @@ class Wanqos(extensions.ExtensionDescriptor):
|
||||
|
||||
@classmethod
|
||||
def get_name(cls):
|
||||
return "WAN QoS"
|
||||
return "WAN Traffic Control"
|
||||
|
||||
@classmethod
|
||||
def get_alias(cls):
|
||||
@ -68,7 +68,7 @@ class Wanqos(extensions.ExtensionDescriptor):
|
||||
{}, RESOURCE_ATTRIBUTE_MAP)
|
||||
resources = resource_helper.build_resource_info(plural_mappings,
|
||||
RESOURCE_ATTRIBUTE_MAP,
|
||||
constants.WANQOS,
|
||||
constants.WANTC,
|
||||
action_map=mem_actions,
|
||||
register_quota=True,
|
||||
translate_name=True)
|
||||
|
@ -15,10 +15,12 @@
|
||||
|
||||
from neutron.common import rpc as n_rpc
|
||||
from neutron.db import agents_db
|
||||
from neutron_lib import exceptions
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import importutils
|
||||
|
||||
import oslo_messaging as messaging
|
||||
|
||||
from wan_qos.common import api
|
||||
@ -60,7 +62,7 @@ class WanQosPlugin(wanqos.WanQosPluginBase):
|
||||
|
||||
def get_plugin_type(self):
|
||||
"""Get type of the plugin."""
|
||||
return constants.WANQOS
|
||||
return constants.WANTC
|
||||
|
||||
def get_plugin_description(self):
|
||||
"""Get description of the plugin."""
|
||||
@ -84,6 +86,26 @@ class WanQosPlugin(wanqos.WanQosPluginBase):
|
||||
pass
|
||||
# self.agent_rpc.create_wan_qos(context, wan_qos)
|
||||
|
||||
def agent_up_notification(self, host):
|
||||
tenant_id = self._get_tenant_id_for_create(context, wan_qos_class)
|
||||
|
||||
|
||||
|
||||
@staticmethod
|
||||
def _get_tenant_id_for_create(self, context, resource):
|
||||
"""Get tenant id for creation of resources."""
|
||||
if context.is_admin and 'tenant_id' in resource:
|
||||
tenant_id = resource['tenant_id']
|
||||
elif ('tenant_id' in resource and
|
||||
resource['tenant_id'] != context.tenant_id):
|
||||
reason = 'Cannot create resource for another tenant'
|
||||
raise exceptions.AdminRequired(reason=reason)
|
||||
else:
|
||||
tenant_id = context.tenant_id
|
||||
return tenant_id
|
||||
|
||||
|
||||
|
||||
|
||||
def agent_up_notification(self, host):
|
||||
LOG.debug('agent %s is up' % host)
|
||||
return 'OK'
|
||||
|
@ -19,35 +19,35 @@ from wan_qos.common import constants
|
||||
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {'wan_tc': {}, }
|
||||
body = {constants.WAN_TC: {}, }
|
||||
return body
|
||||
|
||||
|
||||
class WanQos(extension.NeutronClientExtension):
|
||||
resource = constants.WAN_QOS
|
||||
resource_plural = '%ss' % constants.WAN_QOS
|
||||
path = constants.WAN_QOS_PATH
|
||||
class WanTc(extension.NeutronClientExtension):
|
||||
resource = constants.WAN_TC
|
||||
resource_plural = '%ss' % constants.WAN_TC
|
||||
path = constants.WAN_TC_PATH
|
||||
object_path = '/%s' % path
|
||||
resource_path = '/%s/%%s' % path
|
||||
versions = ['2.0']
|
||||
|
||||
|
||||
class WanQosShow(extension.ClientExtensionShow, WanQos):
|
||||
class WanTcShow(extension.ClientExtensionShow, WanTc):
|
||||
|
||||
shell_command = 'wan-qos-show'
|
||||
shell_command = 'wan-tc-show'
|
||||
|
||||
|
||||
class WanQosList(extension.ClientExtensionList, WanQos):
|
||||
class WanTcList(extension.ClientExtensionList, WanTc):
|
||||
|
||||
shell_command = 'wan-qos-list'
|
||||
shell_command = 'wan-tc-list'
|
||||
list_columns = ['id', 'name', 'network']
|
||||
pagination_support = True
|
||||
sorting_support = True
|
||||
|
||||
|
||||
class WanQosCreate(extension.ClientExtensionCreate, WanQos):
|
||||
class WanTcCreate(extension.ClientExtensionCreate, WanTc):
|
||||
|
||||
shell_command = 'wan-qos-create'
|
||||
shell_command = 'wan-tc-create'
|
||||
|
||||
def add_known_arguments(self, parser):
|
||||
pass
|
||||
@ -59,14 +59,14 @@ class WanQosCreate(extension.ClientExtensionCreate, WanQos):
|
||||
return body
|
||||
|
||||
|
||||
class WanQosDelete(extension.ClientExtensionDelete, WanQos):
|
||||
class WanTcDelete(extension.ClientExtensionDelete, WanTc):
|
||||
|
||||
shell_command = 'wan-qos-delete'
|
||||
shell_command = 'wan-tc-delete'
|
||||
|
||||
|
||||
class WanQosUpdate(extension.ClientExtensionUpdate, WanQos):
|
||||
class WanTcUpdate(extension.ClientExtensionUpdate, WanTc):
|
||||
|
||||
shell_command = 'wan-qos-update'
|
||||
shell_command = 'wan-tc-update'
|
||||
|
||||
def add_known_arguments(self, parser):
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user