Add api support for log related parameters
Add two parameters access_log_enabled and log_significant_event_only They're supported since nsx-t 3.0.0. 1. for policy, it needs to add extra parameters. 2. for manager, ** kargs supports more parameters, nothing changed. Change-Id: I2b313eef80def69e17d664022ae2074950812897
This commit is contained in:
parent
0323737ed1
commit
99015e71b1
@ -20,9 +20,9 @@ from unittest import mock
|
|||||||
from vmware_nsxlib.tests.unit.v3 import nsxlib_testcase
|
from vmware_nsxlib.tests.unit.v3 import nsxlib_testcase
|
||||||
from vmware_nsxlib.tests.unit.v3.policy import test_resources
|
from vmware_nsxlib.tests.unit.v3.policy import test_resources
|
||||||
from vmware_nsxlib.v3 import exceptions as nsxlib_exc
|
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 constants
|
||||||
from vmware_nsxlib.v3.policy import lb_defs
|
from vmware_nsxlib.v3.policy import lb_defs
|
||||||
|
|
||||||
TEST_TENANT = 'test'
|
TEST_TENANT = 'test'
|
||||||
|
|
||||||
|
|
||||||
@ -1138,6 +1138,52 @@ class TestPolicyLBVirtualServer(test_resources.NsxPolicyLibTestCase):
|
|||||||
tenant=TEST_TENANT)
|
tenant=TEST_TENANT)
|
||||||
self.assert_called_with_def(update_call, expected_def)
|
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):
|
def test_non_partial_update(self):
|
||||||
obj_id = '111'
|
obj_id = '111'
|
||||||
vs_name = 'name-name'
|
vs_name = 'name-name'
|
||||||
|
@ -275,6 +275,8 @@ class LBVirtualServerDef(ResourceDef):
|
|||||||
body = super(LBVirtualServerDef, self).get_obj_dict()
|
body = super(LBVirtualServerDef, self).get_obj_dict()
|
||||||
self._set_attrs_if_specified(
|
self._set_attrs_if_specified(
|
||||||
body, ['ip_address', 'ports', 'max_concurrent_connections'])
|
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')
|
client_ssl_binding = self.get_attr('client_ssl_profile_binding')
|
||||||
if client_ssl_binding:
|
if client_ssl_binding:
|
||||||
self._set_attr_if_specified(
|
self._set_attr_if_specified(
|
||||||
@ -343,7 +345,9 @@ class LBVirtualServerDef(ResourceDef):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def version_dependant_attr_map(self):
|
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):
|
class ClientSSLProfileBindingDef(object):
|
||||||
|
@ -789,7 +789,8 @@ class NsxPolicyLoadBalancerVirtualServerAPI(NsxPolicyResourceBase):
|
|||||||
max_concurrent_connections=IGNORE,
|
max_concurrent_connections=IGNORE,
|
||||||
access_list_control=IGNORE,
|
access_list_control=IGNORE,
|
||||||
tenant=constants.POLICY_INFRA_TENANT,
|
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)
|
virtual_server_id = self._init_obj_uuid(virtual_server_id)
|
||||||
lbvs_def = self._init_def(
|
lbvs_def = self._init_def(
|
||||||
virtual_server_id=virtual_server_id,
|
virtual_server_id=virtual_server_id,
|
||||||
@ -808,7 +809,9 @@ class NsxPolicyLoadBalancerVirtualServerAPI(NsxPolicyResourceBase):
|
|||||||
waf_profile_binding=waf_profile_binding,
|
waf_profile_binding=waf_profile_binding,
|
||||||
max_concurrent_connections=max_concurrent_connections,
|
max_concurrent_connections=max_concurrent_connections,
|
||||||
access_list_control=access_list_control,
|
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)
|
self._create_or_store(lbvs_def)
|
||||||
return virtual_server_id
|
return virtual_server_id
|
||||||
@ -842,7 +845,8 @@ class NsxPolicyLoadBalancerVirtualServerAPI(NsxPolicyResourceBase):
|
|||||||
access_list_control=IGNORE,
|
access_list_control=IGNORE,
|
||||||
tags=IGNORE,
|
tags=IGNORE,
|
||||||
tenant=constants.POLICY_INFRA_TENANT,
|
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(
|
@utils.retry_upon_exception(
|
||||||
nsxlib_exc.StaleRevision,
|
nsxlib_exc.StaleRevision,
|
||||||
@ -866,7 +870,9 @@ class NsxPolicyLoadBalancerVirtualServerAPI(NsxPolicyResourceBase):
|
|||||||
max_concurrent_connections=max_concurrent_connections,
|
max_concurrent_connections=max_concurrent_connections,
|
||||||
access_list_control=access_list_control,
|
access_list_control=access_list_control,
|
||||||
tags=tags,
|
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()
|
_update()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user