summaryrefslogtreecommitdiffstats
path: root/lcm
diff options
context:
space:
mode:
authorying.yunlong <ying.yunlong@zte.com.cn>2017-09-20 13:43:08 +0800
committerying.yunlong <ying.yunlong@zte.com.cn>2017-09-20 13:43:08 +0800
commite97e0b12f8aa84d136e619902c95303333fb3a6c (patch)
treef2df8fb0de9c03baba5012ea68916640d4278c46 /lcm
parent3ac66a9fad25031ca3976cd9f14fe2c5f0162535 (diff)
Modify vnflcm code according to PEP8 standard
Change-Id: I8df05103e9f7e4659a1a845bce5fd8810d5f5f17 Issue-ID: VFC-395 Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
Diffstat (limited to 'lcm')
-rw-r--r--lcm/.gitreview2
-rw-r--r--lcm/lcm/jobs/__init__.py2
-rw-r--r--lcm/lcm/jobs/job_get.py1
-rw-r--r--lcm/lcm/jobs/tests.py3
-rw-r--r--lcm/lcm/jobs/urls.py1
-rw-r--r--lcm/lcm/jobs/views.py1
-rw-r--r--lcm/lcm/nf/vnfs/const.py103
-rw-r--r--lcm/lcm/nf/vnfs/urls.py2
-rw-r--r--lcm/lcm/pub/config/config.py3
-rw-r--r--lcm/lcm/pub/database/models.py12
-rw-r--r--lcm/lcm/pub/exceptions.py1
-rw-r--r--lcm/lcm/pub/msapi/gvnfmdriver.py2
-rw-r--r--lcm/lcm/pub/utils/values.py4
-rw-r--r--lcm/lcm/wsgi.py1
14 files changed, 80 insertions, 58 deletions
diff --git a/lcm/.gitreview b/lcm/.gitreview
index 83418307..c6e1c2bd 100644
--- a/lcm/.gitreview
+++ b/lcm/.gitreview
@@ -1,4 +1,4 @@
[gerrit]
host=gerrit.onap.org
port=29418
-project=vfc/gvnfm/vnflcm \ No newline at end of file
+project=vfc/gvnfm/vnflcm
diff --git a/lcm/lcm/jobs/__init__.py b/lcm/lcm/jobs/__init__.py
index 650d17ec..c7b6818e 100644
--- a/lcm/lcm/jobs/__init__.py
+++ b/lcm/lcm/jobs/__init__.py
@@ -10,4 +10,4 @@
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
-# limitations under the License. \ No newline at end of file
+# limitations under the License.
diff --git a/lcm/lcm/jobs/job_get.py b/lcm/lcm/jobs/job_get.py
index d7bee942..0953df9b 100644
--- a/lcm/lcm/jobs/job_get.py
+++ b/lcm/lcm/jobs/job_get.py
@@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+
import logging
from lcm.pub.utils.jobutil import JobUtil
diff --git a/lcm/lcm/jobs/tests.py b/lcm/lcm/jobs/tests.py
index df466563..3eb60ab2 100644
--- a/lcm/lcm/jobs/tests.py
+++ b/lcm/lcm/jobs/tests.py
@@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+
from django.test import TestCase, Client
from rest_framework import status
@@ -29,4 +30,4 @@ class JobsViewTest(TestCase):
JobModel(jobid=self.job_id, jobtype='VNF', jobaction='INST', resid='1').save()
JobStatusModel(indexid=1, jobid=self.job_id, status='inst', progress=20, descp='inst').save()
response = self.client.get("/api/vnflcm/v1/vnf_lc_ops/%s?responseId=123456jhj" % self.job_id)
- self.failUnlessEqual(status.HTTP_200_OK, response.status_code) \ No newline at end of file
+ self.failUnlessEqual(status.HTTP_200_OK, response.status_code)
diff --git a/lcm/lcm/jobs/urls.py b/lcm/lcm/jobs/urls.py
index 0aeb7fa8..33eec201 100644
--- a/lcm/lcm/jobs/urls.py
+++ b/lcm/lcm/jobs/urls.py
@@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+
from django.conf.urls import patterns, url
from rest_framework.urlpatterns import format_suffix_patterns
diff --git a/lcm/lcm/jobs/views.py b/lcm/lcm/jobs/views.py
index be1803f1..57a999b4 100644
--- a/lcm/lcm/jobs/views.py
+++ b/lcm/lcm/jobs/views.py
@@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+
import logging
from rest_framework.response import Response
diff --git a/lcm/lcm/nf/vnfs/const.py b/lcm/lcm/nf/vnfs/const.py
index bb114e4a..d3489627 100644
--- a/lcm/lcm/nf/vnfs/const.py
+++ b/lcm/lcm/nf/vnfs/const.py
@@ -23,44 +23,44 @@ inst_req_data = {
"flavourId": "flavour_1",
"instantiationLevelId": "instantiationLevel_1",
"extVirtualLinks": [
- # {
- # "vlInstanceId": "1",
- # "vim": {
- # "vimInfoId": "1",
- # "vimId": "1",
- # "interfaceInfo": {
- # "vimType": "vim",
- # "apiVersion": "v2",
- # "protocolType": "http"
- # },
- # "accessInfo": {
- # "tenant": "tenant_vCPE",
- # "username": "vCPE",
- # "password": "vCPE_321"
- # },
- # "interfaceEndpoint": "http://10.43.21.105:80/"
- # },
- # "resourceId": "1246",
- # "extCps": [
- # {
- # "cpdId": "11",
- # "addresses": [
- # {
- # "addressType": "MAC",
- # "l2AddressData": "00:f3:43:20:a2:a3"
- # },
- # {
- # "addressType": "IP",
- # "l3AddressData": {
- # "iPAddressType": "IPv4",
- # "iPAddress": "192.168.104.2"
- # }
- # }
- # ],
- # "numDynamicAddresses": 0
- # }
- # ]
- # },
+ {
+ "vlInstanceId": "1",
+ "vim": {
+ "vimInfoId": "1",
+ "vimId": "1",
+ "interfaceInfo": {
+ "vimType": "vim",
+ "apiVersion": "v2",
+ "protocolType": "http"
+ },
+ "accessInfo": {
+ "tenant": "tenant_vCPE",
+ "username": "vCPE",
+ "password": "vCPE_321"
+ },
+ "interfaceEndpoint": "http://10.43.21.105:80/"
+ },
+ "resourceId": "1246",
+ "extCps": [
+ {
+ "cpdId": "11",
+ "addresses": [
+ {
+ "addressType": "MAC",
+ "l2AddressData": "00:f3:43:20:a2:a3"
+ },
+ {
+ "addressType": "IP",
+ "l3AddressData": {
+ "iPAddressType": "IPv4",
+ "iPAddress": "192.168.104.2"
+ }
+ }
+ ],
+ "numDynamicAddresses": 0
+ }
+ ]
+ },
{
"vlInstanceId": '55',
"resourceId": '55_network',
@@ -72,16 +72,23 @@ inst_req_data = {
}
],
"localizationLanguage": "en_US",
- "additionalParams": {"inputs": {"key1":"test1","key2":"test2"},
- "extVirtualLinks": [{
- "vlInstanceId": '55',
- "resourceId": '55_network',
- "resourceSubnetId": '55_subnet',
- "cpdId": 'cpId1',
- "vim": {
- "vimid": '55_vimid'
- }
- }]}
+ "additionalParams": {
+ "inputs": {
+ "key1": "test1",
+ "key2": "test2"
+ },
+ "extVirtualLinks": [
+ {
+ "vlInstanceId": '55',
+ "resourceId": '55_network',
+ "resourceSubnetId": '55_subnet',
+ "cpdId": 'cpId1',
+ "vim": {
+ "vimid": '55_vimid'
+ }
+ }
+ ]
+ }
}
diff --git a/lcm/lcm/nf/vnfs/urls.py b/lcm/lcm/nf/vnfs/urls.py
index c6f00a6f..5be0073e 100644
--- a/lcm/lcm/nf/vnfs/urls.py
+++ b/lcm/lcm/nf/vnfs/urls.py
@@ -25,7 +25,7 @@ urlpatterns = patterns('',
DeleteVnfAndQueryVnf.as_view()),
url(r'^api/vnflcm/v1/vnf_instances/(?P<instanceid>[0-9a-zA-Z_-]+)/terminate$',
TerminateVnf.as_view()),
- url(r'^api/vnflcm/v1/swagger.json$', SwaggerJsonView.as_view()),
+ url(r'^api/vnflcm/v1/swagger.json$', SwaggerJsonView.as_view())
)
urlpatterns = format_suffix_patterns(urlpatterns)
diff --git a/lcm/lcm/pub/config/config.py b/lcm/lcm/pub/config/config.py
index c47d7637..f18ef8e6 100644
--- a/lcm/lcm/pub/config/config.py
+++ b/lcm/lcm/pub/config/config.py
@@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import os
-
# [MSB]
MSB_SERVICE_IP = '127.0.0.1'
MSB_SERVICE_PORT = '80'
@@ -24,7 +22,6 @@ AAI_USER = "AAI"
AAI_PASSWORD = "AAI"
REPORT_TO_AAI = True
-
# [REDIS]
REDIS_HOST = '127.0.0.1'
REDIS_PORT = '6379'
diff --git a/lcm/lcm/pub/database/models.py b/lcm/lcm/pub/database/models.py
index e46f7af9..02993e71 100644
--- a/lcm/lcm/pub/database/models.py
+++ b/lcm/lcm/pub/database/models.py
@@ -39,6 +39,7 @@ class NfInstModel(models.Model):
vnfConfigurableProperties = models.TextField(db_column='VNFCONFIGURABLEPROPERTIES', max_length=20000, blank=True, null=True)
localizationLanguage = models.CharField(db_column='LOCALIZATIONLANGUAGE', max_length=255, null=True)
+
class JobModel(models.Model):
class Meta:
db_table = 'JOB'
@@ -61,6 +62,7 @@ class JobModel(models.Model):
import json
return json.dumps(dict([(attr, getattr(self, attr)) for attr in [f.name for f in self._meta.fields]]))
+
class JobStatusModel(models.Model):
class Meta:
db_table = 'JOB_STATUS'
@@ -79,6 +81,7 @@ class JobStatusModel(models.Model):
import json
return json.dumps(dict([(attr, getattr(self, attr)) for attr in [f.name for f in self._meta.fields]]))
+
class NfvoRegInfoModel(models.Model):
class Meta:
db_table = 'NFVOREGINFO'
@@ -93,6 +96,7 @@ class NfvoRegInfoModel(models.Model):
servercert = models.CharField(max_length=255, db_column='SERVERCERT', null=True)
regtime = models.CharField(max_length=255, db_column='REGTIME')
+
class StorageInstModel(models.Model):
class Meta:
db_table = 'STORAGEINST'
@@ -116,6 +120,7 @@ class StorageInstModel(models.Model):
create_time = models.CharField(db_column='CREATETIME', max_length=200, null=True, blank=True)
nodeId = models.CharField(db_column='NODEID', max_length=255, null=True)
+
class VmInstModel(models.Model):
class Meta:
db_table = 'VMINST'
@@ -139,6 +144,7 @@ class VmInstModel(models.Model):
instid = models.CharField(db_column='INSTID', max_length=255)
nodeId = models.CharField(db_column='NODEID', max_length=255, null=True)
+
class VNFCInstModel(models.Model):
class Meta:
db_table = 'VNFCINST'
@@ -150,6 +156,7 @@ class VNFCInstModel(models.Model):
vmid = models.CharField(db_column='VMID', max_length=255)
is_predefined = models.IntegerField(db_column='ISPREDEFINED', default=0, null=True)
+
class FlavourInstModel(models.Model):
class Meta:
db_table = 'FLAVOURINST'
@@ -170,6 +177,7 @@ class FlavourInstModel(models.Model):
create_time = models.CharField(db_column='CREATETIME', max_length=200, null=True, blank=True)
is_predefined = models.IntegerField(db_column='ISPREDEFINED', default=0, null=True)
+
class NetworkInstModel(models.Model):
class Meta:
db_table = 'NETWORKINST'
@@ -196,6 +204,7 @@ class NetworkInstModel(models.Model):
routerExternal = models.IntegerField(db_column='ROUTEREXTERNAL', default=0, null=True)
nodeId = models.CharField(db_column='NODEID', max_length=255, null=True)
+
class SubNetworkInstModel(models.Model):
class Meta:
db_table = 'SUBNETWORKINST'
@@ -220,6 +229,7 @@ class SubNetworkInstModel(models.Model):
hostRoutes = models.TextField(db_column='HOSTROUTES', max_length=1024)
allocationPools = models.TextField(db_column='ALLOCATIONPOOLS', max_length=1024)
+
class VLInstModel(models.Model):
class Meta:
db_table = 'VLINST'
@@ -235,6 +245,7 @@ class VLInstModel(models.Model):
vimid = models.CharField(db_column='VIMID', max_length=255)
tenant = models.CharField(db_column='TENANT', max_length=50)
+
class PortInstModel(models.Model):
class Meta:
db_table = 'PORTINST'
@@ -266,6 +277,7 @@ class PortInstModel(models.Model):
is_predefined = models.IntegerField(db_column='ISPREDEFINED', default=0, null=True)
nodeId = models.CharField(db_column='NODEID', max_length=255, null=True)
+
class CPInstModel(models.Model):
class Meta:
db_table = 'CPINST'
diff --git a/lcm/lcm/pub/exceptions.py b/lcm/lcm/pub/exceptions.py
index 274c0d06..6249dd4e 100644
--- a/lcm/lcm/pub/exceptions.py
+++ b/lcm/lcm/pub/exceptions.py
@@ -12,6 +12,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-
class NFLCMException(Exception):
pass
diff --git a/lcm/lcm/pub/msapi/gvnfmdriver.py b/lcm/lcm/pub/msapi/gvnfmdriver.py
index 8449f6d3..5244da67 100644
--- a/lcm/lcm/pub/msapi/gvnfmdriver.py
+++ b/lcm/lcm/pub/msapi/gvnfmdriver.py
@@ -22,7 +22,7 @@ logger = logging.getLogger(__name__)
def get_packageinfo_by_vnfdid(vnfdid):
- ret = req_by_msb("api/gvnfmdriver/v1/vnfpackages", "GET") # TODO
+ ret = req_by_msb("api/gvnfmdriver/v1/vnfpackages", "GET")
if ret[0] != 0:
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
raise NFLCMException("Failed to query package_info of vnfdid(%s) from nslcm." % vnfdid)
diff --git a/lcm/lcm/pub/utils/values.py b/lcm/lcm/pub/utils/values.py
index 00cf5899..b5c5e90c 100644
--- a/lcm/lcm/pub/utils/values.py
+++ b/lcm/lcm/pub/utils/values.py
@@ -22,15 +22,19 @@ def ignore_case_get(args, key, def_val=""):
return args[old_key]
return def_val
+
def set_opt_val(param, key, val):
if val or val is False:
param[key] = val
+
def get_none(val, def_val=""):
return val if val else def_val
+
def get_boolean(val, def_val=0):
return 1 if val else 0
+
def get_integer(val, def_val=0):
return val if val else 0
diff --git a/lcm/lcm/wsgi.py b/lcm/lcm/wsgi.py
index 90b2e131..ed4edd16 100644
--- a/lcm/lcm/wsgi.py
+++ b/lcm/lcm/wsgi.py
@@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-
import os
from django.core.wsgi import get_wsgi_application