Beispiel #1
0
 def _build_args(body,
                 display_name=None,
                 description=None,
                 tags=None,
                 resource_type=None,
                 **kwargs):
     if display_name:
         body['display_name'] = display_name
     if description:
         body['description'] = description
     if tags:
         body['tags'] = tags
     if resource_type is None:
         return body
     if resource_type == ApplicationProfileTypes.HTTP:
         body['resource_type'] = resource_type
         extra_args = [
             'http_redirect_to', 'http_redirect_to_https', 'ntlm',
             'request_header_size', 'x_forwarded_for', 'idle_timeout'
         ]
         return utils.build_extra_args(body, extra_args, **kwargs)
     elif (resource_type == ApplicationProfileTypes.FAST_TCP
           or resource_type == ApplicationProfileTypes.FAST_UDP):
         body['resource_type'] = resource_type
         extra_args = ['ha_flow_mirroring_enabled', 'idle_timeout']
         return utils.build_extra_args(body, extra_args, **kwargs)
     else:
         raise nsxlib_exc.InvalidInput(
             operation='create_application_profile',
             arg_val=resource_type,
             arg_name='resource_type')
Beispiel #2
0
 def _build_args(body,
                 display_name=None,
                 description=None,
                 tags=None,
                 resource_type=None,
                 **kwargs):
     if display_name:
         body['display_name'] = display_name
     if description:
         body['description'] = description
     if tags:
         body['tags'] = tags
     if resource_type == PersistenceProfileTypes.COOKIE:
         body['resource_type'] = resource_type
         extra_args = [
             'cookie_domain', 'cookie_fallback', 'cookie_garble',
             'cookie_mode', 'cookie_name', 'cookie_path', 'cookie_time'
         ]
         return utils.build_extra_args(body, extra_args, **kwargs)
     elif resource_type == PersistenceProfileTypes.SOURCE_IP:
         body['resource_type'] = resource_type
         extra_args = [
             'ha_persistence_mirroring_enabled', 'purge', 'timeout'
         ]
         return utils.build_extra_args(body, extra_args, **kwargs)
     else:
         raise nsxlib_exc.InvalidInput(
             operation='create_persistence_profile',
             arg_val=resource_type,
             arg_name='resource_type')
 def _build_args(body, display_name=None, description=None, tags=None,
                 resource_type=None, **kwargs):
     if display_name:
         body['display_name'] = display_name
     if description:
         body['description'] = description
     if tags:
         body['tags'] = tags
     if resource_type is None:
         return body
     if resource_type == ApplicationProfileTypes.HTTP:
         body['resource_type'] = resource_type
         extra_args = ['http_redirect_to', 'http_redirect_to_https',
                       'ntlm', 'request_header_size', 'x_forwarded_for',
                       'idle_timeout']
         return utils.build_extra_args(body, extra_args, **kwargs)
     elif (resource_type == ApplicationProfileTypes.FAST_TCP or
           resource_type == ApplicationProfileTypes.FAST_UDP):
         body['resource_type'] = resource_type
         extra_args = ['ha_flow_mirroring_enabled', 'idle_timeout']
         return utils.build_extra_args(body, extra_args, **kwargs)
     else:
         raise nsxlib_exc.InvalidInput(
             operation='create_application_profile',
             arg_val=resource_type,
             arg_name='resource_type')
