Use neutron extensions

Use the extensions defined in Neutron

Change-Id: Id3ed016e39a91b4b4998ca6b62516a43131b9810
This commit is contained in:
Gary Kotton 2015-01-20 08:09:44 -08:00 committed by garyk
parent 85dcc08c9f
commit 79275a9982
20 changed files with 31 additions and 930 deletions

View File

@ -1,3 +1,5 @@
import os import os
NSX_EXT_PATH = os.path.join(os.path.dirname(__file__), 'extensions') from neutron.plugins.vmware import extensions
NSX_EXT_PATH = os.path.dirname(extensions.__file__)

View File

@ -14,9 +14,8 @@
# under the License. # under the License.
# #
from neutron.extensions import dvr as dist_rtr
from vmware_nsx.neutron.plugins.vmware.dbexts import nsxrouter from vmware_nsx.neutron.plugins.vmware.dbexts import nsxrouter
from vmware_nsx.neutron.plugins.vmware.extensions import (
distributedrouter as dist_rtr)
class DistributedRouter_mixin(nsxrouter.NsxRouterMixin): class DistributedRouter_mixin(nsxrouter.NsxRouterMixin):

View File

@ -19,7 +19,7 @@ from neutron.api.v2 import attributes as attr
from neutron.db import db_base_plugin_v2 from neutron.db import db_base_plugin_v2
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
from neutron.plugins.vmware.dbexts import nsxv_models from neutron.plugins.vmware.dbexts import nsxv_models
from vmware_nsx.neutron.plugins.vmware.extensions import vnic_index as vnicidx from neutron.plugins.vmware.extensions import vnicindex as vnicidx
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -28,13 +28,13 @@ from neutron.db import agents_db
from neutron.i18n import _LW from neutron.i18n import _LW
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
from neutron.plugins.vmware.common import exceptions as nsx_exc from neutron.plugins.vmware.common import exceptions as nsx_exc
from neutron.plugins.vmware.extensions import lsn
from vmware_nsx.neutron.plugins.vmware.common import config from vmware_nsx.neutron.plugins.vmware.common import config
from vmware_nsx.neutron.plugins.vmware.dhcp_meta import combined from vmware_nsx.neutron.plugins.vmware.dhcp_meta import combined
from vmware_nsx.neutron.plugins.vmware.dhcp_meta import lsnmanager from vmware_nsx.neutron.plugins.vmware.dhcp_meta import lsnmanager
from vmware_nsx.neutron.plugins.vmware.dhcp_meta import migration from vmware_nsx.neutron.plugins.vmware.dhcp_meta import migration
from vmware_nsx.neutron.plugins.vmware.dhcp_meta import nsx as nsx_svc from vmware_nsx.neutron.plugins.vmware.dhcp_meta import nsx as nsx_svc
from vmware_nsx.neutron.plugins.vmware.dhcp_meta import rpc as nsx_rpc from vmware_nsx.neutron.plugins.vmware.dhcp_meta import rpc as nsx_rpc
from vmware_nsx.neutron.plugins.vmware.extensions import lsn
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -1,70 +0,0 @@
# Copyright 2013 VMware, Inc. 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.api.v2 import attributes
def convert_to_boolean_if_not_none(data):
if data is not None:
return attributes.convert_to_boolean(data)
return data
DISTRIBUTED = 'distributed'
EXTENDED_ATTRIBUTES_2_0 = {
'routers': {
DISTRIBUTED: {'allow_post': True, 'allow_put': False,
'convert_to': convert_to_boolean_if_not_none,
'default': attributes.ATTR_NOT_SPECIFIED,
'is_visible': True},
}
}
class Distributedrouter(object):
"""Extension class supporting distributed router."""
@classmethod
def get_name(cls):
return "Distributed Router"
@classmethod
def get_alias(cls):
return "dist-router"
@classmethod
def get_description(cls):
return "Enables configuration of NSX Distributed routers."
@classmethod
def get_namespace(cls):
return "http://docs.openstack.org/ext/dist-router/api/v1.0"
@classmethod
def get_updated(cls):
return "2013-08-1T10:00:00-00:00"
def get_required_extensions(self):
return ["router"]
@classmethod
def get_resources(cls):
"""Returns Ext Resources."""
return []
def get_extended_resources(self, version):
if version == "2.0":
return EXTENDED_ATTRIBUTES_2_0
else:
return {}

View File

