use l3 ext gw mode api def from neutron-lib

The l3 ext gw mode extension's API defintion was rehomed into
neutron-lib with commit I2fbef43f076652758476f988d868e1d47c8cf713
This patch consumes the API definition by removing the rehomed code
and using APIExtensionDescriptor for the extensions parent class.

NeutronLibImpact

Change-Id: Ifb924d6a700f068465e60a85729fb1cdbc28c9fc
This commit is contained in:
Boden R 2017-11-08 13:52:25 -07:00
parent cfc0a1ae5b
commit ebe013bcab
2 changed files with 5 additions and 53 deletions

View File

@ -13,58 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron_lib.api import converters
from neutron_lib.api.definitions import l3_ext_gw_mode as apidef
from neutron_lib.api import extensions
from neutron.extensions import l3
class L3_ext_gw_mode(extensions.APIExtensionDescriptor):
EXTENDED_ATTRIBUTES_2_0 = {
'routers': {l3.EXTERNAL_GW_INFO:
{'allow_post': True,
'allow_put': True,
'is_visible': True,
'default': None,
'enforce_policy': True,
'validate':
{'type:dict_or_nodata':
{'network_id': {'type:uuid': None, 'required': True},
'enable_snat': {'type:boolean': None, 'required': False,
'convert_to':
converters.convert_to_boolean},
'external_fixed_ips': {
'convert_list_to': converters.convert_kvp_list_to_dict,
'type:fixed_ips': None,
'default': None,
'required': False}
}
}}}}
class L3_ext_gw_mode(extensions.ExtensionDescriptor):
@classmethod
def get_name(cls):
return "Neutron L3 Configurable external gateway mode"
@classmethod
def get_alias(cls):
return "ext-gw-mode"
@classmethod
def get_description(cls):
return ("Extension of the router abstraction for specifying whether "
"SNAT should occur on the external gateway")
@classmethod
def get_updated(cls):
return "2013-03-28T10:00:00-00:00"
def get_required_extensions(self):
return ["router"]
def get_extended_resources(self, version):
if version == "2.0":
return dict(EXTENDED_ATTRIBUTES_2_0.items())
else:
return {}
api_definition = apidef

View File

@ -18,6 +18,7 @@ import copy
import mock
import netaddr
from neutron_lib.api.definitions import l3_ext_gw_mode as l3gwm_apidef
from neutron_lib import constants
from neutron_lib import context as nctx
from neutron_lib.plugins import directory
@ -34,7 +35,6 @@ from neutron.db import l3_db
from neutron.db import l3_gwmode_db
from neutron.db.models import l3 as l3_models
from neutron.extensions import l3
from neutron.extensions import l3_ext_gw_mode
from neutron.objects import network as net_obj
from neutron.objects import ports as port_obj
from neutron.objects import subnet as subnet_obj
@ -60,7 +60,7 @@ class TestExtensionManager(object):
# Simulate extension of L3 attribute map
for key in l3.RESOURCE_ATTRIBUTE_MAP.keys():
l3.RESOURCE_ATTRIBUTE_MAP[key].update(
l3_ext_gw_mode.EXTENDED_ATTRIBUTES_2_0.get(key, {}))
l3gwm_apidef.RESOURCE_ATTRIBUTE_MAP.get(key, {}))
return l3.L3.get_resources()
def get_actions(self):