diff options
author | Barry Warsaw <barry@python.org> | 2015-01-27 14:40:05 -0500 |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2015-01-27 14:40:05 -0500 |
commit | 69c64029997599b3f1764ef48fe571094e2ee5f2 (patch) | |
tree | 45b82b51a1ca5b76c8a8dbafb5a5a613a6b58727 /cloudinit/sources/DataSourceOpenNebula.py | |
parent | c3ced2d4bdbbbdcb2466202e1571d4ea7bfc7c72 (diff) | |
download | vyos-cloud-init-69c64029997599b3f1764ef48fe571094e2ee5f2.tar.gz vyos-cloud-init-69c64029997599b3f1764ef48fe571094e2ee5f2.zip |
Respond to review:
- Just use util.load_file() instead of yet another way to open and read the
file.
Diffstat (limited to 'cloudinit/sources/DataSourceOpenNebula.py')
-rw-r--r-- | cloudinit/sources/DataSourceOpenNebula.py | 12 |
1 files changed, 1 insertions, 11 deletions
diff --git a/cloudinit/sources/DataSourceOpenNebula.py b/cloudinit/sources/DataSourceOpenNebula.py index 6da569ec..a0275cda 100644 --- a/cloudinit/sources/DataSourceOpenNebula.py +++ b/cloudinit/sources/DataSourceOpenNebula.py @@ -25,7 +25,6 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import base64 -import codecs import os import pwd import re @@ -35,7 +34,6 @@ from cloudinit import log as logging from cloudinit import sources from cloudinit import util -import six LOG = logging.getLogger(__name__) @@ -46,12 +44,6 @@ CONTEXT_DISK_FILES = ["context.sh"] VALID_DSMODES = ("local", "net", "disabled") -def utf8_open(path): - if six.PY3: - return open(path, 'r', encoding='utf-8') - return codecs.open(path, 'r', encoding='utf-8') - - class DataSourceOpenNebula(sources.DataSource): def __init__(self, sys_cfg, distro, paths): sources.DataSource.__init__(self, sys_cfg, distro, paths) @@ -389,9 +381,7 @@ def read_context_disk_dir(source_dir, asuser=None): "does not exist", asuser) try: path = os.path.join(source_dir, 'context.sh') - with utf8_open(path) as f: - content = f.read().strip() - + content = util.load_file(path) context = parse_shell_config(content, asuser=asuser) except util.ProcessExecutionError as e: raise BrokenContextDiskDir("Error processing context.sh: %s" % (e)) |