@ -1,82 +0,0 @@
# Copyright 2014 VMware, Inc.
#
# 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.api import extensions
from neutron.api.v2 import base
from neutron import manager
EXT_ALIAS = 'lsn'
COLLECTION_NAME = "%ss" % EXT_ALIAS
RESOURCE_ATTRIBUTE_MAP = {
COLLECTION_NAME: {
'network': {'allow_post': True, 'allow_put': False,
'validate': {'type:string': None},
'is_visible': True},
'report': {'allow_post': False, 'allow_put': False,
'is_visible': True},
'tenant_id': {'allow_post': True, 'allow_put': False,
'required_by_policy': True,
'validate': {'type:string': None}, 'is_visible': True},
},
}
class Lsn(object):
"""Enable LSN configuration for Neutron NSX networks."""
@classmethod
def get_name(cls):
return "Logical Service Node configuration"
@classmethod
def get_alias(cls):
return EXT_ALIAS
@classmethod
def get_description(cls):
return "Enables configuration of NSX Logical Services Node."
@classmethod
def get_namespace(cls):
return "http://docs.openstack.org/ext/%s/api/v2.0" % EXT_ALIAS
@classmethod
def get_updated(cls):
return "2013-10-05T10:00:00-00:00"
@classmethod
def get_resources(cls):
"""Returns Ext Resources."""
exts = []
plugin = manager.NeutronManager.get_plugin()
resource_name = EXT_ALIAS
collection_name = resource_name.replace('_', '-') + "s"
params = RESOURCE_ATTRIBUTE_MAP.get(COLLECTION_NAME, dict())
controller = base.create_resource(collection_name,
resource_name,
plugin, params, allow_bulk=False)
ex = extensions.ResourceExtension(collection_name, controller)
exts.append(ex)
return exts
def get_extended_resources(self, version):
if version == "2.0":
return RESOURCE_ATTRIBUTE_MAP
else:
return {}

View File

@ -1,61 +0,0 @@
# Copyright 2013 VMware, Inc. 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.api.v2 import attributes
MAC_LEARNING = 'mac_learning_enabled'
EXTENDED_ATTRIBUTES_2_0 = {
'ports': {
MAC_LEARNING: {'allow_post': True, 'allow_put': True,
'convert_to': attributes.convert_to_boolean,
'default': attributes.ATTR_NOT_SPECIFIED,
'is_visible': True},
}
}
class Maclearning(object):
"""Extension class supporting port mac learning."""
@classmethod
def get_name(cls):
return "MAC Learning"
@classmethod
def get_alias(cls):
return "mac-learning"
@classmethod
def get_description(cls):
return "Provides MAC learning capabilities."
@classmethod
def get_namespace(cls):
return "http://docs.openstack.org/ext/maclearning/api/v1.0"
@classmethod
def get_updated(cls):
return "2013-05-1T10:00:00-00:00"
@classmethod
def get_resources(cls):
"""Returns Ext Resources."""
return []
def get_extended_resources(self, version):
if version == "2.0":
return EXTENDED_ATTRIBUTES_2_0
else:
return {}

View File

@ -1,56 +0,0 @@
# Copyright 2014 VMware, Inc. 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.
# Attribute Map
METADATA_PROVIDERS = 'metadata_providers'
EXTENDED_ATTRIBUTES_2_0 = {
'subnets': {
METADATA_PROVIDERS:
{'allow_post': False,
'allow_put': False,
'is_visible': True,
'default': None}}}
class Metadata_providers(object):
@classmethod
def get_name(cls):
return "Metadata Providers"
@classmethod
def get_alias(cls):
return "metadata-providers"
@classmethod
def get_description(cls):
return ("Id of the metadata providers attached to the subnet")
@classmethod
def get_namespace(cls):
return(
"http://docs.openstack.org/ext/neutron/metadata_providers/api/v1.0"
)
@classmethod
def get_updated(cls):
return "2014-12-11T12:00:00-00:00"
def get_extended_resources(self, version):
if version == "2.0":
return EXTENDED_ATTRIBUTES_2_0
else:
return {}

View File

