summaryrefslogtreecommitdiff
path: root/cloudinit/util.py
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/util.py
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/util.py')
-rw-r--r--cloudinit/util.py16
1 files changed, 1 insertions, 15 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py
index 0d338ca7..1f600df4 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -38,7 +38,6 @@ from base64 import b64decode, b64encode
from six.moves.urllib import parse as urlparse
import six
-import yaml
from cloudinit import importer
from cloudinit import log as logging
@@ -958,7 +957,7 @@ def load_yaml(blob, default=None, allowed=(dict,)):
" but got %s instead") %
(allowed, type_utils.obj_name(converted)))
loaded = converted
- except (yaml.YAMLError, TypeError, ValueError) as e:
+ except (safeyaml.YAMLError, TypeError, ValueError) as e:
msg = 'Failed loading yaml blob'
mark = None
if hasattr(e, 'context_mark') and getattr(e, 'context_mark'):
@@ -1629,19 +1628,6 @@ def json_dumps(data):
raise
-def yaml_dumps(obj, explicit_start=True, explicit_end=True, noalias=False):
- """Return data in nicely formatted yaml."""
-
- return yaml.dump(obj,
- line_break="\n",
- indent=4,
- explicit_start=explicit_start,
- explicit_end=explicit_end,
- default_flow_style=False,
- Dumper=(safeyaml.NoAliasSafeDumper
- if noalias else yaml.dumper.Dumper))
-
-
def ensure_dir(path, mode=None):
if not os.path.isdir(path):
# Make the dir and adjust the mode