Beispiel #4
0
 def _build_args(body,
                 display_name=None,
                 description=None,
                 tags=None,
                 resource_type=None,
                 **kwargs):
     if display_name:
         body['display_name'] = display_name
     if description:
         body['description'] = description
     if tags:
         body['tags'] = tags
     if resource_type == MonitorTypes.HTTP:
         body['resource_type'] = resource_type
         extra_args = [
             'fall_count', 'interval', 'monitor_port', 'request_body',
             'request_method', 'request_url', 'request_version',
             'response_body', 'response_status_codes', 'rise_count',
             'timeout'
         ]
         return utils.build_extra_args(body, extra_args, **kwargs)
     elif resource_type == MonitorTypes.HTTPS:
         body['resource_type'] = resource_type
         extra_args = [
             'certificate_chain_depth', 'ciphers', 'client_certificate_id',
             'fall_count', 'interval', 'monitor_port', 'protocols',
             'request_body', 'request_method', 'request_url',
             'request_version', 'response_body', 'response_status_codes',
             'rise_count', 'server_auth', 'server_auth_ca_ids',
             'server_auth_crl_ids', 'timeout'
         ]
         return utils.build_extra_args(body, extra_args, **kwargs)
     elif resource_type == MonitorTypes.ICMP:
         body['resource_type'] = resource_type
         extra_args = [
             'data_length', 'fall_count', 'interval', 'monitor_port',
             'rise_count', 'timeout'
         ]
         return utils.build_extra_args(body, extra_args, **kwargs)
     elif resource_type == MonitorTypes.PASSIVE:
         body['resource_type'] = resource_type
         extra_args = ['max_fails', 'timeout']
         return utils.build_extra_args(body, extra_args, **kwargs)
     elif (resource_type == MonitorTypes.TCP
           or resource_type == MonitorTypes.UDP):
         body['resource_type'] = resource_type
         extra_args = [
             'fall_count', 'interval', 'monitor_port', 'receive',
             'rise_count', 'send', 'timeout'
         ]
         return utils.build_extra_args(body, extra_args, **kwargs)
     else:
         raise nsxlib_exc.InvalidInput(operation='create_monitor',
                                       arg_val=resource_type,
                                       arg_name='resource_type')
 def _build_args(body, display_name=None, description=None, tags=None,
                 resource_type=None, **kwargs):
     if display_name:
         body['display_name'] = display_name
     if description:
         body['description'] = description
     if tags:
         body['tags'] = tags
     if resource_type == MonitorTypes.HTTP:
         body['resource_type'] = resource_type
         extra_args = ['fall_count', 'interval', 'monitor_port',
                       'request_body', 'request_method', 'request_url',
                       'request_version', 'response_body',
                       'response_status_codes', 'rise_count', 'timeout']
         return utils.build_extra_args(body, extra_args, **kwargs)
     elif resource_type == MonitorTypes.HTTPS:
         body['resource_type'] = resource_type
         extra_args = ['certificate_chain_depth', 'ciphers',
                       'client_certificate_id', 'fall_count', 'interval',
                       'monitor_port', 'protocols', 'request_body',
                       'request_method', 'request_url', 'request_version',
                       'response_body', 'response_status_codes',
                       'rise_count', 'server_auth', 'server_auth_ca_ids',
                       'server_auth_crl_ids', 'timeout']
         return utils.build_extra_args(body, extra_args, **kwargs)
     elif resource_type == MonitorTypes.ICMP:
         body['resource_type'] = resource_type
         extra_args = ['data_length', 'fall_count', 'interval',
                       'monitor_port', 'rise_count', 'timeout']
         return utils.build_extra_args(body, extra_args, **kwargs)
     elif resource_type == MonitorTypes.PASSIVE:
         body['resource_type'] = resource_type
         extra_args = ['max_fails', 'timeout']
         return utils.build_extra_args(body, extra_args, **kwargs)
     elif (resource_type == MonitorTypes.TCP or
           resource_type == MonitorTypes.UDP):
         body['resource_type'] = resource_type
         extra_args = ['fall_count', 'interval', 'monitor_port', 'receive',
                       'rise_count', 'send', 'timeout']
         return utils.build_extra_args(body, extra_args, **kwargs)
     else:
         raise nsxlib_exc.InvalidInput(
             operation='create_monitor',
             arg_val=resource_type,
             arg_name='resource_type')
