summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfujinhua <fu.jinhua@zte.com.cn>2019-07-03 15:17:30 +0800
committerfujinhua <fu.jinhua@zte.com.cn>2019-07-03 15:48:46 +0800
commit8470eb9f5845d55a3bec9351b1982f61a2fdd319 (patch)
tree569e39d02ac87900867f49e28aafa0cff5cc52f3
parent21c2a798f6adca51eb2881e1a84ca1d10967d4e8 (diff)
Update python2 to python3
Change-Id: Icb5a35dd320ccbf80c66089977550755810c859f Issue-ID: VFC-1429 Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
-rw-r--r--gvnfmadapter/docker/Dockerfile2
-rwxr-xr-xgvnfmadapter/docker/docker-env-conf.sh2
-rw-r--r--gvnfmadapter/driver/interfaces/tests.py1
-rw-r--r--gvnfmadapter/driver/interfaces/views.py46
-rw-r--r--gvnfmadapter/driver/pub/utils/restcall.py4
-rw-r--r--gvnfmadapter/driver/swagger/management/commands/export_swagger.py2
-rw-r--r--gvnfmadapter/requirements.txt11
-rwxr-xr-xgvnfmadapter/run.sh13
-rwxr-xr-xgvnfmadapter/stop.sh4
-rw-r--r--gvnfmadapter/tox.ini5
10 files changed, 44 insertions, 46 deletions
diff --git a/gvnfmadapter/docker/Dockerfile b/gvnfmadapter/docker/Dockerfile
index 2b99d44..86bde96 100644
--- a/gvnfmadapter/docker/Dockerfile
+++ b/gvnfmadapter/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/gvnfmadapter/docker/docker-env-conf.sh b/gvnfmadapter/docker/docker-env-conf.sh
index 2cf7956..1edcd7e 100755
--- a/gvnfmadapter/docker/docker-env-conf.sh
+++ b/gvnfmadapter/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-catalog
wget -q -O vfc-nfvo-driver-vnfm-gvnfm-gvnfmadapter.zip "https://nexus.onap.org/service/local/artifact/maven/redirect?r=snapshots&g=org.onap.vfc.nfvo.driver.vnfm.gvnfm.gvnfmadapter&a=vfc-nfvo-driver-vnfm-gvnfm-gvnfmadapter&v=${pkg_version}-SNAPSHOT&e=zip" && \
diff --git a/gvnfmadapter/driver/interfaces/tests.py b/gvnfmadapter/driver/interfaces/tests.py
index 427f872..c92a1f9 100644
--- a/gvnfmadapter/driver/interfaces/tests.py
+++ b/gvnfmadapter/driver/interfaces/tests.py
@@ -219,7 +219,6 @@ class InterfacesTest(TestCase):
mock_call_req.side_effect = [r1, r2]
response = self.client.get("/api/gvnfmdriver/v1/%s/jobs/%s?responseId=0"
% (vnfm_info["vnfmId"], expected_body["jobId"]))
- print response
self.assertEqual(status.HTTP_200_OK, response.status_code)
self.assertDictEqual(expected_body, response.data)
diff --git a/gvnfmadapter/driver/interfaces/views.py b/gvnfmadapter/driver/interfaces/views.py
index fa8a651..b99dc10 100644
--- a/gvnfmadapter/driver/interfaces/views.py
+++ b/gvnfmadapter/driver/interfaces/views.py
@@ -92,8 +92,8 @@ class VnfInstInfo(APIView):
logger.debug("Instantiate vnf end!")
return Response(data=resp_data, status=status.HTTP_201_CREATED)
except GvnfmDriverException as e:
- logger.error('instantiate vnf failed, detail message: %s' % e.message)
- return Response(data={'error': e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+ logger.error('instantiate vnf failed, detail message: %s' % e.args[0])
+ return Response(data={'error': e.args[0]}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
except:
logger.error(traceback.format_exc())
return Response(data={'error': 'unexpected exception'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
@@ -115,7 +115,7 @@ class VnfTermInfo(APIView):
vnf_info = do_queryvnf(request, vnfm_id, vnfInstanceId)
logger.debug("VNF instance info: %s" % vnf_info)
except GvnfmDriverException as e:
- logger.debug('VNF already does not exist, detail message: %s' % e.message)
+ logger.debug('VNF already does not exist, detail message: %s' % e.args[0])
return Response(data={"vnfInstanceId": vnfInstanceId}, status=status.HTTP_201_CREATED)
try:
@@ -144,8 +144,8 @@ class VnfTermInfo(APIView):
}
return Response(data=resp_data, status=status.HTTP_201_CREATED)
except GvnfmDriverException as e:
- logger.error('Terminate vnf failed, detail message: %s' % e.message)
- return Response(data={'error': e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+ logger.error('Terminate vnf failed, detail message: %s' % e.args[0])
+ return Response(data={'error': e.args[0]}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
except:
logger.error(traceback.format_exc())
return Response(data={'error': 'unexpected exception'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
@@ -195,8 +195,8 @@ class VnfQueryInfo(APIView):
logger.debug("[%s]resp_data=%s", fun_name(), resp_data)
return Response(data=resp_data, status=status.HTTP_200_OK)
except GvnfmDriverException as e:
- logger.error('Query vnf failed, detail message: %s' % e.message)
- return Response(data={'error': e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+ logger.error('Query vnf failed, detail message: %s' % e.args[0])
+ return Response(data={'error': e.args[0]}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
except:
logger.error(traceback.format_exc())
return Response(data={'error': 'unexpected exception'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
@@ -238,8 +238,8 @@ class VnfOperInfo(APIView):
}
return Response(data=operation_data, status=status.HTTP_200_OK)
except GvnfmDriverException as e:
- logger.error('Query vnf failed, detail message: %s' % e.message)
- return Response(data={'error': e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+ logger.error('Query vnf failed, detail message: %s' % e.args[0])
+ return Response(data={'error': e.args[0]}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
except:
logger.error(traceback.format_exc())
return Response(data={'error': 'unexpected exception'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
@@ -273,8 +273,8 @@ class VnfGrantInfo(APIView):
logger.debug("[%s]resp_data=%s", fun_name(), resp)
return Response(data=resp, status=status.HTTP_201_CREATED)
except GvnfmDriverException as e:
- logger.error('Grant vnf failed, detail message: %s' % e.message)
- return Response(data={'error': e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+ logger.error('Grant vnf failed, detail message: %s' % e.args[0])
+ return Response(data={'error': e.args[0]}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
except:
logger.error(traceback.format_exc())
return Response(data={'error': 'unexpected exception'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
@@ -303,8 +303,8 @@ class VnfNotifyInfo(APIView):
raise GvnfmDriverException('Failed to notify vnf.')
return Response(data=None, status=status.HTTP_200_OK)
except GvnfmDriverException as e:
- logger.error('Grant vnf failed, detail message: %s' % e.message)
- return Response(data={'error': e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+ logger.error('Grant vnf failed, detail message: %s' % e.args[0])
+ return Response(data={'error': e.args[0]}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
except:
logger.error(traceback.format_exc())
return Response(data={'error': 'unexpected exception'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
@@ -343,8 +343,8 @@ class VnfOperateView(APIView):
response["Location"] = location
return response
except GvnfmDriverException as e:
- logger.error('operate vnf failed, detail message: %s' % e.message)
- return Response(data={'error': e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+ logger.error('operate vnf failed, detail message: %s' % e.args[0])
+ return Response(data={'error': e.args[0]}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
except:
logger.error(traceback.format_exc())
return Response(data={'error': 'unexpected exception'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
@@ -393,8 +393,8 @@ class VnfHealView(APIView):
response["Location"] = location
return response
except GvnfmDriverException as e:
- logger.error('Heal vnf failed, detail message: %s' % e.message)
- return Response(data={'error': e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+ logger.error('Heal vnf failed, detail message: %s' % e.args[0])
+ return Response(data={'error': e.args[0]}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
except:
logger.error(traceback.format_exc())
return Response(data={'error': 'unexpected exception'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
@@ -411,8 +411,8 @@ class VnfPkgsInfo(APIView):
resp = json.JSONDecoder().decode(ret[1])
return Response(data=resp, status=status.HTTP_200_OK)
except GvnfmDriverException as e:
- logger.error('Get vnfpkgs failed, detail message: %s' % e.message)
- return Response(data={'error': e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+ logger.error('Get vnfpkgs failed, detail message: %s' % e.args[0])
+ return Response(data={'error': e.args[0]}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
except:
logger.error(traceback.format_exc())
return Response(data={'error': 'unexpected exception'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
@@ -442,8 +442,8 @@ class QuerySingleVnfLcmOpOcc(APIView):
else:
raise GvnfmDriverException(vnf_lcm_op_occ_serializer.errors)
except GvnfmDriverException as e:
- logger.error("Query vnflcmopocc failed, detail message: %s" % e.message)
- return Response(data={'error': e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+ logger.error("Query vnflcmopocc failed, detail message: %s" % e.args[0])
+ return Response(data={'error': e.args[0]}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
except:
logger.error(traceback.format_exc())
return Response(data={'error': traceback.format_exc()}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
@@ -473,10 +473,10 @@ class Subscription(APIView):
logger.debug("Subscription end!")
return Response(data=lccn_subscription_serializer.data, status=status.HTTP_201_CREATED)
except GvnfmDriverException as e:
- logger.error(e.message)
+ logger.error(e.args[0])
return Response(status=status.HTTP_500_INTERNAL_SERVER_ERROR)
except Exception as e:
- logger.error(e.message)
+ logger.error(e.args[0])
logger.error(traceback.format_exc())
return Response(status=status.HTTP_500_INTERNAL_SERVER_ERROR)
diff --git a/gvnfmadapter/driver/pub/utils/restcall.py b/gvnfmadapter/driver/pub/utils/restcall.py
index 46defd3..28578cd 100644
--- a/gvnfmadapter/driver/pub/utils/restcall.py
+++ b/gvnfmadapter/driver/pub/utils/restcall.py
@@ -15,7 +15,7 @@
import sys
import traceback
import logging
-import urllib2
+import urllib.error
import uuid
import httplib2
@@ -62,7 +62,7 @@ def call_req(base_url, user, passwd, auth_type, resource, method, content=''):
ret = [1, "Unable to connect to %s" % full_url, resp_status, resp_Location]
continue
raise ex
- except urllib2.URLError as err:
+ except urllib.error.URLError as err:
ret = [2, str(err), resp_status, resp_Location]
except Exception as ex:
logger.error(traceback.format_exc())
diff --git a/gvnfmadapter/driver/swagger/management/commands/export_swagger.py b/gvnfmadapter/driver/swagger/management/commands/export_swagger.py
index 2c17ae9..324e420 100644
--- a/gvnfmadapter/driver/swagger/management/commands/export_swagger.py
+++ b/gvnfmadapter/driver/swagger/management/commands/export_swagger.py
@@ -33,4 +33,4 @@ class Command(BaseCommand):
response = self.client.get("/api/gvnfmdriver/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/gvnfmadapter/requirements.txt b/gvnfmadapter/requirements.txt
index eb9570d..ee8f60f 100644
--- a/gvnfmadapter/requirements.txt
+++ b/gvnfmadapter/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
@@ -18,8 +18,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 \ No newline at end of file
+# uwsgi
diff --git a/gvnfmadapter/run.sh b/gvnfmadapter/run.sh
index cb87753..69063fd 100755
--- a/gvnfmadapter/run.sh
+++ b/gvnfmadapter/run.sh
@@ -18,11 +18,10 @@ if [ ! -x $logDir ]; then
mkdir -p $logDir
fi
-# nohup python manage.py runserver 0.0.0.0:8484 > /dev/null &
-
-if [ "${SSL_ENABLED}" = "true" ]; then
- nohup uwsgi --https :8484,driver/pub/ssl/cert/foobar.crt,driver/pub/ssl/cert/foobar.key, -t 120 --module driver.wsgi --master --processes 4 &
-else
- nohup uwsgi --http :8484 -t 120 --module driver.wsgi --master --processes 4 &
-fi
+nohup python manage.py runserver 0.0.0.0:8484 > /dev/null &
+# if [ "${SSL_ENABLED}" = "true" ]; then
+# nohup uwsgi --https :8484,driver/pub/ssl/cert/foobar.crt,driver/pub/ssl/cert/foobar.key, -t 120 --module driver.wsgi --master --processes 4 &
+# else
+# nohup uwsgi --http :8484 -t 120 --module driver.wsgi --master --processes 4 &
+# fi
diff --git a/gvnfmadapter/stop.sh b/gvnfmadapter/stop.sh
index 709ea14..abfb4f5 100755
--- a/gvnfmadapter/stop.sh
+++ b/gvnfmadapter/stop.sh
@@ -13,5 +13,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# ps auxww | grep 'manage.py runserver 0.0.0.0:8484' | awk '{print $1}' | xargs kill -9
-ps auxww |grep 'uwsgi --http' |awk '{print $1}' |xargs kill -9
+ps auxww | grep 'manage.py runserver 0.0.0.0:8484' | awk '{print $1}' | xargs kill -9
+# ps auxww |grep 'uwsgi --http' |awk '{print $1}' |xargs kill -9
diff --git a/gvnfmadapter/tox.ini b/gvnfmadapter/tox.ini
index 43bb510..ddc0f37 100644
--- a/gvnfmadapter/tox.ini
+++ b/gvnfmadapter/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