summaryrefslogtreecommitdiffstats
path: root/fcaps
diff options
context:
space:
mode:
authorBin Yang <bin.yang@windriver.com>2019-08-27 03:52:08 +0000
committerBin Yang <bin.yang@windriver.com>2019-08-27 04:50:43 +0000
commit7a31c2e438da2d165f473f7428cee7d2164312df (patch)
treeace10c3428b58f2d8d2066978964ed80478279d6 /fcaps
parent4a42f215d7009fc825bbff5b120913f21660ee59 (diff)
Fix py3 related issue
Change-Id: I2b21aaab2cbf0df11b9940bf62585294dd1ce576 Issue-ID: MULTICLOUD-774 Signed-off-by: Bin Yang <bin.yang@windriver.com>
Diffstat (limited to 'fcaps')
-rw-r--r--fcaps/docker/Dockerfile11
-rw-r--r--fcaps/fcaps/vesagent/tests/tests_tasks.py8
-rw-r--r--fcaps/fcaps/vesagent/tests/tests_vesagent_ctrl.py8
-rw-r--r--fcaps/fcaps/vesagent/tests/tests_vespublish.py7
-rw-r--r--fcaps/fcaps/vesagent/vespublish.py9
-rw-r--r--fcaps/initialize.sh2
-rwxr-xr-xfcaps/mvn-phase-script.sh2
-rw-r--r--fcaps/pom.xml13
-rw-r--r--fcaps/requirements.txt7
-rw-r--r--fcaps/test-requirements.txt2
-rw-r--r--fcaps/tox.ini8
-rw-r--r--fcaps/uwsgi-requirements.txt2
12 files changed, 49 insertions, 30 deletions
diff --git a/fcaps/docker/Dockerfile b/fcaps/docker/Dockerfile
index 93ad6f1f..021e40eb 100644
--- a/fcaps/docker/Dockerfile
+++ b/fcaps/docker/Dockerfile
@@ -1,4 +1,4 @@
-FROM python:2-alpine
+FROM python:3-alpine
ARG HTTP_PROXY=${HTTP_PROXY}
ARG HTTPS_PROXY=${HTTPS_PROXY}
@@ -18,16 +18,17 @@ EXPOSE 9011
RUN addgroup -S onap && adduser -S -G onap onap
# COPY ./ /opt/fcaps/
+COPY ./multicloud-openstack-fcaps-*.zip /opt/multicloud-openstack-fcaps.zip
RUN apk update && \
- apk add uwsgi memcached wget unzip gcc make libc-dev libffi-dev openssl-dev && \
+ apk add pcre pcre-dev uwsgi memcached wget unzip gcc make libc-dev libffi-dev openssl-dev && \
cd /opt/ && \
- wget -O multicloud-openstack-fcaps.zip "https://nexus.onap.org/service/local/artifact/maven/redirect?r=staging&g=org.onap.multicloud.openstack&a=multicloud-openstack-fcaps&e=zip&v=1.4.0" && \
unzip -q -o -B multicloud-openstack-fcaps.zip && \
chmod +x /opt/fcaps/*.sh && \
rm -f multicloud-openstack-fcaps.zip && \
- pip install -r /opt/fcaps/requirements.txt && \
- apk del wget unzip gcc make libc-dev libffi-dev openssl-dev && \
+ pip3 install -r /opt/fcaps/requirements.txt && \
+ pip3 install -r /opt/fcaps/uwsgi-requirements.txt && \
+ apk del wget unzip gcc make libc-dev libffi-dev openssl-dev pcre-dev && \
mkdir -p /var/log/onap/multicloud/fcaps && \
chown onap:onap /var/log/onap -R && \
chown onap:onap /opt/fcaps -R
diff --git a/fcaps/fcaps/vesagent/tests/tests_tasks.py b/fcaps/fcaps/vesagent/tests/tests_tasks.py
index 23cd182d..1bb1fe23 100644
--- a/fcaps/fcaps/vesagent/tests/tests_tasks.py
+++ b/fcaps/fcaps/vesagent/tests/tests_tasks.py
@@ -64,7 +64,7 @@ class VesTaskTest(unittest.TestCase):
COUNT_TIME_SLOT2
]
result = tasks.scheduleBacklogs(vimid="fcaps-hudson-dc_RegionOne")
- self.assertEquals(None, result)
+ self.assertEqual(None, result)
@mock.patch.object(tasks, 'processBacklogsOfOneVIM')
@mock.patch.object(cache, 'get')
@@ -77,7 +77,7 @@ class VesTaskTest(unittest.TestCase):
json.dumps(mock_VesAgentBacklogs_vimlist),
]
result = tasks.processBacklogs()
- self.assertEquals(COUNT_TIME_SLOT_ONE_VIM, result)
+ self.assertEqual(COUNT_TIME_SLOT_ONE_VIM, result)
@mock.patch.object(tasks, 'processOneBacklog')
@mock.patch.object(cache, 'set')
@@ -105,7 +105,7 @@ class VesTaskTest(unittest.TestCase):
mock_cache_set.return_value = "mocked cache set"
result = tasks.processBacklogsOfOneVIM(vimid="fcaps-hudson-dc_RegionOne")
COUNT_TIME_SLOT = (1, 10)
- self.assertEquals(COUNT_TIME_SLOT, result)
+ self.assertEqual(COUNT_TIME_SLOT, result)
@mock.patch.object(fault_vm, 'processBacklog_fault_vm')
def test_tasks_processOneBacklog(
@@ -140,4 +140,4 @@ class VesTaskTest(unittest.TestCase):
poll_interval_default=10,
oneBacklog=vesagent_onebacklog)
COUNT_TIME_SLOT = (1, 10)
- self.assertEquals(COUNT_TIME_SLOT, result)
+ self.assertEqual(COUNT_TIME_SLOT, result)
diff --git a/fcaps/fcaps/vesagent/tests/tests_vesagent_ctrl.py b/fcaps/fcaps/vesagent/tests/tests_vesagent_ctrl.py
index 760c44d3..73b324cd 100644
--- a/fcaps/fcaps/vesagent/tests/tests_vesagent_ctrl.py
+++ b/fcaps/fcaps/vesagent/tests/tests_vesagent_ctrl.py
@@ -73,7 +73,7 @@ class VesAgentCtrlTest(unittest.TestCase):
mock_request.data = {"testdatakey": "testdatavalue"}
response = self.view.post(request=mock_request, vimid="fcaps-hudson-dc_RegionOne")
- self.assertEquals(status.HTTP_201_CREATED, response.status_code)
+ self.assertEqual(status.HTTP_201_CREATED, response.status_code)
@mock.patch.object(vesagent_ctrl.VesAgentCtrl, 'clearBacklogsOneVIM')
@mock.patch.object(extsys, 'get_vim_by_id')
@@ -84,7 +84,7 @@ class VesAgentCtrlTest(unittest.TestCase):
mock_request.META = {"testkey": "testvalue"}
response = self.view.delete(request=mock_request, vimid="fcaps-hudson-dc_RegionOne")
- self.assertEquals(status.HTTP_200_OK, response.status_code)
+ self.assertEqual(status.HTTP_200_OK, response.status_code)
@mock.patch.object(cache, 'get')
def test_getBacklogsOneVIM(self, mock_get):
@@ -100,7 +100,7 @@ class VesAgentCtrlTest(unittest.TestCase):
mock_get.return_value = json.dumps(mock_vesagent_config)
vesAgentConfig = self.view.getBacklogsOneVIM(vimid="fcaps-hudson-dc_RegionOne")
- self.assertEquals(vesAgentConfig, mock_vesagent_config)
+ self.assertEqual(vesAgentConfig, mock_vesagent_config)
@mock.patch.object(cache, 'set')
@mock.patch.object(cache, 'get')
@@ -129,7 +129,7 @@ class VesAgentCtrlTest(unittest.TestCase):
result = self.view.clearBacklogsOneVIM(
vimid="fcaps-hudson-dc_RegionOne")
- self.assertEquals(0, result)
+ self.assertEqual(0, result)
@mock.patch.object(scheduleBacklogs, 'delay')
@mock.patch.object(cache, 'set')
diff --git a/fcaps/fcaps/vesagent/tests/tests_vespublish.py b/fcaps/fcaps/vesagent/tests/tests_vespublish.py
index 791b0ca8..82f194fa 100644
--- a/fcaps/fcaps/vesagent/tests/tests_vespublish.py
+++ b/fcaps/fcaps/vesagent/tests/tests_vespublish.py
@@ -16,7 +16,8 @@ import mock
import unittest
# import json
-import urllib2
+# import urllib2
+import urllib
from fcaps.vesagent import vespublish
@@ -36,8 +37,8 @@ class VespublishTest(unittest.TestCase):
def tearDown(self):
pass
- @mock.patch.object(urllib2, 'urlopen')
- @mock.patch.object(urllib2, 'Request')
+ @mock.patch.object(urllib.request, 'urlopen')
+ @mock.patch.object(urllib.request, 'Request')
def test_publishAnyEventToVES(self, mock_Request, mock_urlopen):
mock_request = mock.Mock()
diff --git a/fcaps/fcaps/vesagent/vespublish.py b/fcaps/fcaps/vesagent/vespublish.py
index a53245cc..8fe58ac4 100644
--- a/fcaps/fcaps/vesagent/vespublish.py
+++ b/fcaps/fcaps/vesagent/vespublish.py
@@ -17,7 +17,8 @@ from __future__ import absolute_import, unicode_literals
import time
import logging
import json
-import urllib2
+# import urllib2
+import urllib
logger = logging.getLogger(__name__)
@@ -41,11 +42,11 @@ def publishAnyEventToVES(ves_subscription, events):
logger.info("publish event to VES: %s" % endpoint)
headers = {'Content-Type': 'application/json'}
- request = urllib2.Request(url=endpoint, headers=headers, data=json.dumps(events))
+ request = urllib.request.Request(url=endpoint, headers=headers, data=json.dumps(events))
time.sleep(1)
- response = urllib2.urlopen(request)
+ response = urllib.request.urlopen(request)
logger.info("VES response is: %s" % response.read())
- except urllib2.URLError as e:
+ except urllib.error.URLError as e:
logger.critical("Failed to publish to %s: %s" % (endpoint, e.reason))
except Exception as e:
logger.error("exception:%s" % str(e))
diff --git a/fcaps/initialize.sh b/fcaps/initialize.sh
index 5c471454..4bb9ab38 100644
--- a/fcaps/initialize.sh
+++ b/fcaps/initialize.sh
@@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-pip install -r requirements.txt
+pip3 install -r requirements.txt
diff --git a/fcaps/mvn-phase-script.sh b/fcaps/mvn-phase-script.sh
index d09584d2..af3ed299 100755
--- a/fcaps/mvn-phase-script.sh
+++ b/fcaps/mvn-phase-script.sh
@@ -53,7 +53,7 @@ run_tox_test()
DIR=$(echo "$TOXINI" | rev | cut -f2- -d'/' | rev)
cd "${CURDIR}/${DIR}"
rm -rf ./venv-tox ./.tox
- virtualenv ./venv-tox
+ virtualenv ./venv-tox --python=python3
source ./venv-tox/bin/activate
pip install --upgrade pip
pip install --upgrade tox argparse
diff --git a/fcaps/pom.xml b/fcaps/pom.xml
index ce627360..91f522e7 100644
--- a/fcaps/pom.xml
+++ b/fcaps/pom.xml
@@ -125,17 +125,28 @@
<executions>
<execution>
<id>copy-resources</id>
- <phase>validate</phase>
+ <phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
+ <overwrite>true</overwrite>
+ <nonFilteredFileExtensions>
+ <nonFilteredFileExtension>zip</nonFilteredFileExtension>
+ </nonFilteredFileExtensions>
<outputDirectory>${project.basedir}/docker_target</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/docker</directory>
<filtering>true</filtering>
</resource>
+ <resource>
+ <directory>${project.basedir}/target</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>*.zip</include>
+ </includes>
+ </resource>
</resources>
</configuration>
</execution>
diff --git a/fcaps/requirements.txt b/fcaps/requirements.txt
index 33120c70..8cfc2ceb 100644
--- a/fcaps/requirements.txt
+++ b/fcaps/requirements.txt
@@ -1,7 +1,6 @@
# rest framework
-# Django==1.9.6
-Django >= 1.11
-djangorestframework==3.3.3
+Django>=2.2.3
+djangorestframework>=3.9.4
# for call rest api
httplib2==0.9.2
@@ -21,7 +20,7 @@ uwsgi
# unittest_xml_reporting==1.12.0
# for onap logging
-onappylog>=1.0.8
+onappylog>=1.0.9
# for background tasks
celery >= 4.0
diff --git a/fcaps/test-requirements.txt b/fcaps/test-requirements.txt
index 7cfc85fb..59851bad 100644
--- a/fcaps/test-requirements.txt
+++ b/fcaps/test-requirements.txt
@@ -1,6 +1,6 @@
# Add for unit test
coverage==4.2
-mock==2.0.0
+mock==3.0.5
unittest_xml_reporting==1.12.0
pylint # GPLv2
diff --git a/fcaps/tox.ini b/fcaps/tox.ini
index 7710e46c..6467f0d8 100644
--- a/fcaps/tox.ini
+++ b/fcaps/tox.ini
@@ -1,5 +1,5 @@
[tox]
-envlist = py27,cov,pylint
+envlist = py36,cov,pylint
skipsdist = true
[tox:jenkins]
@@ -11,6 +11,10 @@ exclude = ./venv-tox,./.tox
max-complexity = 27
[testenv]
+basepython =
+ py36: python3
+ cov: python3
+ pylint: python3
setenv =
PYTHONPATH = {toxinidir}/../share
deps =
@@ -22,7 +26,7 @@ commands =
[testenv:pep8]
deps=flake8
-commands=flake8
+commands=python3 -m flake8
[testenv:cov]
commands = coverage xml --omit="./venv-tox/*,./.tox/*,*tests*,*__init__.py,*newton_base*,*common*, *site-packages*"
diff --git a/fcaps/uwsgi-requirements.txt b/fcaps/uwsgi-requirements.txt
new file mode 100644
index 00000000..5894a40d
--- /dev/null
+++ b/fcaps/uwsgi-requirements.txt
@@ -0,0 +1,2 @@
+#uwsgi for parallel processing
+uwsgi \ No newline at end of file