@ -1,249 +0,0 @@
# Copyright 2013 VMware. 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.
#
import abc
from oslo.config import cfg
from neutron.api.v2 import attributes
from neutron.api.v2 import resource_helper
from vmware_nsx.neutron.plugins.vmware.common import utils
GATEWAY_RESOURCE_NAME = "network_gateway"
DEVICE_RESOURCE_NAME = "gateway_device"
# Use dash for alias and collection name
EXT_ALIAS = GATEWAY_RESOURCE_NAME.replace('_', '-')
NETWORK_GATEWAYS = "%ss" % EXT_ALIAS
GATEWAY_DEVICES = "%ss" % DEVICE_RESOURCE_NAME.replace('_', '-')
DEVICE_ID_ATTR = 'id'
IFACE_NAME_ATTR = 'interface_name'
# Attribute Map for Network Gateway Resource
# TODO(salvatore-orlando): add admin state as other neutron resources
RESOURCE_ATTRIBUTE_MAP = {
NETWORK_GATEWAYS: {
'id': {'allow_post': False, 'allow_put': False,
'is_visible': True},
'name': {'allow_post': True, 'allow_put': True,
'validate': {'type:string': None},
'is_visible': True, 'default': ''},
'default': {'allow_post': False, 'allow_put': False,
'is_visible': True},
'devices': {'allow_post': True, 'allow_put': False,
'validate': {'type:device_list': None},
'is_visible': True},
'ports': {'allow_post': False, 'allow_put': False,
'default': [],
'is_visible': True},
'tenant_id': {'allow_post': True, 'allow_put': False,
'validate': {'type:string': None},
'required_by_policy': True,
'is_visible': True}
},
GATEWAY_DEVICES: {
'id': {'allow_post': False, 'allow_put': False,
'is_visible': True},
'name': {'allow_post': True, 'allow_put': True,
'validate': {'type:string': None},
'is_visible': True, 'default': ''},
'client_certificate': {'allow_post': True, 'allow_put': True,
'validate': {'type:string': None},
'is_visible': True},
'connector_type': {'allow_post': True, 'allow_put': True,
'validate': {'type:connector_type': None},
'is_visible': True},
'connector_ip': {'allow_post': True, 'allow_put': True,
'validate': {'type:ip_address': None},
'is_visible': True},
'tenant_id': {'allow_post': True, 'allow_put': False,
'validate': {'type:string': None},
'required_by_policy': True,
'is_visible': True},
'status': {'allow_post': False, 'allow_put': False,
'is_visible': True},
}
}
def _validate_device_list(data, valid_values=None):
"""Validate the list of service definitions."""
if not data:
# Devices must be provided
msg = _("Cannot create a gateway with an empty device list")
return msg
try:
for device in data:
key_specs = {DEVICE_ID_ATTR:
{'type:regex': attributes.UUID_PATTERN,
'required': True},
IFACE_NAME_ATTR:
{'type:string': None,
'required': False}}
err_msg = attributes._validate_dict(
device, key_specs=key_specs)
if err_msg:
return err_msg
unexpected_keys = [key for key in device if key not in key_specs]
if unexpected_keys:
err_msg = (_("Unexpected keys found in device description:%s")
% ",".join(unexpected_keys))
return err_msg
except TypeError:
return (_("%s: provided data are not iterable") %
_validate_device_list.__name__)
def _validate_connector_type(data, valid_values=None):
if not data:
# A connector type is compulsory
msg = _("A connector type is required to create a gateway device")
return msg
connector_types = (valid_values if valid_values else
[utils.NetworkTypes.GRE,
utils.NetworkTypes.STT,
utils.NetworkTypes.BRIDGE,
'ipsec%s' % utils.NetworkTypes.GRE,
'ipsec%s' % utils.NetworkTypes.STT])
if data not in connector_types:
msg = _("Unknown connector type: %s") % data
return msg
nw_gw_quota_opts = [
cfg.IntOpt('quota_network_gateway',
default=5,
help=_('Number of network gateways allowed per tenant, '
'-1 for unlimited'))
]
cfg.CONF.register_opts(nw_gw_quota_opts, 'QUOTAS')
attributes.validators['type:device_list'] = _validate_device_list
attributes.validators['type:connector_type'] = _validate_connector_type
class Networkgw(object):
"""API extension for Layer-2 Gateway support.
The Layer-2 gateway feature allows for connecting neutron networks
with external networks at the layer-2 level. No assumption is made on
the location of the external network, which might not even be directly
reachable from the hosts where the VMs are deployed.
This is achieved by instantiating 'network gateways', and then connecting
Neutron network to them.
"""
@classmethod
def get_name(cls):
return "Network Gateway"
@classmethod
def get_alias(cls):
return EXT_ALIAS
@classmethod
def get_description(cls):
return "Connects Neutron networks with external networks at layer 2."
@classmethod
def get_namespace(cls):
return "http://docs.openstack.org/ext/network-gateway/api/v1.0"
@classmethod
def get_updated(cls):
return "2014-01-01T00:00:00-00:00"
@classmethod
def get_resources(cls):
"""Returns Ext Resources."""
member_actions = {
GATEWAY_RESOURCE_NAME.replace('_', '-'): {
'connect_network': 'PUT',
'disconnect_network': 'PUT'}}
plural_mappings = resource_helper.build_plural_mappings(
{}, RESOURCE_ATTRIBUTE_MAP)
return resource_helper.build_resource_info(plural_mappings,
RESOURCE_ATTRIBUTE_MAP,
None,
action_map=member_actions,
register_quota=True,
translate_name=True)
def get_extended_resources(self, version):
if version == "2.0":
return RESOURCE_ATTRIBUTE_MAP
else:
return {}
class NetworkGatewayPluginBase(object):
@abc.abstractmethod
def create_network_gateway(self, context, network_gateway):
pass
@abc.abstractmethod
def update_network_gateway(self, context, id, network_gateway):
pass
@abc.abstractmethod
def get_network_gateway(self, context, id, fields=None):
pass
@abc.abstractmethod
def delete_network_gateway(self, context, id):
pass
@abc.abstractmethod
def get_network_gateways(self, context, filters=None, fields=None,
sorts=None, limit=None, marker=None,
page_reverse=False):
pass
@abc.abstractmethod
def connect_network(self, context, network_gateway_id,
network_mapping_info):
pass
@abc.abstractmethod
def disconnect_network(self, context, network_gateway_id,
network_mapping_info):
pass
@abc.abstractmethod
def create_gateway_device(self, context, gateway_device):
pass
@abc.abstractmethod
def update_gateway_device(self, context, id, gateway_device):
pass
@abc.abstractmethod
def delete_gateway_device(self, context, id):
pass
@abc.abstractmethod
def get_gateway_device(self, context, id, fields=None):
pass
@abc.abstractmethod
def get_gateway_devices(self, context, filters=None, fields=None,
sorts=None, limit=None, marker=None,
page_reverse=False):
pass

