diff --git a/CHANGELOG.txt b/CHANGELOG.txt index ab1f5553..cf8b58d0 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,5 @@ +3.2.12: + - Support previously base64 encoded userdata. 3.2.11: - Keystone V3 validation to refer to docs URL in case of missing configuration. - Add public_ip property when using server_connected_to_floating_ip and if use_public_ip is set True. diff --git a/openstack_plugin/tests/test_utils.py b/openstack_plugin/tests/test_utils.py new file mode 100644 index 00000000..a91aa666 --- /dev/null +++ b/openstack_plugin/tests/test_utils.py @@ -0,0 +1,32 @@ +# ####### +# Copyright (c) 2019 Cloudify Platform Ltd. All rights reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import base64 + +# Local imports +from openstack_plugin.tests.base import OpenStackTestBase +from openstack_plugin.utils import is_userdata_encoded + + +class UtilsTestCase(OpenStackTestBase): + + def setUp(self): + super(UtilsTestCase, self).setUp() + + def test_base64_encoding(self): + encoded_string = base64.b64encode('foo') + not_encoded_string = 'foo' + self.assertTrue(is_userdata_encoded(encoded_string)) + self.assertFalse(is_userdata_encoded(not_encoded_string)) diff --git a/openstack_plugin/utils.py b/openstack_plugin/utils.py index bc71a06e..28d1981d 100644 --- a/openstack_plugin/utils.py +++ b/openstack_plugin/utils.py @@ -18,6 +18,7 @@ import copy import logging import base64 +import binascii import inspect import re @@ -209,6 +210,14 @@ def resolve_ctx(_ctx): return _ctx +def is_userdata_encoded(userdata_string): + try: + base64.decodestring(userdata_string) + except binascii.Error: + return False + return True + + def handle_userdata(existing_userdata): """ This method will be responsible for handle user data provided by the @@ -232,6 +241,8 @@ def handle_userdata(existing_userdata): if not existing_userdata: existing_userdata = '' + elif is_userdata_encoded(existing_userdata): + return existing_userdata if install_agent_userdata and os_family == 'windows': diff --git a/plugin.yaml b/plugin.yaml index c0c9a43e..46ed8ee0 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -2,9 +2,9 @@ plugins: openstack: executor: central_deployment_agent - source: https://github.com/cloudify-cosmo/cloudify-openstack-plugin/archive/3.2.11.zip + source: https://github.com/cloudify-cosmo/cloudify-openstack-plugin/archive/3.2.12.zip package_name: cloudify-openstack-plugin - package_version: '3.2.11' + package_version: '3.2.12' dsl_definitions: diff --git a/setup.py b/setup.py index adcd4e34..1a26d6f2 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ setup( name='cloudify-openstack-plugin', - version='3.2.11', + version='3.2.12', author='Cloudify', author_email='info@cloudify.co', license='LICENSE',