Server ssl profiles
Added support for server ssl profile CRUD operations Change-Id: Ief7c0d189fc89a35b49cc289da408e4ea6764997
This commit is contained in:
parent
bcf20e2466
commit
aae37e05ee
|
@ -126,6 +126,108 @@ class TestPolicyLBClientSSLProfileApi(test_resources.NsxPolicyLibTestCase):
|
||||||
self.assert_called_with_def(update_call, expected_def)
|
self.assert_called_with_def(update_call, expected_def)
|
||||||
|
|
||||||
|
|
||||||
|
class TestPolicyLBServerSSLProfileApi(test_resources.NsxPolicyLibTestCase):
|
||||||
|
|
||||||
|
def setUp(self, *args, **kwargs):
|
||||||
|
super(TestPolicyLBServerSSLProfileApi, self).setUp()
|
||||||
|
self.resourceApi = self.policy_lib.load_balancer.server_ssl_profile
|
||||||
|
|
||||||
|
def test_create_with_id(self):
|
||||||
|
name = 'd1'
|
||||||
|
description = 'desc'
|
||||||
|
obj_id = '111'
|
||||||
|
protocols = ['TLS_V1_1']
|
||||||
|
with mock.patch.object(self.policy_api,
|
||||||
|
"create_or_update") as api_call:
|
||||||
|
result = self.resourceApi.create_or_overwrite(
|
||||||
|
name,
|
||||||
|
server_ssl_profile_id=obj_id,
|
||||||
|
description=description,
|
||||||
|
protocols=protocols,
|
||||||
|
tenant=TEST_TENANT)
|
||||||
|
expected_def = lb_defs.LBServerSslProfileDef(
|
||||||
|
server_ssl_profile_id=obj_id,
|
||||||
|
name=name,
|
||||||
|
description=description,
|
||||||
|
protocols=protocols,
|
||||||
|
tenant=TEST_TENANT)
|
||||||
|
self.assert_called_with_def(api_call, expected_def)
|
||||||
|
self.assertEqual(obj_id, result)
|
||||||
|
|
||||||
|
def test_create_without_id(self):
|
||||||
|
name = 'd1'
|
||||||
|
description = 'desc'
|
||||||
|
with mock.patch.object(self.policy_api,
|
||||||
|
"create_or_update") as api_call:
|
||||||
|
result = self.resourceApi.create_or_overwrite(
|
||||||
|
name, description=description,
|
||||||
|
tenant=TEST_TENANT)
|
||||||
|
expected_def = lb_defs.LBServerSslProfileDef(
|
||||||
|
server_ssl_profile_id=mock.ANY,
|
||||||
|
name=name,
|
||||||
|
description=description,
|
||||||
|
tenant=TEST_TENANT)
|
||||||
|
self.assert_called_with_def(api_call, expected_def)
|
||||||
|
self.assertIsNotNone(result)
|
||||||
|
|
||||||
|
def test_delete(self):
|
||||||
|
obj_id = '111'
|
||||||
|
with mock.patch.object(self.policy_api, "delete") as api_call:
|
||||||
|
self.resourceApi.delete(obj_id, tenant=TEST_TENANT)
|
||||||
|
expected_def = lb_defs.LBServerSslProfileDef(
|
||||||
|
server_ssl_profile_id=obj_id,
|
||||||
|
tenant=TEST_TENANT)
|
||||||
|
self.assert_called_with_def(api_call, expected_def)
|
||||||
|
|
||||||
|
def test_get(self):
|
||||||
|
obj_id = '111'
|
||||||
|
with mock.patch.object(self.policy_api, "get",
|
||||||
|
return_value={'id': obj_id}) as api_call:
|
||||||
|
result = self.resourceApi.get(obj_id, tenant=TEST_TENANT)
|
||||||
|
expected_def = lb_defs.LBServerSslProfileDef(
|
||||||
|
server_ssl_profile_id=obj_id,
|
||||||
|
tenant=TEST_TENANT)
|
||||||
|
self.assert_called_with_def(api_call, expected_def)
|
||||||
|
self.assertEqual(obj_id, result['id'])
|
||||||
|
|
||||||
|
def test_get_by_name(self):
|
||||||
|
name = 'd1'
|
||||||
|
with mock.patch.object(
|
||||||
|
self.policy_api, "list",
|
||||||
|
return_value={'results': [{'display_name': name}]}) as api_call:
|
||||||
|
obj = self.resourceApi.get_by_name(name, tenant=TEST_TENANT)
|
||||||
|
self.assertIsNotNone(obj)
|
||||||
|
expected_def = lb_defs.LBServerSslProfileDef(
|
||||||
|
tenant=TEST_TENANT)
|
||||||
|
self.assert_called_with_def(api_call, expected_def)
|
||||||
|
|
||||||
|
def test_list(self):
|
||||||
|
with mock.patch.object(self.policy_api, "list",
|
||||||
|
return_value={'results': []}) as api_call:
|
||||||
|
result = self.resourceApi.list(tenant=TEST_TENANT)
|
||||||
|
expected_def = lb_defs.LBServerSslProfileDef(
|
||||||
|
tenant=TEST_TENANT)
|
||||||
|
self.assert_called_with_def(api_call, expected_def)
|
||||||
|
self.assertEqual([], result)
|
||||||
|
|
||||||
|
def test_update(self):
|
||||||
|
obj_id = '111'
|
||||||
|
name = 'new name'
|
||||||
|
description = 'new desc'
|
||||||
|
with self.mock_get(obj_id, name), \
|
||||||
|
self.mock_create_update() as update_call:
|
||||||
|
self.resourceApi.update(obj_id,
|
||||||
|
name=name,
|
||||||
|
description=description,
|
||||||
|
tenant=TEST_TENANT)
|
||||||
|
expected_def = lb_defs.LBServerSslProfileDef(
|
||||||
|
server_ssl_profile_id=obj_id,
|
||||||
|
name=name,
|
||||||
|
description=description,
|
||||||
|
tenant=TEST_TENANT)
|
||||||
|
self.assert_called_with_def(update_call, expected_def)
|
||||||
|
|
||||||
|
|
||||||
class TestPolicyLBPersistenceProfile(
|
class TestPolicyLBPersistenceProfile(
|
||||||
test_resources.NsxPolicyLibTestCase):
|
test_resources.NsxPolicyLibTestCase):
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,8 @@ LB_APP_PROFILE_PATTERN = TENANTS_PATH_PATTERN + "lb-app-profiles/"
|
||||||
LB_MONITOR_PROFILE_PATTERN = TENANTS_PATH_PATTERN + "lb-monitor-profiles/"
|
LB_MONITOR_PROFILE_PATTERN = TENANTS_PATH_PATTERN + "lb-monitor-profiles/"
|
||||||
LB_CLIENT_SSL_PROFILE_PATTERN = (TENANTS_PATH_PATTERN +
|
LB_CLIENT_SSL_PROFILE_PATTERN = (TENANTS_PATH_PATTERN +
|
||||||
"lb-client-ssl-profiles/")
|
"lb-client-ssl-profiles/")
|
||||||
|
LBSERVER_SSL_PROFILE_PATTERN = (TENANTS_PATH_PATTERN +
|
||||||
|
"lb-server-ssl-profiles/")
|
||||||
LB_PERSISTENCE_PROFILE_PATTERN = (TENANTS_PATH_PATTERN +
|
LB_PERSISTENCE_PROFILE_PATTERN = (TENANTS_PATH_PATTERN +
|
||||||
"lb-persistence-profiles/")
|
"lb-persistence-profiles/")
|
||||||
|
|
||||||
|
@ -84,6 +86,28 @@ class LBPoolMemberDef(object):
|
||||||
return body
|
return body
|
||||||
|
|
||||||
|
|
||||||
|
class LBServerSslProfileDef(ResourceDef):
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path_pattern(self):
|
||||||
|
return LBSERVER_SSL_PROFILE_PATTERN
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path_ids(self):
|
||||||
|
return ('tenant', 'server_ssl_profile_id')
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def resource_type():
|
||||||
|
return "LBServerSslProfile"
|
||||||
|
|
||||||
|
def get_obj_dict(self):
|
||||||
|
body = super(LBServerSslProfileDef, self).get_obj_dict()
|
||||||
|
self._set_attrs_if_specified(body, ['cipher_group_label', 'ciphers',
|
||||||
|
'protocols',
|
||||||
|
'session_cache_enabled'])
|
||||||
|
return body
|
||||||
|
|
||||||
|
|
||||||
class LBClientSslProfileDef(ResourceDef):
|
class LBClientSslProfileDef(ResourceDef):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -154,6 +154,61 @@ class NsxPolicyLBAppProfileFastUdpApi(
|
||||||
return lb_defs.LBFastUdpProfile
|
return lb_defs.LBFastUdpProfile
|
||||||
|
|
||||||
|
|
||||||
|
class NsxPolicyLoadBalancerServerSSLProfileApi(NsxPolicyResourceBase):
|
||||||
|
"""NSX Policy LB server ssl profile"""
|
||||||
|
|
||||||
|
@property
|
||||||
|
def entry_def(self):
|
||||||
|
return lb_defs.LBServerSslProfileDef
|
||||||
|
|
||||||
|
def create_or_overwrite(self, name, server_ssl_profile_id=None,
|
||||||
|
description=IGNORE, tags=IGNORE,
|
||||||
|
cipher_group_label=IGNORE, ciphers=IGNORE,
|
||||||
|
protocols=IGNORE, session_cache_enabled=IGNORE,
|
||||||
|
tenant=constants.POLICY_INFRA_TENANT):
|
||||||
|
server_ssl_profile_id = self._init_obj_uuid(server_ssl_profile_id)
|
||||||
|
lb_server_ssl_profile_def = self._init_def(
|
||||||
|
server_ssl_profile_id=server_ssl_profile_id,
|
||||||
|
name=name,
|
||||||
|
description=description,
|
||||||
|
tags=tags,
|
||||||
|
protocols=protocols,
|
||||||
|
tenant=tenant)
|
||||||
|
self._create_or_store(lb_server_ssl_profile_def)
|
||||||
|
return server_ssl_profile_id
|
||||||
|
|
||||||
|
def delete(self, server_ssl_profile_id,
|
||||||
|
tenant=constants.POLICY_INFRA_TENANT):
|
||||||
|
lb_server_ssl_profile_def = self.entry_def(
|
||||||
|
server_ssl_profile_id=server_ssl_profile_id,
|
||||||
|
tenant=tenant)
|
||||||
|
self.policy_api.delete(lb_server_ssl_profile_def)
|
||||||
|
|
||||||
|
def get(self, server_ssl_profile_id,
|
||||||
|
tenant=constants.POLICY_INFRA_TENANT):
|
||||||
|
lb_server_ssl_profile_def = self.entry_def(
|
||||||
|
server_ssl_profile_id=server_ssl_profile_id,
|
||||||
|
tenant=tenant)
|
||||||
|
return self.policy_api.get(lb_server_ssl_profile_def)
|
||||||
|
|
||||||
|
def list(self, tenant=constants.POLICY_INFRA_TENANT):
|
||||||
|
lb_server_ssl_profile_def = self.entry_def(tenant=tenant)
|
||||||
|
return self._list(lb_server_ssl_profile_def)
|
||||||
|
|
||||||
|
def update(self, server_ssl_profile_id,
|
||||||
|
name=IGNORE, description=IGNORE, tags=IGNORE,
|
||||||
|
cipher_group_label=IGNORE, ciphers=IGNORE,
|
||||||
|
protocols=IGNORE, session_cache_enabled=IGNORE,
|
||||||
|
tenant=constants.POLICY_INFRA_TENANT):
|
||||||
|
self._update(
|
||||||
|
server_ssl_profile_id=server_ssl_profile_id,
|
||||||
|
name=name,
|
||||||
|
description=description,
|
||||||
|
tags=tags,
|
||||||
|
protocols=protocols,
|
||||||
|
tenant=tenant)
|
||||||
|
|
||||||
|
|
||||||
class NsxPolicyLoadBalancerClientSSLProfileApi(NsxPolicyResourceBase):
|
class NsxPolicyLoadBalancerClientSSLProfileApi(NsxPolicyResourceBase):
|
||||||
"""NSX Policy LB client ssl profile"""
|
"""NSX Policy LB client ssl profile"""
|
||||||
|
|
||||||
|
@ -1253,6 +1308,8 @@ class NsxPolicyLoadBalancerApi(object):
|
||||||
self.lb_fast_udp_profile = NsxPolicyLBAppProfileFastUdpApi(*args)
|
self.lb_fast_udp_profile = NsxPolicyLBAppProfileFastUdpApi(*args)
|
||||||
self.client_ssl_profile = (
|
self.client_ssl_profile = (
|
||||||
NsxPolicyLoadBalancerClientSSLProfileApi(*args))
|
NsxPolicyLoadBalancerClientSSLProfileApi(*args))
|
||||||
|
self.server_ssl_profile = (
|
||||||
|
NsxPolicyLoadBalancerServerSSLProfileApi(*args))
|
||||||
self.lb_persistence_profile = (
|
self.lb_persistence_profile = (
|
||||||
NsxPolicyLoadBalancerPersistenceProfileApi(*args))
|
NsxPolicyLoadBalancerPersistenceProfileApi(*args))
|
||||||
self.lb_cookie_persistence_profile = (
|
self.lb_cookie_persistence_profile = (
|
||||||
|
|
Loading…
Reference in New Issue