View File

@ -1,40 +0,0 @@
# Copyright 2013 VMware, Inc.
#
# 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.
#
# TODO(arosen): This is deprecated in Juno, and
# to be removed in Kxxxx.
from vmware_nsx.neutron.plugins.vmware.extensions import qos
class Nvp_qos(qos.Qos):
"""(Deprecated) Port Queue extension."""
@classmethod
def get_name(cls):
return "nvp-qos"
@classmethod
def get_alias(cls):
return "nvp-qos"
@classmethod
def get_description(cls):
return "NVP QoS extension (deprecated)."
@classmethod
def get_namespace(cls):
return "http://docs.openstack.org/ext/nvp-qos/api/v2.0"

View File

@ -1,229 +0,0 @@
# Copyright 2013 VMware, Inc.
# 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.
#
import abc
from neutron.api import extensions
from neutron.api.v2 import attributes as attr
from neutron.api.v2 import base
from neutron.common import exceptions as nexception
from neutron import manager
# For policy.json/Auth
qos_queue_create = "create_qos_queue"
qos_queue_delete = "delete_qos_queue"
qos_queue_get = "get_qos_queue"
qos_queue_list = "get_qos_queues"
class DefaultQueueCreateNotAdmin(nexception.InUse):
message = _("Need to be admin in order to create queue called default")
class DefaultQueueAlreadyExists(nexception.InUse):
message = _("Default queue already exists.")
class QueueInvalidDscp(nexception.InvalidInput):
message = _("Invalid value for dscp %(data)s must be integer value"
" between 0 and 63.")
class QueueInvalidMarking(nexception.InvalidInput):
message = _("The qos marking cannot be set to 'trusted' "
"when the DSCP field is set")
class QueueMinGreaterMax(nexception.InvalidInput):
message = _("Invalid bandwidth rate, min greater than max.")
class QueueInvalidBandwidth(nexception.InvalidInput):
message = _("Invalid bandwidth rate, %(data)s must be a non negative"
" integer.")
class QueueNotFound(nexception.NotFound):
message = _("Queue %(id)s does not exist")
class QueueInUseByPort(nexception.InUse):
message = _("Unable to delete queue attached to port.")
class QueuePortBindingNotFound(nexception.NotFound):
message = _("Port is not associated with lqueue")
def convert_to_unsigned_int_or_none(val):
if val is None:
return
try:
val = int(val)
if val < 0:
raise ValueError()
except (ValueError, TypeError):
msg = _("'%s' must be a non negative integer.") % val
raise nexception.InvalidInput(error_message=msg)
return val
def convert_to_unsigned_int_or_none_max_63(val):
val = convert_to_unsigned_int_or_none(val)
if val > 63:
raise QueueInvalidDscp(data=val)
return val
# As per NSX API, if a queue is trusted, DSCP must be omitted; if a queue is
# untrusted, DSCP must be specified. Whichever default values we choose for
# the tuple (qos_marking, dscp), there will be at least one combination of a
# request with conflicting values: for instance given the default values below,
# requests with qos_marking = 'trusted' and the default dscp value will fail.
# In order to avoid API users to explicitly specify a setting for clearing
# the DSCP field when a trusted queue is created, the code serving this API
# will adopt the following behaviour when qos_marking is set to 'trusted':
# - if the DSCP attribute is set to the default value (0), silently drop
# its value
# - if the DSCP attribute is set to anything than 0 (but still a valid DSCP
# value) return a 400 error as qos_marking and DSCP setting conflict.
# TODO(salv-orlando): Evaluate whether it will be possible from a backward
# compatibility perspective to change the default value for DSCP in order to
# avoid this peculiar behaviour
RESOURCE_ATTRIBUTE_MAP = {
'qos_queues': {
'id': {'allow_post': False, 'allow_put': False,
'is_visible': True},
'default': {'allow_post': True, 'allow_put': False,
'convert_to': attr.convert_to_boolean,
'is_visible': True, 'default': False},
'name': {'allow_post': True, 'allow_put': False,
'validate': {'type:string': None},
'is_visible': True, 'default': ''},
'min': {'allow_post': True, 'allow_put': False,
'is_visible': True, 'default': '0',
'convert_to': convert_to_unsigned_int_or_none},
'max': {'allow_post': True, 'allow_put': False,
'is_visible': True, 'default': None,
'convert_to': convert_to_unsigned_int_or_none},
'qos_marking': {'allow_post': True, 'allow_put': False,
'validate': {'type:values': ['untrusted', 'trusted']},
'default': 'untrusted', 'is_visible': True},
'dscp': {'allow_post': True, 'allow_put': False,
'is_visible': True, 'default': '0',
'convert_to': convert_to_unsigned_int_or_none_max_63},
'tenant_id': {'allow_post': True, 'allow_put': False,
'required_by_policy': True,
'validate': {'type:string': None},
'is_visible': True},
},
}
QUEUE = 'queue_id'
RXTX_FACTOR = 'rxtx_factor'
EXTENDED_ATTRIBUTES_2_0 = {
'ports': {
RXTX_FACTOR: {'allow_post': True,
# FIXME(arosen): the plugin currently does not
# implement updating rxtx factor on port.
'allow_put': True,
'is_visible': False,
'default': 1,
'enforce_policy': True,
'convert_to': convert_to_unsigned_int_or_none},
QUEUE: {'allow_post': False,
'allow_put': False,
'is_visible': True,
'default': False,
'enforce_policy': True}},
'networks': {QUEUE: {'allow_post': True,
'allow_put': True,
'is_visible': True,
'default': False,
'enforce_policy': True}}
}
class Qos(object):
"""Port Queue extension."""
@classmethod
def get_name(cls):
return "QoS Queue"
@classmethod
def get_alias(cls):
return "qos-queue"
@classmethod
def get_description(cls):
return "NSX QoS extension."
@classmethod
def get_namespace(cls):
return "http://docs.openstack.org/ext/qos-queue/api/v2.0"
@classmethod
def get_updated(cls):
return "2014-01-01T00:00:00-00:00"
@classmethod
def get_resources(cls):
"""Returns Ext Resources."""
exts = []
plugin = manager.NeutronManager.get_plugin()
resource_name = 'qos_queue'
collection_name = resource_name.replace('_', '-') + "s"
params = RESOURCE_ATTRIBUTE_MAP.get(resource_name + "s", dict())
controller = base.create_resource(collection_name,
resource_name,
plugin, params, allow_bulk=False)
ex = extensions.ResourceExtension(collection_name,
controller)
exts.append(ex)
return exts
def get_extended_resources(self, version):
if version == "2.0":
return dict(EXTENDED_ATTRIBUTES_2_0.items() +
RESOURCE_ATTRIBUTE_MAP.items())
else:
return {}
class QueuePluginBase(object):
@abc.abstractmethod
def create_qos_queue(self, context, queue):
pass
@abc.abstractmethod
def delete_qos_queue(self, context, id):
pass
@abc.abstractmethod
def get_qos_queue(self, context, id, fields=None):
pass
@abc.abstractmethod
def get_qos_queues(self, context, filters=None, fields=None, sorts=None,
limit=None, marker=None, page_reverse=False):
pass

