summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorying.yunlong <ying.yunlong@zte.com.cn>2017-09-29 11:02:30 +0800
committeryunlong ying <ying.yunlong@zte.com.cn>2017-09-29 05:14:52 +0000
commitf554dbb49c9ae6e10226716e38756fd29038be19 (patch)
treef65f134a95c421a16b1d576b5e01ad05824c8383
parentb38e9fb27f547e8a7dd7f8cd184337963bb4bce7 (diff)
Fix vfc-gvnfm-vnfres pep8 issues.
Change-Id: I90c332791a903cc8c536902501f6c8a2645b40bf Issue-ID: VFC-478 Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
-rw-r--r--res/res/pub/database/models.py2
-rw-r--r--res/res/pub/utils/enumutil.py1
-rw-r--r--res/res/pub/utils/values.py1
-rw-r--r--res/res/resources/tests.py30
-rw-r--r--res/res/resources/urls.py12
-rw-r--r--res/res/resources/views.py28
-rw-r--r--res/tox.ini2
7 files changed, 45 insertions, 31 deletions
diff --git a/res/res/pub/database/models.py b/res/res/pub/database/models.py
index 9642d2f..b809b4a 100644
--- a/res/res/pub/database/models.py
+++ b/res/res/pub/database/models.py
@@ -55,6 +55,7 @@ class CPInstModel(models.Model):
relatedcp = models.CharField(db_column='RELATEDCP', max_length=255, blank=True, null=True)
relatedport = models.CharField(db_column='RELATEDPORT', max_length=255, blank=True, null=True)
+
class StorageInstModel(models.Model):
class Meta:
db_table = 'STORAGEINST'
@@ -202,6 +203,7 @@ class VLInstModel(models.Model):
vimid = models.CharField(db_column='VIMID', max_length=255)
tenant = models.CharField(db_column='TENANT', max_length=50)
+
class VNFCInstModel(models.Model):
class Meta:
db_table = 'VNFCINST'
diff --git a/res/res/pub/utils/enumutil.py b/res/res/pub/utils/enumutil.py
index 9656f7d..48e4ffe 100644
--- a/res/res/pub/utils/enumutil.py
+++ b/res/res/pub/utils/enumutil.py
@@ -12,5 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+
def enum(**enums):
return type('Enum', (), enums)
diff --git a/res/res/pub/utils/values.py b/res/res/pub/utils/values.py
index 4adb7ba..0fd2d1a 100644
--- a/res/res/pub/utils/values.py
+++ b/res/res/pub/utils/values.py
@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+
def ignore_case_get(args, key, def_val=""):
if not key:
return def_val
diff --git a/res/res/resources/tests.py b/res/res/resources/tests.py
index b865ab6..c660e10 100644
--- a/res/res/resources/tests.py
+++ b/res/res/resources/tests.py
@@ -145,11 +145,11 @@ class ResourceTest(TestCase):
def tearDown(self):
pass
-
+
def test_get_vnf(self):
vnf_inst_id = "1"
NfInstModel(nfinstid=vnf_inst_id, nf_name='VNF1').save()
- StorageInstModel(storageid='s02', vimid='vim01', resouceid='resource01', insttype=1,\
+ StorageInstModel(storageid='s02', vimid='vim01', resouceid='resource01', insttype=1,
instid=vnf_inst_id, storagetype='desc01', size='ten').save()
response = self.client.get("/api/vnfres/v1/vnfs/%s" % vnf_inst_id)
self.failUnlessEqual(status.HTTP_200_OK, response.status_code)
@@ -158,7 +158,8 @@ class ResourceTest(TestCase):
def test_get_vnfs(self):
for i in range(1):
NfInstModel(nfinstid='%s' % i, nf_name='VNF%s' % i).save()
- StorageInstModel(storageid='s0%s' % i, vimid='vim0%s' % i, resouceid='resource0%s' % i, insttype=1, instid='%s' % i, storagetype='desc%s' % i, size='ten').save()
+ StorageInstModel(storageid='s0%s' % i, vimid='vim0%s' % i, resouceid='resource0%s' % i,
+ insttype=1, instid='%s' % i, storagetype='desc%s' % i, size='ten').save()
response = self.client.get("/api/vnfres/v1/vnfs")
self.failUnlessEqual(status.HTTP_200_OK, response.status_code)
@@ -166,7 +167,10 @@ class ResourceTest(TestCase):
NfInstModel(nfinstid='%s' % '01', nf_name='VFS%s' % '01').save()
nfInst = NfInstModel.objects.get(pk='01')
for i in range(1):
- VmInstModel(vmid='vm%s' % i, vimid='vim%s' % i, resouceid='res%s' % i, instid='%s' % nfInst.nfinstid, insttype=0, vmname='v1', nic_array='nic%s' % i, metadata='meta%s' % i, volume_array='volume%s' % i, server_group='server%s' % i, availability_zone='ava%s' %i, flavor_id='flavor%s' % i, security_groups='sec%s' % i).save()
+ VmInstModel(vmid='vm%s' % i, vimid='vim%s' % i, resouceid='res%s' % i, instid='%s' % nfInst.nfinstid,
+ insttype=0, vmname='v1', nic_array='nic%s' % i, metadata='meta%s' % i,
+ volume_array='volume%s' % i, server_group='server%s' % i, availability_zone='ava%s' % i,
+ flavor_id='flavor%s' % i, security_groups='sec%s' % i).save()
response = self.client.get("/api/vnfres/v1/%s/vms" % nfInst.nfinstid)
self.failUnlessEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual(self.vms_data, response.data)
@@ -175,36 +179,42 @@ class ResourceTest(TestCase):
NfInstModel(nfinstid='%s' % '01', nf_name='VFS%s' % '01').save()
nfInst = NfInstModel.objects.get(pk='01')
for i in range(1):
- FlavourInstModel(flavourid='fla%s' % i, name='fname%s' % i, vcpu='%d' % i, instid='%s' % nfInst.nfinstid, memory='%d' % i, extraspecs='ext%s' % i, vimid='vim%s' % i, resouceid='res%s' % i).save()
+ FlavourInstModel(flavourid='fla%s' % i, name='fname%s' % i, vcpu='%d' % i, instid='%s' % nfInst.nfinstid,
+ memory='%d' % i, extraspecs='ext%s' % i, vimid='vim%s' % i, resouceid='res%s' % i).save()
response = self.client.get("/api/vnfres/v1/%s/flavors" % nfInst.nfinstid)
self.failUnlessEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual(self.flavors_data, response.data)
def test_get_networks(self):
for i in range(1):
- NetworkInstModel(networkid='net%s' % i, name='net_name%s' % i, vimid='vim%s' % i, instid='%s' % self.nf_inst_id,
- resouceid='res%s' % i, insttype='%d' % i).save()
+ NetworkInstModel(networkid='net%s' % i, name='net_name%s' % i, vimid='vim%s' % i,
+ instid='%s' % self.nf_inst_id, resouceid='res%s' % i, insttype='%d' % i).save()
response = self.client.get("/api/vnfres/v1/%s/networks" % self.nf_inst_id)
self.failUnlessEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual(self.networks_data, response.data)
def test_get_subnets(self):
for i in range(1):
- SubNetworkInstModel(subnetworkid="sub%s" % i, vimid='vim%s' % i, resouceid='res%s' % i, networkid='net%s' % i, insttype='%d' % i, instid='%s' % self.nf_inst_id, name='sub_name%s' % i, cidr="cidr%s" % i).save()
+ SubNetworkInstModel(subnetworkid="sub%s" % i, vimid='vim%s' % i, resouceid='res%s' % i,
+ networkid='net%s' % i, insttype='%d' % i, instid='%s' % self.nf_inst_id,
+ name='sub_name%s' % i, cidr="cidr%s" % i).save()
response = self.client.get("/api/vnfres/v1/%s/subnets" % self.nf_inst_id)
self.failUnlessEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual(self.subnets_data, response.data)
def test_get_cps(self):
for i in range(1):
- CPInstModel(cpinstanceid="cp%s" % i, cpdid='cpd%s' % i, cpinstancename='cpinstname%s' % i, vlinstanceid='vlinst%s' % i, ownertype='%d' % i, ownerid='%s' % self.nf_inst_id, relatedtype='%d' % i).save()
+ CPInstModel(cpinstanceid="cp%s" % i, cpdid='cpd%s' % i, cpinstancename='cpinstname%s' % i,
+ vlinstanceid='vlinst%s' % i, ownertype='%d' % i, ownerid='%s' % self.nf_inst_id,
+ relatedtype='%d' % i).save()
response = self.client.get("/api/vnfres/v1/%s/cps" % self.nf_inst_id)
self.failUnlessEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual(self.cps_data, response.data)
def test_get_volumes(self):
for i in range(1):
- StorageInstModel(storageid="st%s" % i, vimid='vim%s' % i, resouceid='res%s' % i, insttype='%d' % i, instid='%s' % self.nf_inst_id, storagetype='stype%s' % i, size='%s' % i).save()
+ StorageInstModel(storageid="st%s" % i, vimid='vim%s' % i, resouceid='res%s' % i, insttype='%d' % i,
+ instid='%s' % self.nf_inst_id, storagetype='stype%s' % i, size='%s' % i).save()
response = self.client.get("/api/vnfres/v1/%s/volumes" % self.nf_inst_id)
self.assertEqual(self.volumes_data, response.data)
self.failUnlessEqual(status.HTTP_200_OK, response.status_code)
diff --git a/res/res/resources/urls.py b/res/res/resources/urls.py
index b855a60..32b6f2a 100644
--- a/res/res/resources/urls.py
+++ b/res/res/resources/urls.py
@@ -21,12 +21,12 @@ from res.resources.views import SwaggerJsonView
urlpatterns = [
url(r'^api/vnfres/v1/vnfs/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)$', views.get_vnf, name='get_vnf'),
url(r'^api/vnfres/v1/vnfs$', views.get_vnfs, name='get_vnfs'),
- url(r'^'+'api/vnfres/v1/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)/vms$', views.get_vms, name='get_vms'),
- url(r'^'+'api/vnfres/v1/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)/flavors$', views.get_flavors, name='get_flavors'),
- url(r'^'+'api/vnfres/v1/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)/networks$', views.get_networks, name='get_networks'),
- url(r'^'+'api/vnfres/v1/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)/subnets$', views.get_subnets, name='get_subnets'),
- url(r'^'+'api/vnfres/v1/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)/cps$', views.get_cps, name='get_cps'),
- url(r'^'+'api/vnfres/v1/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)/volumes$', views.get_volumes, name='get_volumes'),
+ url(r'^api/vnfres/v1/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)/vms$', views.get_vms, name='get_vms'),
+ url(r'^api/vnfres/v1/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)/flavors$', views.get_flavors, name='get_flavors'),
+ url(r'^api/vnfres/v1/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)/networks$', views.get_networks, name='get_networks'),
+ url(r'^api/vnfres/v1/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)/subnets$', views.get_subnets, name='get_subnets'),
+ url(r'^api/vnfres/v1/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)/cps$', views.get_cps, name='get_cps'),
+ url(r'^api/vnfres/v1/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)/volumes$', views.get_volumes, name='get_volumes'),
url(r'^api/vnfres/v1/swagger.json$', SwaggerJsonView.as_view()),
]
diff --git a/res/res/resources/views.py b/res/res/resources/views.py
index 65259e0..7356089 100644
--- a/res/res/resources/views.py
+++ b/res/res/resources/views.py
@@ -68,13 +68,13 @@ def fill_resp_data(vnf):
if not net:
raise VNFRESException('NetworkInst(%s) does not exist.' % v.relatednetworkid)
v_dic = {
- "virtualLinkInstanceId": v.vlinstanceid,
- "virtualLinkDescId": v.vldid,
- "networkResource": {
- "vimId": net[0].vimid,
- "resourceId": net[0].resouceid
- }
- }
+ "virtualLinkInstanceId": v.vlinstanceid,
+ "virtualLinkDescId": v.vldid,
+ "networkResource": {
+ "vimId": net[0].vimid,
+ "resourceId": net[0].resouceid
+ }
+ }
vl_arr.append(v_dic)
logger.info('Get VNFCInstModel of list.')
vnfc_insts = VNFCInstModel.objects.filter(instid=vnf.nfinstid)
@@ -87,13 +87,13 @@ def fill_resp_data(vnf):
if not storage:
raise VNFRESException('StorageInst(%s) does not exist.' % vm[0].vmid)
vnfc_dic = {
- "vnfcInstanceId": vnfc.vnfcinstanceid,
- "vduId": vnfc.vduid,
- "computeResource": {
- "vimId": vm[0].vimid,
- "resourceId": vm[0].resouceid
- },
- "storageResourceIds": [s.storageid for s in storage]
+ "vnfcInstanceId": vnfc.vnfcinstanceid,
+ "vduId": vnfc.vduid,
+ "computeResource": {
+ "vimId": vm[0].vimid,
+ "resourceId": vm[0].resouceid
+ },
+ "storageResourceIds": [s.storageid for s in storage]
}
vnfc_arr.append(vnfc_dic)
logger.info('Get the VimInstModel of list.')
diff --git a/res/tox.ini b/res/tox.ini
index 42f8d9f..cbc09b6 100644
--- a/res/tox.ini
+++ b/res/tox.ini
@@ -6,7 +6,7 @@ skipsdist = true
downloadcache = ~/cache/pip
[flake8]
-ignore = E501,E226,E126,W293,E502,E225,E302
+ignore = E501
max-complexity = 12
[testenv]