summaryrefslogtreecommitdiff
path: root/cloudinit/net
diff options
context:
space:
mode:
authorScott Moser <smoser@brickies.net>2019-10-24 20:02:15 +0000
committerServer Team CI Bot <josh.powers+server-team-bot@canonical.com>2019-10-24 20:02:15 +0000
commit5bec6b0e2a2ce5fd03bb04f441536fc130e67997 (patch)
treed4fbc5ae8d7360ff87c283c2550f4661ef007dff /cloudinit/net
parent3e2482e8aa6630ca9bc115dc1f82d44d3fde1681 (diff)
downloadvyos-cloud-init-5bec6b0e2a2ce5fd03bb04f441536fc130e67997.tar.gz
vyos-cloud-init-5bec6b0e2a2ce5fd03bb04f441536fc130e67997.zip
Fix usages of yaml, and move yaml_dump to safeyaml.dumps.
Here we replace uses of the pyyaml module directly with functions provided by cloudinit.safeyaml. Also, change/move cloudinit.util.yaml_dumps to cloudinit.safeyaml.dumps LP: #1849640
Diffstat (limited to 'cloudinit/net')
-rw-r--r--cloudinit/net/netplan.py15
-rw-r--r--cloudinit/net/network_state.py5
2 files changed, 11 insertions, 9 deletions
diff --git a/cloudinit/net/netplan.py b/cloudinit/net/netplan.py
index e54a34e5..54be1221 100644
--- a/cloudinit/net/netplan.py
+++ b/cloudinit/net/netplan.py
@@ -8,6 +8,7 @@ from .network_state import subnet_is_ipv6, NET_CONFIG_TO_V2
from cloudinit import log as logging
from cloudinit import util
+from cloudinit import safeyaml
from cloudinit.net import SYS_CLASS_NET, get_devicelist
KNOWN_SNAPD_CONFIG = b"""\
@@ -235,9 +236,9 @@ class Renderer(renderer.Renderer):
# if content already in netplan format, pass it back
if network_state.version == 2:
LOG.debug('V2 to V2 passthrough')
- return util.yaml_dumps({'network': network_state.config},
- explicit_start=False,
- explicit_end=False)
+ return safeyaml.dumps({'network': network_state.config},
+ explicit_start=False,
+ explicit_end=False)
ethernets = {}
wifis = {}
@@ -359,10 +360,10 @@ class Renderer(renderer.Renderer):
# workaround yaml dictionary key sorting when dumping
def _render_section(name, section):
if section:
- dump = util.yaml_dumps({name: section},
- explicit_start=False,
- explicit_end=False,
- noalias=True)
+ dump = safeyaml.dumps({name: section},
+ explicit_start=False,
+ explicit_end=False,
+ noalias=True)
txt = util.indent(dump, ' ' * 4)
return [txt]
return []
diff --git a/cloudinit/net/network_state.py b/cloudinit/net/network_state.py
index c0c415d0..b485f3d9 100644
--- a/cloudinit/net/network_state.py
+++ b/cloudinit/net/network_state.py
@@ -12,6 +12,7 @@ import struct
import six
+from cloudinit import safeyaml
from cloudinit import util
LOG = logging.getLogger(__name__)
@@ -253,7 +254,7 @@ class NetworkStateInterpreter(object):
'config': self._config,
'network_state': self._network_state,
}
- return util.yaml_dumps(state)
+ return safeyaml.dumps(state)
def load(self, state):
if 'version' not in state:
@@ -272,7 +273,7 @@ class NetworkStateInterpreter(object):
setattr(self, key, state[key])
def dump_network_state(self):
- return util.yaml_dumps(self._network_state)
+ return safeyaml.dumps(self._network_state)
def as_dict(self):
return {'version': self._version, 'config': self._config}