Merge "Add api support for log related parameters"

This commit is contained in:
Zuul 2020-12-02 05:46:25 +00:00 committed by Gerrit Code Review
commit 0ec8b223b4
3 changed files with 62 additions and 6 deletions

View File

@ -20,9 +20,9 @@ from unittest import mock
from vmware_nsxlib.tests.unit.v3 import nsxlib_testcase
from vmware_nsxlib.tests.unit.v3.policy import test_resources
from vmware_nsxlib.v3 import exceptions as nsxlib_exc
from vmware_nsxlib.v3 import nsx_constants
from vmware_nsxlib.v3.policy import constants
from vmware_nsxlib.v3.policy import lb_defs
TEST_TENANT = 'test'
@ -1138,6 +1138,52 @@ class TestPolicyLBVirtualServer(test_resources.NsxPolicyLibTestCase):
tenant=TEST_TENANT)
self.assert_called_with_def(update_call, expected_def)
def test_update_log_parameters(self):
obj_id = '111'
name = 'new name'
description = 'new desc'
vs_name = 'name-name'
with self.mock_get(obj_id, vs_name), \
self.mock_create_update() as update_call:
self.resourceApi.update(obj_id,
name=name,
description=description,
tenant=TEST_TENANT,
access_log_enabled=True,
log_significant_event_only=True)
expected_def = lb_defs.LBVirtualServerDef(
nsx_version=nsx_constants.NSX_VERSION_3_0_0,
virtual_server_id=obj_id, name=name,
description=description,
tenant=TEST_TENANT, access_log_enabled=True,
log_significant_event_only=True)
self.assert_called_with_def(update_call, expected_def)
def test_log_parameters_for_version(self):
obj_id = '111'
name = 'new name'
description = 'new desc'
expected_def = lb_defs.LBVirtualServerDef(
nsx_version=nsx_constants.NSX_VERSION_2_5_0,
virtual_server_id=obj_id, name=name,
description=description,
tenant=TEST_TENANT, access_log_enabled=True,
log_significant_event_only=True)
self.assertFalse('access_log_enabled' in expected_def.get_obj_dict())
self.assertFalse('log_significant_event_only' in
expected_def.get_obj_dict())
expected_def = lb_defs.LBVirtualServerDef(
nsx_version=nsx_constants.NSX_VERSION_3_0_0,
virtual_server_id=obj_id, name=name,
description=description,
tenant=TEST_TENANT, access_log_enabled=True,
log_significant_event_only=True)
self.assertTrue('access_log_enabled' in expected_def.get_obj_dict())
self.assertTrue('log_significant_event_only' in
expected_def.get_obj_dict())
def test_non_partial_update(self):
obj_id = '111'
vs_name = 'name-name'

View File

@ -276,6 +276,8 @@ class LBVirtualServerDef(ResourceDef):
body = super(LBVirtualServerDef, self).get_obj_dict()
self._set_attrs_if_specified(
body, ['ip_address', 'ports', 'max_concurrent_connections'])
self._set_attrs_if_supported(
body, ['access_log_enabled', 'log_significant_event_only'])
client_ssl_binding = self.get_attr('client_ssl_profile_binding')
if client_ssl_binding:
self._set_attr_if_specified(
@ -344,7 +346,9 @@ class LBVirtualServerDef(ResourceDef):
@property
def version_dependant_attr_map(self):
return {'access_list_control': nsx_constants.NSX_VERSION_3_0_0}
return {'access_list_control': nsx_constants.NSX_VERSION_3_0_0,
'access_log_enabled': nsx_constants.NSX_VERSION_3_0_0,
'log_significant_event_only': nsx_constants.NSX_VERSION_3_0_0}
class ClientSSLProfileBindingDef(object):

View File

@ -796,7 +796,8 @@ class NsxPolicyLoadBalancerVirtualServerAPI(NsxPolicyResourceBase):
max_concurrent_connections=IGNORE,
access_list_control=IGNORE,
tenant=constants.POLICY_INFRA_TENANT,
tags=IGNORE):
tags=IGNORE, access_log_enabled=IGNORE,
log_significant_event_only=IGNORE):
virtual_server_id = self._init_obj_uuid(virtual_server_id)
lbvs_def = self._init_def(
virtual_server_id=virtual_server_id,
@ -815,7 +816,9 @@ class NsxPolicyLoadBalancerVirtualServerAPI(NsxPolicyResourceBase):
waf_profile_binding=waf_profile_binding,
max_concurrent_connections=max_concurrent_connections,
access_list_control=access_list_control,
tags=tags
tags=tags,
access_log_enabled=access_log_enabled,
log_significant_event_only=log_significant_event_only
)
self._create_or_store(lbvs_def)
return virtual_server_id
@ -849,7 +852,8 @@ class NsxPolicyLoadBalancerVirtualServerAPI(NsxPolicyResourceBase):
access_list_control=IGNORE,
tags=IGNORE,
tenant=constants.POLICY_INFRA_TENANT,
allow_partial_updates=True):
allow_partial_updates=True, access_log_enabled=IGNORE,
log_significant_event_only=IGNORE):
@utils.retry_upon_exception(
nsxlib_exc.StaleRevision,
@ -873,7 +877,9 @@ class NsxPolicyLoadBalancerVirtualServerAPI(NsxPolicyResourceBase):
max_concurrent_connections=max_concurrent_connections,
access_list_control=access_list_control,
tags=tags,
allow_partial_updates=allow_partial_updates)
allow_partial_updates=allow_partial_updates,
access_log_enabled=access_log_enabled,
log_significant_event_only=log_significant_event_only)
_update()