summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docker/ChangeLog.md4
-rw-r--r--docker/docker-node-type.yaml2
-rw-r--r--docker/dockerplugin/tasks.py44
-rw-r--r--docker/examples/blueprint-laika-policy.yaml2
-rw-r--r--docker/requirements.txt2
-rw-r--r--docker/setup.py4
-rw-r--r--docker/tox.ini1
7 files changed, 27 insertions, 32 deletions
diff --git a/docker/ChangeLog.md b/docker/ChangeLog.md
index 0d0eafc..302fe6c 100644
--- a/docker/ChangeLog.md
+++ b/docker/ChangeLog.md
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
+## [3.0.0]
+
+* Update docker plugin to use dcaepolicy 2.1.0. This involved all sorts of updates in how policy is expected to work for the component where the updates are not backwards friendly.
+
## [2.4.0]
* Change *components* to be policy reconfigurable:
diff --git a/docker/docker-node-type.yaml b/docker/docker-node-type.yaml
index c827cff..4798a44 100644
--- a/docker/docker-node-type.yaml
+++ b/docker/docker-node-type.yaml
@@ -24,7 +24,7 @@ plugins:
docker:
executor: 'central_deployment_agent'
package_name: dockerplugin
- package_version: 2.4.0
+ package_version: 3.0.0
node_types:
# The DockerContainerForComponents node type is to be used for DCAE service components that
diff --git a/docker/dockerplugin/tasks.py b/docker/dockerplugin/tasks.py
index 899f4ed..d64a65c 100644
--- a/docker/dockerplugin/tasks.py
+++ b/docker/dockerplugin/tasks.py
@@ -25,7 +25,7 @@ from cloudify import ctx
from cloudify.decorators import operation
from cloudify.exceptions import NonRecoverableError, RecoverableError
import dockering as doc
-from onap_dcae_dcaepolicy_lib import Policies, POLICIES, POLICY_MESSAGE_TYPE
+from onap_dcae_dcaepolicy_lib import Policies
from dockerplugin import discovery as dis
from dockerplugin.decorators import monkeypatch_loggers, wrap_error_handling_start, \
merge_inputs_for_start, merge_inputs_for_create
@@ -113,15 +113,10 @@ def _done_for_create(**kwargs):
ctx.logger.info("Done setting up: {0}".format(name))
return kwargs
-def _merge_policy_updates(**kwargs):
- app_config = kwargs[APPLICATION_CONFIG]
- kwargs[APPLICATION_CONFIG] = Policies.shallow_merge_policies_into(app_config)
- return kwargs
-
@merge_inputs_for_create
@monkeypatch_loggers
-@Policies.gather_policies_to_node
+@Policies.gather_policies_to_node()
@operation
def create_for_components(**create_inputs):
"""Create step for Docker containers that are components
@@ -133,9 +128,8 @@ def create_for_components(**create_inputs):
"""
_done_for_create(
**_setup_for_discovery(
- **_merge_policy_updates(
**_generate_component_name(
- **create_inputs))))
+ **create_inputs)))
def _parse_streams(**kwargs):
@@ -204,7 +198,7 @@ def _setup_for_discovery_streams(**kwargs):
@merge_inputs_for_create
@monkeypatch_loggers
-@Policies.gather_policies_to_node
+@Policies.gather_policies_to_node()
@operation
def create_for_components_with_streams(**create_inputs):
"""Create step for Docker containers that are components that use DMaaP
@@ -219,10 +213,9 @@ def create_for_components_with_streams(**create_inputs):
_done_for_create(
**_setup_for_discovery(
**_setup_for_discovery_streams(
- **_merge_policy_updates(
**_parse_streams(
**_generate_component_name(
- **create_inputs))))))
+ **create_inputs)))))
@merge_inputs_for_create
@@ -586,6 +579,7 @@ def stop_and_remove_container(**kwargs):
raise NonRecoverableError(e)
@monkeypatch_loggers
+@Policies.cleanup_policies_on_node
@operation
def cleanup_discovery(**kwargs):
"""Delete configuration from Consul"""
@@ -606,11 +600,15 @@ def _notify_container(**kwargs):
if dc["policy"]["trigger_type"] == "docker":
# REVIEW: Need to finalize on the docker config policy data structure
script_path = dc["policy"]["script_path"]
- app_config = kwargs["application_config"]
updated_policies = kwargs["updated_policies"]
+ removed_policies = kwargs["removed_policies"]
+ policies = kwargs["policies"]
cmd = doc.build_policy_update_cmd(script_path, use_sh=False,
+ msg_type="policies",
updated_policies=updated_policies,
- application_config=app_config)
+ removed_policies=removed_policies,
+ policies=policies
+ )
docker_host = kwargs[SELECTED_CONTAINER_DESTINATION]
docker_host_ip = _lookup_service(docker_host)
@@ -624,16 +622,10 @@ def _notify_container(**kwargs):
return kwargs
-def _done_for_policy_update(**kwargs):
- name = kwargs['name']
- ctx.instance.runtime_properties.update(kwargs)
- ctx.logger.info("Done updating for policy: {0}".format(name))
- return kwargs
-
@monkeypatch_loggers
-@Policies.update_policies_on_node(configs_only=True)
+@Policies.update_policies_on_node()
@operation
-def policy_update(updated_policies, **kwargs):
+def policy_update(updated_policies, removed_policies=None, policies=None, **kwargs):
"""Policy update task
This method is responsible for updating the application configuration and
@@ -645,12 +637,10 @@ def policy_update(updated_policies, **kwargs):
"""
update_inputs = copy.deepcopy(ctx.instance.runtime_properties)
update_inputs["updated_policies"] = updated_policies
+ update_inputs["removed_policies"] = removed_policies
+ update_inputs["policies"] = policies
- # Merge in policy updates into application config and make available
- _done_for_policy_update(
- **_notify_container(
- **_setup_for_discovery(
- **_merge_policy_updates(**update_inputs))))
+ _notify_container(**update_inputs)
# Lifecycle interface calls for dcae.nodes.DockerHost
diff --git a/docker/examples/blueprint-laika-policy.yaml b/docker/examples/blueprint-laika-policy.yaml
index efa5672..f6b6925 100644
--- a/docker/examples/blueprint-laika-policy.yaml
+++ b/docker/examples/blueprint-laika-policy.yaml
@@ -22,7 +22,7 @@ description: >
imports:
- http://www.getcloudify.org/spec/cloudify/3.4/types.yaml
- - {{ ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2 }}/type_files/docker/2.3.0/node-type.yaml
+ - {{ ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2 }}/type_files/docker/3.0.0/node-type.yaml
- {{ ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2 }}/type_files/relationship/1.0.0/node-type.yaml
- {{ ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2 }}/type_files/dcaepolicy/1.0.0/node-type.yaml
diff --git a/docker/requirements.txt b/docker/requirements.txt
index 7e04a5f..6eff87f 100644
--- a/docker/requirements.txt
+++ b/docker/requirements.txt
@@ -1,2 +1,2 @@
onap-dcae-dockering==1.4.0
-onap-dcae-dcaepolicy-lib==1.0.0
+onap-dcae-dcaepolicy-lib==2.1.0
diff --git a/docker/setup.py b/docker/setup.py
index ececb43..a6b50f8 100644
--- a/docker/setup.py
+++ b/docker/setup.py
@@ -24,7 +24,7 @@ from setuptools import setup
setup(
name='dockerplugin',
description='Cloudify plugin for applications run in Docker containers',
- version="2.4.0",
+ version="3.0.0",
author='Michael Hwang, Tommy Carpenter',
packages=['dockerplugin'],
zip_safe=False,
@@ -32,6 +32,6 @@ setup(
"python-consul>=0.6.0,<1.0.0",
"onap-dcae-dockering>=1.0.0,<2.0.0",
"uuid==1.30",
- "onap-dcae-dcaepolicy-lib>=1.0.0"
+ "onap-dcae-dcaepolicy-lib>=2.1.0,<3.0.0"
]
)
diff --git a/docker/tox.ini b/docker/tox.ini
index 5fad68b..9e3cfb2 100644
--- a/docker/tox.ini
+++ b/docker/tox.ini
@@ -4,6 +4,7 @@ envlist = py27
[testenv]
deps=
+ -rrequirements.txt
cloudify-plugins-common==3.4
pytest
coverage