Update python2 to python3 23/90823/1
authorfujinhua <fu.jinhua@zte.com.cn>
Wed, 3 Jul 2019 08:16:15 +0000 (16:16 +0800)
committerfujinhua <fu.jinhua@zte.com.cn>
Wed, 3 Jul 2019 08:16:15 +0000 (16:16 +0800)
Change-Id: I1dfd73fe4a934ed1f46d016bdb29df17dfda2a75
Issue-ID: VFC-1429
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
zte/vmanager/docker/Dockerfile
zte/vmanager/docker/docker-env-conf.sh
zte/vmanager/driver/interfaces/views.py
zte/vmanager/driver/pub/utils/restcall.py
zte/vmanager/driver/swagger/management/commands/export_swagger.py
zte/vmanager/requirements.txt
zte/vmanager/run.sh
zte/vmanager/stop.sh
zte/vmanager/tox.ini

index 3fbaa38..466000e 100644 (file)
@@ -1,4 +1,4 @@
-FROM python:2-alpine
+FROM python:3.6-alpine
 
 ARG HTTP_PROXY=${HTTP_PROXY}
 ARG HTTPS_PROXY=${HTTPS_PROXY}
index 6447fc9..19cee17 100755 (executable)
@@ -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" && \
index 93d6510..811a189 100644 (file)
@@ -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={
index fd0b3dd..6b2c4b0 100644 (file)
@@ -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())
index 4971022..31f4e19 100644 (file)
@@ -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'])
index c522c1b..d51b3b2 100644 (file)
@@ -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
index 5cc179f..5665583 100755 (executable)
@@ -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
index 3261916..daece1e 100755 (executable)
@@ -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
index 98d1783..354b12d 100644 (file)
@@ -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