Browse Source

Remove six package usage

Since py2 is no longer supported, built in methods can replace the
six package usage, as been done in the neutron project.

Change-Id: I435462c940e68fa48a910210e584cf139b3b9d95
changes/39/741839/2
asarfaty 1 year ago
parent
commit
dfe26e5f81
  1. 3
      doc/requirements.txt
  2. 1
      lower-constraints.txt
  3. 1
      requirements.txt
  4. 4
      vmware_nsxlib/tests/unit/v3/mocks.py
  5. 2
      vmware_nsxlib/tests/unit/v3/test_cluster.py
  6. 5
      vmware_nsxlib/tests/unit/v3/test_security.py
  7. 3
      vmware_nsxlib/v3/client.py
  8. 8
      vmware_nsxlib/v3/cluster.py
  9. 5
      vmware_nsxlib/v3/exceptions.py
  10. 4
      vmware_nsxlib/v3/lib.py
  11. 4
      vmware_nsxlib/v3/policy/core_defs.py
  12. 4
      vmware_nsxlib/v3/policy/core_resources.py
  13. 3
      vmware_nsxlib/v3/policy/lb_resources.py
  14. 5
      vmware_nsxlib/v3/token_provider.py
  15. 4
      vmware_nsxlib/v3/trust_management.py

3
doc/requirements.txt

@ -1,8 +1,7 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
sphinx!=1.6.6,!=1.6.7,>=1.6.2,<2.0.0;python_version=='2.7' # BSD
sphinx!=1.6.6,!=1.6.7,>=1.6.2;python_version>='3.4' # BSD
sphinx>=2.0.0,!=2.1.0 # BSD
oslosphinx>=4.7.0 # Apache-2.0
openstackdocstheme>=1.18.1 # Apache-2.0
oslotest>=3.2.0 # Apache-2.0

1
lower-constraints.txt

@ -20,7 +20,6 @@ python-subunit==1.0.0
pylint==1.7.1
reno==2.5.0
requests-mock==1.2.0
six==1.10.0
sphinx==1.6.5
stestr==1.0.0
tempest==17.1.0

1
requirements.txt

@ -8,7 +8,6 @@ decorator>=4.3.0 # BSD
eventlet>=0.24.1 # MIT
netaddr>=0.7.18 # BSD
tenacity>=5.0.1 # Apache-2.0
six>=1.10.0 # MIT
oslo.i18n>=3.15.3 # Apache-2.0
oslo.log>=3.36.0 # Apache-2.0
oslo.serialization>=2.28.1 # Apache-2.0

4
vmware_nsxlib/tests/unit/v3/mocks.py

@ -12,11 +12,11 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import requests
import six.moves.urllib.parse as urlparse
from urllib import parse as urlparse
from oslo_serialization import jsonutils
from oslo_utils import uuidutils
import requests
from vmware_nsxlib.v3 import nsx_constants

2
vmware_nsxlib/tests/unit/v3/test_cluster.py

@ -15,11 +15,11 @@
#
import unittest
from unittest import mock
from urllib import parse as urlparse
from requests import codes
from requests import exceptions as requests_exceptions
from requests import models
import six.moves.urllib.parse as urlparse
from oslo_serialization import jsonutils

5
vmware_nsxlib/tests/unit/v3/test_security.py

