diff options
author | fujinhua <fu.jinhua@zte.com.cn> | 2019-07-03 16:16:15 +0800 |
---|---|---|
committer | fujinhua <fu.jinhua@zte.com.cn> | 2019-07-03 16:16:15 +0800 |
commit | d19480a60b4337698df55f4d9c0fadbd38737811 (patch) | |
tree | ce1f9f24f02255a6a714a9dd24fa8bf00e546e0e /zte/vmanager | |
parent | 98315d35b20a4b035570ce86be9342526b6f3866 (diff) |
Update python2 to python3
Change-Id: I1dfd73fe4a934ed1f46d016bdb29df17dfda2a75
Issue-ID: VFC-1429
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
Diffstat (limited to 'zte/vmanager')
-rw-r--r-- | zte/vmanager/docker/Dockerfile | 2 | ||||
-rwxr-xr-x | zte/vmanager/docker/docker-env-conf.sh | 2 | ||||
-rw-r--r-- | zte/vmanager/driver/interfaces/views.py | 16 | ||||
-rw-r--r-- | zte/vmanager/driver/pub/utils/restcall.py | 4 | ||||
-rw-r--r-- | zte/vmanager/driver/swagger/management/commands/export_swagger.py | 2 | ||||
-rw-r--r-- | zte/vmanager/requirements.txt | 10 | ||||
-rwxr-xr-x | zte/vmanager/run.sh | 12 | ||||
-rwxr-xr-x | zte/vmanager/stop.sh | 4 | ||||
-rw-r--r-- | zte/vmanager/tox.ini | 5 |
9 files changed, 29 insertions, 28 deletions
diff --git a/zte/vmanager/docker/Dockerfile b/zte/vmanager/docker/Dockerfile index 3fbaa38d..466000e8 100644 --- a/zte/vmanager/docker/Dockerfile +++ b/zte/vmanager/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM python:2-alpine +FROM python:3.6-alpine ARG HTTP_PROXY=${HTTP_PROXY} ARG HTTPS_PROXY=${HTTPS_PROXY} diff --git a/zte/vmanager/docker/docker-env-conf.sh b/zte/vmanager/docker/docker-env-conf.sh index 6447fc9b..19cee170 100755 --- a/zte/vmanager/docker/docker-env-conf.sh +++ b/zte/vmanager/docker/docker-env-conf.sh @@ -4,7 +4,7 @@ install_sf(){ apk --no-cache update apk --no-cache add bash curl gcc wget mysql-client openssl-dev - apk --no-cache add python-dev libffi-dev musl-dev py2-virtualenv + apk --no-cache add python36-dev libffi-dev musl-dev py3-virtualenv # get binary zip from nexus - vfc-nfvo-driver-vnfm-svnfm-zte-vmanager wget -q -O vfc-nfvo-driver-vnfm-svnfm-zte-vmanager.zip "https://nexus.onap.org/service/local/artifact/maven/redirect?r=snapshots&g=org.onap.vfc.nfvo.driver.vnfm.svnfm.zte.vmanager&a=vfc-nfvo-driver-vnfm-svnfm-zte-vmanager&v=${pkg_verison}-SNAPSHOT&e=zip" && \ diff --git a/zte/vmanager/driver/interfaces/views.py b/zte/vmanager/driver/interfaces/views.py index 93d65100..811a189f 100644 --- a/zte/vmanager/driver/interfaces/views.py +++ b/zte/vmanager/driver/interfaces/views.py @@ -139,7 +139,7 @@ class InstantiateVnf(APIView): return Response(data=resp_data, status=status.HTTP_200_OK) except Exception as e: - logger.error("Error occurred when instantiating VNF,error:%s", e.message) + logger.error("Error occurred when instantiating VNF,error:%s", e.args[0]) logger.error(traceback.format_exc()) return Response( data={ @@ -188,7 +188,7 @@ class TerminateVnf(APIView): logger.debug("[%s]resp_data=%s", funname, resp_data) return Response(data=resp_data, status=status.HTTP_200_OK) except Exception as e: - logger.error("Error occurred when terminating VNF,error: %s", e.message) + logger.error("Error occurred when terminating VNF,error: %s", e.args[0]) logger.error(traceback.format_exc()) return Response( data={ @@ -236,7 +236,7 @@ class QueryVnf(APIView): logger.debug("[%s]resp_data=%s", funname, resp_data) return Response(data=resp_data, status=status.HTTP_200_OK) except Exception as e: - logger.error("Error occurred when querying VNF information,error:%s", e.message) + logger.error("Error occurred when querying VNF information,error:%s", e.args[0]) logger.error(traceback.format_exc()) return Response( data={ @@ -295,7 +295,7 @@ class JobView(APIView): return Response(data=resp_data, status=status.HTTP_200_OK) except Exception as e: - logger.error("Error occurred when getting operation status information,error:%s", e.message) + logger.error("Error occurred when getting operation status information,error:%s", e.args[0]) logger.error(traceback.format_exc()) return Response( data={ @@ -365,7 +365,7 @@ class GrantVnf(APIView): return Response(data=resp_data, status=status.HTTP_201_CREATED) except Exception as e: - logger.error("Error occurred in Grant VNF, error: %s", e.message) + logger.error("Error occurred in Grant VNF, error: %s", e.args[0]) logger.error(traceback.format_exc()) return Response( data={ @@ -455,7 +455,7 @@ class Notify(APIView): return Response(data=None, status=status.HTTP_200_OK) except Exception as e: - logger.error("Error occurred in LCM notification,error: %s", e.message) + logger.error("Error occurred in LCM notification,error: %s", e.args[0]) logger.error(traceback.format_exc()) return Response( data={ @@ -515,7 +515,7 @@ class Scale(APIView): return Response(data=resp_data, status=status.HTTP_202_ACCEPTED) except Exception as e: - logger.error("Error occurred when scaling VNF,error:%s", e.message) + logger.error("Error occurred when scaling VNF,error:%s", e.args[0]) logger.error(traceback.format_exc()) return Response( data={ @@ -576,7 +576,7 @@ class Heal(APIView): return Response(data=resp_data, status=status.HTTP_202_ACCEPTED) except Exception as e: - logger.error("Error occurred when healing VNF,error:%s", e.message) + logger.error("Error occurred when healing VNF,error:%s", e.args[0]) logger.error(traceback.format_exc()) return Response( data={ diff --git a/zte/vmanager/driver/pub/utils/restcall.py b/zte/vmanager/driver/pub/utils/restcall.py index fd0b3ddd..6b2c4b05 100644 --- a/zte/vmanager/driver/pub/utils/restcall.py +++ b/zte/vmanager/driver/pub/utils/restcall.py @@ -15,7 +15,7 @@ import logging import sys import traceback -import urllib2 +import urllib.error import uuid import httplib2 @@ -61,7 +61,7 @@ def call_req(base_url, user, passwd, auth_type, resource, method, content=''): ret = [1, "Unable to connect to %s" % full_url, resp_status] continue raise ex - except urllib2.URLError as err: + except urllib.error.URLError as err: ret = [2, str(err), resp_status] except Exception as ex: logger.error(traceback.format_exc()) diff --git a/zte/vmanager/driver/swagger/management/commands/export_swagger.py b/zte/vmanager/driver/swagger/management/commands/export_swagger.py index 4971022f..31f4e190 100644 --- a/zte/vmanager/driver/swagger/management/commands/export_swagger.py +++ b/zte/vmanager/driver/swagger/management/commands/export_swagger.py @@ -33,4 +33,4 @@ class Command(BaseCommand): response = self.client.get("/api/ztevnfmdriver/v1/swagger.json") with open(options['name'], 'w') as swagger_file: swagger_file.write(json.dumps(response.data)) - print "swagger api is written to %s" % options['name'] + print("swagger api is written to %s" % options['name']) diff --git a/zte/vmanager/requirements.txt b/zte/vmanager/requirements.txt index c522c1b3..d51b3b2c 100644 --- a/zte/vmanager/requirements.txt +++ b/zte/vmanager/requirements.txt @@ -1,13 +1,13 @@ # rest framework -Django==1.11.9 -djangorestframework==3.7.7 +Django==2.1.4 +djangorestframework==3.9.4 # for call rest api httplib2==0.12.3 # for unit test coverage==4.2 -mock==2.0.0 +mock==3.0.5 unittest_xml_reporting==1.12.0 # for auto swagger @@ -16,7 +16,7 @@ flex>=6.11.1 swagger-spec-validator>=2.1.0 # for onap logging -onappylog>=1.0.6 +onappylog>=1.0.9 # uwsgi for parallel processing -uwsgi +# uwsgi diff --git a/zte/vmanager/run.sh b/zte/vmanager/run.sh index 5cc179f7..56655835 100755 --- a/zte/vmanager/run.sh +++ b/zte/vmanager/run.sh @@ -18,10 +18,10 @@ if [ ! -x $logDir ]; then mkdir -p $logDir fi -# nohup python manage.py runserver 0.0.0.0:8410 > /dev/null & +nohup python manage.py runserver 0.0.0.0:8410 > /dev/null & -if [ "${SSL_ENABLED}" = "true" ]; then - nohup uwsgi --https :8410,driver/pub/ssl/cert/foobar.crt,driver/pub/ssl/cert/foobar.key, -t 120 --module driver.wsgi --master --processes 4 & -else - nohup uwsgi --http :8410 -t 120 --module driver.wsgi --master --processes 4 & -fi +# if [ "${SSL_ENABLED}" = "true" ]; then +# nohup uwsgi --https :8410,driver/pub/ssl/cert/foobar.crt,driver/pub/ssl/cert/foobar.key, -t 120 --module driver.wsgi --master --processes 4 & +# else +# nohup uwsgi --http :8410 -t 120 --module driver.wsgi --master --processes 4 & +# fi diff --git a/zte/vmanager/stop.sh b/zte/vmanager/stop.sh index 3261916f..daece1ec 100755 --- a/zte/vmanager/stop.sh +++ b/zte/vmanager/stop.sh @@ -13,6 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# ps auxww | grep "manage.py runserver 0.0.0.0:8410" | awk '{print $2}' | xargs kill -9 +ps auxww | grep "manage.py runserver 0.0.0.0:8410" | awk '{print $1}' | xargs kill -9 -ps auxww |grep 'uwsgi --http' |awk '{print $1}' |xargs kill -9 +# ps auxww |grep 'uwsgi --http' |awk '{print $1}' |xargs kill -9 diff --git a/zte/vmanager/tox.ini b/zte/vmanager/tox.ini index 98d17830..354b12d2 100644 --- a/zte/vmanager/tox.ini +++ b/zte/vmanager/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,pep8,cov +envlist = py36,pep8,cov skipsdist = true [testenv] @@ -15,9 +15,10 @@ max-complexity = 12 deps = flake8 commands = flake8 -[testenv:py27] +[testenv:py36] commands = {[testenv]commands} [testenv:cov] +deps = coverage commands = coverage xml --omit="*test*,*__init__.py,*site-packages*"
\ No newline at end of file |