View File

@ -1,57 +0,0 @@
# Copyright 2013 VMware, Inc. 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.api import extensions
from neutron.api.v2 import attributes
SERVICE_ROUTER = 'service_router'
EXTENDED_ATTRIBUTES_2_0 = {
'routers': {
SERVICE_ROUTER: {'allow_post': True, 'allow_put': False,
'convert_to': attributes.convert_to_boolean,
'default': False, 'is_visible': True},
}
}
class Servicerouter(extensions.ExtensionDescriptor):
"""Extension class supporting advanced service router."""
@classmethod
def get_name(cls):
return "Service Router"
@classmethod
def get_alias(cls):
return "service-router"
@classmethod
def get_description(cls):
return "Provides service router."
@classmethod
def get_namespace(cls):
return "http://docs.openstack.org/ext/service-router/api/v1.0"
@classmethod
def get_updated(cls):
return "2013-08-08T00:00:00-00:00"
def get_extended_resources(self, version):
if version == "2.0":
return EXTENDED_ATTRIBUTES_2_0
else:
return {}

View File

@ -1,61 +0,0 @@
# Copyright 2013 VMware, Inc. 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.api.v2 import attributes
# Attribute Map
VNIC_INDEX = 'vnic_index'
def convert_to_int_if_not_none(data):
if data is not None:
return attributes.convert_to_int(data)
return data
EXTENDED_ATTRIBUTES_2_0 = {
'ports': {
VNIC_INDEX:
{'allow_post': True,
'allow_put': True,
'is_visible': True,
'default': None,
'convert_to': convert_to_int_if_not_none}}}
class Vnic_index(object):
@classmethod
def get_name(cls):
return "VNIC Index"
@classmethod
def get_alias(cls):
return "vnic-index"
@classmethod
def get_description(cls):
return ("Enable a port to be associated with a VNIC index")
@classmethod
def get_namespace(cls):
return "http://docs.openstack.org/ext/neutron/vnic_index/api/v1.0"
@classmethod
def get_updated(cls):
return "2014-09-15T12:00:00-00:00"
def get_extended_resources(self, version):
if version == "2.0":
return EXTENDED_ATTRIBUTES_2_0
else:
return {}

View File

@ -61,6 +61,8 @@ from neutron.plugins.vmware.dbexts import maclearning as mac_db
from neutron.plugins.vmware.dbexts import networkgw_db from neutron.plugins.vmware.dbexts import networkgw_db
from neutron.plugins.vmware.dbexts import qos_db from neutron.plugins.vmware.dbexts import qos_db
from neutron.plugins.vmware.extensions import maclearning as mac_ext from neutron.plugins.vmware.extensions import maclearning as mac_ext
from neutron.plugins.vmware.extensions import networkgw
from neutron.plugins.vmware.extensions import qos
from vmware_nsx.neutron.plugins import vmware from vmware_nsx.neutron.plugins import vmware
from vmware_nsx.neutron.plugins.vmware.common import config # noqa from vmware_nsx.neutron.plugins.vmware.common import config # noqa
from vmware_nsx.neutron.plugins.vmware.common import nsx_utils from vmware_nsx.neutron.plugins.vmware.common import nsx_utils
@ -69,8 +71,6 @@ from vmware_nsx.neutron.plugins.vmware.common import sync
from vmware_nsx.neutron.plugins.vmware.common import utils as c_utils from vmware_nsx.neutron.plugins.vmware.common import utils as c_utils
from vmware_nsx.neutron.plugins.vmware.dbexts import db as nsx_db from vmware_nsx.neutron.plugins.vmware.dbexts import db as nsx_db
from vmware_nsx.neutron.plugins.vmware import dhcpmeta_modes from vmware_nsx.neutron.plugins.vmware import dhcpmeta_modes
from vmware_nsx.neutron.plugins.vmware.extensions import networkgw
from vmware_nsx.neutron.plugins.vmware.extensions import qos
from vmware_nsx.neutron.plugins.vmware.nsxlib import l2gateway as l2gwlib from vmware_nsx.neutron.plugins.vmware.nsxlib import l2gateway as l2gwlib
from vmware_nsx.neutron.plugins.vmware.nsxlib import queue as queuelib from vmware_nsx.neutron.plugins.vmware.nsxlib import queue as queuelib
from vmware_nsx.neutron.plugins.vmware.nsxlib import router as routerlib from vmware_nsx.neutron.plugins.vmware.nsxlib import router as routerlib

View File