@ -16,7 +16,6 @@
from unittest import mock
from oslo_utils import uuidutils
import six
from vmware_nsxlib.tests.unit.v3 import nsxlib_testcase
from vmware_nsxlib.tests.unit.v3 import test_constants
@ -482,7 +481,7 @@ class TestNsxLibNSGroup(nsxlib_testcase.NsxClientTestCase):
def test_get_nsgroup_lp_complex_expression(self):
port_tags = {'app': 'foo', 'project': 'myproject'}
port_exp = [self.nsxlib.ns_group.get_port_tag_expression(k, v)
for k, v in six.iteritems(port_tags)]
for k, v in port_tags.items()]
complex_exp = self.nsxlib.ns_group.get_nsgroup_complex_expression(
expressions=port_exp)
expected_exp = {'resource_type': const.NSGROUP_COMPLEX_EXP,
@ -492,7 +491,7 @@ class TestNsxLibNSGroup(nsxlib_testcase.NsxClientTestCase):
def test_get_nsgroup_ls_complex_expression(self):
switch_tags = {'app': 'foo', 'project': 'myproject'}
switch_exp = [self.nsxlib.ns_group.get_switch_tag_expression(k, v)
for k, v in six.iteritems(switch_tags)]
for k, v in switch_tags.items()]
complex_exp = self.nsxlib.ns_group.get_nsgroup_complex_expression(
expressions=switch_exp)
expected_exp = {'resource_type': const.NSGROUP_COMPLEX_EXP,

3
vmware_nsxlib/v3/client.py

@ -15,11 +15,12 @@
#
import re
import time
from urllib import parse as urlparse
from oslo_log import log
from oslo_serialization import jsonutils
import requests
import six.moves.urllib.parse as urlparse
from vmware_nsxlib._i18n import _
from vmware_nsxlib.v3 import exceptions
from vmware_nsxlib.v3 import utils

8
vmware_nsxlib/v3/cluster.py

@ -23,6 +23,8 @@ import itertools
import logging
import re
import time
from urllib import parse as urlparse
import urllib3
import eventlet
from eventlet import greenpool
@ -32,9 +34,6 @@ from oslo_log import log
from oslo_service import loopingcall
import requests
from requests import adapters
import six
import six.moves.urllib.parse as urlparse
import urllib3
from vmware_nsxlib._i18n import _
from vmware_nsxlib.v3 import client as nsx_client
@ -53,8 +52,7 @@ logging.getLogger(
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
@six.add_metaclass(abc.ABCMeta)
class AbstractHTTPProvider(object):
class AbstractHTTPProvider(object, metaclass=abc.ABCMeta):
"""Interface for providers of HTTP connections.
which are responsible for creating and validating connections

5
vmware_nsxlib/v3/exceptions.py

@ -15,7 +15,6 @@
#
from oslo_utils import excutils
import six
from vmware_nsxlib._i18n import _
@ -40,10 +39,6 @@ class NsxLibException(Exception):
# at least get the core message out if something happened
super(NsxLibException, self).__init__(self.message)
if six.PY2:
def __unicode__(self):
return unicode(self.msg) if six.PY2 else self.msg # noqa
def __str__(self):
return self.msg

4
vmware_nsxlib/v3/lib.py

@ -17,7 +17,6 @@ import abc
from distutils import version
from oslo_log import log
import six
from vmware_nsxlib._i18n import _
from vmware_nsxlib.v3 import client
@ -29,8 +28,7 @@ from vmware_nsxlib.v3 import utils
LOG = log.getLogger(__name__)
@six.add_metaclass(abc.ABCMeta)
class NsxLibBase(object):
class NsxLibBase(object, metaclass=abc.ABCMeta):
def __init__(self, nsxlib_config):
self.nsx_version = None

4
vmware_nsxlib/v3/policy/core_defs.py

@ -18,7 +18,6 @@ import abc
from distutils import version
from oslo_log import log as logging
import six
from vmware_nsxlib.v3 import exceptions
from vmware_nsxlib.v3 import nsx_constants
@ -70,8 +69,7 @@ TIER1_LOCALE_SERVICES_PATH_PATTERN = (TIER1S_PATH_PATTERN +
"%s/locale-services/")
@six.add_metaclass(abc.ABCMeta)
class ResourceDef(object):
class ResourceDef(object, metaclass=abc.ABCMeta):
def __init__(self, nsx_version=None, **kwargs):
self.attrs = kwargs

4
vmware_nsxlib/v3/policy/core_resources.py

@ -22,7 +22,6 @@ import decorator
import eventlet
from oslo_log import log as logging
from oslo_utils import uuidutils
import six
from vmware_nsxlib._i18n import _
from vmware_nsxlib.v3 import exceptions
@ -56,8 +55,7 @@ def check_allowed_passthrough(f, *args, **kwargs):
return f(*args, **kwargs)
@six.add_metaclass(abc.ABCMeta)
class NsxPolicyResourceBase(object):
class NsxPolicyResourceBase(object, metaclass=abc.ABCMeta):
"""Abstract class for NSX policy resources
declaring the basic apis each policy resource should support,

3
vmware_nsxlib/v3/policy/lb_resources.py

@ -14,11 +14,9 @@
# under the License.
#
import abc
import copy
from oslo_log import log as logging
import six
from vmware_nsxlib._i18n import _
from vmware_nsxlib.v3 import exceptions as nsxlib_exc
@ -1080,7 +1078,6 @@ class NsxPolicyLoadBalancerVirtualServerAPI(NsxPolicyResourceBase):
sleep=sleep, max_attempts=max_attempts)
@six.add_metaclass(abc.ABCMeta)
class NsxPolicyLBMonitorProfileBase(NsxPolicyResourceBase):
"""NSX Policy LB monitor profile"""

5
vmware_nsxlib/v3/token_provider.py

@ -15,13 +15,10 @@
import abc
import six
# NOTE: Consider inheriting from an abstract TokenProvider class to share
# interface with XSRF token
@six.add_metaclass(abc.ABCMeta)
class AbstractJWTProvider(object):
class AbstractJWTProvider(object, metaclass=abc.ABCMeta):
"""Interface for providers of JSON Web Tokens(JWT)
Responsible to provide the token value and refresh it once expired,

4
vmware_nsxlib/v3/trust_management.py

@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import six
from vmware_nsxlib.v3 import exceptions as nsxlib_exc
from vmware_nsxlib.v3 import utils
@ -98,7 +96,7 @@ class NsxLibTrustManagement(utils.NsxLibApiBase):
def find_cert_and_identity(self, name, cert_pem):
certs = self.get_certs()
if not isinstance(cert_pem, six.text_type):
if not isinstance(cert_pem, str):
cert_pem = cert_pem.decode('ascii')
cert_ids = [cert['id'] for cert in certs

Loading…
Cancel
Save