summaryrefslogtreecommitdiff
path: root/cloudinit/sources/DataSourceCloudSigma.py
diff options
context:
space:
mode:
authorKiril Vladimiroff <kiril.vladimiroff@cloudsigma.com>2014-02-19 10:45:53 +0200
committerKiril Vladimiroff <kiril.vladimiroff@cloudsigma.com>2014-02-19 10:45:53 +0200
commitd1e26fc118cdb641829fbe6b838ef46d4ab1f113 (patch)
tree9b0b43b9c43e5e69540628d60189a18df01ed536 /cloudinit/sources/DataSourceCloudSigma.py
parent5e5c8051fb2b3bd7c39e46fb090b2df282779ea1 (diff)
downloadvyos-cloud-init-d1e26fc118cdb641829fbe6b838ef46d4ab1f113.tar.gz
vyos-cloud-init-d1e26fc118cdb641829fbe6b838ef46d4ab1f113.zip
Read encoded with base64 user data
This allows users of CloudSigma's VM to encode their user data with base64. In order to do that thet have to add the ``cloudinit-user-data`` field to the ``base64_fields``. The latter is a comma-separated field with all the meta fields whit base64 encoded values.
Diffstat (limited to 'cloudinit/sources/DataSourceCloudSigma.py')
-rw-r--r--cloudinit/sources/DataSourceCloudSigma.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/cloudinit/sources/DataSourceCloudSigma.py b/cloudinit/sources/DataSourceCloudSigma.py
index e734d7e5..79ced3f4 100644
--- a/cloudinit/sources/DataSourceCloudSigma.py
+++ b/cloudinit/sources/DataSourceCloudSigma.py
@@ -15,6 +15,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/>.
+from base64 import b64decode
import re
from cloudinit import log as logging
@@ -60,7 +61,11 @@ class DataSourceCloudSigma(sources.DataSource):
if dsmode == "disabled" or dsmode != self.dsmode:
return False
+ base64_fields = server_meta.get('base64_fields', '').split(',')
self.userdata_raw = server_meta.get('cloudinit-user-data', "")
+ if 'cloudinit-user-data' in base64_fields:
+ self.userdata_raw = b64decode(self.userdata_raw)
+
self.metadata = server_context
self.ssh_public_key = server_meta['ssh_public_key']