summaryrefslogtreecommitdiffstats
path: root/dcae-policy
diff options
context:
space:
mode:
authorMiroslav Los <miroslav.los@pantheon.tech>2019-11-26 14:20:36 +0100
committerMiroslav Los <miroslav.los@pantheon.tech>2019-11-26 19:24:24 +0100
commit01a60ff23b979eb676658713748598ba4892163a (patch)
tree1fb1b260c3723ddc42f047796db6b1928171b48c /dcae-policy
parent77e27adeab5ff155b690f2e058c06f0a7812e225 (diff)
Support python3 in all plugins
Unify tox/requirements/setup.py requirement specifications. Do not set upper version limits if possible. Drop uuid as dependency included with standard library. Drop import of unmaintained cloudify_importer without python3 version. Use PEP 508 URLs in requirements for non-PyPI (github) releases. Use cloudify-common 5 release; pre-release package for python3. Rewrite uses of map with loops/comprehensions. Signed-off-by: Miroslav Los <miroslav.los@pantheon.tech> Issue-ID: DCAEGEN2-1956 Change-Id: I7b3ceb97a628e3af5bda3178d182f4207069e86d
Diffstat (limited to 'dcae-policy')
-rw-r--r--dcae-policy/dcaepolicyplugin/tasks.py15
-rw-r--r--dcae-policy/requirements.txt4
-rw-r--r--dcae-policy/setup.py4
-rw-r--r--dcae-policy/tests/test_discovery.py3
-rw-r--r--dcae-policy/tox-local.ini11
-rw-r--r--dcae-policy/tox.ini13
6 files changed, 30 insertions, 20 deletions
diff --git a/dcae-policy/dcaepolicyplugin/tasks.py b/dcae-policy/dcaepolicyplugin/tasks.py
index 4e3b37a..2e62b15 100644
--- a/dcae-policy/dcaepolicyplugin/tasks.py
+++ b/dcae-policy/dcaepolicyplugin/tasks.py
@@ -1,5 +1,6 @@
# ================================================================================
# Copyright (c) 2017-2019 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2019 Pantheon.tech. 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.
@@ -194,11 +195,15 @@ def _policies_find():
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()
- if v or isinstance(v, (int, float))
- ))
- _fix_policy_filter(policy_filter)
+ policy_filter = ctx.node.properties.get(POLICY_FILTER)
+ if policy_filter:
+ policy_filter = {
+ k: copy.deepcopy(v) for k, v in policy_filter.items()
+ if v or isinstance(v, (int, float))
+ }
+ _fix_policy_filter(policy_filter)
+ else:
+ policy_filter = {}
if REQUEST_ID not in policy_filter:
policy_filter[REQUEST_ID] = str(uuid.uuid4())
diff --git a/dcae-policy/requirements.txt b/dcae-policy/requirements.txt
index 220b585..e9526b8 100644
--- a/dcae-policy/requirements.txt
+++ b/dcae-policy/requirements.txt
@@ -1 +1,3 @@
-requests>=2.11.0,<3.0.0
+requests>=2.11.0
+cloudify-common>=5.0.0; python_version<"3"
+cloudify-common @ git+https://github.com/cloudify-cosmo/cloudify-common@cy-1374-python3#egg=cloudify-common==5.0.0; python_version>="3"
diff --git a/dcae-policy/setup.py b/dcae-policy/setup.py
index d7a6756..b95e303 100644
--- a/dcae-policy/setup.py
+++ b/dcae-policy/setup.py
@@ -1,5 +1,6 @@
# ================================================================================
# Copyright (c) 2017-2019 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2019 Pantheon.tech. 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.
@@ -27,7 +28,8 @@ setup(
author='Alex Shatov',
packages=['dcaepolicyplugin'],
install_requires=[
- "requests>=2.11.0,<3.0.0"
+ 'requests>=2.11.0',
+ 'cloudify-common>=5.0.0',
],
keywords='policy dcae controller cloudify plugin',
classifiers=[
diff --git a/dcae-policy/tests/test_discovery.py b/dcae-policy/tests/test_discovery.py
index 0c41fe3..07c652e 100644
--- a/dcae-policy/tests/test_discovery.py
+++ b/dcae-policy/tests/test_discovery.py
@@ -1,5 +1,6 @@
# ================================================================================
# Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2019 Pantheon.tech. 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.
@@ -75,7 +76,7 @@ def monkeyed_discovery_get_kv(full_path, **kwargs):
{tasks.DCAE_POLICY_PLUGIN: {
tasks.PolicyHandler.SERVICE_NAME_POLICY_HANDLER: {
"url": POLICY_HANDLER_FROM_KV}}}
- ))
+ ).encode()).decode()
return MonkeyedResponse(full_path, {}, [{"Value": value}])
return MonkeyedResponse(full_path)
diff --git a/dcae-policy/tox-local.ini b/dcae-policy/tox-local.ini
index 6bd1c58..d3ffbb0 100644
--- a/dcae-policy/tox-local.ini
+++ b/dcae-policy/tox-local.ini
@@ -1,15 +1,16 @@
# tox -c tox-local.ini | tee -a logs/test_dcaepolicyplugin.log 2>&1
[tox]
-envlist = py27
+envlist = py27,py36
[testenv]
deps=
-rrequirements.txt
- cloudify-plugins-common==3.4
pytest
coverage
pytest-cov
-setenv =
- PYTHONPATH={toxinidir}
+whitelist_externals=
+ /bin/mkdir
# recreate = True
-commands=pytest -v --cov dcaepolicyplugin --cov-report html
+commands=
+ mkdir -p logs
+ pytest -v --cov dcaepolicyplugin --cov-report html
diff --git a/dcae-policy/tox.ini b/dcae-policy/tox.ini
index 40caed5..42a4c39 100644
--- a/dcae-policy/tox.ini
+++ b/dcae-policy/tox.ini
@@ -1,17 +1,16 @@
# content of: tox.ini , put in same dir as setup.py
[tox]
-envlist = py27
+envlist = py27,py36
[testenv]
deps=
-rrequirements.txt
- cloudify-plugins-common==3.4
pytest
coverage
pytest-cov
-setenv =
- PYTHONPATH={toxinidir}
+whitelist_externals=
+ /bin/mkdir
commands=
- -mkdir logs
- pytest --junitxml xunit-results.xml --cov dcaepolicyplugin --cov-report xml
- coverage xml
+ mkdir -p logs
+ pytest --junitxml xunit-results.xml --cov dcaepolicyplugin --cov-report xml
+ coverage xml