From 1c60bc8e537c95fe9ee1ab99262973c0f2571db2 Mon Sep 17 00:00:00 2001 From: Mateusz Mizerski Date: Wed, 17 May 2023 11:31:13 +0200 Subject: [PATCH 01/18] add pull image node --- cloudify_docker/tasks.py | 16 ++++++++++++++++ plugin.yaml | 31 +++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/cloudify_docker/tasks.py b/cloudify_docker/tasks.py index 38d0e42..6739640 100644 --- a/cloudify_docker/tasks.py +++ b/cloudify_docker/tasks.py @@ -44,6 +44,7 @@ from cloudify_common_sdk.resource_downloader import get_shared_resource from cloudify_common_sdk.resource_downloader import TAR_FILE_EXTENSTIONS from cloudify_common_sdk._compat import text_type, PY2 +from docker.errors import ImageNotFound try: if PY2: @@ -633,6 +634,21 @@ def list_containers(ctx, docker_client, **kwargs): docker_client.containers.list(all=True, trunc=True) +@operation +@handle_docker_exception +@with_docker +def pull_image(ctx, docker_client, **kwargs): + resource_config = ctx.node.properties.get('resource_config', {}) + image_name = resource_config.get('image_name') + tag = resource_config.get('tag', 'latest') + all_tags = resource_config.get('all_tags') + try: + docker_client.images.get('{0}:{1}'.format(image_name, tag)) + except ImageNotFound: + docker_client.images.pull(repository=image_name, + tag=tag, all_tags=all_tags) + + @operation @handle_docker_exception @with_docker diff --git a/plugin.yaml b/plugin.yaml index 24bb883..ffe5e24 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -198,6 +198,22 @@ data_types: type: string default: '' + cloudify.types.docker.PullImage: + properties: + image_name: + description: Docker image name + type: string + default: '' + tag: + description: Docker image tag + type: string + default: '' + all_tags: + dtype: boolean + description: Pull all tags + default: false + + cloudify.types.docker.Container: properties: image_tag: @@ -333,6 +349,21 @@ node_types: delete: implementation: docker.cloudify_docker.tasks.remove_image + cloudify.nodes.docker.pullimage: + derived_from: cloudify.nodes.Root + properties: + <<: *client_config + resource_config: + type: cloudify.types.docker.PullImage + description: Docker Image type + required: true + interfaces: + cloudify.interfaces.lifecycle: + create: + implementation: docker.cloudify_docker.tasks.pull_image + delete: + implementation: docker.cloudify_docker.tasks.remove_image + cloudify.nodes.docker.container: derived_from: cloudify.nodes.Root properties: From c175e86de2e83239b02337820b6dce79189a7824 Mon Sep 17 00:00:00 2001 From: Mateusz Mizerski Date: Wed, 17 May 2023 12:47:03 +0200 Subject: [PATCH 02/18] update post-install script --- cloudify_docker/resources/post-install.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cloudify_docker/resources/post-install.sh b/cloudify_docker/resources/post-install.sh index 848b6e2..45f0b08 100644 --- a/cloudify_docker/resources/post-install.sh +++ b/cloudify_docker/resources/post-install.sh @@ -1,12 +1,19 @@ #!/bin/bash -e if [ -f /etc/redhat-release ]; then + sed -i '/ExecStart/s/usr\/bin\/dockerd/usr\/bin\/dockerd --mtu=1450/' /lib/systemd/system/docker.service + sed -i '/ExecStart/ s/$/ -H=tcp:\/\/0.0.0.0:2375 --dns 8.8.8.8 --bip 172.99.0.1\/16/' /lib/systemd/system/docker.service + systemctl daemon-reload + systemctl restart docker.service +fi +if [ -f /etc/lsb-release ]; then + if [[ -n $(systemctl list-unit-files | grep -w "docker") ]]; then sed -i '/ExecStart/s/usr\/bin\/dockerd/usr\/bin\/dockerd --mtu=1450/' /lib/systemd/system/docker.service sed -i '/ExecStart/ s/$/ -H=tcp:\/\/0.0.0.0:2375 --dns 8.8.8.8 --bip 172.99.0.1\/16/' /lib/systemd/system/docker.service systemctl daemon-reload systemctl restart docker.service -fi -if [ -f /etc/lsb-release ]; then + else echo "DOCKER_OPTS=\"--mtu=1450 --dns 8.8.8.8 --dns 8.8.4.4 \ -H=tcp://0.0.0.0:2375 --bip 172.99.0.1/16\"" >> /etc/default/docker service docker restart -fi \ No newline at end of file + fi +fi From 1cc9d2a2c0da5c00bd23bcefd2e36e84f487206a Mon Sep 17 00:00:00 2001 From: Mateusz Mizerski Date: Wed, 17 May 2023 15:29:01 +0200 Subject: [PATCH 03/18] Update plugin.yaml --- plugin.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.yaml b/plugin.yaml index ffe5e24..eb1985f 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -209,7 +209,7 @@ data_types: type: string default: '' all_tags: - dtype: boolean + type: boolean description: Pull all tags default: false From 033ea47a5d01bd5556bf7972e80bc7cb9135ba00 Mon Sep 17 00:00:00 2001 From: Mateusz Mizerski Date: Wed, 17 May 2023 16:56:02 +0200 Subject: [PATCH 04/18] fix stop container and change task for pull to cover removing --- cloudify_docker/tasks.py | 26 +++++++++++++++++++------- plugin.yaml | 4 ---- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/cloudify_docker/tasks.py b/cloudify_docker/tasks.py index 6739640..993fc39 100644 --- a/cloudify_docker/tasks.py +++ b/cloudify_docker/tasks.py @@ -44,7 +44,7 @@ from cloudify_common_sdk.resource_downloader import get_shared_resource from cloudify_common_sdk.resource_downloader import TAR_FILE_EXTENSTIONS from cloudify_common_sdk._compat import text_type, PY2 -from docker.errors import ImageNotFound +from docker.errors import ImageNotFound, NotFound try: if PY2: @@ -639,14 +639,20 @@ def list_containers(ctx, docker_client, **kwargs): @with_docker def pull_image(ctx, docker_client, **kwargs): resource_config = ctx.node.properties.get('resource_config', {}) - image_name = resource_config.get('image_name') - tag = resource_config.get('tag', 'latest') - all_tags = resource_config.get('all_tags') + tag = resource_config.get('tag') + all_tags = resource_config.get('all_tags', False) + if not tag: + return + repository = tag.split(':')[0] + try: + image_tag = tag.split(':')[1] + except IndexError: + image_tag = 'latest' try: - docker_client.images.get('{0}:{1}'.format(image_name, tag)) + docker_client.images.get(tag) except ImageNotFound: - docker_client.images.pull(repository=image_name, - tag=tag, all_tags=all_tags) + docker_client.images.pull(repository=repository, + tag=image_tag, all_tags=all_tags) @operation @@ -1003,6 +1009,12 @@ def stop_container(ctx, docker_client, stop_command, **kwargs): 'container_args') if not stop_command: ctx.logger.info("no stop command, nothing to do") + try: + container_obj = docker_client.containers.get(container) + container_obj.stop() + container_obj.wait() + except NotFound: + pass return script_executor = stop_command.split(' ', 1)[0] diff --git a/plugin.yaml b/plugin.yaml index eb1985f..8290269 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -200,10 +200,6 @@ data_types: cloudify.types.docker.PullImage: properties: - image_name: - description: Docker image name - type: string - default: '' tag: description: Docker image tag type: string From dbc54ac554d8481e6202f11641f1d28c49dce321 Mon Sep 17 00:00:00 2001 From: Mateusz Mizerski Date: Wed, 17 May 2023 17:26:53 +0200 Subject: [PATCH 05/18] Update tasks.py --- cloudify_docker/tasks.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cloudify_docker/tasks.py b/cloudify_docker/tasks.py index 993fc39..5c6feb8 100644 --- a/cloudify_docker/tasks.py +++ b/cloudify_docker/tasks.py @@ -653,6 +653,7 @@ def pull_image(ctx, docker_client, **kwargs): except ImageNotFound: docker_client.images.pull(repository=repository, tag=image_tag, all_tags=all_tags) + ctx.instance.runtime_properties['build_result'] = 'Image was pull' @operation From 7644cb3cc77b8f6fec905ca12435e6a3e68b53ae Mon Sep 17 00:00:00 2001 From: Mateusz Mizerski Date: Thu, 18 May 2023 08:48:49 +0200 Subject: [PATCH 06/18] add possibility to install docker without sudo --- cloudify_docker/tasks.py | 39 ++++++++++++++++++++++++++------------- plugin.yaml | 4 ++++ 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/cloudify_docker/tasks.py b/cloudify_docker/tasks.py index 5c6feb8..bf0594d 100644 --- a/cloudify_docker/tasks.py +++ b/cloudify_docker/tasks.py @@ -48,7 +48,7 @@ try: if PY2: - from fabric.api import settings, sudo, put + from fabric.api import settings, sudo, put, run FABRIC_VER = 1 else: from fabric import Connection, Config @@ -76,6 +76,16 @@ def call_sudo(command, fab_ctx=None): return sudo(command) +def call_command(command, fab_ctx=None): + ctx.logger.debug('Executing without sudo: {0}'.format(command)) + if FABRIC_VER == 2: + out = fab_ctx.run(command) + ctx.logger.debug('Out: {0}'.format(out)) + return out + elif FABRIC_VER == 1: + return run(command) + + def call_put(destination, destination_parent, mirror_local_mode=None, @@ -568,24 +578,27 @@ def install_docker(ctx, **kwargs): resource_config = ctx.node.properties.get('resource_config', {}) install_url = resource_config.get('install_url') post_install_url = resource_config.get('install_script') + install_with_sudo = resource_config.get('install_with_sudo', True) if not (install_url and post_install_url): raise NonRecoverableError("Please validate your install config") + installation_commands = [ + 'curl -fsSL {0} -o /tmp/install.sh'.format(install_url), + 'chmod 0755 / tmp / install.sh', + 'sh /tmp/install.sh', + 'curl -fsSL {0} -o /tmp/postinstall.sh'.format(post_install_url), + 'chmod 0755 /tmp/postinstall.sh', + 'sh /tmp/postinstall.sh', + 'usermod -aG docker {0}'.format(docker_user) + ] with get_fabric_settings(ctx, docker_ip, docker_user, docker_key) as s: with s: - call_sudo( - 'curl -fsSL {0} -o /tmp/install.sh'.format(install_url), - fab_ctx=s) - call_sudo('chmod 0755 /tmp/install.sh', fab_ctx=s) - call_sudo('sh /tmp/install.sh', fab_ctx=s) - call_sudo( - 'curl -fsSL {0} -o /tmp/postinstall.sh'.format( - post_install_url), - fab_ctx=s) - call_sudo('chmod 0755 /tmp/postinstall.sh', fab_ctx=s) - call_sudo('sh /tmp/postinstall.sh', fab_ctx=s) - call_sudo('usermod -aG docker {0}'.format(docker_user), fab_ctx=s) + for _command in installation_commands: + if install_with_sudo: + call_sudo(_command, fab_ctx=s) + else: + call_command(_command, fab_ctx=s) @operation diff --git a/plugin.yaml b/plugin.yaml index 8290269..bbc0b44 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -169,6 +169,10 @@ data_types: description: Docker Installation script type: string default: 'https://raw.githubusercontent.com/cloudify-cosmo/cloudify-docker-plugin/master/cloudify_docker/resources/post-install.sh' + install_with_sudo: + type: boolean + description: use sudo to run + default: true cloudify.types.docker.ClientConfig: properties: From 0501f2aaff66619bc21e1c3ec2e4ccda18f3a376 Mon Sep 17 00:00:00 2001 From: Mateusz Mizerski Date: Thu, 18 May 2023 10:43:43 +0200 Subject: [PATCH 07/18] fix installation --- cloudify_docker/resources/post-install.sh | 1 + cloudify_docker/tasks.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cloudify_docker/resources/post-install.sh b/cloudify_docker/resources/post-install.sh index 45f0b08..6dbcb78 100644 --- a/cloudify_docker/resources/post-install.sh +++ b/cloudify_docker/resources/post-install.sh @@ -1,4 +1,5 @@ #!/bin/bash -e +sleep 60 if [ -f /etc/redhat-release ]; then sed -i '/ExecStart/s/usr\/bin\/dockerd/usr\/bin\/dockerd --mtu=1450/' /lib/systemd/system/docker.service sed -i '/ExecStart/ s/$/ -H=tcp:\/\/0.0.0.0:2375 --dns 8.8.8.8 --bip 172.99.0.1\/16/' /lib/systemd/system/docker.service diff --git a/cloudify_docker/tasks.py b/cloudify_docker/tasks.py index bf0594d..44e1976 100644 --- a/cloudify_docker/tasks.py +++ b/cloudify_docker/tasks.py @@ -584,7 +584,7 @@ def install_docker(ctx, **kwargs): raise NonRecoverableError("Please validate your install config") installation_commands = [ 'curl -fsSL {0} -o /tmp/install.sh'.format(install_url), - 'chmod 0755 / tmp / install.sh', + 'chmod 0755 /tmp/install.sh', 'sh /tmp/install.sh', 'curl -fsSL {0} -o /tmp/postinstall.sh'.format(post_install_url), 'chmod 0755 /tmp/postinstall.sh', From 428892c291e84a3a9b4499f5924dfd82391da1e9 Mon Sep 17 00:00:00 2001 From: Mateusz Mizerski Date: Thu, 18 May 2023 11:21:54 +0200 Subject: [PATCH 08/18] Update post-install.sh --- cloudify_docker/resources/post-install.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cloudify_docker/resources/post-install.sh b/cloudify_docker/resources/post-install.sh index 6dbcb78..e28178f 100644 --- a/cloudify_docker/resources/post-install.sh +++ b/cloudify_docker/resources/post-install.sh @@ -1,4 +1,5 @@ #!/bin/bash -e +set -x sleep 60 if [ -f /etc/redhat-release ]; then sed -i '/ExecStart/s/usr\/bin\/dockerd/usr\/bin\/dockerd --mtu=1450/' /lib/systemd/system/docker.service @@ -7,7 +8,8 @@ if [ -f /etc/redhat-release ]; then systemctl restart docker.service fi if [ -f /etc/lsb-release ]; then - if [[ -n $(systemctl list-unit-files | grep -w "docker") ]]; then + docker_unit=$(systemctl list-unit-files | grep -w "docker") + if [ -n "$docker_unit" ]; then sed -i '/ExecStart/s/usr\/bin\/dockerd/usr\/bin\/dockerd --mtu=1450/' /lib/systemd/system/docker.service sed -i '/ExecStart/ s/$/ -H=tcp:\/\/0.0.0.0:2375 --dns 8.8.8.8 --bip 172.99.0.1\/16/' /lib/systemd/system/docker.service systemctl daemon-reload From 55f1edb040c6cc0b9af3c5fc05ae9b62feb75406 Mon Sep 17 00:00:00 2001 From: Mateusz Mizerski Date: Thu, 18 May 2023 12:23:54 +0200 Subject: [PATCH 09/18] Update tasks.py --- cloudify_docker/tasks.py | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/cloudify_docker/tasks.py b/cloudify_docker/tasks.py index 44e1976..3582ff1 100644 --- a/cloudify_docker/tasks.py +++ b/cloudify_docker/tasks.py @@ -605,13 +605,20 @@ def install_docker(ctx, **kwargs): def uninstall_docker(ctx, **kwargs): # fetch the data needed for installation docker_ip, docker_user, docker_key, _ = get_docker_machine_from_ctx(ctx) + resource_config = ctx.node.properties.get('resource_config', {}) + install_with_sudo = resource_config.get('install_with_sudo', True) + if install_with_sudo: + command_obj = call_sudo + else: + command_obj = call_command + with get_fabric_settings(ctx, docker_ip, docker_user, docker_key) as s: with s: - os_type = call_sudo("echo $(python -c " - "'import platform; " - "print(platform.linux_distribution(" - "full_distribution_name=False)[0])')", - fab_ctx=s) + os_type = command_obj("echo $(python -c " + "'import platform; " + "print(platform.linux_distribution(" + "full_distribution_name=False)[0])')", + fab_ctx=s) if not PY2: os_type = os_type.stdout os_type = os_type.splitlines() @@ -623,12 +630,25 @@ def uninstall_docker(ctx, **kwargs): else: value += line os_type = value.strip() + yum_command = False + apt_command = False + if not os_type: + ctx.logger.info('OS not detected. Check the commands...') + command_yum = str(command_obj('yum', fab_ctx=s)) + command_apt = str(command_obj('apt-get', fab_ctx=s)) + yum_command = False \ + if 'command not found' in command_yum else True + apt_command = False \ + if 'command not found' in command_apt else True + ctx.logger.info('System: YUM: {0}. APT-GET: {1}'.format( + yum_command, apt_command)) + ctx.logger.info("os_type {0}".format(os_type)) result = "" - if os_type.lower() in REDHAT_OS_VERS: - result = call_sudo("yum remove -y docker*", fab_ctx=s) - elif os_type.lower() in DEBIAN_OS_VERS: - result = call_sudo("apt-get remove -y docker*", fab_ctx=s) + if os_type.lower() in REDHAT_OS_VERS or yum_command: + result = command_obj("yum remove -y docker*", fab_ctx=s) + elif os_type.lower() in DEBIAN_OS_VERS or apt_command: + result = command_obj("apt-get remove -y docker*", fab_ctx=s) ctx.logger.info("uninstall result {0}".format(result)) From 81d6f961b609d56f6ff1bcee78799067f1d4ac9d Mon Sep 17 00:00:00 2001 From: Ahmad Musa Date: Sun, 11 Jun 2023 20:54:27 +0100 Subject: [PATCH 10/18] bump-version-add-change-log --- CHANGELOG.txt | 5 ++++- plugin.yaml | 3 +-- plugin_1_4.yaml | 32 +++++++++++++++++++++++++++++++- v2_plugin.yaml | 32 +++++++++++++++++++++++++++++++- 4 files changed, 67 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 5b81fac..3b0d39c 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -27,4 +27,7 @@ 2.0.11: - add __version__.py file in cloudify_docker folder. 2.0.12: - - fix install config for docker host. \ No newline at end of file + - fix install config for docker host. +2.0.13: + - Add PullImage Node type. + - Allow docker installation without sudo. \ No newline at end of file diff --git a/plugin.yaml b/plugin.yaml index bbc0b44..5899993 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -2,7 +2,7 @@ plugins: docker: executor: central_deployment_agent package_name: 'cloudify-docker-plugin' - package_version: '2.0.12' + package_version: '2.0.13' dsl_definitions: @@ -213,7 +213,6 @@ data_types: description: Pull all tags default: false - cloudify.types.docker.Container: properties: image_tag: diff --git a/plugin_1_4.yaml b/plugin_1_4.yaml index fd6b45f..99a79fa 100644 --- a/plugin_1_4.yaml +++ b/plugin_1_4.yaml @@ -2,7 +2,7 @@ plugins: docker: executor: central_deployment_agent package_name: 'cloudify-docker-plugin' - package_version: '2.0.12' + package_version: '2.0.13' dsl_definitions: @@ -167,6 +167,10 @@ data_types: description: Docker Installation script type: string default: 'https://raw.githubusercontent.com/cloudify-cosmo/cloudify-docker-plugin/master/cloudify_docker/resources/post-install.sh' + install_with_sudo: + type: boolean + description: use sudo to run + default: true cloudify.types.docker.ClientConfig: properties: @@ -196,6 +200,17 @@ data_types: type: string default: '' + cloudify.types.docker.PullImage: + properties: + tag: + description: Docker image tag + type: string + default: '' + all_tags: + type: boolean + description: Pull all tags + default: false + cloudify.types.docker.Container: properties: image_tag: @@ -331,6 +346,21 @@ node_types: delete: implementation: docker.cloudify_docker.tasks.remove_image + cloudify.nodes.docker.pullimage: + derived_from: cloudify.nodes.Root + properties: + <<: *client_config + resource_config: + type: cloudify.types.docker.PullImage + description: Docker Image type + required: true + interfaces: + cloudify.interfaces.lifecycle: + create: + implementation: docker.cloudify_docker.tasks.pull_image + delete: + implementation: docker.cloudify_docker.tasks.remove_image + cloudify.nodes.docker.container: derived_from: cloudify.nodes.Root properties: diff --git a/v2_plugin.yaml b/v2_plugin.yaml index fd6b45f..99a79fa 100644 --- a/v2_plugin.yaml +++ b/v2_plugin.yaml @@ -2,7 +2,7 @@ plugins: docker: executor: central_deployment_agent package_name: 'cloudify-docker-plugin' - package_version: '2.0.12' + package_version: '2.0.13' dsl_definitions: @@ -167,6 +167,10 @@ data_types: description: Docker Installation script type: string default: 'https://raw.githubusercontent.com/cloudify-cosmo/cloudify-docker-plugin/master/cloudify_docker/resources/post-install.sh' + install_with_sudo: + type: boolean + description: use sudo to run + default: true cloudify.types.docker.ClientConfig: properties: @@ -196,6 +200,17 @@ data_types: type: string default: '' + cloudify.types.docker.PullImage: + properties: + tag: + description: Docker image tag + type: string + default: '' + all_tags: + type: boolean + description: Pull all tags + default: false + cloudify.types.docker.Container: properties: image_tag: @@ -331,6 +346,21 @@ node_types: delete: implementation: docker.cloudify_docker.tasks.remove_image + cloudify.nodes.docker.pullimage: + derived_from: cloudify.nodes.Root + properties: + <<: *client_config + resource_config: + type: cloudify.types.docker.PullImage + description: Docker Image type + required: true + interfaces: + cloudify.interfaces.lifecycle: + create: + implementation: docker.cloudify_docker.tasks.pull_image + delete: + implementation: docker.cloudify_docker.tasks.remove_image + cloudify.nodes.docker.container: derived_from: cloudify.nodes.Root properties: From 3f6b7aba7c8ebd610b2777331912a30c5f790f75 Mon Sep 17 00:00:00 2001 From: Mateusz Mizerski <106737627+mateuszmizer@users.noreply.github.com> Date: Fri, 16 Jun 2023 16:21:15 +0200 Subject: [PATCH 11/18] update repo --- cloudify_docker/tasks.py | 100 +++++++++++++++++++++++++++++++++++++++ plugin.yaml | 55 +++++++++++++++++++++ 2 files changed, 155 insertions(+) diff --git a/cloudify_docker/tasks.py b/cloudify_docker/tasks.py index 3582ff1..dae2346 100644 --- a/cloudify_docker/tasks.py +++ b/cloudify_docker/tasks.py @@ -601,6 +601,65 @@ def install_docker(ctx, **kwargs): call_command(_command, fab_ctx=s) +@operation +@handle_docker_exception +def install_docker_offline(ctx, **kwargs): + """ + support only for EDGE OS (ubuntu22.04) + """ + # fetch the data needed for installation + docker_ip, docker_user, docker_key, _ = get_docker_machine_from_ctx(ctx) + resource_config = ctx.node.properties.get('resource_config', {}) + package_tar_path = resource_config.get('package_tar_path') + post_install_path = resource_config.get('post_install_script_path') + installation_dir = resource_config.get('installation_dir') + install_with_sudo = resource_config.get('install_with_sudo', True) + installation_dir = installation_dir if installation_dir.endswith('/')\ + else '{0}/'.format(installation_dir) + if not (package_tar_path and post_install_path): + raise NonRecoverableError("Please validate your install config") + installation_commands = [ + 'tar -xf {0} -C {1}'.format(package_tar_path, installation_dir), + 'dpkg -i {0}*.deb'.format(installation_dir), + 'chmod 0755 {0}'.format(post_install_path), + 'sh {}'.format(post_install_path), + 'usermod -aG docker {0}'.format(docker_user) + ] + + with get_fabric_settings(ctx, docker_ip, docker_user, docker_key) as s: + with s: + for _command in installation_commands: + if install_with_sudo: + call_sudo(_command, fab_ctx=s) + else: + call_command(_command, fab_ctx=s) + + +@operation +@handle_docker_exception +def uninstall_docker_offline(ctx, **kwargs): + """ + support only for EDGE OS (ubuntu22.04) + """ + # fetch the data needed for installation + docker_ip, docker_user, docker_key, _ = get_docker_machine_from_ctx(ctx) + resource_config = ctx.node.properties.get('resource_config', {}) + install_with_sudo = resource_config.get('install_with_sudo', True) + + installation_commands = [ + 'dpkg --remove docker-buildx-plugin docker-ce docker-ce-rootless-' + 'extras docker-ce-cli docker-compose-plugin containerd.io', + 'rm -rf /data/docker' + ] + + with get_fabric_settings(ctx, docker_ip, docker_user, docker_key) as s: + with s: + for _command in installation_commands: + if install_with_sudo: + call_sudo(_command, fab_ctx=s) + else: + call_command(_command, fab_ctx=s) + @operation def uninstall_docker(ctx, **kwargs): # fetch the data needed for installation @@ -1120,3 +1179,44 @@ def remove_container(ctx, docker_client, **kwargs): remove_res = container_obj.remove() ctx.instance.runtime_properties.pop('container') ctx.logger.info("Remove result {0}".format(remove_res)) + + +@operation +@handle_docker_exception +@with_docker +def load_image_from_tar(ctx, docker_client, **kwargs): + resource_config = ctx.node.properties.get('resource_config', {}) + image_tar_path = resource_config.get('image_tar_path', "") + image_tag = resource_config.get('tag', "") + with open(image_tar_path, "r") as f: + docker_client.images.load(f) + + +@operation +@handle_docker_exception +@with_docker +def create_tar_from_image(ctx, docker_client, **kwargs): + """ + support only for EDGE OS (ubuntu22.04) + """ + # fetch the data needed for installation + docker_ip, docker_user, docker_key, _ = get_docker_machine_from_ctx(ctx) + resource_config = ctx.node.properties.get('resource_config', {}) + package_tar = resource_config.get('tar_path') + tag = resource_config.get('tag') + install_with_sudo = resource_config.get('install_with_sudo', True) + + if not (package_tar and tag): + raise NonRecoverableError("Please validate your install config") + + with get_fabric_settings(ctx, docker_ip, docker_user, docker_key) as s: + with s: + if install_with_sudo: + call_sudo( + 'docker save --output {0} {1}'.format(package_tar, tag), + fab_ctx=s) + else: + call_command( + 'docker save --output {0} {1}'.format(package_tar, tag), + fab_ctx=s) + diff --git a/plugin.yaml b/plugin.yaml index bbc0b44..b5fbec5 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -174,6 +174,22 @@ data_types: description: use sudo to run default: true + cloudify.types.docker.DockerOfflineInstallationConfig: + properties: + package_tar_path: + description: Docker Installation Tar path (must be located on the on where docker installed) + type: string + post_install_script_path: + description: Docker Installation post script path + type: string + installation_dir: + description: Docker Installation path + type: string + install_with_sudo: + type: boolean + description: use sudo to run + default: true + cloudify.types.docker.ClientConfig: properties: docker_host: @@ -213,6 +229,16 @@ data_types: description: Pull all tags default: false + cloudify.types.docker.TarImage: + properties: + tag: + description: Docker image tag + type: string + default: '' + image_tar_path: + description: Docker image path + type: string + default: '' cloudify.types.docker.Container: properties: @@ -324,6 +350,20 @@ node_types: delete: implementation: docker.cloudify_docker.tasks.uninstall_docker + cloudify.nodes.docker.offline_host: + derived_from: cloudify.nodes.Root + properties: + <<: *docker_machine + resource_config: + type: cloudify.types.docker.DockerOfflineInstallationConfig + description: Docker Installation type + required: true + interfaces: + cloudify.interfaces.lifecycle: + create: + implementation: docker.cloudify_docker.tasks.install_docker_offline + delete: + implementation: docker.cloudify_docker.tasks.uninstall_docker_offline cloudify.nodes.docker.host_details: derived_from: cloudify.nodes.Root @@ -364,6 +404,21 @@ node_types: delete: implementation: docker.cloudify_docker.tasks.remove_image + cloudify.nodes.docker.tarimage: + derived_from: cloudify.nodes.Root + properties: + <<: *client_config + resource_config: + type: cloudify.types.docker.TarImage + description: Docker Image type + required: true + interfaces: + cloudify.interfaces.lifecycle: + create: + implementation: docker.cloudify_docker.tasks.load_image_from_tar + delete: + implementation: docker.cloudify_docker.tasks.remove_image + cloudify.nodes.docker.container: derived_from: cloudify.nodes.Root properties: From 4ee98215f09a83c51e63cb94e6208833183be3dc Mon Sep 17 00:00:00 2001 From: Mateusz Mizerski <106737627+mateuszmizer@users.noreply.github.com> Date: Mon, 19 Jun 2023 16:04:03 +0200 Subject: [PATCH 12/18] update --- cloudify_docker/tasks.py | 76 ++++++++++++++++++++-------------------- plugin.yaml | 15 -------- 2 files changed, 38 insertions(+), 53 deletions(-) diff --git a/cloudify_docker/tasks.py b/cloudify_docker/tasks.py index dae2346..121e41f 100644 --- a/cloudify_docker/tasks.py +++ b/cloudify_docker/tasks.py @@ -1181,42 +1181,42 @@ def remove_container(ctx, docker_client, **kwargs): ctx.logger.info("Remove result {0}".format(remove_res)) -@operation -@handle_docker_exception -@with_docker -def load_image_from_tar(ctx, docker_client, **kwargs): - resource_config = ctx.node.properties.get('resource_config', {}) - image_tar_path = resource_config.get('image_tar_path', "") - image_tag = resource_config.get('tag', "") - with open(image_tar_path, "r") as f: - docker_client.images.load(f) - - -@operation -@handle_docker_exception -@with_docker -def create_tar_from_image(ctx, docker_client, **kwargs): - """ - support only for EDGE OS (ubuntu22.04) - """ - # fetch the data needed for installation - docker_ip, docker_user, docker_key, _ = get_docker_machine_from_ctx(ctx) - resource_config = ctx.node.properties.get('resource_config', {}) - package_tar = resource_config.get('tar_path') - tag = resource_config.get('tag') - install_with_sudo = resource_config.get('install_with_sudo', True) - - if not (package_tar and tag): - raise NonRecoverableError("Please validate your install config") - - with get_fabric_settings(ctx, docker_ip, docker_user, docker_key) as s: - with s: - if install_with_sudo: - call_sudo( - 'docker save --output {0} {1}'.format(package_tar, tag), - fab_ctx=s) - else: - call_command( - 'docker save --output {0} {1}'.format(package_tar, tag), - fab_ctx=s) +# @operation +# @handle_docker_exception +# @with_docker +# def load_image_from_tar(ctx, docker_client, **kwargs): +# resource_config = ctx.node.properties.get('resource_config', {}) +# image_tar_path = resource_config.get('image_tar_path', "") +# image_tag = resource_config.get('tag', "") +# with open(image_tar_path, "r") as f: +# docker_client.images.load(f) +# +# +# @operation +# @handle_docker_exception +# @with_docker +# def create_tar_from_image(ctx, docker_client, **kwargs): +# """ +# support only for EDGE OS (ubuntu22.04) +# """ +# # fetch the data needed for installation +# docker_ip, docker_user, docker_key, _ = get_docker_machine_from_ctx(ctx) +# resource_config = ctx.node.properties.get('resource_config', {}) +# package_tar = resource_config.get('tar_path') +# tag = resource_config.get('tag') +# install_with_sudo = resource_config.get('install_with_sudo', True) +# +# if not (package_tar and tag): +# raise NonRecoverableError("Please validate your install config") +# +# with get_fabric_settings(ctx, docker_ip, docker_user, docker_key) as s: +# with s: +# if install_with_sudo: +# call_sudo( +# 'docker save --output {0} {1}'.format(package_tar, tag), +# fab_ctx=s) +# else: +# call_command( +# 'docker save --output {0} {1}'.format(package_tar, tag), +# fab_ctx=s) diff --git a/plugin.yaml b/plugin.yaml index b5fbec5..edb6da2 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -404,21 +404,6 @@ node_types: delete: implementation: docker.cloudify_docker.tasks.remove_image - cloudify.nodes.docker.tarimage: - derived_from: cloudify.nodes.Root - properties: - <<: *client_config - resource_config: - type: cloudify.types.docker.TarImage - description: Docker Image type - required: true - interfaces: - cloudify.interfaces.lifecycle: - create: - implementation: docker.cloudify_docker.tasks.load_image_from_tar - delete: - implementation: docker.cloudify_docker.tasks.remove_image - cloudify.nodes.docker.container: derived_from: cloudify.nodes.Root properties: From e249ca4d552397fe512646854544e3985607be15 Mon Sep 17 00:00:00 2001 From: Mateusz Mizerski <106737627+mateuszmizer@users.noreply.github.com> Date: Tue, 20 Jun 2023 11:06:21 +0200 Subject: [PATCH 13/18] Update tasks.py --- cloudify_docker/tasks.py | 46 ++++------------------------------------ 1 file changed, 4 insertions(+), 42 deletions(-) diff --git a/cloudify_docker/tasks.py b/cloudify_docker/tasks.py index 121e41f..72c40dd 100644 --- a/cloudify_docker/tasks.py +++ b/cloudify_docker/tasks.py @@ -589,7 +589,8 @@ def install_docker(ctx, **kwargs): 'curl -fsSL {0} -o /tmp/postinstall.sh'.format(post_install_url), 'chmod 0755 /tmp/postinstall.sh', 'sh /tmp/postinstall.sh', - 'usermod -aG docker {0}'.format(docker_user) + 'usermod -aG docker {0}'.format(docker_user), + 'newgrp docker' ] with get_fabric_settings(ctx, docker_ip, docker_user, docker_key) as s: @@ -623,7 +624,8 @@ def install_docker_offline(ctx, **kwargs): 'dpkg -i {0}*.deb'.format(installation_dir), 'chmod 0755 {0}'.format(post_install_path), 'sh {}'.format(post_install_path), - 'usermod -aG docker {0}'.format(docker_user) + 'usermod -aG docker {0}'.format(docker_user), + 'newgrp docker' ] with get_fabric_settings(ctx, docker_ip, docker_user, docker_key) as s: @@ -1180,43 +1182,3 @@ def remove_container(ctx, docker_client, **kwargs): ctx.instance.runtime_properties.pop('container') ctx.logger.info("Remove result {0}".format(remove_res)) - -# @operation -# @handle_docker_exception -# @with_docker -# def load_image_from_tar(ctx, docker_client, **kwargs): -# resource_config = ctx.node.properties.get('resource_config', {}) -# image_tar_path = resource_config.get('image_tar_path', "") -# image_tag = resource_config.get('tag', "") -# with open(image_tar_path, "r") as f: -# docker_client.images.load(f) -# -# -# @operation -# @handle_docker_exception -# @with_docker -# def create_tar_from_image(ctx, docker_client, **kwargs): -# """ -# support only for EDGE OS (ubuntu22.04) -# """ -# # fetch the data needed for installation -# docker_ip, docker_user, docker_key, _ = get_docker_machine_from_ctx(ctx) -# resource_config = ctx.node.properties.get('resource_config', {}) -# package_tar = resource_config.get('tar_path') -# tag = resource_config.get('tag') -# install_with_sudo = resource_config.get('install_with_sudo', True) -# -# if not (package_tar and tag): -# raise NonRecoverableError("Please validate your install config") -# -# with get_fabric_settings(ctx, docker_ip, docker_user, docker_key) as s: -# with s: -# if install_with_sudo: -# call_sudo( -# 'docker save --output {0} {1}'.format(package_tar, tag), -# fab_ctx=s) -# else: -# call_command( -# 'docker save --output {0} {1}'.format(package_tar, tag), -# fab_ctx=s) - From b6ae6e8ebb3aac69f8dbc49054fee821a0549e4f Mon Sep 17 00:00:00 2001 From: Mateusz Mizerski <106737627+mateuszmizer@users.noreply.github.com> Date: Tue, 20 Jun 2023 13:39:27 +0200 Subject: [PATCH 14/18] revert --- cloudify_docker/tasks.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cloudify_docker/tasks.py b/cloudify_docker/tasks.py index 72c40dd..3aee177 100644 --- a/cloudify_docker/tasks.py +++ b/cloudify_docker/tasks.py @@ -589,8 +589,7 @@ def install_docker(ctx, **kwargs): 'curl -fsSL {0} -o /tmp/postinstall.sh'.format(post_install_url), 'chmod 0755 /tmp/postinstall.sh', 'sh /tmp/postinstall.sh', - 'usermod -aG docker {0}'.format(docker_user), - 'newgrp docker' + 'usermod -aG docker {0}'.format(docker_user) ] with get_fabric_settings(ctx, docker_ip, docker_user, docker_key) as s: @@ -624,8 +623,7 @@ def install_docker_offline(ctx, **kwargs): 'dpkg -i {0}*.deb'.format(installation_dir), 'chmod 0755 {0}'.format(post_install_path), 'sh {}'.format(post_install_path), - 'usermod -aG docker {0}'.format(docker_user), - 'newgrp docker' + 'usermod -aG docker {0}'.format(docker_user) ] with get_fabric_settings(ctx, docker_ip, docker_user, docker_key) as s: From d2c24bc5804d6f961be9953611395a6e7f54f61a Mon Sep 17 00:00:00 2001 From: Mateusz Mizerski <106737627+mateuszmizer@users.noreply.github.com> Date: Wed, 21 Jun 2023 09:39:22 +0200 Subject: [PATCH 15/18] remove artifacts --- plugin.yaml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/plugin.yaml b/plugin.yaml index edb6da2..3b20d16 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -229,17 +229,6 @@ data_types: description: Pull all tags default: false - cloudify.types.docker.TarImage: - properties: - tag: - description: Docker image tag - type: string - default: '' - image_tar_path: - description: Docker image path - type: string - default: '' - cloudify.types.docker.Container: properties: image_tag: From 9f067e923ece2e6f7de1a222f7127ba84d4a7c6e Mon Sep 17 00:00:00 2001 From: Mateusz Mizerski <106737627+mateuszmizer@users.noreply.github.com> Date: Wed, 21 Jun 2023 11:24:16 +0200 Subject: [PATCH 16/18] remove nodes types and change logic --- cloudify_docker/tasks.py | 52 ++++++++++++++++-------------- plugin.yaml | 69 ++++++++++++---------------------------- 2 files changed, 49 insertions(+), 72 deletions(-) diff --git a/cloudify_docker/tasks.py b/cloudify_docker/tasks.py index 3aee177..8d9294e 100644 --- a/cloudify_docker/tasks.py +++ b/cloudify_docker/tasks.py @@ -571,8 +571,17 @@ def list_images(ctx, docker_client, **kwargs): @operation -@handle_docker_exception def install_docker(ctx, **kwargs): + resource_config = ctx.node.properties.get('resource_config', {}) + offline_installation = resource_config.get('offline_installation') + if not offline_installation: + _install_docker(ctx=ctx, **kwargs) + else: + _install_docker_offline(ctx=ctx, **kwargs) + + +@handle_docker_exception +def _install_docker(ctx, **kwargs): # fetch the data needed for installation docker_ip, docker_user, docker_key, _ = get_docker_machine_from_ctx(ctx) resource_config = ctx.node.properties.get('resource_config', {}) @@ -603,7 +612,7 @@ def install_docker(ctx, **kwargs): @operation @handle_docker_exception -def install_docker_offline(ctx, **kwargs): +def _install_docker_offline(ctx, **kwargs): """ support only for EDGE OS (ubuntu22.04) """ @@ -726,28 +735,6 @@ def list_containers(ctx, docker_client, **kwargs): docker_client.containers.list(all=True, trunc=True) -@operation -@handle_docker_exception -@with_docker -def pull_image(ctx, docker_client, **kwargs): - resource_config = ctx.node.properties.get('resource_config', {}) - tag = resource_config.get('tag') - all_tags = resource_config.get('all_tags', False) - if not tag: - return - repository = tag.split(':')[0] - try: - image_tag = tag.split(':')[1] - except IndexError: - image_tag = 'latest' - try: - docker_client.images.get(tag) - except ImageNotFound: - docker_client.images.pull(repository=repository, - tag=image_tag, all_tags=all_tags) - ctx.instance.runtime_properties['build_result'] = 'Image was pull' - - @operation @handle_docker_exception @with_docker @@ -756,6 +743,8 @@ def build_image(ctx, docker_client, **kwargs): image_content, tag = get_from_resource_config(resource_config, 'image_content', 'tag') + pull_image = resource_config.get('pull_image', False) + if image_content: # check what content we got, URL , path or string split = image_content.split('://') @@ -788,6 +777,21 @@ def build_image(ctx, docker_client, **kwargs): raise NonRecoverableError("Build Failed check build-result") ctx.instance.runtime_properties['image'] = \ repr(docker_client.images.get(name=tag)) + elif pull_image: + all_tags = resource_config.get('all_tags', False) + if not tag: + return + repository = tag.split(':')[0] + try: + image_tag = tag.split(':')[1] + except IndexError: + image_tag = 'latest' + try: + docker_client.images.get(tag) + except ImageNotFound: + docker_client.images.pull(repository=repository, + tag=image_tag, all_tags=all_tags) + ctx.instance.runtime_properties['build_result'] = 'Image was pull' @operation diff --git a/plugin.yaml b/plugin.yaml index 3b20d16..f342c2c 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -173,22 +173,28 @@ data_types: type: boolean description: use sudo to run default: true - - cloudify.types.docker.DockerOfflineInstallationConfig: - properties: + offline_installation: + type: boolean + description: Install docker when the vm has no internet access + default: false package_tar_path: - description: Docker Installation Tar path (must be located on the on where docker installed) + description: | + Docker Installation Tar path (must be located on the on where docker installed) + Required when offline installation type: string + default: '' post_install_script_path: - description: Docker Installation post script path + description: | + Docker Installation post script path + Required when offline installation type: string + default: '' installation_dir: - description: Docker Installation path + description: | + Docker Installation path + Required when offline installation type: string - install_with_sudo: - type: boolean - description: use sudo to run - default: true + default: '' cloudify.types.docker.ClientConfig: properties: @@ -217,16 +223,13 @@ data_types: description: Docker image tag type: string default: '' - - cloudify.types.docker.PullImage: - properties: - tag: - description: Docker image tag - type: string - default: '' + pull_image: + type: boolean + description: Pull image + default: false all_tags: type: boolean - description: Pull all tags + description: Pull all tags (only if pull_image is True) default: false cloudify.types.docker.Container: @@ -339,21 +342,6 @@ node_types: delete: implementation: docker.cloudify_docker.tasks.uninstall_docker - cloudify.nodes.docker.offline_host: - derived_from: cloudify.nodes.Root - properties: - <<: *docker_machine - resource_config: - type: cloudify.types.docker.DockerOfflineInstallationConfig - description: Docker Installation type - required: true - interfaces: - cloudify.interfaces.lifecycle: - create: - implementation: docker.cloudify_docker.tasks.install_docker_offline - delete: - implementation: docker.cloudify_docker.tasks.uninstall_docker_offline - cloudify.nodes.docker.host_details: derived_from: cloudify.nodes.Root properties: @@ -378,21 +366,6 @@ node_types: delete: implementation: docker.cloudify_docker.tasks.remove_image - cloudify.nodes.docker.pullimage: - derived_from: cloudify.nodes.Root - properties: - <<: *client_config - resource_config: - type: cloudify.types.docker.PullImage - description: Docker Image type - required: true - interfaces: - cloudify.interfaces.lifecycle: - create: - implementation: docker.cloudify_docker.tasks.pull_image - delete: - implementation: docker.cloudify_docker.tasks.remove_image - cloudify.nodes.docker.container: derived_from: cloudify.nodes.Root properties: From 8bc64751c9396606d709c649caebc99e673389ca Mon Sep 17 00:00:00 2001 From: Mateusz Mizerski <106737627+mateuszmizer@users.noreply.github.com> Date: Wed, 21 Jun 2023 12:45:58 +0200 Subject: [PATCH 17/18] remarks --- cloudify_docker/tasks.py | 23 ++++++++++++++++------- plugin_1_4.yaml | 34 ++++++++++++++++++++++++++++++++++ v2_plugin.yaml | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 7 deletions(-) diff --git a/cloudify_docker/tasks.py b/cloudify_docker/tasks.py index 8d9294e..2f27b3e 100644 --- a/cloudify_docker/tasks.py +++ b/cloudify_docker/tasks.py @@ -610,7 +610,6 @@ def _install_docker(ctx, **kwargs): call_command(_command, fab_ctx=s) -@operation @handle_docker_exception def _install_docker_offline(ctx, **kwargs): """ @@ -645,8 +644,16 @@ def _install_docker_offline(ctx, **kwargs): @operation -@handle_docker_exception -def uninstall_docker_offline(ctx, **kwargs): +def uninstall_docker(ctx, **kwargs): + resource_config = ctx.node.properties.get('resource_config', {}) + offline_installation = resource_config.get('offline_installation') + if not offline_installation: + _uninstall_docker(ctx=ctx, **kwargs) + else: + _uninstall_docker_offline(ctx=ctx, **kwargs) + + +def _uninstall_docker_offline(ctx, **kwargs): """ support only for EDGE OS (ubuntu22.04) """ @@ -654,11 +661,13 @@ def uninstall_docker_offline(ctx, **kwargs): docker_ip, docker_user, docker_key, _ = get_docker_machine_from_ctx(ctx) resource_config = ctx.node.properties.get('resource_config', {}) install_with_sudo = resource_config.get('install_with_sudo', True) - + installation_dir = resource_config.get('installation_dir') + installation_dir = installation_dir if installation_dir.endswith('/') \ + else '{0}/'.format(installation_dir) installation_commands = [ 'dpkg --remove docker-buildx-plugin docker-ce docker-ce-rootless-' 'extras docker-ce-cli docker-compose-plugin containerd.io', - 'rm -rf /data/docker' + 'rm -rf {0}'.format(installation_dir) ] with get_fabric_settings(ctx, docker_ip, docker_user, docker_key) as s: @@ -669,8 +678,8 @@ def uninstall_docker_offline(ctx, **kwargs): else: call_command(_command, fab_ctx=s) -@operation -def uninstall_docker(ctx, **kwargs): + +def _uninstall_docker(ctx, **kwargs): # fetch the data needed for installation docker_ip, docker_user, docker_key, _ = get_docker_machine_from_ctx(ctx) resource_config = ctx.node.properties.get('resource_config', {}) diff --git a/plugin_1_4.yaml b/plugin_1_4.yaml index fd6b45f..23d8403 100644 --- a/plugin_1_4.yaml +++ b/plugin_1_4.yaml @@ -167,6 +167,32 @@ data_types: description: Docker Installation script type: string default: 'https://raw.githubusercontent.com/cloudify-cosmo/cloudify-docker-plugin/master/cloudify_docker/resources/post-install.sh' + install_with_sudo: + type: boolean + description: use sudo to run + default: true + offline_installation: + type: boolean + description: Install docker when the vm has no internet access + default: false + package_tar_path: + description: | + Docker Installation Tar path (must be located on the on where docker installed) + Required when offline installation + type: string + default: '' + post_install_script_path: + description: | + Docker Installation post script path + Required when offline installation + type: string + default: '' + installation_dir: + description: | + Docker Installation path + Required when offline installation + type: string + default: '' cloudify.types.docker.ClientConfig: properties: @@ -195,6 +221,14 @@ data_types: description: Docker image tag type: string default: '' + pull_image: + type: boolean + description: Pull image + default: false + all_tags: + type: boolean + description: Pull all tags (only if pull_image is True) + default: false cloudify.types.docker.Container: properties: diff --git a/v2_plugin.yaml b/v2_plugin.yaml index fd6b45f..23d8403 100644 --- a/v2_plugin.yaml +++ b/v2_plugin.yaml @@ -167,6 +167,32 @@ data_types: description: Docker Installation script type: string default: 'https://raw.githubusercontent.com/cloudify-cosmo/cloudify-docker-plugin/master/cloudify_docker/resources/post-install.sh' + install_with_sudo: + type: boolean + description: use sudo to run + default: true + offline_installation: + type: boolean + description: Install docker when the vm has no internet access + default: false + package_tar_path: + description: | + Docker Installation Tar path (must be located on the on where docker installed) + Required when offline installation + type: string + default: '' + post_install_script_path: + description: | + Docker Installation post script path + Required when offline installation + type: string + default: '' + installation_dir: + description: | + Docker Installation path + Required when offline installation + type: string + default: '' cloudify.types.docker.ClientConfig: properties: @@ -195,6 +221,14 @@ data_types: description: Docker image tag type: string default: '' + pull_image: + type: boolean + description: Pull image + default: false + all_tags: + type: boolean + description: Pull all tags (only if pull_image is True) + default: false cloudify.types.docker.Container: properties: From 9c345e7b8a6710ee72b6c61bccf5760e04eb15ff Mon Sep 17 00:00:00 2001 From: Ahmad Musa Date: Wed, 21 Jun 2023 18:15:44 +0300 Subject: [PATCH 18/18] small-adjustments --- CHANGELOG.txt | 4 ++-- cloudify_docker/__version__.py | 2 +- cloudify_docker/tasks.py | 1 - plugin_1_4.yaml | 26 -------------------------- v2_plugin.yaml | 26 -------------------------- 5 files changed, 3 insertions(+), 56 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 3b0d39c..1385e63 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -29,5 +29,5 @@ 2.0.12: - fix install config for docker host. 2.0.13: - - Add PullImage Node type. - - Allow docker installation without sudo. \ No newline at end of file + - Add PullImage support. + - Allow docker installation without sudo and offline. \ No newline at end of file diff --git a/cloudify_docker/__version__.py b/cloudify_docker/__version__.py index f1af94f..613ee5b 100644 --- a/cloudify_docker/__version__.py +++ b/cloudify_docker/__version__.py @@ -1 +1 @@ -version = '2.0.12' +version = '2.0.13' diff --git a/cloudify_docker/tasks.py b/cloudify_docker/tasks.py index 2f27b3e..f5147b3 100644 --- a/cloudify_docker/tasks.py +++ b/cloudify_docker/tasks.py @@ -1192,4 +1192,3 @@ def remove_container(ctx, docker_client, **kwargs): remove_res = container_obj.remove() ctx.instance.runtime_properties.pop('container') ctx.logger.info("Remove result {0}".format(remove_res)) - diff --git a/plugin_1_4.yaml b/plugin_1_4.yaml index 55b9b94..13f856d 100644 --- a/plugin_1_4.yaml +++ b/plugin_1_4.yaml @@ -230,17 +230,6 @@ data_types: description: Pull all tags (only if pull_image is True) default: false - cloudify.types.docker.PullImage: - properties: - tag: - description: Docker image tag - type: string - default: '' - all_tags: - type: boolean - description: Pull all tags - default: false - cloudify.types.docker.Container: properties: image_tag: @@ -376,21 +365,6 @@ node_types: delete: implementation: docker.cloudify_docker.tasks.remove_image - cloudify.nodes.docker.pullimage: - derived_from: cloudify.nodes.Root - properties: - <<: *client_config - resource_config: - type: cloudify.types.docker.PullImage - description: Docker Image type - required: true - interfaces: - cloudify.interfaces.lifecycle: - create: - implementation: docker.cloudify_docker.tasks.pull_image - delete: - implementation: docker.cloudify_docker.tasks.remove_image - cloudify.nodes.docker.container: derived_from: cloudify.nodes.Root properties: diff --git a/v2_plugin.yaml b/v2_plugin.yaml index 55b9b94..13f856d 100644 --- a/v2_plugin.yaml +++ b/v2_plugin.yaml @@ -230,17 +230,6 @@ data_types: description: Pull all tags (only if pull_image is True) default: false - cloudify.types.docker.PullImage: - properties: - tag: - description: Docker image tag - type: string - default: '' - all_tags: - type: boolean - description: Pull all tags - default: false - cloudify.types.docker.Container: properties: image_tag: @@ -376,21 +365,6 @@ node_types: delete: implementation: docker.cloudify_docker.tasks.remove_image - cloudify.nodes.docker.pullimage: - derived_from: cloudify.nodes.Root - properties: - <<: *client_config - resource_config: - type: cloudify.types.docker.PullImage - description: Docker Image type - required: true - interfaces: - cloudify.interfaces.lifecycle: - create: - implementation: docker.cloudify_docker.tasks.pull_image - delete: - implementation: docker.cloudify_docker.tasks.remove_image - cloudify.nodes.docker.container: derived_from: cloudify.nodes.Root properties: