Skip to content

Commit afe08fd

Browse files
committed
Remove six use from cloudbaseinit
Change-Id: Ia4b4add954ee5192dbf437b415d8e698c0a271b8
1 parent 954753b commit afe08fd

58 files changed

Lines changed: 106 additions & 181 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cloudbaseinit/conf/base.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@
1414

1515
import abc
1616

17-
import six
1817

19-
20-
@six.add_metaclass(abc.ABCMeta)
21-
class Options(object):
18+
class Options(object, metaclass=abc.ABCMeta):
2219

2320
"""Contact class for all the collections of config options."""
2421

cloudbaseinit/metadata/services/azureservice.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
# under the License.
1414

1515
import contextlib
16+
import io
1617
import os
1718
import socket
1819
import time
1920
from xml.etree import ElementTree
2021

2122
from oslo_log import log as oslo_logging
22-
import six
2323
import untangle
2424

2525
from cloudbaseinit import conf as cloudbaseinit_conf
@@ -115,13 +115,13 @@ def _wire_server_request(self, path, data_xml=None, headers=None,
115115
path, data_xml, headers=all_headers))
116116

117117
if parse_xml:
118-
return untangle.parse(six.StringIO(encoding.get_as_string(data)))
118+
return untangle.parse(io.StringIO(encoding.get_as_string(data)))
119119
else:
120120
return data
121121

122122
@staticmethod
123123
def _encode_xml(xml_root):
124-
bio = six.BytesIO()
124+
bio = io.BytesIO()
125125
ElementTree.ElementTree(xml_root).write(
126126
bio, encoding='utf-8', xml_declaration=True)
127127
return bio.getvalue()

cloudbaseinit/metadata/services/base.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
from oslo_log import log as oslo_logging
2323
import requests
24-
import six
2524

2625
from cloudbaseinit import conf as cloudbaseinit_conf
2726
from cloudbaseinit import exception
@@ -35,8 +34,7 @@ class NotExistingMetadataException(Exception):
3534
pass
3635

3736

38-
@six.add_metaclass(abc.ABCMeta)
39-
class BaseMetadataService(object):
37+
class BaseMetadataService(object, metaclass=abc.ABCMeta):
4038
_GZIP_MAGIC_NUMBER = b'\x1f\x8b'
4139

4240
def __init__(self):

cloudbaseinit/metadata/services/cloudstack.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
# under the License.
1414

1515
import contextlib
16+
import http.client
1617
import posixpath
18+
import urllib
1719

1820
from oslo_log import log as oslo_logging
19-
from six.moves import http_client
20-
from six.moves import urllib
2121

