diff --git a/.circleci/test_examples.py b/.circleci/test_examples.py index 4acfa052..d5b5ba80 100644 --- a/.circleci/test_examples.py +++ b/.circleci/test_examples.py @@ -31,6 +31,8 @@ 'openstack_region': False, 'base_image_id': False, 'base_flavor_id': False, + 'openstack_user_domain_name': False, + 'openstack_project_domain_name': False, } prepare_test(secrets=SECRETS_TO_CREATE) diff --git a/openstack_plugin/tests/test_utils.py b/openstack_plugin/tests/test_utils.py deleted file mode 100644 index 6dbbfcae..00000000 --- a/openstack_plugin/tests/test_utils.py +++ /dev/null @@ -1,32 +0,0 @@ -# ####### -# 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(b'foo').decode('ascii', 'replace') - 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 dcb26671..2b1258b5 100644 --- a/openstack_plugin/utils.py +++ b/openstack_plugin/utils.py @@ -18,7 +18,6 @@ import copy import logging import base64 -import binascii import inspect import re @@ -34,7 +33,7 @@ from cloudify.constants import NODE_INSTANCE, RELATIONSHIP_INSTANCE # Py2/3 compatibility -from openstack_sdk._compat import text_type, PY2 +from openstack_sdk._compat import text_type # Local imports @@ -213,17 +212,6 @@ def resolve_ctx(_ctx): return _ctx -def is_userdata_encoded(userdata_string): - try: - if PY2: - base64.decodestring(userdata_string) - else: - base64.decodebytes(userdata_string.encode('utf-8')) - except binascii.Error: - return False - return True - - def handle_userdata(existing_userdata): """ This method will be responsible for handle user data provided by the @@ -247,7 +235,7 @@ def handle_userdata(existing_userdata): if not existing_userdata: existing_userdata = '' - elif is_userdata_encoded(existing_userdata): + elif not ctx.node.properties['encode_user_data']: return existing_userdata if install_agent_userdata and os_family == 'windows': @@ -290,7 +278,8 @@ def handle_userdata(existing_userdata): final_userdata = compute.create_multi_mimetype_userdata( [existing_userdata, install_agent_userdata]) - final_userdata = base64.b64encode(final_userdata) + final_userdata = base64.b64encode(final_userdata.encode('utf-8')).decode( + 'ascii') return final_userdata diff --git a/plugin.yaml b/plugin.yaml index 7a45069c..a745bfbd 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.14.zip + source: https://github.com/cloudify-cosmo/cloudify-openstack-plugin/archive/3.2.15.zip package_name: cloudify-openstack-plugin - package_version: '3.2.14' + package_version: '3.2.15' dsl_definitions: @@ -391,6 +391,7 @@ data_types: Must be Base64 encoded. Restricted to 65535 bytes. required: false type: string + metadata: description: > Metadata key and value pairs. @@ -1047,6 +1048,13 @@ node_types: type: cloudify.types.openstack.Server description: A dictionary that may contain these keys https://developer.openstack.org/api-ref/compute/?expanded=create-server-detail required: true + encode_user_data: + required: false + type: boolean + default: true + description: > + A boolean describing if the plugin will encode the user_data given in resource_config. + if the user data is bae64 encoded and this flag is false, the user_data that accepted will be sent as the server user_data. use_password: type: boolean default: false diff --git a/setup.py b/setup.py index 867e65b6..1ccc6acb 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ setup( name='cloudify-openstack-plugin', - version='3.2.14', + version='3.2.15', author='Cloudify', author_email='info@cloudify.co', license='LICENSE',