def943f447
With [1] the python binding code in Neutronclient prints warning about future deprecation, change taas osc client code to use totally OpenstackSDK. [1]: https://review.opendev.org/c/openstack/python-neutronclient/+/862371 Depends-On: https://review.opendev.org/c/openstack/openstacksdk/+/871287 Related-Bug: #1999774 Change-Id: Id22e20efbf30dddbdbcb986186e02f056f3ed21d
84 lines
2.7 KiB
Python
84 lines
2.7 KiB
Python
# All Rights Reserved 2020
|
|
#
|
|
# 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.
|
|
|
|
import copy
|
|
|
|
from oslo_utils import uuidutils
|
|
|
|
|
|
class FakeTapService(object):
|
|
|
|
@staticmethod
|
|
def create_tap_service(attrs=None):
|
|
"""Create a fake tap service."""
|
|
attrs = attrs or {}
|
|
tap_service_attrs = {
|
|
'id': uuidutils.generate_uuid(),
|
|
'tenant_id': uuidutils.generate_uuid(),
|
|
'name': 'test_tap_service' + uuidutils.generate_uuid(),
|
|
'status': 'ACTIVE',
|
|
}
|
|
tap_service_attrs.update(attrs)
|
|
return copy.deepcopy(tap_service_attrs)
|
|
|
|
@staticmethod
|
|
def create_tap_services(attrs=None, count=1):
|
|
"""Create multiple fake tap services."""
|
|
|
|
tap_services = []
|
|
for i in range(0, count):
|
|
if attrs is None:
|
|
attrs = {'id': 'fake_id%d' % i}
|
|
elif getattr(attrs, 'id', None) is None:
|
|
attrs['id'] = 'fake_id%d' % i
|
|
tap_services.append(FakeTapService.create_tap_service(
|
|
attrs=attrs))
|
|
|
|
return tap_services
|
|
|
|
|
|
class FakeTapFlow(object):
|
|
|
|
@staticmethod
|
|
def create_tap_flow(attrs=None):
|
|
"""Create a fake tap service."""
|
|
attrs = attrs or {}
|
|
tap_flow_attrs = {
|
|
'id': uuidutils.generate_uuid(),
|
|
'tenant_id': uuidutils.generate_uuid(),
|
|
'name': 'test_tap_flow' + uuidutils.generate_uuid(),
|
|
'status': 'ACTIVE',
|
|
'direction': 'BOTH',
|
|
}
|
|
tap_flow_attrs.update(attrs)
|
|
return copy.deepcopy(tap_flow_attrs)
|
|
|
|
@staticmethod
|
|
def create_tap_flows(attrs=None, count=1):
|
|
"""Create multiple fake tap flows."""
|
|
|
|
tap_flows = []
|
|
for i in range(0, count):
|
|
if attrs is None:
|
|
attrs = {
|
|
'id': 'fake_id%d' % i,
|
|
'source_port': uuidutils.generate_uuid(),
|
|
'tap_service_id': uuidutils.generate_uuid()
|
|
}
|
|
elif getattr(attrs, 'id', None) is None:
|
|
attrs['id'] = 'fake_id%d' % i
|
|
tap_flows.append(FakeTapFlow.create_tap_flow(attrs=attrs))
|
|
|
|
return tap_flows
|