@ -50,6 +50,10 @@ from neutron.openstack.common import log as logging
from neutron.openstack.common import uuidutils from neutron.openstack.common import uuidutils
from neutron.plugins.vmware.common import exceptions as nsx_exc from neutron.plugins.vmware.common import exceptions as nsx_exc
from neutron.plugins.vmware.dbexts import networkgw_db from neutron.plugins.vmware.dbexts import networkgw_db
from neutron.plugins.vmware.extensions import (
advancedserviceproviders as subnet_md)
from neutron.plugins.vmware.extensions import (
vnicindex as ext_vnic_idx)
from vmware_nsx.neutron.plugins import vmware from vmware_nsx.neutron.plugins import vmware
from vmware_nsx.neutron.plugins.vmware.common import config # noqa from vmware_nsx.neutron.plugins.vmware.common import config # noqa
from vmware_nsx.neutron.plugins.vmware.common import utils as c_utils from vmware_nsx.neutron.plugins.vmware.common import utils as c_utils
@ -58,10 +62,6 @@ from vmware_nsx.neutron.plugins.vmware.dbexts import (
from vmware_nsx.neutron.plugins.vmware.dbexts import db as nsx_db from vmware_nsx.neutron.plugins.vmware.dbexts import db as nsx_db
from vmware_nsx.neutron.plugins.vmware.dbexts import nsxv_db from vmware_nsx.neutron.plugins.vmware.dbexts import nsxv_db
from vmware_nsx.neutron.plugins.vmware.dbexts import vnic_index_db from vmware_nsx.neutron.plugins.vmware.dbexts import vnic_index_db
from vmware_nsx.neutron.plugins.vmware.extensions import (
metadata_providers as subnet_md)
from vmware_nsx.neutron.plugins.vmware.extensions import (
vnic_index as ext_vnic_idx)
from vmware_nsx.neutron.plugins.vmware.plugins import nsx_v_md_proxy from vmware_nsx.neutron.plugins.vmware.plugins import nsx_v_md_proxy
from vmware_nsx.neutron.plugins.vmware.vshield.common import ( from vmware_nsx.neutron.plugins.vmware.vshield.common import (
constants as vcns_const) constants as vcns_const)
@ -89,7 +89,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
supported_extension_aliases = ["allowed-address-pairs", supported_extension_aliases = ["allowed-address-pairs",
"binding", "binding",
"dist-router", "dvr",
"multi-provider", "multi-provider",
"port-security", "port-security",
"provider", "provider",
@ -99,7 +99,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
"router", "router",
"security-group", "security-group",
"vnic-index", "vnic-index",
"metadata-providers"] "advanced-service-providers"]
__native_bulk_support = True __native_bulk_support = True
__native_pagination_support = True __native_pagination_support = True
@ -310,7 +310,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
def get_subnet(self, context, id, fields=None): def get_subnet(self, context, id, fields=None):
subnet = super(NsxVPluginV2, self).get_subnet(context, id, fields) subnet = super(NsxVPluginV2, self).get_subnet(context, id, fields)
if context.is_admin: if context.is_admin:
subnet[subnet_md.METADATA_PROVIDERS] = ( subnet[subnet_md.ADV_SERVICE_PROVIDERS] = (
self._get_subnet_md_providers(context, subnet)) self._get_subnet_md_providers(context, subnet))
return subnet return subnet
@ -325,8 +325,8 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
new_subnets = [] new_subnets = []
if (not fields if (not fields
or subnet_md.METADATA_PROVIDERS in fields or subnet_md.ADV_SERVICE_PROVIDERS in fields
or (filters and filters.get(subnet_md.METADATA_PROVIDERS))): or (filters and filters.get(subnet_md.ADV_SERVICE_PROVIDERS))):
# We only deal metadata provider field when: # We only deal metadata provider field when:
# - All fields are retrieved # - All fields are retrieved
@ -339,8 +339,8 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
if md_filter is None or len(set(md_provider) & set(md_filter)): if md_filter is None or len(set(md_provider) & set(md_filter)):
# Include metadata_providers only if requested in results # Include metadata_providers only if requested in results
if not fields or subnet_md.METADATA_PROVIDERS in fields: if not fields or subnet_md.ADV_SERVICE_PROVIDERS in fields:
subnet[subnet_md.METADATA_PROVIDERS] = md_provider subnet[subnet_md.ADV_SERVICE_PROVIDERS] = md_provider
new_subnets.append(subnet) new_subnets.append(subnet)
else: else:

View File

@ -28,13 +28,13 @@ from neutron import manager
from neutron.plugins.vmware.api_client import exception as api_exc from neutron.plugins.vmware.api_client import exception as api_exc
from neutron.plugins.vmware.common import exceptions as nsx_exc from neutron.plugins.vmware.common import exceptions as nsx_exc
from neutron.plugins.vmware.dbexts import networkgw_db from neutron.plugins.vmware.dbexts import networkgw_db
from neutron.plugins.vmware.extensions import networkgw
from neutron import quota from neutron import quota
from neutron.tests import base from neutron.tests import base
from neutron.tests.unit import test_api_v2 from neutron.tests.unit import test_api_v2
from neutron.tests.unit import test_db_plugin from neutron.tests.unit import test_db_plugin
from neutron.tests.unit import test_extensions from neutron.tests.unit import test_extensions
from neutron.tests.unit import testlib_plugin from neutron.tests.unit import testlib_plugin
from vmware_nsx.neutron.plugins.vmware.extensions import networkgw
from vmware_nsx.neutron.plugins.vmware import nsxlib from vmware_nsx.neutron.plugins.vmware import nsxlib
from vmware_nsx.neutron.plugins.vmware.nsxlib import l2gateway as l2gwlib from vmware_nsx.neutron.plugins.vmware.nsxlib import l2gateway as l2gwlib
from vmware_nsx.neutron.tests.unit import vmware from vmware_nsx.neutron.tests.unit import vmware

View File

@ -21,8 +21,8 @@ import webob.exc
from neutron import context from neutron import context
from neutron.plugins.vmware.dbexts import qos_db from neutron.plugins.vmware.dbexts import qos_db
from neutron.plugins.vmware.extensions import qos as ext_qos
from neutron.tests.unit import test_extensions from neutron.tests.unit import test_extensions
from vmware_nsx.neutron.plugins.vmware.extensions import qos as ext_qos
from vmware_nsx.neutron.plugins.vmware import nsxlib from vmware_nsx.neutron.plugins.vmware import nsxlib
from vmware_nsx.neutron.tests.unit import vmware from vmware_nsx.neutron.tests.unit import vmware
from vmware_nsx.neutron.tests.unit.vmware import test_nsx_plugin from vmware_nsx.neutron.tests.unit.vmware import test_nsx_plugin

View File

@ -21,9 +21,9 @@ from neutron import context as neutron_context
from neutron.db import db_base_plugin_v2 from neutron.db import db_base_plugin_v2
from neutron import manager from neutron import manager
from neutron.openstack.common import uuidutils from neutron.openstack.common import uuidutils
from neutron.plugins.vmware.extensions import vnicindex as vnicidx
from neutron.tests.unit import test_db_plugin from neutron.tests.unit import test_db_plugin
from vmware_nsx.neutron.plugins.vmware.dbexts import vnic_index_db from vmware_nsx.neutron.plugins.vmware.dbexts import vnic_index_db
from vmware_nsx.neutron.plugins.vmware.extensions import vnic_index as vnicidx
from vmware_nsx.neutron.tests.unit import vmware from vmware_nsx.neutron.tests.unit import vmware

View File

@ -25,6 +25,7 @@ from neutron.common import exceptions as n_exc
from neutron.common import ipv6_utils from neutron.common import ipv6_utils
import neutron.common.test_lib as test_lib import neutron.common.test_lib as test_lib
from neutron import context from neutron import context
from neutron.extensions import dvr as dist_router
from neutron.extensions import external_net from neutron.extensions import external_net
from neutron.extensions import l3 from neutron.extensions import l3
from neutron.extensions import l3_ext_gw_mode from neutron.extensions import l3_ext_gw_mode
@ -33,6 +34,8 @@ from neutron.extensions import providernet as pnet
from neutron.extensions import securitygroup as secgrp from neutron.extensions import securitygroup as secgrp
from neutron import manager from neutron import manager
from neutron.openstack.common import uuidutils from neutron.openstack.common import uuidutils
from neutron.plugins.vmware.extensions import (
vnicindex as ext_vnic_idx)
from neutron.tests.unit import _test_extension_portbindings as test_bindings from neutron.tests.unit import _test_extension_portbindings as test_bindings
import neutron.tests.unit.test_db_plugin as test_plugin import neutron.tests.unit.test_db_plugin as test_plugin
import neutron.tests.unit.test_extension_allowedaddresspairs as test_addr_pair import neutron.tests.unit.test_extension_allowedaddresspairs as test_addr_pair
@ -41,10 +44,6 @@ import neutron.tests.unit.test_extension_security_group as ext_sg
import neutron.tests.unit.test_l3_plugin as test_l3_plugin import neutron.tests.unit.test_l3_plugin as test_l3_plugin
from neutron.tests.unit import testlib_api from neutron.tests.unit import testlib_api
from vmware_nsx.neutron.plugins.vmware.dbexts import nsxv_db from vmware_nsx.neutron.plugins.vmware.dbexts import nsxv_db
from vmware_nsx.neutron.plugins.vmware.extensions import (
distributedrouter as dist_router)
from vmware_nsx.neutron.plugins.vmware.extensions import (
vnic_index as ext_vnic_idx)
from vmware_nsx.neutron.plugins.vmware.vshield.common import ( from vmware_nsx.neutron.plugins.vmware.vshield.common import (
constants as vcns_const) constants as vcns_const)
from vmware_nsx.neutron.plugins.vmware.vshield import edge_utils from vmware_nsx.neutron.plugins.vmware.vshield import edge_utils
@ -1509,6 +1508,12 @@ class TestVdrTestCase(L3NatTest,
test_l3_plugin.L3NatDBIntTestCase, test_l3_plugin.L3NatDBIntTestCase,
NsxVPluginV2TestCase): NsxVPluginV2TestCase):
def test_update_port_device_id_to_different_tenants_router(self):
self.skipTest('TBD')
def test_router_add_gateway_tenant_ctx(self):
self.skipTest('TBD')
def _create_router(self, fmt, tenant_id, name=None, def _create_router(self, fmt, tenant_id, name=None,
admin_state_up=None, set_context=False, admin_state_up=None, set_context=False,
arg_list=None, **kwargs): arg_list=None, **kwargs):