Expand PEP8 tests on nsxlib
There were some directories excluded from the pep8 run, and many checks were ignored. This cleans the exclude list, and fixes the PEP8 issues. Change-Id: Ib56d45443009349a42fecfc14a792fdaa6d88d67
This commit is contained in:
parent
b77a3ec496
commit
d7473ecf2f
@ -22,7 +22,7 @@ sys.path.insert(0, os.path.abspath('../..'))
|
|||||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||||
extensions = [
|
extensions = [
|
||||||
'sphinx.ext.autodoc',
|
'sphinx.ext.autodoc',
|
||||||
#'sphinx.ext.intersphinx',
|
# 'sphinx.ext.intersphinx',
|
||||||
'oslosphinx'
|
'oslosphinx'
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -72,4 +72,4 @@ latex_documents = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
# Example configuration for intersphinx: refer to the Python standard library.
|
# Example configuration for intersphinx: refer to the Python standard library.
|
||||||
#intersphinx_mapping = {'http://docs.python.org/': None}
|
# intersphinx_mapping = {'http://docs.python.org/': None}
|
||||||
|
14
tox.ini
14
tox.ini
@ -82,22 +82,12 @@ commands = sphinx-build -W -b html doc/source doc/build/html
|
|||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
# E125 continuation line does not distinguish itself from next logical line
|
# E125 continuation line does not distinguish itself from next logical line
|
||||||
# E126 continuation line over-indented for hanging indent
|
|
||||||
# E128 continuation line under-indented for visual indent
|
|
||||||
# E129 visually indented line with same indent as next logical line
|
# E129 visually indented line with same indent as next logical line
|
||||||
# E265 block comment should start with ‘# ‘
|
|
||||||
# H305 imports not grouped correctly
|
|
||||||
# H307 like imports should be grouped together
|
|
||||||
# H402 one line docstring needs punctuation
|
|
||||||
# H404 multi line docstring should start with a summary
|
|
||||||
# H405 multi line docstring summary not separated with an empty line
|
|
||||||
# H904 Wrap long lines in parentheses instead of a backslash
|
|
||||||
# TODO(dougwig) -- uncomment this to test for remaining linkages
|
|
||||||
# N530 direct neutron imports not allowed
|
# N530 direct neutron imports not allowed
|
||||||
ignore = E125,E126,E128,E129,E265,H305,H307,H402,H404,H405,H904,N530
|
ignore = N530,E125,E129
|
||||||
show-source = true
|
show-source = true
|
||||||
builtins = _
|
builtins = _
|
||||||
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,.ropeproject
|
exclude = build,dist
|
||||||
|
|
||||||
[hacking]
|
[hacking]
|
||||||
import_exceptions = vmware_nsxlib._i18n,
|
import_exceptions = vmware_nsxlib._i18n,
|
||||||
|
@ -53,10 +53,7 @@ def _mock_create_and_list_nsgroups(test_method):
|
|||||||
|
|
||||||
|
|
||||||
class TestNSGroupManager(nsxlib_testcase.NsxLibTestCase):
|
class TestNSGroupManager(nsxlib_testcase.NsxLibTestCase):
|
||||||
"""
|
"""Tests for vmware_nsxlib.v3.ns_group_manager.NSGroupManager."""
|
||||||
This test suite is responsible for unittesting of class
|
|
||||||
vmware_nsxlib.v3.ns_group_manager.NSGroupManager.
|
|
||||||
"""
|
|
||||||
|
|
||||||
@_mock_create_and_list_nsgroups
|
@_mock_create_and_list_nsgroups
|
||||||
def test_first_initialization(self):
|
def test_first_initialization(self):
|
||||||
|
@ -139,12 +139,12 @@ class NsxLibQosTestCase(nsxlib_testcase.NsxClientTestCase):
|
|||||||
expected_path = ('switching-profiles/%s' %
|
expected_path = ('switching-profiles/%s' %
|
||||||
test_constants.FAKE_QOS_PROFILE['id'])
|
test_constants.FAKE_QOS_PROFILE['id'])
|
||||||
expected_body = self._body_with_shaping(
|
expected_body = self._body_with_shaping(
|
||||||
shaping_enabled=True,
|
shaping_enabled=True,
|
||||||
burst_size=burst_size,
|
burst_size=burst_size,
|
||||||
peak_bandwidth=peak_bandwidth,
|
peak_bandwidth=peak_bandwidth,
|
||||||
average_bandwidth=average_bandwidth,
|
average_bandwidth=average_bandwidth,
|
||||||
qos_marking="untrusted", dscp=10,
|
qos_marking="untrusted", dscp=10,
|
||||||
direction=direction)
|
direction=direction)
|
||||||
self.assertEqual(expected_path, actual_path)
|
self.assertEqual(expected_path, actual_path)
|
||||||
self.assertEqual(expected_body, actual_body)
|
self.assertEqual(expected_body, actual_body)
|
||||||
|
|
||||||
@ -158,9 +158,9 @@ class NsxLibQosTestCase(nsxlib_testcase.NsxClientTestCase):
|
|||||||
|
|
||||||
def _disable_qos_switching_profile_shaping(
|
def _disable_qos_switching_profile_shaping(
|
||||||
self, direction=nsx_constants.EGRESS):
|
self, direction=nsx_constants.EGRESS):
|
||||||
"""Test updating a qos-switching profile
|
"""Test updating a qos-switching profile.
|
||||||
|
|
||||||
returns the correct response
|
Returns the correct response
|
||||||
"""
|
"""
|
||||||
burst_size = 100
|
burst_size = 100
|
||||||
peak_bandwidth = 200
|
peak_bandwidth = 200
|
||||||
@ -187,7 +187,7 @@ class NsxLibQosTestCase(nsxlib_testcase.NsxClientTestCase):
|
|||||||
expected_path = ('switching-profiles/%s' %
|
expected_path = ('switching-profiles/%s' %
|
||||||
test_constants.FAKE_QOS_PROFILE['id'])
|
test_constants.FAKE_QOS_PROFILE['id'])
|
||||||
expected_body = self._body_with_shaping(qos_marking="trusted",
|
expected_body = self._body_with_shaping(qos_marking="trusted",
|
||||||
direction=direction)
|
direction=direction)
|
||||||
self.assertEqual(expected_path, actual_path)
|
self.assertEqual(expected_path, actual_path)
|
||||||
self.assertEqual(expected_body, actual_body)
|
self.assertEqual(expected_body, actual_body)
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ class LogicalPortTestCase(nsxlib_testcase.NsxClientTestCase):
|
|||||||
return fake_pkt_classifiers, fake_binding_repr
|
return fake_pkt_classifiers, fake_binding_repr
|
||||||
|
|
||||||
def test_create_logical_port(self):
|
def test_create_logical_port(self):
|
||||||
"""Test creating a port
|
"""Test creating a port.
|
||||||
|
|
||||||
returns the correct response and 200 status
|
returns the correct response and 200 status
|
||||||
"""
|
"""
|
||||||
@ -346,7 +346,7 @@ class LogicalPortTestCase(nsxlib_testcase.NsxClientTestCase):
|
|||||||
data=jsonutils.dumps(resp_body, sort_keys=True))
|
data=jsonutils.dumps(resp_body, sort_keys=True))
|
||||||
|
|
||||||
def test_create_logical_port_admin_down(self):
|
def test_create_logical_port_admin_down(self):
|
||||||
"""Test creating port with admin_state down"""
|
"""Test creating port with admin_state down."""
|
||||||
fake_port = test_constants.FAKE_PORT
|
fake_port = test_constants.FAKE_PORT
|
||||||
fake_port['admin_state'] = "DOWN"
|
fake_port['admin_state'] = "DOWN"
|
||||||
|
|
||||||
@ -362,7 +362,7 @@ class LogicalPortTestCase(nsxlib_testcase.NsxClientTestCase):
|
|||||||
self.assertEqual(fake_port, result)
|
self.assertEqual(fake_port, result)
|
||||||
|
|
||||||
def test_delete_logical_port(self):
|
def test_delete_logical_port(self):
|
||||||
"""Test deleting port"""
|
"""Test deleting port."""
|
||||||
mocked_resource = self._mocked_lport()
|
mocked_resource = self._mocked_lport()
|
||||||
|
|
||||||
uuid = test_constants.FAKE_PORT['id']
|
uuid = test_constants.FAKE_PORT['id']
|
||||||
@ -390,9 +390,7 @@ class LogicalPortTestCase(nsxlib_testcase.NsxClientTestCase):
|
|||||||
data=jsonutils.dumps(fake_port, sort_keys=True))
|
data=jsonutils.dumps(fake_port, sort_keys=True))
|
||||||
|
|
||||||
def test_create_logical_port_fail(self):
|
def test_create_logical_port_fail(self):
|
||||||
"""
|
"""Test the failure of port creation."""
|
||||||
Test the failure of port creation
|
|
||||||
"""
|
|
||||||
fake_port = test_constants.FAKE_PORT.copy()
|
fake_port = test_constants.FAKE_PORT.copy()
|
||||||
|
|
||||||
profile_dicts = self._get_profile_dicts(fake_port)
|
profile_dicts = self._get_profile_dicts(fake_port)
|
||||||
@ -422,7 +420,7 @@ class LogicalRouterTestCase(nsxlib_testcase.NsxClientTestCase):
|
|||||||
resources.LogicalRouter, session_response=session_response)
|
resources.LogicalRouter, session_response=session_response)
|
||||||
|
|
||||||
def test_create_logical_router(self):
|
def test_create_logical_router(self):
|
||||||
"""Test creating a router returns the correct response and 201 status
|
"""Test creating a router returns the correct response and 201 status.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
fake_router = test_constants.FAKE_ROUTER.copy()
|
fake_router = test_constants.FAKE_ROUTER.copy()
|
||||||
@ -460,7 +458,7 @@ class LogicalRouterPortTestCase(nsxlib_testcase.NsxClientTestCase):
|
|||||||
resources.LogicalRouterPort, session_response=session_response)
|
resources.LogicalRouterPort, session_response=session_response)
|
||||||
|
|
||||||
def test_create_logical_router_port(self):
|
def test_create_logical_router_port(self):
|
||||||
"""Test creating a router port
|
"""Test creating a router port.
|
||||||
|
|
||||||
returns the correct response and 201 status
|
returns the correct response and 201 status
|
||||||
"""
|
"""
|
||||||
@ -487,16 +485,14 @@ class LogicalRouterPortTestCase(nsxlib_testcase.NsxClientTestCase):
|
|||||||
data=jsonutils.dumps(data, sort_keys=True))
|
data=jsonutils.dumps(data, sort_keys=True))
|
||||||
|
|
||||||
def test_logical_router_port_max_attempts(self):
|
def test_logical_router_port_max_attempts(self):
|
||||||
"""
|
"""Test a router port api has the configured retries."""
|
||||||
Test a router port api has the configured retries
|
|
||||||
"""
|
|
||||||
lrport = self._mocked_lrport()
|
lrport = self._mocked_lrport()
|
||||||
|
|
||||||
self.assertEqual(nsxlib_testcase.NSX_MAX_ATTEMPTS,
|
self.assertEqual(nsxlib_testcase.NSX_MAX_ATTEMPTS,
|
||||||
lrport._client.max_attempts)
|
lrport._client.max_attempts)
|
||||||
|
|
||||||
def test_delete_logical_router_port(self):
|
def test_delete_logical_router_port(self):
|
||||||
"""Test deleting router port"""
|
"""Test deleting router port."""
|
||||||
lrport = self._mocked_lrport()
|
lrport = self._mocked_lrport()
|
||||||
|
|
||||||
uuid = test_constants.FAKE_ROUTER_PORT['id']
|
uuid = test_constants.FAKE_ROUTER_PORT['id']
|
||||||
@ -506,7 +502,7 @@ class LogicalRouterPortTestCase(nsxlib_testcase.NsxClientTestCase):
|
|||||||
'https://1.2.3.4/api/v1/logical-router-ports/%s' % uuid)
|
'https://1.2.3.4/api/v1/logical-router-ports/%s' % uuid)
|
||||||
|
|
||||||
def test_get_logical_router_port_by_router_id(self):
|
def test_get_logical_router_port_by_router_id(self):
|
||||||
"""Test getting a router port by router id"""
|
"""Test getting a router port by router id."""
|
||||||
fake_router_port = test_constants.FAKE_ROUTER_PORT.copy()
|
fake_router_port = test_constants.FAKE_ROUTER_PORT.copy()
|
||||||
resp_resources = {'results': [fake_router_port]}
|
resp_resources = {'results': [fake_router_port]}
|
||||||
|
|
||||||
@ -523,7 +519,7 @@ class LogicalRouterPortTestCase(nsxlib_testcase.NsxClientTestCase):
|
|||||||
'logical_router_id=%s' % router_id)
|
'logical_router_id=%s' % router_id)
|
||||||
|
|
||||||
def test_get_logical_router_port_by_switch_id(self):
|
def test_get_logical_router_port_by_switch_id(self):
|
||||||
"""Test getting a router port by switch id"""
|
"""Test getting a router port by switch id."""
|
||||||
fake_router_port = test_constants.FAKE_ROUTER_PORT.copy()
|
fake_router_port = test_constants.FAKE_ROUTER_PORT.copy()
|
||||||
resp_resources = {
|
resp_resources = {
|
||||||
'result_count': 1,
|
'result_count': 1,
|
||||||
|
@ -62,9 +62,9 @@ class NsxLib(object):
|
|||||||
self.transport_zone = NsxLibTransportZone(
|
self.transport_zone = NsxLibTransportZone(
|
||||||
self.client, nsxlib_config)
|
self.client, nsxlib_config)
|
||||||
self.native_dhcp_profile = NsxLibDhcpProfile(
|
self.native_dhcp_profile = NsxLibDhcpProfile(
|
||||||
self.client, nsxlib_config)
|
self.client, nsxlib_config)
|
||||||
self.native_md_proxy = NsxLibMetadataProxy(
|
self.native_md_proxy = NsxLibMetadataProxy(
|
||||||
self.client, nsxlib_config)
|
self.client, nsxlib_config)
|
||||||
self.firewall_section = security.NsxLibFirewallSection(
|
self.firewall_section = security.NsxLibFirewallSection(
|
||||||
self.client, nsxlib_config)
|
self.client, nsxlib_config)
|
||||||
self.ns_group = security.NsxLibNsGroup(
|
self.ns_group = security.NsxLibNsGroup(
|
||||||
@ -183,7 +183,7 @@ class NsxLibLogicalSwitch(utils.NsxLibApiBase):
|
|||||||
return self.client.create(resource, body)
|
return self.client.create(resource, body)
|
||||||
|
|
||||||
def delete(self, lswitch_id):
|
def delete(self, lswitch_id):
|
||||||
#Using internal method so we can access max_attempts in the decorator
|
# Using internal method so we can access max_attempts in the decorator
|
||||||
@utils.retry_upon_exception(
|
@utils.retry_upon_exception(
|
||||||
exceptions.StaleRevision,
|
exceptions.StaleRevision,
|
||||||
max_attempts=self.nsxlib_config.max_attempts)
|
max_attempts=self.nsxlib_config.max_attempts)
|
||||||
@ -199,7 +199,7 @@ class NsxLibLogicalSwitch(utils.NsxLibApiBase):
|
|||||||
return self.client.get(resource)
|
return self.client.get(resource)
|
||||||
|
|
||||||
def update(self, lswitch_id, name=None, admin_state=None, tags=None):
|
def update(self, lswitch_id, name=None, admin_state=None, tags=None):
|
||||||
#Using internal method so we can access max_attempts in the decorator
|
# Using internal method so we can access max_attempts in the decorator
|
||||||
@utils.retry_upon_exception(
|
@utils.retry_upon_exception(
|
||||||
exceptions.StaleRevision,
|
exceptions.StaleRevision,
|
||||||
max_attempts=self.nsxlib_config.max_attempts)
|
max_attempts=self.nsxlib_config.max_attempts)
|
||||||
|
@ -44,11 +44,11 @@ logging.getLogger(
|
|||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
@six.add_metaclass(abc.ABCMeta)
|
||||||
class AbstractHTTPProvider(object):
|
class AbstractHTTPProvider(object):
|
||||||
"""Interface for providers of HTTP connections which
|
"""Interface for providers of HTTP connections.
|
||||||
are responsible for creating and validating connections
|
|
||||||
|
which are responsible for creating and validating connections
|
||||||
for their underlying HTTP support.
|
for their underlying HTTP support.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def default_scheme(self):
|
def default_scheme(self):
|
||||||
return 'https'
|
return 'https'
|
||||||
@ -60,13 +60,14 @@ class AbstractHTTPProvider(object):
|
|||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def validate_connection(self, cluster_api, endpoint, conn):
|
def validate_connection(self, cluster_api, endpoint, conn):
|
||||||
"""Validate the said connection for the given endpoint and cluster.
|
"""Validate the said connection for the given endpoint and cluster."""
|
||||||
"""
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def new_connection(self, cluster_api, provider):
|
def new_connection(self, cluster_api, provider):
|
||||||
"""Create a new http connection for the said cluster and
|
"""Create a new http connection.
|
||||||
|
|
||||||
|
Create a new http connection for the said cluster and
|
||||||
cluster provider. The actual connection should duck type
|
cluster provider. The actual connection should duck type
|
||||||
requests.Session http methods (get(), put(), etc.).
|
requests.Session http methods (get(), put(), etc.).
|
||||||
"""
|
"""
|
||||||
@ -74,16 +75,14 @@ class AbstractHTTPProvider(object):
|
|||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def is_connection_exception(self, exception):
|
def is_connection_exception(self, exception):
|
||||||
"""Determine if the given exception is related to connection
|
"""Determine if the given exception is related to connection failure.
|
||||||
failure. Return True if it's a connection exception and
|
|
||||||
False otherwise.
|
Return True if it's a connection exception and False otherwise.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class TimeoutSession(requests.Session):
|
class TimeoutSession(requests.Session):
|
||||||
"""Extends requests.Session to support timeout
|
"""Extends requests.Session to support timeout at the session level."""
|
||||||
at the session level.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, timeout, read_timeout):
|
def __init__(self, timeout, read_timeout):
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
@ -99,7 +98,8 @@ class TimeoutSession(requests.Session):
|
|||||||
|
|
||||||
|
|
||||||
class NSXRequestsHTTPProvider(AbstractHTTPProvider):
|
class NSXRequestsHTTPProvider(AbstractHTTPProvider):
|
||||||
"""Concrete implementation of AbstractHTTPProvider
|
"""Concrete implementation of AbstractHTTPProvider.
|
||||||
|
|
||||||
using requests.Session() as the underlying connection.
|
using requests.Session() as the underlying connection.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -145,8 +145,9 @@ class NSXRequestsHTTPProvider(AbstractHTTPProvider):
|
|||||||
|
|
||||||
|
|
||||||
class ClusterHealth(object):
|
class ClusterHealth(object):
|
||||||
"""Indicator of overall cluster health with respect
|
"""Indicator of overall cluster health.
|
||||||
to the connectivity of the clusters managed endpoints.
|
|
||||||
|
with respect to the connectivity of the clusters managed endpoints.
|
||||||
"""
|
"""
|
||||||
# all endpoints are UP
|
# all endpoints are UP
|
||||||
GREEN = 'GREEN'
|
GREEN = 'GREEN'
|
||||||
@ -157,8 +158,7 @@ class ClusterHealth(object):
|
|||||||
|
|
||||||
|
|
||||||
class EndpointState(object):
|
class EndpointState(object):
|
||||||
"""Tracks the connectivity state for a said endpoint.
|
"""Tracks the connectivity state for a said endpoint."""
|
||||||
"""
|
|
||||||
# no UP or DOWN state recorded yet
|
# no UP or DOWN state recorded yet
|
||||||
INITIALIZED = 'INITIALIZED'
|
INITIALIZED = 'INITIALIZED'
|
||||||
# endpoint has been validate and is good
|
# endpoint has been validate and is good
|
||||||
@ -168,8 +168,9 @@ class EndpointState(object):
|
|||||||
|
|
||||||
|
|
||||||
class Provider(object):
|
class Provider(object):
|
||||||
"""Data holder for a provider which has a unique id
|
"""Data holder for a provider
|
||||||
a connection URL, and the credential details.
|
|
||||||
|
Which has a unique id a connection URL, and the credential details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, provider_id, provider_url, username, password, ca_file):
|
def __init__(self, provider_id, provider_url, username, password, ca_file):
|
||||||
@ -184,7 +185,9 @@ class Provider(object):
|
|||||||
|
|
||||||
|
|
||||||
class Endpoint(object):
|
class Endpoint(object):
|
||||||
"""A single NSX manager endpoint (host) which includes
|
"""A single NSX manager endpoint (host).
|
||||||
|
|
||||||
|
A single NSX manager endpoint (host) which includes
|
||||||
related information such as the endpoint's provider,
|
related information such as the endpoint's provider,
|
||||||
state, etc.. A pool is used to hold connections to the
|
state, etc.. A pool is used to hold connections to the
|
||||||
endpoint which are doled out when proxying HTTP methods
|
endpoint which are doled out when proxying HTTP methods
|
||||||
@ -224,8 +227,9 @@ class Endpoint(object):
|
|||||||
|
|
||||||
|
|
||||||
class EndpointConnection(object):
|
class EndpointConnection(object):
|
||||||
"""Simple data holder which contains an endpoint and
|
"""Simple data holder
|
||||||
a connection for that endpoint.
|
|
||||||
|
Which contains an endpoint and a connection for that endpoint.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, endpoint, connection):
|
def __init__(self, endpoint, connection):
|
||||||
@ -234,8 +238,9 @@ class EndpointConnection(object):
|
|||||||
|
|
||||||
|
|
||||||
class ClusteredAPI(object):
|
class ClusteredAPI(object):
|
||||||
"""Duck types the major HTTP based methods of a
|
"""Duck types the major HTTP based methods of a requests.Session
|
||||||
requests.Session such as get(), put(), post(), etc.
|
|
||||||
|
Such as get(), put(), post(), etc.
|
||||||
and transparently proxies those calls to one of
|
and transparently proxies those calls to one of
|
||||||
its managed NSX manager endpoints.
|
its managed NSX manager endpoints.
|
||||||
"""
|
"""
|
||||||
@ -444,9 +449,7 @@ class ClusteredAPI(object):
|
|||||||
|
|
||||||
|
|
||||||
class NSXClusteredAPI(ClusteredAPI):
|
class NSXClusteredAPI(ClusteredAPI):
|
||||||
"""Extends ClusteredAPI to get conf values and setup the
|
"""Extends ClusteredAPI to get conf values and setup the NSXv3 cluster."""
|
||||||
NSX v3 cluster.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, nsxlib_config):
|
def __init__(self, nsxlib_config):
|
||||||
self.nsxlib_config = nsxlib_config
|
self.nsxlib_config = nsxlib_config
|
||||||
|
@ -28,8 +28,8 @@ LOG = log.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class NSGroupManager(object):
|
class NSGroupManager(object):
|
||||||
"""
|
"""This class assists with NSX integration for Neutron security-groups
|
||||||
This class assists with NSX integration for Neutron security-groups,
|
|
||||||
Each Neutron security-group is associated with NSX NSGroup object.
|
Each Neutron security-group is associated with NSX NSGroup object.
|
||||||
Some specific security policies are the same across all security-groups,
|
Some specific security policies are the same across all security-groups,
|
||||||
i.e - Default drop rule, DHCP. In order to bind these rules to all
|
i.e - Default drop rule, DHCP. In order to bind these rules to all
|
||||||
@ -44,7 +44,6 @@ class NSGroupManager(object):
|
|||||||
group it should be added, and when deleting an NSGroup (security-group) we
|
group it should be added, and when deleting an NSGroup (security-group) we
|
||||||
use the same procedure to find which nested group it was added.
|
use the same procedure to find which nested group it was added.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
NESTED_GROUP_NAME = 'OS Nested Group'
|
NESTED_GROUP_NAME = 'OS Nested Group'
|
||||||
NESTED_GROUP_DESCRIPTION = ('OpenStack NSGroup. Do not delete.')
|
NESTED_GROUP_DESCRIPTION = ('OpenStack NSGroup. Do not delete.')
|
||||||
|
|
||||||
|
@ -284,7 +284,7 @@ class LogicalPort(AbstractRESTResource):
|
|||||||
return self._client.create(body=body)
|
return self._client.create(body=body)
|
||||||
|
|
||||||
def delete(self, lport_id):
|
def delete(self, lport_id):
|
||||||
#Using internal method so we can access max_attempts in the decorator
|
# Using internal method so we can access max_attempts in the decorator
|
||||||
@utils.retry_upon_exception(
|
@utils.retry_upon_exception(
|
||||||
exceptions.StaleRevision,
|
exceptions.StaleRevision,
|
||||||
max_attempts=self._client.max_attempts)
|
max_attempts=self._client.max_attempts)
|
||||||
@ -299,7 +299,7 @@ class LogicalPort(AbstractRESTResource):
|
|||||||
tags_update=None,
|
tags_update=None,
|
||||||
attachment_type=nsx_constants.ATTACHMENT_VIF,
|
attachment_type=nsx_constants.ATTACHMENT_VIF,
|
||||||
parent_vif_id=None, parent_tag=None):
|
parent_vif_id=None, parent_tag=None):
|
||||||
#Using internal method so we can access max_attempts in the decorator
|
# Using internal method so we can access max_attempts in the decorator
|
||||||
@utils.retry_upon_exception(
|
@utils.retry_upon_exception(
|
||||||
exceptions.StaleRevision,
|
exceptions.StaleRevision,
|
||||||
max_attempts=self._client.max_attempts)
|
max_attempts=self._client.max_attempts)
|
||||||
@ -348,7 +348,7 @@ class LogicalRouter(AbstractRESTResource):
|
|||||||
return self._client.url_delete(lrouter_id)
|
return self._client.url_delete(lrouter_id)
|
||||||
|
|
||||||
def update(self, lrouter_id, *args, **kwargs):
|
def update(self, lrouter_id, *args, **kwargs):
|
||||||
#Using internal method so we can access max_attempts in the decorator
|
# Using internal method so we can access max_attempts in the decorator
|
||||||
@utils.retry_upon_exception(
|
@utils.retry_upon_exception(
|
||||||
exceptions.StaleRevision,
|
exceptions.StaleRevision,
|
||||||
max_attempts=self._client.max_attempts)
|
max_attempts=self._client.max_attempts)
|
||||||
@ -399,7 +399,7 @@ class LogicalRouterPort(AbstractRESTResource):
|
|||||||
return self._client.create(body=body)
|
return self._client.create(body=body)
|
||||||
|
|
||||||
def update(self, logical_port_id, **kwargs):
|
def update(self, logical_port_id, **kwargs):
|
||||||
#Using internal method so we can access max_attempts in the decorator
|
# Using internal method so we can access max_attempts in the decorator
|
||||||
@utils.retry_upon_exception(
|
@utils.retry_upon_exception(
|
||||||
exceptions.StaleRevision,
|
exceptions.StaleRevision,
|
||||||
max_attempts=self._client.max_attempts)
|
max_attempts=self._client.max_attempts)
|
||||||
@ -416,7 +416,7 @@ class LogicalRouterPort(AbstractRESTResource):
|
|||||||
return _do_update()
|
return _do_update()
|
||||||
|
|
||||||
def delete(self, logical_port_id):
|
def delete(self, logical_port_id):
|
||||||
#Using internal method so we can access max_attempts in the decorator
|
# Using internal method so we can access max_attempts in the decorator
|
||||||
@utils.retry_upon_exception(
|
@utils.retry_upon_exception(
|
||||||
exceptions.StaleRevision,
|
exceptions.StaleRevision,
|
||||||
max_attempts=self._client.max_attempts)
|
max_attempts=self._client.max_attempts)
|
||||||
@ -531,7 +531,7 @@ class LogicalDhcpServer(AbstractRESTResource):
|
|||||||
def update(self, uuid, dhcp_profile_id=None, server_ip=None, name=None,
|
def update(self, uuid, dhcp_profile_id=None, server_ip=None, name=None,
|
||||||
dns_nameservers=None, domain_name=None, gateway_ip=False,
|
dns_nameservers=None, domain_name=None, gateway_ip=False,
|
||||||
options=None, tags=None):
|
options=None, tags=None):
|
||||||
#Using internal method so we can access max_attempts in the decorator
|
# Using internal method so we can access max_attempts in the decorator
|
||||||
@utils.retry_upon_exception(
|
@utils.retry_upon_exception(
|
||||||
exceptions.StaleRevision,
|
exceptions.StaleRevision,
|
||||||
max_attempts=self._client.max_attempts)
|
max_attempts=self._client.max_attempts)
|
||||||
@ -564,7 +564,7 @@ class LogicalDhcpServer(AbstractRESTResource):
|
|||||||
return self._client.url_get(url)
|
return self._client.url_get(url)
|
||||||
|
|
||||||
def update_binding(self, server_uuid, binding_uuid, **kwargs):
|
def update_binding(self, server_uuid, binding_uuid, **kwargs):
|
||||||
#Using internal method so we can access max_attempts in the decorator
|
# Using internal method so we can access max_attempts in the decorator
|
||||||
@utils.retry_upon_exception(
|
@utils.retry_upon_exception(
|
||||||
exceptions.StaleRevision,
|
exceptions.StaleRevision,
|
||||||
max_attempts=self._client.max_attempts)
|
max_attempts=self._client.max_attempts)
|
||||||
@ -582,7 +582,7 @@ class LogicalDhcpServer(AbstractRESTResource):
|
|||||||
|
|
||||||
|
|
||||||
class IpPool(AbstractRESTResource):
|
class IpPool(AbstractRESTResource):
|
||||||
#TODO(asarfaty): Check the DK api - could be different
|
# TODO(asarfaty): Check the DK api - could be different
|
||||||
@property
|
@property
|
||||||
def uri_segment(self):
|
def uri_segment(self):
|
||||||
return 'pools/ip-pools'
|
return 'pools/ip-pools'
|
||||||
|
@ -121,7 +121,7 @@ class NsxLibNsGroup(utils.NsxLibApiBase):
|
|||||||
|
|
||||||
def update(self, nsgroup_id, display_name=None, description=None,
|
def update(self, nsgroup_id, display_name=None, description=None,
|
||||||
membership_criteria=None, members=None):
|
membership_criteria=None, members=None):
|
||||||
#Using internal method so we can access max_attempts in the decorator
|
# Using internal method so we can access max_attempts in the decorator
|
||||||
@utils.retry_upon_exception(
|
@utils.retry_upon_exception(
|
||||||
exceptions.StaleRevision,
|
exceptions.StaleRevision,
|
||||||
max_attempts=self.nsxlib_config.max_attempts)
|
max_attempts=self.nsxlib_config.max_attempts)
|
||||||
@ -306,7 +306,7 @@ class NsxLibFirewallSection(utils.NsxLibApiBase):
|
|||||||
|
|
||||||
def update(self, section_id, display_name=None, description=None,
|
def update(self, section_id, display_name=None, description=None,
|
||||||
applied_tos=None, rules=None):
|
applied_tos=None, rules=None):
|
||||||
#Using internal method so we can access max_attempts in the decorator
|
# Using internal method so we can access max_attempts in the decorator
|
||||||
@utils.retry_upon_exception(
|
@utils.retry_upon_exception(
|
||||||
exceptions.StaleRevision,
|
exceptions.StaleRevision,
|
||||||
max_attempts=self.nsxlib_config.max_attempts)
|
max_attempts=self.nsxlib_config.max_attempts)
|
||||||
@ -355,13 +355,10 @@ class NsxLibFirewallSection(utils.NsxLibApiBase):
|
|||||||
return {'target_id': ip_cidr_block,
|
return {'target_id': ip_cidr_block,
|
||||||
'target_type': target_type}
|
'target_type': target_type}
|
||||||
|
|
||||||
def get_rule_dict(
|
def get_rule_dict(self, display_name, source=None, destination=None,
|
||||||
self, display_name, source=None,
|
direction=consts.IN_OUT, ip_protocol=consts.IPV4_IPV6,
|
||||||
destination=None,
|
service=None, action=consts.FW_ACTION_ALLOW,
|
||||||
direction=consts.IN_OUT,
|
logged=False):
|
||||||
ip_protocol=consts.IPV4_IPV6,
|
|
||||||
service=None, action=consts.FW_ACTION_ALLOW,
|
|
||||||
logged=False):
|
|
||||||
return {'display_name': display_name,
|
return {'display_name': display_name,
|
||||||
'sources': [source] if source else [],
|
'sources': [source] if source else [],
|
||||||
'destinations': [destination] if destination else [],
|
'destinations': [destination] if destination else [],
|
||||||
|
@ -72,7 +72,7 @@ def retry_upon_exception(exc, delay=0.5, max_delay=2,
|
|||||||
return tenacity.retry(reraise=True,
|
return tenacity.retry(reraise=True,
|
||||||
retry=tenacity.retry_if_exception_type(exc),
|
retry=tenacity.retry_if_exception_type(exc),
|
||||||
wait=tenacity.wait_exponential(
|
wait=tenacity.wait_exponential(
|
||||||
multiplier=delay, max=max_delay),
|
multiplier=delay, max=max_delay),
|
||||||
stop=tenacity.stop_after_attempt(max_attempts))
|
stop=tenacity.stop_after_attempt(max_attempts))
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user