Merge "NSX|T: Add enable standby relocation"
This commit is contained in:
commit
2f61af4101
@ -345,6 +345,10 @@ Routers
|
||||
|
||||
nsxadmin -r routers -o nsx-update-dhcp-relay
|
||||
|
||||
- Enable standby relocation on NSX routers that were created without it::
|
||||
|
||||
nsxadmin -r routers -o nsx-enable-standby-relocation
|
||||
|
||||
Orphaned Routers
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
@ -87,6 +87,11 @@ def is_nsx_version_2_1_0(nsx_version):
|
||||
version.LooseVersion(v3_const.NSX_VERSION_2_1_0))
|
||||
|
||||
|
||||
def is_nsx_version_2_4_0(nsx_version):
|
||||
return (version.LooseVersion(nsx_version) >=
|
||||
version.LooseVersion(v3_const.NSX_VERSION_2_4_0))
|
||||
|
||||
|
||||
def is_nsxv_version_6_2(nsx_version):
|
||||
return (version.LooseVersion(nsx_version) >=
|
||||
version.LooseVersion('6.2'))
|
||||
|
@ -2940,6 +2940,10 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
|
||||
self._add_az_to_router(context, router['id'], r)
|
||||
|
||||
router_db = self._get_router(context, r['id'])
|
||||
enable_standby_relocation = False
|
||||
if self.nsxlib.feature_supported(
|
||||
nsxlib_consts.FEATURE_ROUTER_ALLOCATION_PROFILE):
|
||||
enable_standby_relocation = True
|
||||
with db_api.CONTEXT_WRITER.using(context):
|
||||
self._process_extra_attr_router_create(context, router_db, r)
|
||||
# Create backend entries here in case neutron DB exception
|
||||
@ -2950,7 +2954,7 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
|
||||
display_name=utils.get_name_and_uuid(
|
||||
router['name'] or 'router', router['id']),
|
||||
description=router.get('description'),
|
||||
tags=tags)
|
||||
tags=tags, enable_standby_relocation=enable_standby_relocation)
|
||||
except nsx_lib_exc.ManagerError:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.error("Unable to create logical router for "
|
||||
|
@ -113,6 +113,33 @@ def update_nat_rules(resource, event, trigger, **kwargs):
|
||||
LOG.info("Did not find any NAT rule to update")
|
||||
|
||||
|
||||
@admin_utils.output_header
|
||||
def update_enable_standby_relocation(resource, event, trigger, **kwargs):
|
||||
"""Enable standby relocation on all routers """
|
||||
# This feature is supported only since nsx version 2.4
|
||||
nsxlib = utils.get_connected_nsxlib()
|
||||
version = nsxlib.get_version()
|
||||
if not nsx_utils.is_nsx_version_2_4_0(version):
|
||||
LOG.info("Standby relocation update is only supported from 2.4 "
|
||||
"onwards")
|
||||
LOG.info("Version is %s", version)
|
||||
return
|
||||
|
||||
# Go over all neutron routers
|
||||
plugin = RoutersPlugin()
|
||||
admin_cxt = neutron_context.get_admin_context()
|
||||
filters = utils.get_plugin_filters(admin_cxt)
|
||||
neutron_routers = plugin.get_routers(admin_cxt, filters=filters)
|
||||
for router in neutron_routers:
|
||||
neutron_id = router['id']
|
||||
# get the router nsx id from the mapping table
|
||||
nsx_id = nsx_db.get_nsx_router_id(admin_cxt.session,
|
||||
neutron_id)
|
||||
nsxlib.logical_router.update(lrouter_id=nsx_id,
|
||||
enable_standby_relocation=True)
|
||||
LOG.info("All routers where enabled with standby relocation")
|
||||
|
||||
|
||||
@admin_utils.output_header
|
||||
def list_orphaned_routers(resource, event, trigger, **kwargs):
|
||||
nsxlib = utils.get_connected_nsxlib()
|
||||
@ -231,3 +258,6 @@ registry.subscribe(delete_backend_router,
|
||||
registry.subscribe(update_dhcp_relay,
|
||||
constants.ROUTERS,
|
||||
shell.Operations.NSX_UPDATE_DHCP_RELAY.value)
|
||||
registry.subscribe(update_enable_standby_relocation,
|
||||
constants.ROUTERS,
|
||||
shell.Operations.NSX_ENABLE_STANDBY_RELOCATION.value)
|
||||
|
@ -51,6 +51,7 @@ class Operations(enum.Enum):
|
||||
NSX_UPDATE_SECRET = 'nsx-update-secret'
|
||||
NSX_UPDATE_RULES = 'nsx-update-rules'
|
||||
NSX_UPDATE_DHCP_RELAY = 'nsx-update-dhcp-relay'
|
||||
NSX_ENABLE_STANDBY_RELOCATION = 'nsx-enable-standby-relocation'
|
||||
NSX_UPDATE_IP = 'nsx-update-ip'
|
||||
NSX_RECREATE = 'nsx-recreate'
|
||||
NSX_REDISTRIBURE = 'nsx-redistribute'
|
||||
@ -106,7 +107,9 @@ nsxv3_resources = {
|
||||
constants.ROUTERS: Resource(constants.ROUTERS,
|
||||
[Operations.LIST_MISMATCHES.value,
|
||||
Operations.NSX_UPDATE_RULES.value,
|
||||
Operations.NSX_UPDATE_DHCP_RELAY.value]),
|
||||
Operations.NSX_UPDATE_DHCP_RELAY.value,
|
||||
Operations.NSX_ENABLE_STANDBY_RELOCATION.value
|
||||
]),
|
||||
constants.DHCP_BINDING: Resource(constants.DHCP_BINDING,
|
||||
[Operations.LIST.value,
|
||||
Operations.NSX_UPDATE.value,
|
||||
|
Loading…
Reference in New Issue
Block a user