Revert "Update docker plugin to use dcaepolicy .." 23/33723/2
authorMichael Hwang <mhwang@research.att.com>
Fri, 2 Mar 2018 04:17:21 +0000 (23:17 -0500)
committerMichael Hwang <mhwang@research.att.com>
Fri, 2 Mar 2018 04:49:15 +0000 (23:49 -0500)
This reverts commit d2ce7db538f97bc7f86b87e15fe6fcda2b089294.

Change-Id: Ia1eb2a55b9c92253ed5f2d85b87455c4fb2683c7
Issue-ID: DCAEGEN2-377
Signed-off-by: Michael Hwang <mhwang@research.att.com>
docker/ChangeLog.md
docker/docker-node-type.yaml
docker/dockerplugin/tasks.py
docker/examples/blueprint-laika-policy.yaml
docker/requirements.txt
docker/setup.py
docker/tox.ini

index 302fe6c..0d0eafc 100644 (file)
@@ -5,10 +5,6 @@ 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:
index 4798a44..c827cff 100644 (file)
@@ -24,7 +24,7 @@ plugins:
   docker:
     executor: 'central_deployment_agent'
     package_name: dockerplugin
-    package_version: 3.0.0
+    package_version: 2.4.0
 
 node_types:
     # The DockerContainerForComponents node type is to be used for DCAE service components that 
index d64a65c..899f4ed 100644 (file)
@@ -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
+from onap_dcae_dcaepolicy_lib import Policies, POLICIES, POLICY_MESSAGE_TYPE
 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,10 +113,15 @@ 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
@@ -128,8 +133,9 @@ 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):
@@ -198,7 +204,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
@@ -213,9 +219,10 @@ 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
@@ -579,7 +586,6 @@ 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"""
@@ -600,15 +606,11 @@ 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,
-                    removed_policies=removed_policies,
-                    policies=policies
-                    )
+                    application_config=app_config)
 
             docker_host = kwargs[SELECTED_CONTAINER_DESTINATION]
             docker_host_ip = _lookup_service(docker_host)
@@ -622,10 +624,16 @@ 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()
+@Policies.update_policies_on_node(configs_only=True)
 @operation
-def policy_update(updated_policies, removed_policies=None, policies=None, **kwargs):
+def policy_update(updated_policies, **kwargs):
     """Policy update task
 
     This method is responsible for updating the application configuration and
@@ -637,10 +645,12 @@ def policy_update(updated_policies, removed_policies=None, policies=None, **kwar
     """
     update_inputs = copy.deepcopy(ctx.instance.runtime_properties)
     update_inputs["updated_policies"] = updated_policies
-    update_inputs["removed_policies"] = removed_policies
-    update_inputs["policies"] = policies
 
-    _notify_container(**update_inputs)
+    # Merge in policy updates into application config and make available
+    _done_for_policy_update(
+            **_notify_container(
+                **_setup_for_discovery(
+                    **_merge_policy_updates(**update_inputs))))
 
 
 # Lifecycle interface calls for dcae.nodes.DockerHost
index f6b6925..efa5672 100644 (file)
@@ -22,7 +22,7 @@ description: >
 
 imports:
   - http://www.getcloudify.org/spec/cloudify/3.4/types.yaml
-  - {{ ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2 }}/type_files/docker/3.0.0/node-type.yaml
+  - {{ ONAPTEMPLATE_RAWREPOURL_org_onap_dcaegen2 }}/type_files/docker/2.3.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
 
index 6eff87f..7e04a5f 100644 (file)
@@ -1,2 +1,2 @@
 onap-dcae-dockering==1.4.0
-onap-dcae-dcaepolicy-lib==2.1.0
+onap-dcae-dcaepolicy-lib==1.0.0
index a6b50f8..ececb43 100644 (file)
@@ -24,7 +24,7 @@ from setuptools import setup
 setup(
     name='dockerplugin',
     description='Cloudify plugin for applications run in Docker containers',
-    version="3.0.0",
+    version="2.4.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>=2.1.0,<3.0.0"
+        "onap-dcae-dcaepolicy-lib>=1.0.0"
     ]
 )
index 9e3cfb2..c064fca 100644 (file)
@@ -4,7 +4,7 @@ envlist = py27
 
 [testenv]
 deps=
-    -rrequirements.txt
+    -rrequirements.txt 
     cloudify-plugins-common==3.4
     pytest
     coverage