| 1 |
# Copyright (C) 2015 Ericsson AB |
| 2 |
# Copyright (c) 2015 Gigamon |
| 3 |
# |
| 4 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 |
# not use this file except in compliance with the License. You may obtain |
| 6 |
# a copy of the License at |
| 7 |
# |
| 8 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
# |
| 10 |
# Unless required by applicable law or agreed to in writing, software |
| 11 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 |
# License for the specific language governing permissions and limitations |
| 14 |
# under the License. |
| 15 |
|
| 16 |
import abc |
| 17 |
|
| 18 |
from neutron_lib.api.definitions import taas as taas_api_def |
| 19 |
from neutron_lib.api import extensions |
| 20 |
from neutron_lib.services import base as service_base |
| 21 |
|
| 22 |
from neutron.api.v2 import resource_helper |
| 23 |
|
| 24 |
from neutron_taas.common import config |
| 25 |
|
| 26 |
|
| 27 |
config.register() |
| 28 |
|
| 29 |
|
| 30 |
class Taas(extensions.APIExtensionDescriptor): |
| 31 |
|
| 32 |
api_definition = taas_api_def |
| 33 |
|
| 34 |
@classmethod |
| 35 |
def get_resources(cls): |
| 36 |
"""Returns Ext Resources.""" |
| 37 |
plural_mappings = resource_helper.build_plural_mappings( |
| 38 |
{}, taas_api_def.RESOURCE_ATTRIBUTE_MAP) |
| 39 |
|
| 40 |
resources = resource_helper.build_resource_info( |
| 41 |
plural_mappings, |
| 42 |
taas_api_def.RESOURCE_ATTRIBUTE_MAP, |
| 43 |
taas_api_def.ALIAS, |
| 44 |
translate_name=False, |
| 45 |
allow_bulk=True) |
| 46 |
|
| 47 |
return resources |
| 48 |
|
| 49 |
@classmethod |
| 50 |
def get_plugin_interface(cls): |
| 51 |
return TaasPluginBase |
| 52 |
|
| 53 |
|
| 54 |
class TaasPluginBase(service_base.ServicePluginBase, metaclass=abc.ABCMeta): |
| 55 |
|
| 56 |
def get_plugin_description(self): |
| 57 |
return taas_api_def.DESCRIPTION |
| 58 |
|
| 59 |
@classmethod |
| 60 |
def get_plugin_type(cls): |
| 61 |
return taas_api_def.ALIAS |
| 62 |
|
| 63 |
@abc.abstractmethod |
| 64 |
def create_tap_service(self, context, tap_service): |
| 65 |
"""Create a Tap Service.""" |
| 66 |
pass |
| 67 |
|
| 68 |
@abc.abstractmethod |
| 69 |
def delete_tap_service(self, context, id): |
| 70 |
"""Delete a Tap Service.""" |
| 71 |
pass |
| 72 |
|
| 73 |
@abc.abstractmethod |
| 74 |
def get_tap_service(self, context, id, fields=None): |
| 75 |
"""Get a Tap Service.""" |
| 76 |
pass |
| 77 |
|
| 78 |
@abc.abstractmethod |
| 79 |
def get_tap_services(self, context, filters=None, fields=None, |
| 80 |
sorts=None, limit=None, marker=None, |
| 81 |
page_reverse=False): |
| 82 |
"""List all Tap Services.""" |
| 83 |
pass |
| 84 |
|
| 85 |
@abc.abstractmethod |
| 86 |
def update_tap_service(self, context, id, tap_service): |
| 87 |
"""Update a Tap Service.""" |
| 88 |
pass |
| 89 |
|
| 90 |
@abc.abstractmethod |
| 91 |
def create_tap_flow(self, context, tap_flow): |
| 92 |
"""Create a Tap Flow.""" |
| 93 |
pass |
| 94 |
|
| 95 |
@abc.abstractmethod |
| 96 |
def get_tap_flow(self, context, id, fields=None): |
| 97 |
"""Get a Tap Flow.""" |
| 98 |
pass |
| 99 |
|
| 100 |
@abc.abstractmethod |
| 101 |
def delete_tap_flow(self, context, id): |
| 102 |
"""Delete a Tap Flow.""" |
| 103 |
pass |
| 104 |
|
| 105 |
@abc.abstractmethod |
| 106 |
def get_tap_flows(self, context, filters=None, fields=None, |
| 107 |
sorts=None, limit=None, marker=None, |
| 108 |
page_reverse=False): |
| 109 |
"""List all Tap Flows.""" |
| 110 |
pass |
| 111 |
|
| 112 |
@abc.abstractmethod |
| 113 |
def update_tap_flow(self, context, id, tap_flow): |
| 114 |
"""Update a Tap Flow.""" |
| 115 |
pass |