Beispiel #6
0
 def test_build_extra_args_positive(self):
     extra_args = ['fall_count', 'interval', 'monitor_port',
                   'request_body', 'request_method', 'request_url',
                   'request_version', 'response_body',
                   'response_status', 'rise_count', 'timeout']
     body = {'display_name': 'httpmonitor1',
             'description': 'my http monitor'}
     expected = {'display_name': 'httpmonitor1',
                 'description': 'my http monitor',
                 'interval': 5,
                 'rise_count': 3,
                 'fall_count': 3}
     resp = utils.build_extra_args(body, extra_args, interval=5,
                                   rise_count=3, fall_count=3)
     self.assertEqual(resp, expected)
Beispiel #7
0
 def test_build_extra_args_positive(self):
     extra_args = ['fall_count', 'interval', 'monitor_port',
                   'request_body', 'request_method', 'request_url',
                   'request_version', 'response_body',
                   'response_status_codes', 'rise_count', 'timeout']
     body = {'display_name': 'httpmonitor1',
             'description': 'my http monitor'}
     expected = {'display_name': 'httpmonitor1',
                 'description': 'my http monitor',
                 'interval': 5,
                 'rise_count': 3,
                 'fall_count': 3}
     resp = utils.build_extra_args(body, extra_args, interval=5,
                                   rise_count=3, fall_count=3)
     self.assertEqual(resp, expected)
 def _build_args(body, display_name=None, description=None, tags=None,
                 resource_type=None, **kwargs):
     if display_name:
         body['display_name'] = display_name
     if description:
         body['description'] = description
     if tags:
         body['tags'] = tags
     if resource_type == PersistenceProfileTypes.COOKIE:
         body['resource_type'] = resource_type
         extra_args = ['cookie_domain', 'cookie_fallback', 'cookie_garble',
                       'cookie_mode', 'cookie_name', 'cookie_path',
                       'cookie_time']
         return utils.build_extra_args(body, extra_args, **kwargs)
     elif resource_type == PersistenceProfileTypes.SOURCE_IP:
         body['resource_type'] = resource_type
         extra_args = ['ha_persistence_mirroring_enabled', 'purge',
                       'timeout']
         return utils.build_extra_args(body, extra_args, **kwargs)
     else:
         raise nsxlib_exc.InvalidInput(
             operation='create_persistence_profile',
             arg_val=resource_type,
             arg_name='resource_type')
Beispiel #9
0
 def test_build_extra_args_negative(self):
     extra_args = ['cookie_domain', 'cookie_fallback', 'cookie_garble',
                   'cookie_mode', 'cookie_name', 'cookie_path',
                   'cookie_time']
     body = {'display_name': 'persistenceprofile1',
             'description': 'my persistence profile',
             'resource_type': 'LoadBalancerCookiePersistenceProfile'}
     expected = {'display_name': 'persistenceprofile1',
                 'description': 'my persistence profile',
                 'resource_type': 'LoadBalancerCookiePersistenceProfile',
                 'cookie_mode': 'INSERT',
                 'cookie_name': 'ABC',
                 'cookie_fallback': True}
     resp = utils.build_extra_args(body, extra_args, cookie_mode='INSERT',
                                   cookie_name='ABC', cookie_fallback=True,
                                   bogus='bogus')
     self.assertEqual(resp, expected)
Beispiel #10
0
 def test_build_extra_args_negative(self):
     extra_args = ['cookie_domain', 'cookie_fallback', 'cookie_garble',
                   'cookie_mode', 'cookie_name', 'cookie_path',
                   'cookie_time']
     body = {'display_name': 'persistenceprofile1',
             'description': 'my persistence profile',
             'resource_type': 'LoadBalancerCookiePersistenceProfile'}
     expected = {'display_name': 'persistenceprofile1',
                 'description': 'my persistence profile',
                 'resource_type': 'LoadBalancerCookiePersistenceProfile',
                 'cookie_mode': 'INSERT',
                 'cookie_name': 'ABC',
                 'cookie_fallback': True}
     resp = utils.build_extra_args(body, extra_args, cookie_mode='INSERT',
                                   cookie_name='ABC', cookie_fallback=True,
                                   bogus='bogus')
     self.assertEqual(resp, expected)