From 9c5886b3d821166193f77fee3f3cdbda4bccb1a4 Mon Sep 17 00:00:00 2001 From: Shawn Wang Date: Wed, 22 Jan 2020 18:30:55 -0800 Subject: [PATCH] Expose failover_mode option for T1 Router in MP This option is already exposed for Policy. In MP this option is only accessable via update calls for now. This patch allows user to create T1 router with this option set to desired value, saving an addtional call. Change-Id: I29f4122f5d5ba60732046b95af9b8de08819cbeb --- vmware_nsxlib/tests/unit/v3/test_resources.py | 5 ++++- vmware_nsxlib/v3/core_resources.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/vmware_nsxlib/tests/unit/v3/test_resources.py b/vmware_nsxlib/tests/unit/v3/test_resources.py index f6311e0d..d1c8fbe3 100644 --- a/vmware_nsxlib/tests/unit/v3/test_resources.py +++ b/vmware_nsxlib/tests/unit/v3/test_resources.py @@ -845,6 +845,7 @@ class LogicalRouterTestCase(BaseTestResource): tier0_router = True description = 'dummy' tz_id = 'tz_id' + failover_mode = 'PREEMPTIVE' allocation_pool = { 'allocation_pool_type': 'LoadBalancerAllocationPool', 'allocation_size': 'SMALL' @@ -854,7 +855,8 @@ class LogicalRouterTestCase(BaseTestResource): router.create(fake_router['display_name'], None, None, tier0_router, description=description, transport_zone_id=tz_id, - allocation_pool=allocation_pool) + allocation_pool=allocation_pool, + failover_mode=failover_mode) data = { 'display_name': fake_router['display_name'], @@ -862,6 +864,7 @@ class LogicalRouterTestCase(BaseTestResource): 'tags': None, 'description': description, 'advanced_config': {'transport_zone_id': tz_id}, + 'failover_mode': failover_mode, 'allocation_profile': { 'allocation_pool': allocation_pool } diff --git a/vmware_nsxlib/v3/core_resources.py b/vmware_nsxlib/v3/core_resources.py index d03f9e3f..4a53915a 100644 --- a/vmware_nsxlib/v3/core_resources.py +++ b/vmware_nsxlib/v3/core_resources.py @@ -766,7 +766,8 @@ class NsxLibLogicalRouter(utils.NsxLibApiBase): def create(self, display_name, tags, edge_cluster_uuid=None, tier_0=False, description=None, transport_zone_id=None, - allocation_pool=None, enable_standby_relocation=False): + allocation_pool=None, enable_standby_relocation=False, + failover_mode=None): # TODO(salv-orlando): If possible do not manage edge clusters # in the main plugin logic. router_type = (nsx_constants.ROUTER_TYPE_TIER0 if tier_0 else @@ -781,6 +782,8 @@ class NsxLibLogicalRouter(utils.NsxLibApiBase): if transport_zone_id: body['advanced_config'] = { 'transport_zone_id': transport_zone_id} + if failover_mode: + body['failover_mode'] = failover_mode allocation_profile = {} if allocation_pool: allocation_profile['allocation_pool'] = allocation_pool