summaryrefslogtreecommitdiff
path: root/cloudinit/net
diff options
context:
space:
mode:
authorDaniel Watkins <oddbloke@ubuntu.com>2020-01-21 18:02:42 -0500
committerChad Smith <chad.smith@canonical.com>2020-01-21 16:02:42 -0700
commitbb71a9d08d25193836eda91c328760305285574e (patch)
tree50a1f2f4a61e04255c5a8129e7a2a26d9d4cecd4 /cloudinit/net
parent8c4fd886931abcf2cc8627a47463907d655b35c3 (diff)
downloadvyos-cloud-init-bb71a9d08d25193836eda91c328760305285574e.tar.gz
vyos-cloud-init-bb71a9d08d25193836eda91c328760305285574e.zip
Drop most of the remaining use of six (#179)
Diffstat (limited to 'cloudinit/net')
-rw-r--r--cloudinit/net/network_state.py11
-rw-r--r--cloudinit/net/renderer.py4
-rw-r--r--cloudinit/net/sysconfig.py15
3 files changed, 13 insertions, 17 deletions
diff --git a/cloudinit/net/network_state.py b/cloudinit/net/network_state.py
index 9b126100..63d6e291 100644
--- a/cloudinit/net/network_state.py
+++ b/cloudinit/net/network_state.py
@@ -10,8 +10,6 @@ import logging
import socket
import struct
-import six
-
from cloudinit import safeyaml
from cloudinit import util
@@ -186,7 +184,7 @@ class NetworkState(object):
def iter_interfaces(self, filter_func=None):
ifaces = self._network_state.get('interfaces', {})
- for iface in six.itervalues(ifaces):
+ for iface in ifaces.values():
if filter_func is None:
yield iface
else:
@@ -220,8 +218,7 @@ class NetworkState(object):
)
-@six.add_metaclass(CommandHandlerMeta)
-class NetworkStateInterpreter(object):
+class NetworkStateInterpreter(metaclass=CommandHandlerMeta):
initial_network_state = {
'interfaces': {},
@@ -970,7 +967,7 @@ def ipv4_mask_to_net_prefix(mask):
"""
if isinstance(mask, int):
return mask
- if isinstance(mask, six.string_types):
+ if isinstance(mask, str):
try:
return int(mask)
except ValueError:
@@ -997,7 +994,7 @@ def ipv6_mask_to_net_prefix(mask):
if isinstance(mask, int):
return mask
- if isinstance(mask, six.string_types):
+ if isinstance(mask, str):
try:
return int(mask)
except ValueError:
diff --git a/cloudinit/net/renderer.py b/cloudinit/net/renderer.py
index 5f32e90f..2a61a7a8 100644
--- a/cloudinit/net/renderer.py
+++ b/cloudinit/net/renderer.py
@@ -6,7 +6,7 @@
# This file is part of cloud-init. See LICENSE file for license information.
import abc
-import six
+import io
from .network_state import parse_net_config_data
from .udev import generate_udev_rule
@@ -34,7 +34,7 @@ class Renderer(object):
"""Given state, emit udev rules to map mac to ifname."""
# TODO(harlowja): this seems shared between eni renderer and
# this, so move it to a shared location.
- content = six.StringIO()
+ content = io.StringIO()
for iface in network_state.iter_interfaces(filter_by_physical):
# for physical interfaces write out a persist net udev rule
if 'name' in iface and iface.get('mac_address'):
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
index 3e06af01..07668d3e 100644
--- a/cloudinit/net/sysconfig.py
+++ b/cloudinit/net/sysconfig.py
@@ -1,16 +1,15 @@
# This file is part of cloud-init. See LICENSE file for license information.
+import io
import os
import re
-import six
+from configobj import ConfigObj
-from cloudinit.distros.parsers import networkmanager_conf
-from cloudinit.distros.parsers import resolv_conf
from cloudinit import log as logging
from cloudinit import util
-
-from configobj import ConfigObj
+from cloudinit.distros.parsers import networkmanager_conf
+from cloudinit.distros.parsers import resolv_conf
from . import renderer
from .network_state import (
@@ -96,7 +95,7 @@ class ConfigMap(object):
return len(self._conf)
def to_string(self):
- buf = six.StringIO()
+ buf = io.StringIO()
buf.write(_make_header())
if self._conf:
buf.write("\n")
@@ -104,7 +103,7 @@ class ConfigMap(object):
value = self._conf[key]
if isinstance(value, bool):
value = self._bool_map[value]
- if not isinstance(value, six.string_types):
+ if not isinstance(value, str):
value = str(value)
buf.write("%s=%s\n" % (key, _quote_value(value)))
return buf.getvalue()
@@ -150,7 +149,7 @@ class Route(ConfigMap):
# only accept ipv4 and ipv6
if proto not in ['ipv4', 'ipv6']:
raise ValueError("Unknown protocol '%s'" % (str(proto)))
- buf = six.StringIO()
+ buf = io.StringIO()
buf.write(_make_header())
if self._conf:
buf.write("\n")