summaryrefslogtreecommitdiff
path: root/cloudinit/sources/DataSourceOpenNebula.py
diff options
context:
space:
mode:
authorEnol Fernandez <enolfc@ifca.unican.es>2014-03-25 16:31:16 +0100
committerEnol Fernandez <enolfc@ifca.unican.es>2014-03-25 16:31:16 +0100
commit9486c1a1abacb9829e5ab172212d57c3735e35e0 (patch)
tree54e02557f9c60cbeaf6c3ad32cbe845c8bfb957f /cloudinit/sources/DataSourceOpenNebula.py
parent11d6dbfad89e3f9a56925f7671fa7ee3e86af918 (diff)
downloadcloud-init-git-9486c1a1abacb9829e5ab172212d57c3735e35e0.tar.gz
Added base64 decoding of user data for OpenNebula.
Diffstat (limited to 'cloudinit/sources/DataSourceOpenNebula.py')
-rw-r--r--cloudinit/sources/DataSourceOpenNebula.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/cloudinit/sources/DataSourceOpenNebula.py b/cloudinit/sources/DataSourceOpenNebula.py
index b0464cbb..d91b80ab 100644
--- a/cloudinit/sources/DataSourceOpenNebula.py
+++ b/cloudinit/sources/DataSourceOpenNebula.py
@@ -4,11 +4,13 @@
# Copyright (C) 2012 Yahoo! Inc.
# Copyright (C) 2012-2013 CERIT Scientific Cloud
# Copyright (C) 2012-2013 OpenNebula.org
+# Copyright (C) 2014 Consejo Superior de Investigaciones Cientificas
#
# Author: Scott Moser <scott.moser@canonical.com>
# Author: Joshua Harlow <harlowja@yahoo-inc.com>
# Author: Vlastimil Holer <xholer@mail.muni.cz>
# Author: Javier Fontan <jfontan@opennebula.org>
+# Author: Enol Fernandez <enolfc@ifca.unican.es>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3, as
@@ -22,6 +24,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+import base64
import os
import pwd
import re
@@ -417,6 +420,15 @@ def read_context_disk_dir(source_dir, asuser=None):
elif "USERDATA" in context:
results['userdata'] = context["USERDATA"]
+ # b64decode user data if necessary (default)
+ if 'userdata' in results:
+ userdata_encoding = context.get('USERDATA_ENCODING', None)
+ if userdata_encoding in (None, "base64"):
+ try:
+ results['userdata'] = base64.b64decode(results['userdata'])
+ except TypeError:
+ LOG.warn("Failed base64 decoding of userdata")
+
# generate static /etc/network/interfaces
# only if there are any required context variables
# http://opennebula.org/documentation:rel3.8:cong#network_configuration