Debian Codegraph @

networking_l2gw/extensions/l2gatewayconnection.py

raw
1 # Copyright 2015 OpenStack Foundation
2 # Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
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
17 import abc
18
19 from neutron_lib.api import extensions
20
21 from neutron.api.v2 import resource_helper
22
23 from networking_l2gw.services.l2gateway.common import constants
24
25 RESOURCE_ATTRIBUTE_MAP = {
26 constants.L2_GATEWAYS_CONNECTION: {
27 'id': {'allow_post': False, 'allow_put': False,
28 'is_visible': True},
29 'l2_gateway_id': {'allow_post': True, 'allow_put': False,
30 'validate': {'type:string': None},
31 'is_visible': True, 'default': ''},
32 'network_id': {'allow_post': True, 'allow_put': False,
33 'validate': {'type:string': None},
34 'is_visible': True},
35 'segmentation_id': {'allow_post': True, 'allow_put': False,
36 'validate': {'type:string': None},
37 'is_visible': True, 'default': ''},
38 'tenant_id': {'allow_post': True, 'allow_put': False,
39 'validate': {'type:string': None},
40 'required_by_policy': True,
41 'is_visible': True}
42 },
43 }
44
45
46 class L2gatewayconnection(extensions.ExtensionDescriptor):
47
48 """API extension for Layer-2 Gateway connection support."""
49
50 @classmethod
51 def get_name(cls):
52 return "L2 Gateway connection"
53
54 @classmethod
55 def get_alias(cls):
56 return "l2-gateway-connection"
57
58 @classmethod
59 def get_description(cls):
60 return "Connects Neutron networks with external networks at layer 2."
61
62 @classmethod
63 def get_updated(cls):
64 return "2014-01-01T00:00:00-00:00"
65
66 @classmethod
67 def get_resources(cls):
68 """Returns Ext Resources."""
69
70 mem_actions = {}
71 plural_mappings = resource_helper.build_plural_mappings(
72 {}, RESOURCE_ATTRIBUTE_MAP)
73 resources = resource_helper.build_resource_info(plural_mappings,
74 RESOURCE_ATTRIBUTE_MAP,
75 constants.L2GW,
76 action_map=mem_actions,
77 register_quota=True,
78 translate_name=True)
79
80 return resources
81
82 def get_extended_resources(self, version):
83 if version == "2.0":
84 return RESOURCE_ATTRIBUTE_MAP
85 else:
86 return {}
87
88
89 class L2GatewayConnectionPluginBase:
90
91 @abc.abstractmethod
92 def delete_l2_gateway_connection(self, context, l2_gateway_id,
93 network_mapping_list):
94 pass
95
96 @abc.abstractmethod
97 def create_l2_gateway_connection(self, context, l2_gateway_id,
98 network_mapping_list):
99 pass
100
101 @abc.abstractmethod
102 def get_l2_gateway_connections(self, context, filters=None,
103 fields=None,
104 sorts=None, limit=None, marker=None,
105 page_reverse=False):
106 pass
107
108 @abc.abstractmethod
109 def get_l2_gateway_connection(self, context, id, fields=None):
110 pass