Merge "Neutron LBaaS Deprecation Update"

This commit is contained in:
Jenkins 2016-05-20 17:18:48 +00:00 committed by Gerrit Code Review
commit b0b6a0aa85
13 changed files with 39 additions and 37 deletions

View File

@ -13,7 +13,6 @@
# under the License.
#
from neutron.api.v2 import attributes
from neutron.callbacks import events
from neutron.callbacks import registry
from neutron.callbacks import resources
@ -326,7 +325,7 @@ class LoadBalancerPluginDb(loadbalancer.LoadBalancerPluginBase,
# resolve subnet and create port
subnet = self._core_plugin.get_subnet(context, subnet_id)
fixed_ip = {'subnet_id': subnet['id']}
if ip_address and ip_address != attributes.ATTR_NOT_SPECIFIED:
if ip_address and ip_address != n_constants.ATTR_NOT_SPECIFIED:
fixed_ip['ip_address'] = ip_address
if subnet.get('gateway_ip') == ip_address:
raise n_exc.IpAddressInUse(net_id=subnet['network_id'],
@ -336,7 +335,7 @@ class LoadBalancerPluginDb(loadbalancer.LoadBalancerPluginBase,
'tenant_id': vip_db.tenant_id,
'name': 'vip-' + vip_db.id,
'network_id': subnet['network_id'],
'mac_address': attributes.ATTR_NOT_SPECIFIED,
'mac_address': n_constants.ATTR_NOT_SPECIFIED,
'admin_state_up': False,
'device_id': '',
'device_owner': n_constants.DEVICE_OWNER_LOADBALANCER,

View File

@ -15,7 +15,6 @@
import re
from neutron.api.v2 import attributes
from neutron.callbacks import events
from neutron.callbacks import registry
from neutron.callbacks import resources
@ -93,14 +92,14 @@ class LoadBalancerPluginDbv2(base_db.CommonDbMixin,
# resolve subnet and create port
subnet = self._core_plugin.get_subnet(context, lb_db.vip_subnet_id)
fixed_ip = {'subnet_id': subnet['id']}
if ip_address and ip_address != attributes.ATTR_NOT_SPECIFIED:
if ip_address and ip_address != n_constants.ATTR_NOT_SPECIFIED:
fixed_ip['ip_address'] = ip_address
port_data = {
'tenant_id': lb_db.tenant_id,
'name': 'loadbalancer-' + lb_db.id,
'network_id': subnet['network_id'],
'mac_address': attributes.ATTR_NOT_SPECIFIED,
'mac_address': n_constants.ATTR_NOT_SPECIFIED,
'admin_state_up': False,
'device_id': lb_db.id,
'device_owner': n_constants.DEVICE_OWNER_LOADBALANCERV2,
@ -385,7 +384,7 @@ class LoadBalancerPluginDbv2(base_db.CommonDbMixin,
# Check for unspecified loadbalancer_id and listener_id and
# set to None
for id in ['loadbalancer_id', 'default_pool_id']:
if listener.get(id) == attributes.ATTR_NOT_SPECIFIED:
if listener.get(id) == n_constants.ATTR_NOT_SPECIFIED:
listener[id] = None
self._validate_listener_data(context, listener)
@ -668,7 +667,7 @@ class LoadBalancerPluginDbv2(base_db.CommonDbMixin,
loadbalancer.stats)
def create_l7policy(self, context, l7policy):
if l7policy['redirect_pool_id'] == attributes.ATTR_NOT_SPECIFIED:
if l7policy['redirect_pool_id'] == n_constants.ATTR_NOT_SPECIFIED:
l7policy['redirect_pool_id'] = None
self._validate_l7policy_data(context, l7policy)

View File

@ -17,9 +17,9 @@ import netaddr
import threading
import time
from neutron.api.v2 import attributes
from neutron import context
from neutron.plugins.common import constants
from neutron_lib import constants as n_constants
from oslo_config import cfg
from oslo_log import helpers as log_helpers
from oslo_log import log as logging
@ -493,7 +493,7 @@ class RadwareLBaaSV2Driver(base_v2_driver.RadwareLBaaSBaseV2Driver):
'tenant_id': lb.tenant_id,
'name': proxy_port_name,
'network_id': proxy_port_subnet['network_id'],
'mac_address': attributes.ATTR_NOT_SPECIFIED,
'mac_address': n_constants.ATTR_NOT_SPECIFIED,
'admin_state_up': False,
'device_id': '',
'device_owner': 'neutron:' + constants.LOADBALANCERV2,

View File

@ -20,6 +20,7 @@ from neutron.api.v2 import base
from neutron.api.v2 import resource_helper
from neutron import manager
from neutron.plugins.common import constants
from neutron_lib import constants as n_constants
from neutron_lib import exceptions as nexception
from neutron_lbaas._i18n import _
@ -96,7 +97,7 @@ RESOURCE_ATTRIBUTE_MAP = {
'is_visible': True},
'redirect_pool_id': {'allow_post': True, 'allow_put': True,
'validate': {'type:uuid_or_none': None},
'default': attr.ATTR_NOT_SPECIFIED,
'default': n_constants.ATTR_NOT_SPECIFIED,
'is_visible': True},
'redirect_url': {'allow_post': True, 'allow_put': True,
'validate': {

View File

@ -25,6 +25,7 @@ from neutron.api.v2 import resource_helper
from neutron import manager
from neutron.plugins.common import constants
from neutron.services import service_base
from neutron_lib import constants as n_constants
from neutron_lib import exceptions as nexception
from neutron_lbaas._i18n import _
@ -125,7 +126,7 @@ RESOURCE_ATTRIBUTE_MAP = {
'validate': {'type:uuid': None},
'is_visible': True},
'address': {'allow_post': True, 'allow_put': False,
'default': attr.ATTR_NOT_SPECIFIED,
'default': n_constants.ATTR_NOT_SPECIFIED,
'validate': {'type:ip_address_or_none': None},
'is_visible': True},
'port_id': {'allow_post': False, 'allow_put': False,
@ -194,8 +195,8 @@ RESOURCE_ATTRIBUTE_MAP = {
'validate': {'type:values': ['TCP', 'HTTP', 'HTTPS']},
'is_visible': True},
'provider': {'allow_post': True, 'allow_put': False,
'validate': {'type:string': None},
'is_visible': True, 'default': attr.ATTR_NOT_SPECIFIED},
'validate': {'type:string': None}, 'is_visible': True,
'default': n_constants.ATTR_NOT_SPECIFIED},
'lb_method': {'allow_post': True, 'allow_put': True,
'validate': {'type:values': ['ROUND_ROBIN',
'LEAST_CONNECTIONS',

View File

@ -27,6 +27,7 @@ from neutron.api.v2 import resource_helper
from neutron import manager
from neutron.plugins.common import constants
from neutron.services import service_base
from neutron_lib import constants as n_constants
from neutron_lib import exceptions as nexception
from neutron_lbaas._i18n import _
@ -164,14 +165,14 @@ RESOURCE_ATTRIBUTE_MAP = {
'validate': {'type:uuid': None},
'is_visible': True},
'vip_address': {'allow_post': True, 'allow_put': False,
'default': attr.ATTR_NOT_SPECIFIED,
'default': n_constants.ATTR_NOT_SPECIFIED,
'validate': {'type:ip_address_or_none': None},
'is_visible': True},
'vip_port_id': {'allow_post': False, 'allow_put': False,
'is_visible': True},
'provider': {'allow_post': True, 'allow_put': False,
'validate': {'type:string': None},
'is_visible': True, 'default': attr.ATTR_NOT_SPECIFIED},
'validate': {'type:string': None}, 'is_visible': True,
'default': n_constants.ATTR_NOT_SPECIFIED},
'listeners': {'allow_post': False, 'allow_put': False,
'is_visible': True},
'admin_state_up': {'allow_post': True, 'allow_put': True,
@ -185,7 +186,7 @@ RESOURCE_ATTRIBUTE_MAP = {
'flavor_id': {'allow_post': True, 'allow_put': False,
'is_visible': True,
'validate': {'type:string': attr.NAME_MAX_LEN},
'default': attr.ATTR_NOT_SPECIFIED}
'default': n_constants.ATTR_NOT_SPECIFIED}
},
'listeners': {
'id': {'allow_post': False, 'allow_put': False,

View File

@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron.api.v2 import attributes
from neutron.plugins.common import constants
from neutron_lib import constants as n_constants
from oslo_config import cfg
from oslo_log import log as logging
@ -421,13 +421,13 @@ class NetScalerPluginDriver(abstract_driver.LoadBalancerAbstractDriver):
ip_address):
subnet = self.plugin._core_plugin.get_subnet(context, subnet_id)
fixed_ip = {'subnet_id': subnet['id']}
if ip_address and ip_address != attributes.ATTR_NOT_SPECIFIED:
if ip_address and ip_address != n_constants.ATTR_NOT_SPECIFIED:
fixed_ip['ip_address'] = ip_address
port_data = {
'tenant_id': tenant_id,
'name': '_lb-snatport-' + subnet_id,
'network_id': subnet['network_id'],
'mac_address': attributes.ATTR_NOT_SPECIFIED,
'mac_address': n_constants.ATTR_NOT_SPECIFIED,
'admin_state_up': False,
'device_id': '_lb-snatport-' + subnet_id,
'device_owner': DRIVER_NAME,

View File

@ -21,9 +21,9 @@ import time
import eventlet
eventlet.monkey_patch(thread=True)
from neutron.api.v2 import attributes
from neutron import context as ncontext
from neutron.plugins.common import constants
from neutron_lib import constants as n_constants
from oslo_config import cfg
from oslo_log import helpers as log_helpers
from oslo_log import log as logging
@ -633,7 +633,7 @@ class LoadBalancerDriver(abstract_driver.LoadBalancerAbstractDriver):
'tenant_id': tenant_id,
'name': port_name,
'network_id': network_id,
'mac_address': attributes.ATTR_NOT_SPECIFIED,
'mac_address': n_constants.ATTR_NOT_SPECIFIED,
'admin_state_up': False,
'device_id': '',
'device_owner': 'neutron:' + constants.LOADBALANCER,

View File

@ -18,7 +18,6 @@ import copy
import mock
from neutron.api import extensions
from neutron.api.v2 import attributes
from neutron.common import config
from neutron import context
import neutron.db.l3_db # noqa
@ -965,7 +964,7 @@ class ListenerTestBase(LbaasPluginDbTestCase):
super(ListenerTestBase, self).setUp()
network = self._make_network(self.fmt, 'test-net', True)
self.test_subnet = self._make_subnet(
self.fmt, network, gateway=attributes.ATTR_NOT_SPECIFIED,
self.fmt, network, gateway=n_constants.ATTR_NOT_SPECIFIED,
cidr='10.0.0.0/24')
self.test_subnet_id = self.test_subnet['subnet']['id']
lb_res = self._create_loadbalancer(

View File

@ -15,10 +15,10 @@
import re
import mock
from neutron.api.v2 import attributes
from neutron import context
from neutron import manager
from neutron.plugins.common import constants
from neutron_lib import constants as n_constants
from oslo_config import cfg
from oslo_serialization import jsonutils
from six.moves import queue as Queue
@ -161,7 +161,7 @@ class TestLoadBalancerPlugin(TestLoadBalancerPluginBase):
'tenant_id': 'tenant_id',
'name': 'port_name',
'network_id': 'network_id',
'mac_address': attributes.ATTR_NOT_SPECIFIED,
'mac_address': n_constants.ATTR_NOT_SPECIFIED,
'admin_state_up': False,
'device_id': '',
'device_owner': 'neutron:' + constants.LOADBALANCER,

View File

@ -14,9 +14,9 @@
#
import mock
from neutron.api.v2 import attributes
from neutron import context as ncontext
from neutron.plugins.common import constants
from neutron_lib import constants as n_constants
from neutron_lbaas.drivers import driver_mixins
from neutron_lbaas.extensions import loadbalancerv2
@ -79,7 +79,7 @@ class TestBaseManager(test_db_loadbalancerv2.LbaasPluginDbTestCase):
self.manager = DummyManager(self.driver)
network = self._make_network(self.fmt, 'test-net', True)
self.subnet = self._make_subnet(
self.fmt, network, gateway=attributes.ATTR_NOT_SPECIFIED,
self.fmt, network, gateway=n_constants.ATTR_NOT_SPECIFIED,
cidr='10.0.0.0/24')
self.subnet_id = self.subnet['subnet']['id']
self.listener = self._setup_db_data(self.context)

View File

@ -16,9 +16,9 @@
import copy
import mock
from neutron.api.v2 import attributes as attr
from neutron.plugins.common import constants
from neutron.tests.unit.api.v2 import test_base
from neutron_lib import constants as n_constants
from oslo_utils import uuidutils
from webob import exc
@ -178,7 +178,7 @@ class LoadBalancerExtensionTestCase(base.ExtensionTestCase):
res = self.api.post(_get_path('lb/pools', fmt=self.fmt),
self.serialize(data),
content_type='application/%s' % self.fmt)
data['pool']['provider'] = attr.ATTR_NOT_SPECIFIED
data['pool']['provider'] = n_constants.ATTR_NOT_SPECIFIED
instance.create_pool.assert_called_with(mock.ANY,
pool=data)
self.assertEqual(exc.HTTPCreated.code, res.status_int)
@ -517,8 +517,9 @@ class LoadBalancerExtensionV2TestCase(base.ExtensionTestCase):
res = self.api.post(_get_path('lbaas/loadbalancers', fmt=self.fmt),
self.serialize(data),
content_type='application/{0}'.format(self.fmt))
data['loadbalancer'].update({'provider': attr.ATTR_NOT_SPECIFIED,
'flavor_id': attr.ATTR_NOT_SPECIFIED})
data['loadbalancer'].update({
'provider': n_constants.ATTR_NOT_SPECIFIED,
'flavor_id': n_constants.ATTR_NOT_SPECIFIED})
instance.create_loadbalancer.assert_called_with(mock.ANY,
loadbalancer=data)

View File

@ -30,6 +30,7 @@ from neutron.tests.unit.api import test_extensions
from neutron.tests.unit.db import test_agentschedulers_db
import neutron.tests.unit.extensions
from neutron.tests.unit.extensions import test_agent
from neutron_lib import constants as n_constants
import six
from webob import exc
@ -172,8 +173,8 @@ class LBaaSAgentSchedulerTestCase(test_agent.AgentDBTestMixIn,
'loadbalancer': {
'vip_subnet_id': subnet['id'],
'provider': 'lbaas',
'flavor_id': attributes.ATTR_NOT_SPECIFIED,
'vip_address': attributes.ATTR_NOT_SPECIFIED,
'flavor_id': n_constants.ATTR_NOT_SPECIFIED,
'vip_address': n_constants.ATTR_NOT_SPECIFIED,
'admin_state_up': True,
'tenant_id': self._tenant_id}}
self.assertRaises(lbaas_agentschedulerv2.NoEligibleLbaasAgent,
@ -207,8 +208,8 @@ class LBaaSAgentSchedulerTestCase(test_agent.AgentDBTestMixIn,
'loadbalancer': {
'vip_subnet_id': subnet['id'],
'provider': 'lbaas',
'flavor_id': attributes.ATTR_NOT_SPECIFIED,
'vip_address': attributes.ATTR_NOT_SPECIFIED,
'flavor_id': n_constants.ATTR_NOT_SPECIFIED,
'vip_address': n_constants.ATTR_NOT_SPECIFIED,
'admin_state_up': True,
'tenant_id': self._tenant_id}}
self.assertRaises(lbaas_agentschedulerv2.NoEligibleLbaasAgent,