summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorying.yunlong <ying.yunlong@zte.com.cn>2017-02-28 10:02:20 +0800
committerying.yunlong <ying.yunlong@zte.com.cn>2017-02-28 10:02:20 +0800
commit27c0765c2cc92ee84a83040c4963cceec9f84b05 (patch)
tree267941c65b62a60528a2a25a0068c8a267c79613
parentdd3cd3e422b6bc2798aa826f6315c26c913433bf (diff)
Modify code and models of gvnfm vnfres
Change-Id: Ia351bb36eb095c07dc3a4a4272692b9c15a5fe57 Issue-Id: GVNFM-12 Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
-rw-r--r--res/res/pub/database/models.py214
-rw-r--r--res/res/resources/swagger.json17
-rw-r--r--res/res/resources/tests.py70
-rw-r--r--res/res/resources/urls.py12
-rw-r--r--res/res/resources/views.py78
5 files changed, 212 insertions, 179 deletions
diff --git a/res/res/pub/database/models.py b/res/res/pub/database/models.py
index 919ee6b..5c8c62c 100644
--- a/res/res/pub/database/models.py
+++ b/res/res/pub/database/models.py
@@ -19,40 +19,19 @@ class NfInstModel(models.Model):
db_table = 'NFINST'
nfinstid = models.CharField(db_column='NFINSTID', max_length=200, primary_key=True)
- mnfinstid = models.CharField(db_column='M_NFINSTID', max_length=200, blank=True, null=True)
- nf_name = models.CharField(db_column='NFNAME', max_length=100, blank=True, null=True) #CreateVnfRequest.vnfInstanceName
- template_id = models.CharField(db_column='TEMPLATEID', max_length=200, blank=True, null=True)
- vnf_id = models.CharField(db_column='VNFID', max_length=200, blank=True, null=True)
+ nf_name = models.CharField(db_column='NFNAME', max_length=100, blank=True, null=True) # CreateVnfRequest.vnfInstanceName
package_id = models.CharField(db_column='PACKAGEID', max_length=200, blank=True, null=True)
- vnfm_inst_id = models.CharField(db_column='VNFMINSTID', max_length=200, blank=True, null=True)
- multivim = models.IntegerField(db_column='MULTIVIM', default=0)
- ns_inst_id = models.CharField(db_column='NSINSTID', max_length=200, blank=True, null=True)
status = models.CharField(db_column='STATUS', max_length=20, blank=True, null=True)
- flavour_id = models.CharField(db_column='FLAVOURID', max_length=200, blank=True, null=True) #InstantiateVnfRequest.flavourId
- vnf_level = models.CharField(db_column='VNFLEVEL', max_length=200, blank=True, null=True) #InstantiateVnfRequest.instantiationLevelId
+ flavour_id = models.CharField(db_column='FLAVOURID', max_length=200, blank=True, null=True) # InstantiateVnfRequest.flavourId
location = models.CharField(db_column='LOCATION', max_length=200, blank=True, null=True)
- deploy_environment = models.CharField(db_column='DEPLOYENVIRONMENT', max_length=100, blank=True, null=True)
- max_vm = models.IntegerField(db_column='MAXVM', blank=True, null=True)
- max_cpu = models.IntegerField(db_column='MAXCPU', blank=True, null=True)
- max_ram = models.IntegerField(db_column='MAXRAM', blank=True, null=True)
- max_hd = models.IntegerField(db_column='MAXHD', blank=True, null=True)
- max_shd = models.IntegerField(db_column='MAXSHD', blank=True, null=True)
- max_net = models.IntegerField(db_column='MAXNET', blank=True, null=True)
version = models.CharField(db_column='VERSION', max_length=255, null=True)
vendor = models.CharField(db_column='VENDOR', max_length=255, null=True, blank=True)
- producttype = models.CharField(db_column='PRODUCTTYPE', max_length=255, null=True)
netype = models.CharField(db_column='NETYPE', max_length=255, null=True)
vnfd_model = models.TextField(db_column='VNFDMODEL', max_length=20000, blank=True, null=True)
- input_params = models.TextField(db_column='INPUTPARAMS', max_length=2000, blank=True, null=True) #InstantiateVnfRequest.additionalParams
- scale_params = models.TextField(db_column='SCALEPARAMS', max_length=2000, null=True, blank=True)
+ input_params = models.TextField(db_column='INPUTPARAMS', max_length=2000, blank=True, null=True) # InstantiateVnfRequest.additionalParams
create_time = models.CharField(db_column='CREATETIME', max_length=200, null=True, blank=True)
lastuptime = models.CharField(db_column='LASTUPTIME', max_length=200, blank=True, null=True)
- extension = models.TextField(db_column='EXTENSION', max_length=65535, blank=True, null=True)
- initallocatedata = models.TextField(db_column='INITALLOCATEDATA', max_length=20000, blank=True, null=True)
- predefinedvm = models.TextField(db_column='PREDEFINEDVM', max_length=65535, blank=True, null=True)
- vnfextendtype = models.CharField(db_column='VNFEXTENDTYPE', max_length=255, null=True)
- instantiationState = models.CharField(db_column='INSTANTIATIONSTATE', max_length=200, blank=True, null=True)
nf_desc = models.CharField(db_column='VNFINSTANCEDESC', max_length=200, blank=True, null=True)
vnfdid = models.CharField(db_column='VNFDID', max_length=200, blank=True, null=True)
vnfSoftwareVersion = models.CharField(db_column='VNFSOFTWAREVER', max_length=200, blank=True, null=True)
@@ -60,6 +39,48 @@ class NfInstModel(models.Model):
localizationLanguage = models.CharField(db_column='LOCALIZATIONLANGUAGE', max_length=255, null=True)
+# class JobModel(models.Model):
+# class Meta:
+# db_table = 'JOB'
+#
+# _database = 'job'
+#
+# jobid = models.CharField(db_column='JOBID', primary_key=True, max_length=255)
+# jobtype = models.CharField(db_column='JOBTYPE', max_length=255)
+# jobaction = models.CharField(db_column='JOBACTION', max_length=255)
+# resid = models.CharField(db_column='RESID', max_length=255)
+# status = models.IntegerField(db_column='STATUS', null=True, blank=True)
+# starttime = models.CharField(db_column='STARTTIME', max_length=255, null=True, blank=True)
+# endtime = models.CharField(db_column='ENDTIME', max_length=255, null=True, blank=True)
+# progress = models.IntegerField(db_column='PROGRESS', null=True, blank=True)
+# user = models.CharField(db_column='USER', max_length=255, null=True, blank=True)
+# parentjobid = models.CharField(db_column='PARENTJOBID', max_length=255, null=True, blank=True)
+# resname = models.CharField(db_column='RESNAME', max_length=255, null=True, blank=True)
+#
+# def toJSON(self):
+# 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'
+#
+# _database = 'job'
+#
+# indexid = models.IntegerField(db_column='INDEXID')
+# jobid = models.CharField(db_column='JOBID', max_length=255)
+# status = models.CharField(db_column='STATUS', max_length=255)
+# progress = models.IntegerField(db_column='PROGRESS', null=True, blank=True)
+# descp = models.TextField(db_column='DESCP', max_length=1024)
+# errcode = models.CharField(db_column='ERRCODE', max_length=255, null=True, blank=True)
+# addtime = models.CharField(db_column='ADDTIME', max_length=255, null=True, blank=True)
+#
+# def toJSON(self):
+# import json
+# return json.dumps(dict([(attr, getattr(self, attr)) for attr in [f.name for f in self._meta.fields]]))
+
+
class CPInstModel(models.Model):
class Meta:
db_table = 'CPINST'
@@ -85,17 +106,18 @@ class StorageInstModel(models.Model):
insttype = models.IntegerField(db_column='INSTTYPE')
instid = models.CharField(db_column='INSTID', max_length=255)
name = models.CharField(db_column='NAME', max_length=255, null=True)
- storageDesc = models.CharField(db_column='STORAGEDESC', max_length=255, null=True)
storagetype = models.CharField(db_column='STORAGETYPE', max_length=255)
size = models.CharField(db_column='SIZE', max_length=255)
- rdmaenabled = models.IntegerField(db_column='RDMAENABLED', null=True)
- disktype = models.CharField(db_column='DISKTYPE', max_length=255)
- ownerid = models.CharField(db_column='OWNERID', max_length=255, null=True)
- zoneid = models.CharField(db_column='ZONEID', max_length=255, null=True)
- hostid = models.CharField(db_column='HOSTID', max_length=255, null=True)
- operationalstate = models.CharField(db_column='OPERATIONALSTATE', max_length=255, null=True)
+ # rdmaenabled = models.IntegerField(db_column='RDMAENABLED', null=True)
+ # disktype = models.CharField(db_column='DISKTYPE', max_length=255)
+ # ownerid = models.CharField(db_column='OWNERID', max_length=255, null=True)
+ # zoneid = models.CharField(db_column='ZONEID', max_length=255, null=True)
+ # hostid = models.CharField(db_column='HOSTID', max_length=255, null=True)
+ # operationalstate = models.CharField(db_column='OPERATIONALSTATE', max_length=255, null=True)
tenant = models.CharField(db_column='TENANT', max_length=50, null=True)
is_predefined = models.IntegerField(db_column='ISPREDEFINED', default=0, null=True)
+ 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 NetworkInstModel(models.Model):
@@ -109,7 +131,6 @@ class NetworkInstModel(models.Model):
instid = models.CharField(db_column='INSTID', max_length=255)
name = models.CharField(db_column='NAME', max_length=255)
tenant = models.CharField(db_column='TENANT', max_length=255, null=True)
- is_shared = models.IntegerField(db_column='ISSHARED', default=0, null=True)
is_predefined = models.IntegerField(db_column='ISPREDEFINED', default=0, null=True)
desc = models.CharField(db_column='DESC', max_length=255, null=True)
vendor = models.CharField(db_column='VENDOR', max_length=255, null=True)
@@ -117,8 +138,13 @@ class NetworkInstModel(models.Model):
mtu = models.IntegerField(db_column='MTU', null=True)
network_type = models.CharField(db_column='NETWORKTYPE', max_length=255, null=True)
segmentid = models.CharField(db_column='SEGMENTID', max_length=255, null=True)
- vlantrans = models.IntegerField(db_column='VLANTRANS', null=True)
networkqos = models.CharField(db_column='NETWORKQOS', max_length=255, null=True)
+ create_time = models.CharField(db_column='CREATETIME', max_length=200, null=True, blank=True)
+ physicalNetwork = models.CharField(db_column='PHYNETWORK', max_length=255, null=True)
+ is_shared = models.IntegerField(db_column='ISSHARED', default=0, null=True)
+ vlantrans = models.IntegerField(db_column='VLANTRANS', null=True)
+ 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):
@@ -140,6 +166,10 @@ class SubNetworkInstModel(models.Model):
operationalstate = models.CharField(db_column='OPERATIONALSTATE', max_length=255, null=True)
tenant = models.CharField(db_column='TENANT', max_length=255, null=True)
is_predefined = models.IntegerField(db_column='ISPREDEFINED', default=0, null=True)
+ create_time = models.CharField(db_column='CREATETIME', max_length=200, null=True, blank=True)
+ dnsNameservers = models.TextField(db_column='DNSNAMESERVERS', max_length=1024)
+ hostRoutes = models.TextField(db_column='HOSTROUTES', max_length=1024)
+ allocationPools = models.TextField(db_column='ALLOCATIONPOOLS', max_length=1024)
class PortInstModel(models.Model):
@@ -168,18 +198,10 @@ class PortInstModel(models.Model):
tenant = models.CharField(db_column='TENANT', max_length=255, null=True)
interfacename = models.CharField(db_column='INTERFACENAME', max_length=255, blank=True, null=True)
vmid = models.CharField(db_column='VMID', max_length=255, blank=True, null=True)
-
-
-class FlavourInstModel(models.Model):
- class Meta:
- db_table = 'FLAVOURINST'
-
- flavourid = models.CharField(db_column='FLAVOURID', max_length=255, primary_key=True)
- name = models.CharField(db_column='NAME', max_length=255)
- vcpu = models.CharField(db_column='VCPU', max_length=255)
- memory = models.CharField(db_column='MEMORY', max_length=255)
- extraspecs = models.CharField(db_column='EXTRASPECS', max_length=255)
- instid = models.CharField(db_column='INSTID', max_length=255)
+ create_time = models.CharField(db_column='CREATETIME', max_length=200, null=True, blank=True)
+ securityGroups = models.CharField(db_column='SECURITYGROUPS', max_length=255)
+ is_predefined = models.IntegerField(db_column='ISPREDEFINED', default=0, null=True)
+ nodeId = models.CharField(db_column='NODEID', max_length=255, null=True)
class VmInstModel(models.Model):
@@ -188,16 +210,23 @@ class VmInstModel(models.Model):
vmid = models.CharField(db_column='VMID', primary_key=True, max_length=255)
vimid = models.CharField(db_column='VIMID', max_length=255)
+ tenant = models.CharField(db_column='TENANT', max_length=255, null=True)
resouceid = models.CharField(db_column='RESOURCEID', max_length=255)
- insttype = models.IntegerField(db_column='INSTTYPE')
- instid = models.CharField(db_column='INSTID', max_length=255)
vmname = models.CharField(db_column='VMNAME', max_length=255)
- operationalstate = models.IntegerField(db_column='OPERATIONALSTATE', null=True)
- zoneid = models.CharField(db_column='ZONEID', max_length=255, null=True)
- tenant = models.CharField(db_column='TENANT', max_length=255, null=True)
- hostid = models.CharField(db_column='HOSTID', max_length=255, null=True)
- detailinfo = models.CharField(db_column='DETAILINFO', max_length=8192, null=True)
+ nic_array = models.CharField(db_column='NICARRAY', max_length=255)
+ metadata = models.CharField(db_column='METADATA', max_length=255)
+ volume_array = models.CharField(db_column='VOLUMEARRAY', max_length=255)
+ server_group = models.CharField(db_column='SERVERGROUP', max_length=255)
+ availability_zone = models.CharField(db_column='AVAILABILITYZONE', max_length=255)
+ flavor_id = models.CharField(db_column='FLAVORID', max_length=255)
+ security_groups = models.CharField(db_column='SECURITYGROUPS', max_length=255)
+ operationalstate = models.CharField(db_column='OPERATIONALSTATE', max_length=255, null=True)
+ insttype = models.IntegerField(db_column='INSTTYPE')
is_predefined = models.IntegerField(db_column='ISPREDEFINED', default=0, null=True)
+ create_time = models.CharField(db_column='CREATETIME', max_length=200, null=True, blank=True)
+ instid = models.CharField(db_column='INSTID', max_length=255)
+ nodeId = models.CharField(db_column='NODEID', max_length=255, null=True)
+
class VLInstModel(models.Model):
class Meta:
@@ -221,42 +250,43 @@ class VNFCInstModel(models.Model):
vnfcinstanceid = models.CharField(db_column='VNFCINSTANCEID', max_length=255, primary_key=True)
vduid = models.CharField(db_column='VDUID', max_length=255)
vdutype = models.CharField(db_column='VDUTYPE', max_length=255)
- nfinstid = models.CharField(db_column='NFINSTID', max_length=255)
+ instid = models.CharField(db_column='NFINSTID', max_length=255)
vmid = models.CharField(db_column='VMID', max_length=255)
+ is_predefined = models.IntegerField(db_column='ISPREDEFINED', default=0, null=True)
-class VimModel(models.Model):
- vimid = models.IntegerField(db_column='CMSERVERID', primary_key=True)
- name = models.CharField(db_column='NAME', max_length=255, blank=True, null=True)
- type = models.CharField(db_column='CMSTYPE', max_length=255, blank=True, null=True)
- imageurl = models.CharField(db_column='IMAGEURL', max_length=1024, blank=True, null=True)
- apiurl = models.CharField(db_column='APIURL', max_length=1024, blank=True, null=True)
- version = models.CharField(db_column='VER', max_length=1024, blank=True, null=True)
- supportnotification = models.IntegerField(db_column='SUPPORTNOTIFICATION', default=0)
- longitude = models.CharField(db_column='LONGITUDE', max_length=1024, blank=True, null=True)
- latitude = models.CharField(db_column='LATITUDE', max_length=1024, blank=True, null=True)
- grantexclude = models.CharField(db_column='GRANTEXCLUDE', max_length=1, default='0', blank=True, null=True)
- slalevel = models.IntegerField(db_column='SLALEVEL', default=0)
-
- class Meta:
- db_table = 'CMSSERVER'
-
- def __unicode__(self):
- return '%s' % self.name
-
-
-class VimUserModel(models.Model):
- class Meta:
- db_table = 'CMSSERVER_USER'
-
- uuid = models.CharField(db_column='UUID', primary_key=True, max_length=255)
- vimid = models.IntegerField(db_column='CMSERVERID')
- username = models.CharField(db_column='USERNAME', max_length=255)
- password = models.CharField(db_column='PWD', max_length=255, blank=True)
- defaulttenant = models.CharField(db_column='TENANT', max_length=255, blank=True)
-
- def __unicode__(self):
- return '%s' % self.username
+# class VimModel(models.Model):
+# vimid = models.IntegerField(db_column='CMSERVERID', primary_key=True)
+# name = models.CharField(db_column='NAME', max_length=255, blank=True, null=True)
+# type = models.CharField(db_column='CMSTYPE', max_length=255, blank=True, null=True)
+# imageurl = models.CharField(db_column='IMAGEURL', max_length=1024, blank=True, null=True)
+# apiurl = models.CharField(db_column='APIURL', max_length=1024, blank=True, null=True)
+# version = models.CharField(db_column='VER', max_length=1024, blank=True, null=True)
+# supportnotification = models.IntegerField(db_column='SUPPORTNOTIFICATION', default=0)
+# longitude = models.CharField(db_column='LONGITUDE', max_length=1024, blank=True, null=True)
+# latitude = models.CharField(db_column='LATITUDE', max_length=1024, blank=True, null=True)
+# grantexclude = models.CharField(db_column='GRANTEXCLUDE', max_length=1, default='0', blank=True, null=True)
+# slalevel = models.IntegerField(db_column='SLALEVEL', default=0)
+#
+# class Meta:
+# db_table = 'CMSSERVER'
+#
+# def __unicode__(self):
+# return '%s' % self.name
+#
+#
+# class VimUserModel(models.Model):
+# class Meta:
+# db_table = 'CMSSERVER_USER'
+#
+# uuid = models.CharField(db_column='UUID', primary_key=True, max_length=255)
+# vimid = models.IntegerField(db_column='CMSERVERID')
+# username = models.CharField(db_column='USERNAME', max_length=255)
+# password = models.CharField(db_column='PWD', max_length=255, blank=True)
+# defaulttenant = models.CharField(db_column='TENANT', max_length=255, blank=True)
+#
+# def __unicode__(self):
+# return '%s' % self.username
class FlavourInstModel(models.Model):
@@ -264,14 +294,20 @@ class FlavourInstModel(models.Model):
db_table = 'FLAVOURINST'
flavourid = models.CharField(db_column='FLAVOURID', max_length=255, primary_key=True)
+ vimid = models.CharField(db_column='VIMID', max_length=255)
+ resouceid = models.CharField(db_column='RESOURCEID', max_length=255)
name = models.CharField(db_column='NAME', max_length=255)
- vcpu = models.CharField(db_column='VCPU', max_length=255)
- memory = models.CharField(db_column='MEMORY', max_length=255)
+ tenant = models.CharField(db_column='TENANT', max_length=255, null=True)
+ vcpu = models.IntegerField(db_column='VCPU', null=True)
+ memory = models.IntegerField(db_column='MEMORY', null=True)
+ disk = models.IntegerField(db_column='DISK', null=True)
+ ephemeral = models.IntegerField(db_column='EPHEMERAL', null=True)
+ swap = models.IntegerField(db_column='SWAP', null=True)
+ isPublic = models.IntegerField(db_column='ISPUBLIC', null=True)
extraspecs = models.CharField(db_column='EXTRASPECS', max_length=255)
instid = models.CharField(db_column='INSTID', max_length=255)
- tenant = models.CharField(db_column='TENANT', max_length=255, null=True)
- vmid = models.CharField(db_column='VMID', max_length=255)
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)
def __unicode__(self):
return '%s' % self.name
diff --git a/res/res/resources/swagger.json b/res/res/resources/swagger.json
index 54983ed..61d00e4 100644
--- a/res/res/resources/swagger.json
+++ b/res/res/resources/swagger.json
@@ -458,18 +458,18 @@
"type": "string"
},
"operationalstate": {
- "type": "integer"
+ "type": "string"
},
- "zoneid": {
+ "availability_zone": {
"type": "string"
},
"tenant": {
"type": "string"
},
- "hostid": {
+ "nodeId": {
"type": "string"
},
- "detailinfo": {
+ "metadata": {
"type": "string"
},
"is_predefined": {
@@ -490,10 +490,10 @@
"type": "string"
},
"vcpu": {
- "type": "string"
+ "type": "integer"
},
"memory": {
- "type": "string"
+ "type": "integer"
},
"extraspecs": {
"type": "string"
@@ -504,7 +504,7 @@
"tenant": {
"type": "string"
},
- "vmid": {
+ "vimid": {
"type": "string"
},
"create_time": {
@@ -625,9 +625,6 @@
},
"size": {
"type": "string"
- },
- "disktype": {
- "type": "string"
}
}
}
diff --git a/res/res/resources/tests.py b/res/res/resources/tests.py
index 8ce9550..2ab5a0a 100644
--- a/res/res/resources/tests.py
+++ b/res/res/resources/tests.py
@@ -43,7 +43,7 @@ class ResourceTest(TestCase):
"extVirtualLink": [],
"monitoringParameters": {},
"localizationLanguage": None,
- "vimInfo": [],
+ "vmInfo": [],
"vnfcResourceInfo": [],
"virtualLinkResourceInfo": [],
"virtualStorageResourceInfo": [
@@ -70,23 +70,28 @@ class ResourceTest(TestCase):
"instid": u"01",
"vmname": u"v1",
"operationalstate": None,
- "zoneid": None,
"tenant": None,
- "hostid": None,
- "detailinfo": None,
- "is_predefined": 0
+ "is_predefined": 0,
+ "security_groups": 'sec0',
+ "flavor_id": 'flavor0',
+ "availability_zone": 'ava0',
+ "server_group": 'server0',
+ "volume_array": 'volume0',
+ "metadata": 'meta0',
+ "nic_array": 'nic0'
}]
}
self.flavors_data = {
"resp_data": [{
"flavourid": "fla0",
"name": "fname0",
- "vcpu": "cpu0",
- "memory": "mem0",
+ "vcpu": 0,
+ "memory": 0,
"extraspecs": "ext0",
"instid": "01",
"tenant": None,
- "vmid": "vm0",
+ "vimid": "vim0",
+ "resouceid": 'res0',
"create_time": None
}]
}
@@ -124,6 +129,7 @@ class ResourceTest(TestCase):
"relatedtype": 0
}]
}
+
self.volumes_data = {
"resp_data": [{
"storageid": "st0",
@@ -132,8 +138,7 @@ class ResourceTest(TestCase):
"insttype": 0,
"instid": "01",
"storagetype": "stype0",
- "size": "0",
- "disktype": "disk0"
+ "size": "0"
}]
}
@@ -143,77 +148,68 @@ class ResourceTest(TestCase):
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,
- instid=vnf_inst_id, storageDesc='desc01').save()
+ StorageInstModel(storageid='s02', vimid='vim01', resouceid='resource01', insttype=1,\
+ instid=vnf_inst_id, storagetype='desc01', size='ten').save()
response = self.client.get("/openoapi/vnfres/v1/vnfs/%s" % vnf_inst_id)
self.failUnlessEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual(self.test_data, response.data)
+
def test_get_vnfs(self):
- for i in range(1, 5):
+ 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, storageDesc='desc%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()
response = self.client.get("/openoapi/vnfres/v1/vnfs")
self.failUnlessEqual(status.HTTP_200_OK, response.status_code)
# self.assertEqual(self.test_data, response.data)
def test_get_vms(self):
NfInstModel(nfinstid='%s' % '01', nf_name='VFS%s' % '01').save()
- nfinst = NfInstModel.objects.get(pk='01')
+ 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').save()
- response = self.client.get("/openoapi/vnfres/v1/%s/vms" % nfinst.nfinstid)
+ 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("/openoapi/vnfres/v1/%s/vms" % nfInst.nfinstid)
self.failUnlessEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual(self.vms_data, response.data)
def test_get_flavors(self):
NfInstModel(nfinstid='%s' % '01', nf_name='VFS%s' % '01').save()
- nfinst = NfInstModel.objects.get(pk='01')
+ nfInst = NfInstModel.objects.get(pk='01')
for i in range(1):
- FlavourInstModel(flavourid='fla%s' % i, name='fname%s' % i, vcpu='cpu%s' % i,
- instid='%s' % nfinst.nfinstid, memory='mem%s' % i,
- extraspecs='ext%s' % i, vmid='vm%s' % i).save()
- response = self.client.get("/openoapi/vnfres/v1/%s/flavors" % nfinst.nfinstid)
+ 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("/openoapi/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("/openoapi/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("/openoapi/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("/openoapi/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,
- disktype='disk%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("/openoapi/vnfres/v1/%s/volumes" % self.nf_inst_id)
- self.failUnlessEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual(self.volumes_data, response.data)
+ self.failUnlessEqual(status.HTTP_200_OK, response.status_code)
def test_swagger_ok(self):
resp = self.client.get("/openoapi/vnfres/v1/swagger.json", format='json')
- self.assertEqual(resp.status_code, status.HTTP_200_OK)
+ self.assertEqual(resp.status_code, status.HTTP_200_OK, resp.content) \ No newline at end of file
diff --git a/res/res/resources/urls.py b/res/res/resources/urls.py
index 6d7c792..76a39a1 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'^openoapi/vnfres/v1/vnfs/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)$', views.get_vnf, name='get_vnf'),
url(r'^openoapi/vnfres/v1/vnfs$', views.get_vnfs, name='get_vnfs'),
- url(r'^openoapi/vnfres/v1/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)/vms$', views.get_vms, name='get_vms'),
- url(r'^openoapi/vnfres/v1/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)/flavors$', views.get_flavors, name='get_flavors'),
- url(r'^openoapi/vnfres/v1/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)/networks$', views.get_networks, name='get_networks'),
- url(r'^openoapi/vnfres/v1/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)/subnets$', views.get_subnets, name='get_subnets'),
- url(r'^openoapi/vnfres/v1/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)/cps$', views.get_cps, name='get_cps'),
- url(r'^openoapi/vnfres/v1/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)/volumes$', views.get_volumes, name='get_volumes'),
+ url(r'^'+'openoapi/vnfres/v1/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)/vms$', views.get_vms, name='get_vms'),
+ url(r'^'+'openoapi/vnfres/v1/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)/flavors$', views.get_flavors, name='get_flavors'),
+ url(r'^'+'openoapi/vnfres/v1/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)/networks$', views.get_networks, name='get_networks'),
+ url(r'^'+'openoapi/vnfres/v1/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)/subnets$', views.get_subnets, name='get_subnets'),
+ url(r'^'+'openoapi/vnfres/v1/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)/cps$', views.get_cps, name='get_cps'),
+ url(r'^'+'openoapi/vnfres/v1/(?P<vnfInstanceId>[0-9a-zA-Z\-\_]+)/volumes$', views.get_volumes, name='get_volumes'),
url(r'^openoapi/vnfres/v1/swagger.json$', SwaggerJsonView.as_view()),
]
diff --git a/res/res/resources/views.py b/res/res/resources/views.py
index cfbe8c5..38de8e1 100644
--- a/res/res/resources/views.py
+++ b/res/res/resources/views.py
@@ -25,7 +25,7 @@ from res.pub.exceptions import VNFRESException
from res.pub.utils.values import ignore_case_get
from res.pub.utils.syscomm import fun_name
from res.pub.database.models import NfInstModel, StorageInstModel, NetworkInstModel, VLInstModel, \
- VNFCInstModel, VmInstModel, VimModel, VimUserModel, FlavourInstModel, SubNetworkInstModel, CPInstModel
+ VNFCInstModel, VmInstModel, FlavourInstModel, SubNetworkInstModel, CPInstModel
logger = logging.getLogger(__name__)
@@ -52,7 +52,7 @@ def fill_resp_data(vnf):
for s in storage_inst:
storage = {
"virtualStorageInstanceId": s.storageid,
- "virtualStorageDescId": s.storageDesc,
+ "virtualStorageDescId": s.storagetype,
"storageResource": {
"vimId": s.vimid,
"resourceId": s.resouceid
@@ -76,7 +76,7 @@ def fill_resp_data(vnf):
}
vl_arr.append(v_dic)
logger.info('Get VNFCInstModel of list.')
- vnfc_insts = VNFCInstModel.objects.filter(nfinstid=vnf.nfinstid)
+ vnfc_insts = VNFCInstModel.objects.filter(instid=vnf.nfinstid)
vnfc_arr = []
for vnfc in vnfc_insts:
vm = VmInstModel.objects.filter(vmid=vnfc.vmid)
@@ -97,28 +97,30 @@ def fill_resp_data(vnf):
vnfc_arr.append(vnfc_dic)
logger.info('Get the VimInstModel of list.')
vms = VmInstModel.objects.filter(instid=vnf.nfinstid)
- vim_arr = []
+ vm_arr = []
# The 'vimInfoId' and 'vimId' each value are same
for vm in vms:
- vims = VimModel.objects.filter(vimid=vm.vimid)
- for vim in vims:
- vim_users = VimUserModel.objects.filter(vimid=vim.vimid)
- vim_dic = {
- "vimInfoId": vim.vimid,
- "vimId": vim.vimid,
- "interfaceInfo": {
- "vimType": vim.type,
- "apiVersion": vim.version,
- "protocolType": (vim.apiurl.split(':')[0] if vim.apiurl and vim.apiurl.index(':') else 'http')
- },
- "accessInfo": {
- "tenant": (vim_users[0].defaulttenant if vim_users and vim_users[0].defaulttenant else ''),
- "username": (vim_users[0].username if vim_users and vim_users[0].username else ''),
- "password": (vim_users[0].password if vim_users and vim_users[0].password else '')
- },
- "interfaceEndpoint": vim.apiurl
- }
- vim_arr.append(vim_dic)
+ vm_dic = {
+ "vmid": vm.vmid,
+ "vimid": vm.vimid,
+ "tenant": vm.tenant,
+ "resouceid": vm.resouceid,
+ "vmname": vm.vmname,
+ "nic_array": vm.nic_array,
+ "metadata": vm.metadata,
+ "volume_array": vm.volume_array,
+ "server_group": vm.server_group,
+ "availability_zone": vm.availability_zone,
+ "flavor_id": vm.flavor_id,
+ "security_groups": vm.security_groups,
+ "operationalstate": vm.operationalstate,
+ "insttype": vm.insttype,
+ "is_predefined": vm.is_predefined,
+ "create_time": vm.create_time,
+ "instid": vm.instid,
+ "nodeId": vm.nodeId
+ }
+ vm_arr.append(vm_dic)
resp_data = {
"vnfInstanceId": vnf.nfinstid,
@@ -129,9 +131,9 @@ def fill_resp_data(vnf):
"vnfdVersion": vnf.version,
"vnfSoftwareVersion": vnf.vnfSoftwareVersion,
"vnfProvider": vnf.vendor,
- "vnfProductName": vnf.producttype,
+ "vnfProductName": vnf.netype,
"vnfConfigurableProperties": {vnf.vnfConfigurableProperties},
- "instantiationState": vnf.instantiationState,
+ "instantiationState": vnf.status,
"instantiatedVnfInfo": {
"flavourId": vnf.flavour_id,
"vnfState": vnf.status,
@@ -140,13 +142,13 @@ def fill_resp_data(vnf):
"extVirtualLink": [],
"monitoringParameters": {},
"localizationLanguage": vnf.localizationLanguage,
- "vimInfo": vim_arr,
+ "vmInfo": vm_arr,
"vnfcResourceInfo": vnfc_arr,
"virtualLinkResourceInfo": vl_arr,
"virtualStorageResourceInfo": arr
},
"metadata": vnf.input_params,
- "extensions": vnf.extension
+ "extensions": vnf.vnfd_model
}
return resp_data
@@ -193,11 +195,15 @@ def fill_vms_data(vm):
"instid": vm.instid,
"vmname": vm.vmname,
"operationalstate": vm.operationalstate,
- "zoneid": vm.zoneid,
"tenant": vm.tenant,
- "hostid": vm.hostid,
- "detailinfo": vm.detailinfo,
- "is_predefined": vm.is_predefined
+ "is_predefined": vm.is_predefined,
+ "security_groups": vm.security_groups,
+ "flavor_id": vm.flavor_id,
+ "availability_zone": vm.availability_zone,
+ "server_group": vm.server_group,
+ "volume_array": vm.volume_array,
+ "metadata": vm.metadata,
+ "nic_array": vm.nic_array
}
return vms_data
@@ -228,12 +234,12 @@ def fill_flavours_data(f):
"extraspecs": f.extraspecs,
"instid": f.instid,
"tenant": f.tenant,
- "vmid": f.vmid,
+ "vimid": f.vimid,
+ "resouceid": f.resouceid,
"create_time": f.create_time
}
return flavours_data
-
@api_view(http_method_names=['GET'])
def get_networks(request, *args, **kwargs):
logger.debug("Query all the networks by vnfInstanceId[%s]", fun_name())
@@ -334,7 +340,6 @@ def fill_cps_data(cp):
}
return cps_data
-
@api_view(http_method_names=['GET'])
def get_volumes(request, *args, **kwargs):
logger.debug("Query all the volumes by vnfInstanceId[%s]", fun_name())
@@ -360,8 +365,7 @@ def fill_volumes_data(v):
"insttype": v.insttype,
"instid": v.instid,
"storagetype": v.storagetype,
- "size": v.size,
- "disktype": v.disktype
+ "size": v.size
}
return volumes_data
@@ -372,4 +376,4 @@ class SwaggerJsonView(APIView):
f = open(json_file)
json_data = json.JSONDecoder().decode(f.read())
f.close()
- return Response(json_data)
+ return Response(json_data) \ No newline at end of file