use object event_types from neutron-lib

This patch consumes the OVO event_types from neutron-lib by removing
the module from neutron and using it from lib instead.

NeutronLibImpact

Change-Id: I3bc3ceb0c47766b0984b67081c4c7d243b8609c2
This commit is contained in:
Boden R 2019-06-11 14:51:36 -06:00
parent 76754e06f5
commit 7181cad179
3 changed files with 2 additions and 40 deletions

View File

@ -1,38 +0,0 @@
# 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.services.logapi import constants as log_const
from oslo_versionedobjects import fields as obj_fields
from neutron._i18n import _
class SecurityEvent(obj_fields.String):
def __init__(self, valid_values, **kwargs):
self._valid_values = valid_values
super(SecurityEvent, self).__init__(**kwargs)
def coerce(self, obj, attr, value):
if value not in self._valid_values:
msg = (
_("Field value %(value)s is not in the list "
"of valid values: %(values)s") %
{'value': value, 'values': self._valid_values}
)
raise ValueError(msg)
return super(SecurityEvent, self).coerce(obj, attr, value)
class SecurityEventField(obj_fields.AutoTypedField):
AUTO_TYPE = SecurityEvent(valid_values=log_const.LOG_EVENTS)

View File

@ -13,13 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron_lib.objects.logapi import event_types
from neutron_lib.services.logapi import constants as log_const
from oslo_versionedobjects import fields as obj_fields
from neutron.db.models import loggingapi as log_db
from neutron.objects import base
from neutron.objects import common_types
from neutron.objects.logapi import event_types
@base.NeutronObjectRegistry.register

View File

@ -24,6 +24,7 @@ from neutron_lib.db import api as db_api
from neutron_lib.db import model_query
from neutron_lib import exceptions as n_exc
from neutron_lib.objects import exceptions as o_exc
from neutron_lib.objects.logapi import event_types
from neutron_lib.objects import utils as obj_utils
from neutron_lib.tests import tools as lib_test_tools
from neutron_lib.utils import helpers
@ -42,7 +43,6 @@ from neutron.objects import base
from neutron.objects import common_types
from neutron.objects.db import api as obj_db_api
from neutron.objects import flavor
from neutron.objects.logapi import event_types
from neutron.objects import network as net_obj
from neutron.objects import ports
from neutron.objects.qos import policy as qos_policy