diff options
author | Kiril Vladimiroff <kiril.vladimiroff@cloudsigma.com> | 2014-03-04 12:11:10 -0500 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2014-03-04 12:11:10 -0500 |
commit | 5c95d6817a4aea17054addceef5d955c75390aa1 (patch) | |
tree | 6c23e1ad42e9bf945eda1995b9eaab9508530c98 /cloudinit | |
parent | 3fa4022be5a88c93ad7f8c864b4f0962e22c1ecd (diff) | |
parent | d1e26fc118cdb641829fbe6b838ef46d4ab1f113 (diff) | |
download | vyos-cloud-init-5c95d6817a4aea17054addceef5d955c75390aa1.tar.gz vyos-cloud-init-5c95d6817a4aea17054addceef5d955c75390aa1.zip |
CloudSigma: support user-data being base64 encoded
This adds the ability to read a 'base64_fields' entry in the metadata,
and if cloud-init-userdata is listed in that, then content will be
base64 decoded first.
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/sources/DataSourceCloudSigma.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/cloudinit/sources/DataSourceCloudSigma.py b/cloudinit/sources/DataSourceCloudSigma.py index dad37119..e1c7e566 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 @@ -61,7 +62,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'] |