2222
from cloudbaseinit import conf as cloudbaseinit_conf
2323
from cloudbaseinit.metadata.services import base
@@ -131,12 +131,12 @@ def get_public_keys(self):
131131
def _password_client(self, body=None, headers=None, decode=True):
132132
"""Client for the Password Server."""
133133
port = CONF.cloudstack.password_server_port
134-
with contextlib.closing(http_client.HTTPConnection(
134+
with contextlib.closing(http.client.HTTPConnection(
135135
self._metadata_host, port, timeout=TIMEOUT)) as connection:
136136
try:
137137
connection.request("GET", "/", body=body, headers=headers)
138138
response = connection.getresponse()
139-
except http_client.HTTPException as exc:
139+
except http.client.HTTPException as exc:
140140
LOG.error("Request failed: %s", exc)
141141
raise
142142

@@ -145,7 +145,7 @@ def _password_client(self, body=None, headers=None, decode=True):
145145
content = encoding.get_as_string(content)
146146

147147
if response.status != 200:
148-
raise http_client.HTTPException(
148+
raise http.client.HTTPException(
149149
"%(status)s %(reason)s - %(message)r",
150150
{"status": response.status, "reason": response.reason,
151151
"message": content})

cloudbaseinit/metadata/services/httpservice.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
1414

15+
from urllib import error
16+
1517
from oslo_log import log as oslo_logging
16-
from six.moves.urllib import error
1718

1819
from cloudbaseinit import conf as cloudbaseinit_conf
1920
from cloudbaseinit.metadata.services import base

cloudbaseinit/metadata/services/opennebulaservice.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import struct
2222

2323
from oslo_log import log as oslo_logging
24-
import six
2524

2625
from cloudbaseinit.metadata.services import base
2726
from cloudbaseinit.models import network as network_model
@@ -108,8 +107,7 @@ def _calculate_netmask(address, gateway):
108107
address_chunks = address.split(".")
109108
gateway_chunks = gateway.split(".")
110109
netmask_chunks = []
111-
for achunk, gchunk in six.moves.zip(
112-
address_chunks, gateway_chunks):
110+
for achunk, gchunk in zip(address_chunks, gateway_chunks):
113111
if achunk == gchunk:
114112
nchunk = "255"
115113
else:

cloudbaseinit/metadata/services/osconfigdrive/base.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@
1515
import abc
1616
import tempfile
1717

18-
import six
1918

20-
21-
@six.add_metaclass(abc.ABCMeta)
22-
class BaseConfigDriveManager(object):
19+
class BaseConfigDriveManager(object, metaclass=abc.ABCMeta):
2320

2421
def __init__(self):
2522
self.target_path = tempfile.mkdtemp()

cloudbaseinit/metadata/services/packet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515

1616
import json
1717
import requests
18+
from urllib import error
1819

1920
from cloudbaseinit import conf as cloudbaseinit_conf
2021
from cloudbaseinit import exception
2122
from cloudbaseinit.metadata.services import base
2223
from oslo_log import log as oslo_logging
23-
from six.moves.urllib import error
2424

2525
CONF = cloudbaseinit_conf.CONF
2626
LOG = oslo_logging.getLogger(__name__)

cloudbaseinit/osutils/windows.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@
2020
import struct
2121
import subprocess
2222
import time
23+
import winreg
2324

2425
import netaddr
2526
from oslo_log import log as oslo_logging
2627
import pywintypes
27-
import six
28-
from six.moves import winreg
2928
from tzlocal import windows_tz
3029
import win32api
3130
from win32com import client
@@ -602,7 +601,7 @@ def _get_user_sid_and_domain(self, username):
602601
sidNameUse = wintypes.DWORD()
603602

604603
ret_val = advapi32.LookupAccountNameW(
605-
0, six.text_type(username), sid, ctypes.byref(cbSid), domainName,
604+
0, str(username), sid, ctypes.byref(cbSid), domainName,
606605
ctypes.byref(cchReferencedDomainName), ctypes.byref(sidNameUse))
607606
if not ret_val:
608607
raise exception.WindowsCloudbaseInitException(
@@ -613,9 +612,9 @@ def _get_user_sid_and_domain(self, username):
613612
def add_user_to_local_group(self, username, groupname):
614613

615614
lmi = Win32_LOCALGROUP_MEMBERS_INFO_3()
616-
lmi.lgrmi3_domainandname = six.text_type(username)
615+
lmi.lgrmi3_domainandname = str(username)
617616

618-
ret_val = netapi32.NetLocalGroupAddMembers(0, six.text_type(groupname),
617+
ret_val = netapi32.NetLocalGroupAddMembers(0, str(groupname),
619618
3, ctypes.pointer(lmi), 1)
620619

621620
if ret_val == self.NERR_GroupNotFound:
@@ -652,9 +651,9 @@ def create_user_logon_session(self, username, password, domain='.',
652651
{"username": username, "domain": domain})
653652

654653
token = wintypes.HANDLE()
655-
ret_val = advapi32.LogonUserW(six.text_type(username),
656-
six.text_type(domain),
657-
six.text_type(password),
654+
ret_val = advapi32.LogonUserW(str(username),
655+
str(domain),
656+
str(password),
658657
logon_type,
659658
self.LOGON32_PROVIDER_DEFAULT,
660659
ctypes.byref(token))
@@ -665,7 +664,7 @@ def create_user_logon_session(self, username, password, domain='.',
665664
if load_profile:
666665
pi = Win32_PROFILEINFO()
667666
pi.dwSize = ctypes.sizeof(Win32_PROFILEINFO)
668-
pi.lpUserName = six.text_type(username)
667+
pi.lpUserName = str(username)
669668
ret_val = userenv.LoadUserProfileW(token, ctypes.byref(pi))
670669
if not ret_val:
671670
kernel32.CloseHandle(token)
@@ -756,8 +755,7 @@ def sanitize_shell_input(self, value):
756755

757756
def set_host_name(self, new_host_name):
758757
ret_val = kernel32.SetComputerNameExW(
759-
self.ComputerNamePhysicalDnsHostname,
760-
six.text_type(new_host_name))
758+
self.ComputerNamePhysicalDnsHostname, str(new_host_name))
761759
if not ret_val:
762760
raise exception.WindowsCloudbaseInitException(
763761
"Cannot set host name: %r")
@@ -1401,7 +1399,7 @@ def check_os_version(self, major, minor, build=0):
14011399
def get_volume_label(self, drive):
14021400
max_label_size = 261
14031401
label = ctypes.create_unicode_buffer(max_label_size)
1404-
ret_val = kernel32.GetVolumeInformationW(six.text_type(drive), label,
1402+
ret_val = kernel32.GetVolumeInformationW(str(drive), label,
14051403
max_label_size, 0, 0, 0, 0, 0)
14061404
if ret_val:
14071405
return label.value
@@ -1411,8 +1409,7 @@ def get_volume_path_names_by_mount_point(self, mount_point):
14111409
volume_name = ctypes.create_unicode_buffer(max_volume_name_len)
14121410

14131411
if not kernel32.GetVolumeNameForVolumeMountPointW(
1414-
six.text_type(mount_point), volume_name,
1415-
max_volume_name_len):
1412+
str(mount_point), volume_name, max_volume_name_len):
14161413
if kernel32.GetLastError() in [self.ERROR_INVALID_NAME,
14171414
self.ERROR_PATH_NOT_FOUND]:
14181415
raise exception.ItemNotFoundException(

cloudbaseinit/plugins/common/createuser.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import abc
1616

1717
from oslo_log import log as oslo_logging
18-
import six
1918

2019
from cloudbaseinit import conf as cloudbaseinit_conf
2120
from cloudbaseinit.osutils import factory as osutils_factory
@@ -26,8 +25,7 @@
2625
LOG = oslo_logging.getLogger(__name__)
2726

2827

29-
@six.add_metaclass(abc.ABCMeta)
30-
class BaseCreateUserPlugin(base.BasePlugin):
28+
class BaseCreateUserPlugin(base.BasePlugin, metaclass=abc.ABCMeta):
3129
"""This is a base class for creating or modifying an user."""
3230

3331
@abc.abstractmethod

0 commit comments

Comments
 (0)