```yaml
imports:
- - https://YOUR_NEXUS_RAW_SERVER/type_files/dcaepolicy/2.3.0/node-type.yaml
+ - https://YOUR_NEXUS_RAW_SERVER/type_files/dcaepolicy/2.3.2/node-type.yaml
```
provide the value for policy_id property
# ================================================================================
-# Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2017-2019 AT&T Intellectual Property. 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.
#
# ECOMP is a trademark and service mark of AT&T Intellectual Property.
-tosca_definitions_version: cloudify_dsl_1_3
-
-imports:
- - http://www.getcloudify.org/spec/cloudify/3.4/types.yaml
-
plugins:
dcaepolicy:
executor: 'central_deployment_agent'
package_name: dcaepolicyplugin
- package_version: 2.3.0
+ package_version: 2.3.2
data_types:
# the properties inside dcae.data.policy_filter are identical to /getConfig API of policy-engine except the requestID field.
policy_filter:
type: dcae.data.policy_filter
default: {}
+ policy_required:
+ description: whether to throw an exception when failed to get a policy
+ type: boolean
+ default: false
interfaces:
cloudify.interfaces.lifecycle:
create:
# ================================================================================
-# Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2017-2019 AT&T Intellectual Property. 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.
ctx.logger.info("getting service_url at {0}".format(service_url))
try:
- response = requests.get(service_url)
+ response = requests.get(service_url, timeout=60)
except requests.ConnectionError as ex:
raise NonRecoverableError(
"ConnectionError - failed to get {0}: {1}".format(service_url, str(ex)))
ctx.logger.info("getting kv at {0}".format(kv_url))
try:
- response = requests.get(kv_url)
+ response = requests.get(kv_url, timeout=60)
except requests.ConnectionError as ex:
raise NonRecoverableError(
"ConnectionError - failed to get {0}: {1}".format(kv_url, str(ex)))
# ================================================================================
-# Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2017-2019 AT&T Intellectual Property. 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.
ctx.logger.info("getting latest policy from {0} headers={1}".format(
ph_path, json.dumps(headers)))
- res = requests.get(ph_path, headers=headers)
+ res = requests.get(ph_path, headers=headers, timeout=60)
ctx.logger.info("latest policy for policy_id({0}) status({1}) response: {2}"
.format(policy_id, res.status_code, res.text))
ctx.logger.info("finding the latest polices from {0} by {1} headers={2}".format(
ph_path, json.dumps(policy_filter), json.dumps(headers)))
- res = requests.post(ph_path, json=policy_filter, headers=headers)
+ res = requests.post(ph_path, json=policy_filter, headers=headers, timeout=60)
ctx.logger.info("latest policies status({0}) response: {1}"
.format(res.status_code, res.text))
except Exception as ex:
error = "failed to get policy({0}): {1}".format(policy_id, str(ex))
ctx.logger.error("{0}: {1}".format(error, traceback.format_exc()))
- if policy_required:
- raise NonRecoverableError(error)
+ raise NonRecoverableError(error)
if not policy:
error = "policy not found for policy_id {0}".format(policy_id)
if DCAE_POLICIES_TYPE not in ctx.node.type_hierarchy:
return
+ policy_required = ctx.node.properties.get(POLICY_REQUIRED)
+
try:
policy_filter = copy.deepcopy(dict(
(k, v) for (k, v) in dict(ctx.node.properties.get(POLICY_FILTER, {})).iteritems()
policies_filtered = PolicyHandler.find_latest_policies(policy_filter)
if not policies_filtered:
- ctx.logger.info("policies not found by {0}".format(json.dumps(policy_filter)))
+ error = "policies not found by {0}".format(json.dumps(policy_filter))
+ ctx.logger.info(error)
+ if policy_required:
+ raise NonRecoverableError(error)
return True
ctx.logger.info("found policies by {0}: {1}".format(
except Exception as ex:
error = "failed to find policies: {0}".format(str(ex))
ctx.logger.error("{0}: {1}".format(error, traceback.format_exc()))
+ raise NonRecoverableError(error)
return True
<?xml version="1.0"?>
<!--
================================================================================
-Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved.
+Copyright (c) 2017-2019 AT&T Intellectual Property. 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.
<groupId>org.onap.dcaegen2.platform.plugins</groupId>
<artifactId>dcae-policy</artifactId>
<name>dcae-policy-plugin</name>
- <version>2.3.0-SNAPSHOT</version>
+ <version>2.3.2-SNAPSHOT</version>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
# ================================================================================
-# Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2017-2019 AT&T Intellectual Property. 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.
setup(
name='dcaepolicyplugin',
description='Cloudify plugin for dcae.nodes.policy node to retrieve the policy config',
- version="2.3.0",
+ version="2.3.2",
author='Alex Shatov',
packages=['dcaepolicyplugin'],
install_requires=[
# ================================================================================
-# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2019 AT&T Intellectual Property. 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.
POLICY_HANDLER_FROM_KV = "http://policy_handler_from_kv:25577"
-def monkeyed_discovery_get_failure(full_path):
+def monkeyed_discovery_get_failure(full_path, **kwargs):
"""monkeypatch for the GET to consul"""
raise requests.ConnectionError("monkey-boom")
current_ctx.clear()
-def monkeyed_discovery_get_kv(full_path):
+def monkeyed_discovery_get_kv(full_path, **kwargs):
"""monkeypatch for the GET to consul"""
if full_path.startswith(discovery.CONSUL_SERVICE_URL.format("")):
return MonkeyedResponse(full_path)
current_ctx.clear()
-def monkeyed_discovery_get(full_path):
+def monkeyed_discovery_get(full_path, **kwargs):
"""monkeypatch for the GET to consul"""
return MonkeyedResponse(full_path, {},
[{"ServiceAddress": "monkey-policy-handler-address", "ServicePort": "9999"}])
# ================================================================================
-# Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2017-2019 AT&T Intellectual Property. 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.
LATEST_POLICIES = "latest_policies"
-def monkeyed_policy_handler_get(full_path, headers=None):
+def monkeyed_policy_handler_get(full_path, headers=None, **kwargs):
"""monkeypatch for the GET to policy-engine"""
return MonkeyedResponse(full_path, headers,
MonkeyedPolicyBody.create_policy(MONKEYED_POLICY_ID))
current_ctx.clear()
-def monkeyed_policy_handler_find(full_path, json, headers):
+def monkeyed_policy_handler_find(full_path, json, headers, **kwargs):
"""monkeypatch for the GET to policy-engine"""
return MonkeyedResponse(
full_path, headers,