summaryrefslogtreecommitdiffstats
path: root/pgaas
diff options
context:
space:
mode:
authorMiroslav Los <miroslav.los@pantheon.tech>2019-11-14 17:36:44 +0100
committerMiroslav Los <miroslav.los@pantheon.tech>2020-02-14 17:34:04 +0100
commit9b7e81e78c70514aa123482610e274869b6ba137 (patch)
treee2e44b515d518825db9240a5e4a8fe2efe0b3126 /pgaas
parent4daa9d9a30306cfa6d25999cdc992d886fa405a8 (diff)
Support python3 in all plugins
Unify tox/requirements/setup.py requirement specifications. Use cloudify-common 5.0.5 release. For helm, use a dev cloudify-common build with better python3 code. Use PEP 508 URLs in requirements for the non-PyPI (github) release. Fix mixed indentation and trailing whitespace. Signed-off-by: Miroslav Los <miroslav.los@pantheon.tech> Issue-ID: CCSDK-1931 Change-Id: I607957d9e2c299121785f3f02420c6038966a200
Diffstat (limited to 'pgaas')
-rw-r--r--pgaas/pgaas/pgaas_plugin.py54
-rw-r--r--pgaas/pgaas_types.yaml2
-rw-r--r--pgaas/pom.xml4
-rw-r--r--pgaas/requirements.txt2
-rw-r--r--pgaas/setup.py11
-rw-r--r--pgaas/tox.ini15
6 files changed, 41 insertions, 47 deletions
diff --git a/pgaas/pgaas/pgaas_plugin.py b/pgaas/pgaas/pgaas_plugin.py
index b1625c5..a73407c 100644
--- a/pgaas/pgaas/pgaas_plugin.py
+++ b/pgaas/pgaas/pgaas_plugin.py
@@ -2,6 +2,7 @@
# ============LICENSE_START====================================================
# =============================================================================
# Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2020 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.
@@ -22,22 +23,6 @@ PostgreSQL plugin to manage passwords
from __future__ import print_function
import sys
-USING_PYTHON2 = sys.version_info[0] < 3
-
-# pylint: disable=wrong-import-position
-# pylint: disable=wrong-import-order
-# pylint: disable=import-error
-from cloudify import ctx
-from cloudify.decorators import operation
-from cloudify.exceptions import NonRecoverableError
-from cloudify.exceptions import RecoverableError
-
-# pylint: disable=wildcard-import
-if USING_PYTHON2:
- from logginginterface import debug, info, warn, error
-else:
- from .logginginterface import debug, info, warn, error
-
import os
import re
import json
@@ -45,20 +30,31 @@ import hashlib
import socket
import traceback
import base64
-if USING_PYTHON2:
- import urllib
-else:
- import urllib.request
- import urllib.parse
- import urllib.error
+import binascii
import collections
+try:
+ from urllib.parse import quote
+except ImportError:
+ from urllib import quote
+
+from cloudify import ctx
+from cloudify.decorators import operation
+from cloudify.exceptions import NonRecoverableError
+from cloudify.exceptions import RecoverableError
+
+try:
+ import psycopg2
+except ImportError:
+ # FIXME: any users of this plugin installing its dependencies in nonstandard
+ # directories should set up PYTHONPATH accordingly, outside the program code
+ SYSPATH = sys.path
+ sys.path = list(SYSPATH)
+ sys.path.append('/usr/lib64/python2.7/site-packages')
+ import psycopg2
+ sys.path = SYSPATH
+from pgaas.logginginterface import debug, info, warn, error
-SYSPATH = sys.path
-sys.path = list(SYSPATH)
-sys.path.append('/usr/lib64/python2.7/site-packages')
-import psycopg2
-sys.path = SYSPATH
"""
To set up a cluster:
@@ -185,8 +181,7 @@ def safestr(s):
"""
returns a safely printable version of the string
"""
- # pylint: disable=no-member
- return urllib.quote(str(s), '') if USING_PYTHON2 else urllib.parse.quote(str(s), '')
+ return quote(str(s), '')
def raiseRecoverableError(msg):
"""
@@ -739,7 +734,6 @@ def update_database(refctx, **kwargs):
with open(hostPortDbname, "a") as fp:
with open("/dev/urandom", "rb") as rp:
b = rp.read(16)
- import binascii
print(binascii.hexlify(b).decode('utf-8'), file=fp)
appended = True
if not appended:
diff --git a/pgaas/pgaas_types.yaml b/pgaas/pgaas_types.yaml
index 60a8fa7..951fbd5 100644
--- a/pgaas/pgaas_types.yaml
+++ b/pgaas/pgaas_types.yaml
@@ -5,7 +5,7 @@ plugins:
pgaas:
executor: central_deployment_agent
package_name: pgaas
- package_version: 1.1.0
+ package_version: 1.2.0
node_types:
dcae.nodes.pgaas.cluster:
diff --git a/pgaas/pom.xml b/pgaas/pom.xml
index 6db8454..9946840 100644
--- a/pgaas/pom.xml
+++ b/pgaas/pom.xml
@@ -23,7 +23,7 @@ limitations under the License.
<parent>
<groupId>org.onap.ccsdk.platform</groupId>
<artifactId>plugins</artifactId>
- <version>1.0.1-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
</parent>
<!--- CHANGE THE FOLLOWING 3 OBJECTS for your own repo -->
@@ -31,7 +31,7 @@ limitations under the License.
<artifactId>pgaas</artifactId>
<name>pgaas</name>
- <version>1.0.1-SNAPSHOT</version>
+ <version>1.2.0-SNAPSHOT</version>
<url>http://maven.apache.org</url>
<properties>
<!-- name from the setup.py file -->
diff --git a/pgaas/requirements.txt b/pgaas/requirements.txt
index e69de29..83a931a 100644
--- a/pgaas/requirements.txt
+++ b/pgaas/requirements.txt
@@ -0,0 +1,2 @@
+psycopg2-binary
+cloudify-common>=5.0.5
diff --git a/pgaas/setup.py b/pgaas/setup.py
index 5454a37..55a6596 100644
--- a/pgaas/setup.py
+++ b/pgaas/setup.py
@@ -2,13 +2,14 @@
# ============LICENSE_START====================================================
# =============================================================================
# Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2020 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.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,7 +21,7 @@ from setuptools import setup, find_packages
setup(
name="pgaas",
- version="1.1.0",
+ version="1.2.0",
packages=find_packages(),
author="AT&T",
description=("Cloudify plugin for pgaas/pgaas."),
@@ -29,5 +30,7 @@ setup(
url="https://onap.org",
zip_safe=False,
install_requires=[
- ]
+ 'psycopg2-binary',
+ 'cloudify-common>=5.0.5',
+ ],
)
diff --git a/pgaas/tox.ini b/pgaas/tox.ini
index 4a2f99e..d6956bb 100644
--- a/pgaas/tox.ini
+++ b/pgaas/tox.ini
@@ -2,6 +2,7 @@
# org.onap.ccsdk
# =============================================================================
# Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2020 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.
@@ -17,21 +18,15 @@
# ============LICENSE_END======================================================
[tox]
-envlist = py27
-# The PGaaS plugin uses several Cloudify mock libraries, one of which
-# is not compatible with Python3.
-# Until we get an updated version of that Cloudify mock libraries,
-# we will have to leave out py3X from the tox tests.
-# We cannot use py37 yet because Jenkins returns:
-# InterpreterNotFound: python3.7
-#envlist = py27,py36
+envlist = py27,py36,py37
+skip_missing_interpreters = true
+
[testenv]
deps=
pytest
- cloudify==4.2
- requests
coverage
pytest-cov
+ -r requirements.txt
setenv=
PYTHONPATH={toxinidir}
commands=pytest --junitxml xunit-results.xml --cov --cov-report=xml