Add status field in the TaaS API
In the current implementation, when the TaaS API (tap-service, tap-flow) call completes, the status of result is returned. [1] In order to adopt an asynchronous model, the 'status' field is needed in the API. The following code adds the status field in the API. In the first step, the status is set to 'ACTIVE' by default. [1]: http://lists.openstack.org/pipermail/openstack-dev/2016-March/090088.html Depends-On: Ie6b3811e41a94721679c9178cdd5119bdad8208d Change-Id: Ib8e4ad15e5b4272ac7f8800f72d7f2c003db798e
This commit is contained in:
parent
5068617c49
commit
752fb029fa
@ -1 +1 @@
|
||||
04625466c6fa
|
||||
fddbdec8711a
|
||||
|
@ -0,0 +1,38 @@
|
||||
# Copyright 2016 FUJITSU LABORATORIES LTD.
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""add status
|
||||
|
||||
Revision ID: fddbdec8711a
|
||||
Revises: 04625466c6fa
|
||||
Create Date: 2016-06-06 10:54:42.252898
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'fddbdec8711a'
|
||||
down_revision = '04625466c6fa'
|
||||
|
||||
from alembic import op
|
||||
from neutron_lib import constants
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column('tap_services', sa.Column('status', sa.String(16),
|
||||
server_default=constants.ACTIVE,
|
||||
nullable=False))
|
||||
op.add_column('tap_flows', sa.Column('status', sa.String(16),
|
||||
server_default=constants.ACTIVE,
|
||||
nullable=False))
|
@ -20,6 +20,7 @@ from sqlalchemy.orm import exc
|
||||
|
||||
from neutron.db import common_db_mixin as base_db
|
||||
from neutron import manager
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.db import model_base
|
||||
from neutron_taas.extensions import taas
|
||||
from oslo_log import log as logging
|
||||
@ -37,6 +38,8 @@ class TapService(model_base.BASEV2, model_base.HasId,
|
||||
name = sa.Column(sa.String(255), nullable=True)
|
||||
description = sa.Column(sa.String(1024), nullable=True)
|
||||
port_id = sa.Column(sa.String(36), nullable=False)
|
||||
status = sa.Column(sa.String(16), nullable=False,
|
||||
server_default=constants.ACTIVE)
|
||||
|
||||
|
||||
class TapFlow(model_base.BASEV2, model_base.HasId,
|
||||
@ -54,6 +57,8 @@ class TapFlow(model_base.BASEV2, model_base.HasId,
|
||||
direction = sa.Column(sa.Enum('IN', 'OUT', 'BOTH',
|
||||
name='tapflows_direction'),
|
||||
nullable=False)
|
||||
status = sa.Column(sa.String(16), nullable=False,
|
||||
server_default=constants.ACTIVE)
|
||||
|
||||
|
||||
class TapIdAssociation(model_base.BASEV2):
|
||||
@ -102,7 +107,8 @@ class Taas_db_Mixin(taas.TaasPluginBase, base_db.CommonDbMixin):
|
||||
'tenant_id': tap_service['tenant_id'],
|
||||
'name': tap_service['name'],
|
||||
'description': tap_service['description'],
|
||||
'port_id': tap_service['port_id']}
|
||||
'port_id': tap_service['port_id'],
|
||||
'status': tap_service['status']}
|
||||
|
||||
return self._fields(res, fields)
|
||||
|
||||
@ -119,7 +125,8 @@ class Taas_db_Mixin(taas.TaasPluginBase, base_db.CommonDbMixin):
|
||||
'name': tap_flow['name'],
|
||||
'description': tap_flow['description'],
|
||||
'source_port': tap_flow['source_port'],
|
||||
'direction': tap_flow['direction']}
|
||||
'direction': tap_flow['direction'],
|
||||
'status': tap_flow['status']}
|
||||
|
||||
return self._fields(res, fields)
|
||||
|
||||
@ -134,6 +141,7 @@ class Taas_db_Mixin(taas.TaasPluginBase, base_db.CommonDbMixin):
|
||||
name=t_s['name'],
|
||||
description=t_s['description'],
|
||||
port_id=t_s['port_id'],
|
||||
status=constants.ACTIVE,
|
||||
)
|
||||
context.session.add(tap_service_db)
|
||||
|
||||
@ -164,7 +172,8 @@ class Taas_db_Mixin(taas.TaasPluginBase, base_db.CommonDbMixin):
|
||||
description=t_f['description'],
|
||||
tap_service_id=t_f['tap_service_id'],
|
||||
source_port=t_f['source_port'],
|
||||
direction=t_f['direction']
|
||||
direction=t_f['direction'],
|
||||
status=constants.ACTIVE,
|
||||
)
|
||||
context.session.add(tap_flow_db)
|
||||
|
||||
|
@ -90,6 +90,8 @@ RESOURCE_ATTRIBUTE_MAP = {
|
||||
'port_id': {'allow_post': True, 'allow_put': False,
|
||||
'validate': {'type:uuid': None},
|
||||
'is_visible': True},
|
||||
'status': {'allow_post': False, 'allow_put': False,
|
||||
'is_visible': True}
|
||||
},
|
||||
'tap_flows': {
|
||||
'id': {'allow_post': False, 'allow_put': False,
|
||||
@ -112,7 +114,9 @@ RESOURCE_ATTRIBUTE_MAP = {
|
||||
'required_by_policy': True, 'is_visible': True},
|
||||
'direction': {'allow_post': True, 'allow_put': False,
|
||||
'validate': {'type:values': direction_enum},
|
||||
'is_visible': True}
|
||||
'is_visible': True},
|
||||
'status': {'allow_post': False, 'allow_put': False,
|
||||
'is_visible': True}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ class ListTapFlow(extension.ClientExtensionList, TapFlow):
|
||||
"""List tap flows."""
|
||||
|
||||
shell_command = 'tap-flow-list'
|
||||
list_columns = ['id', 'name', 'source_port', 'tap_service_id']
|
||||
list_columns = ['id', 'name', 'source_port', 'tap_service_id', 'status']
|
||||
pagination_support = True
|
||||
sorting_support = True
|
||||
|
||||
|
@ -46,7 +46,7 @@ class ListTapService(extension.ClientExtensionList, TapService):
|
||||
"""List tap services."""
|
||||
|
||||
shell_command = 'tap-service-list'
|
||||
list_columns = ['id', 'name', 'port']
|
||||
list_columns = ['id', 'name', 'port', 'status']
|
||||
pagination_support = True
|
||||
sorting_support = True
|
||||
|
||||
|
@ -87,6 +87,7 @@ class TestTaasPlugin(testlib_api.SqlTestCase):
|
||||
return_value=self._port_details):
|
||||
yield self._plugin.create_tap_service(self._context, req)
|
||||
self._tap_service['id'] = mock.ANY
|
||||
self._tap_service['status'] = 'ACTIVE'
|
||||
|
||||
self.driver.assert_has_calls([
|
||||
mock.call.create_tap_service_precommit(mock.ANY),
|
||||
@ -111,6 +112,7 @@ class TestTaasPlugin(testlib_api.SqlTestCase):
|
||||
return_value=self._port_details):
|
||||
yield self._plugin.create_tap_flow(self._context, req)
|
||||
self._tap_flow['id'] = mock.ANY
|
||||
self._tap_flow['status'] = 'ACTIVE'
|
||||
self._tap_service['id'] = mock.ANY
|
||||
|
||||
self.driver.assert_has_calls([
|
||||
|
Loading…
x
Reference in New Issue
Block a user