NSX|V3 remove lbaas import to allow the plugin to work without lbaas
Replace LBaaS constants/classes with local ones or mocks to allow the plugin to work without checking out the neutron-lbaas. Change-Id: Iadf21ffcf7d4db8ab4e429b1daab2f8eccae1bc6
This commit is contained in:
parent
9c7991dacb
commit
25b37d5f5e
@ -124,3 +124,8 @@ LOADBALANCERS = 'loadbalancers'
|
||||
LISTENERS = 'listeners'
|
||||
POOLS = 'pools'
|
||||
MEMBERS = 'members'
|
||||
|
||||
ONLINE = 'ONLINE'
|
||||
OFFLINE = 'OFFLINE'
|
||||
DEGRADED = 'DEGRADED'
|
||||
DISABLED = 'DISABLED'
|
||||
|
21
vmware_nsx/services/lbaas/lbaas_mocks.py
Normal file
21
vmware_nsx/services/lbaas/lbaas_mocks.py
Normal file
@ -0,0 +1,21 @@
|
||||
# Copyright 2018 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.
|
||||
|
||||
# This file contains LBaaS mocks, to allow the vmware nsx plugins to work when
|
||||
# LBaaS code does not exist, and LBaaS is not configured in neutron
|
||||
|
||||
|
||||
class LoadBalancer(object):
|
||||
pass
|
@ -18,8 +18,6 @@ from neutron_lib import exceptions as n_exc
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import excutils
|
||||
|
||||
from neutron_lbaas.services.loadbalancer import constants
|
||||
|
||||
from vmware_nsx._i18n import _
|
||||
from vmware_nsx.db import db as nsx_db
|
||||
from vmware_nsx.services.lbaas import base_mgr
|
||||
@ -115,21 +113,21 @@ class EdgeLoadBalancerManagerFromDict(base_mgr.Nsxv3LoadbalancerBaseManager):
|
||||
def _nsx_status_to_lb_status(self, nsx_status):
|
||||
if not nsx_status:
|
||||
# default fallback
|
||||
return constants.ONLINE
|
||||
return lb_const.ONLINE
|
||||
|
||||
# Statuses that are considered ONLINE:
|
||||
if nsx_status.upper() in ['UP', 'UNKNOWN', 'PARTIALLY_UP',
|
||||
'NO_STANDBY']:
|
||||
return constants.ONLINE
|
||||
return lb_const.ONLINE
|
||||
# Statuses that are considered OFFLINE:
|
||||
if nsx_status.upper() in ['PRIMARY_DOWN', 'DETACHED', 'DOWN', 'ERROR']:
|
||||
return constants.OFFLINE
|
||||
return lb_const.OFFLINE
|
||||
if nsx_status.upper() == 'DISABLED':
|
||||
return constants.DISABLED
|
||||
return lb_const.DISABLED
|
||||
|
||||
# default fallback
|
||||
LOG.debug("NSX LB status %s - interpreted as ONLINE", nsx_status)
|
||||
return constants.ONLINE
|
||||
return lb_const.ONLINE
|
||||
|
||||
def get_lb_pool_members_statuses(self, nsx_pool_id, members_statuses):
|
||||
# Combine the NSX pool members data and the NSX statuses to provide
|
||||
|
@ -25,10 +25,14 @@ from oslo_log import log as logging
|
||||
import oslo_messaging as messaging
|
||||
from oslo_messaging.rpc import dispatcher
|
||||
|
||||
from neutron_lbaas.db.loadbalancer import models
|
||||
|
||||
from vmware_nsx.services.lbaas.octavia import constants
|
||||
|
||||
try:
|
||||
from neutron_lbaas.db.loadbalancer import models
|
||||
except ImportError:
|
||||
# LBaaS project not found.
|
||||
from vmware_nsx.services.lbaas import lbaas_mocks as models
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@ -342,6 +346,10 @@ class NSXOctaviaStatisticsCollector(object):
|
||||
case that the plugin is currently unavailable, but entries already
|
||||
exist on the DB.
|
||||
"""
|
||||
if not hasattr(models.LoadBalancer, '__tablename__'):
|
||||
# No neutron-lbaas on this deployment
|
||||
return []
|
||||
|
||||
nl_loadbalancers = context.session.query(models.LoadBalancer).all()
|
||||
return [lb.id for lb in nl_loadbalancers]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user