Fixed a bug in Neutron GCE router to run on master and stable/newton
Issue: - Classes used in gce_router_plugin.py are different on master and stable/newton branch. Example: - In newton branch, we are importing "from neutron.db import l3_db" and we are using this import as l3_db.Router. But on master branch, l3_db doesn't have attribute "Router". Hence to solve this, we need to import "from neutron.db.models import l3". File Modified: - neutron/neutron/services/l3_router/gce_router_plugin.py Closes-Bug: #1702881 Change-Id: I4d872ee0034417cdf38e774d69d1acec7924cc17
This commit is contained in:
parent
84b9c632f5
commit
ed23220a8d
@ -12,6 +12,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import neutron_lib
|
||||
from distutils.version import LooseVersion
|
||||
from oslo_log import log as logging
|
||||
|
||||
from neutron.common import exceptions
|
||||
@ -31,6 +33,18 @@ from neutron_lib import constants as n_const
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
if LooseVersion(neutron_lib.__version__) < LooseVersion("1.0.0"):
|
||||
router = l3_db.Router
|
||||
floating_ip = l3_db.FloatingIP
|
||||
plugin_type = constants.L3_ROUTER_NAT
|
||||
else:
|
||||
from neutron.db.models import l3
|
||||
from neutron_lib.plugins import constants as plugin_constants
|
||||
from neutron_lib.services import base as service_base
|
||||
router = l3.Router
|
||||
floating_ip = l3.FloatingIP
|
||||
plugin_type = plugin_constants.L3
|
||||
|
||||
|
||||
class GceRouterPlugin(
|
||||
service_base.ServicePluginBase, common_db_mixin.CommonDbMixin,
|
||||
@ -51,8 +65,8 @@ class GceRouterPlugin(
|
||||
"l3-ha"
|
||||
]
|
||||
|
||||
@resource_registry.tracked_resources(router=l3_db.Router,
|
||||
floatingip=l3_db.FloatingIP)
|
||||
@resource_registry.tracked_resources(router=router,
|
||||
floatingip=floating_ip)
|
||||
def __init__(self):
|
||||
super(GceRouterPlugin, self).__init__()
|
||||
l3_db.subscribe()
|
||||
@ -65,7 +79,7 @@ class GceRouterPlugin(
|
||||
(self.gce_project, self.gce_region))
|
||||
|
||||
def get_plugin_type(self):
|
||||
return constants.L3_ROUTER_NAT
|
||||
return plugin_type
|
||||
|
||||
def get_plugin_description(self):
|
||||
"""returns string description of the plugin."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user