Merge "Decompose the VNF instance"
[vfc/gvnfm/vnflcm.git] / lcm / lcm / pub / database / models.py
1 # Copyright 2017 ZTE Corporation.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #         http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 from django.db import models
15
16
17 # class VnfInstModel(models.Model):
18 #     class Meta:
19 #         db_table = 'GVNFM_VNFINST'
20 #
21 #     id = models.CharField(db_column='ID', primary_key=True, max_length=200)
22 #     name = models.CharField(db_column='NAME', max_length=200)
23 #     vnfd_id = models.CharField(db_column='VNFDID', max_length=200)
24 #     description = models.CharField(db_column='DESCRIPTION', max_length=255, null=True, blank=True)
25 #     status = models.CharField(db_column='STATUS', max_length=200, null=True, blank=True)
26 #     create_time = models.CharField(db_column='CREATETIME', max_length=200, null=True, blank=True)
27 #     lastuptime = models.CharField(db_column='LASTUPTIME', max_length=200, null=True, blank=True)
28
29 class NfInstModel(models.Model):
30     class Meta:
31         db_table = 'NFINST'
32
33     nfinstid = models.CharField(db_column='NFINSTID', max_length=200, primary_key=True)
34     mnfinstid = models.CharField(db_column='M_NFINSTID', max_length=200, blank=True, null=True)
35     nf_name = models.CharField(db_column='NFNAME', max_length=100, blank=True, null=True) #CreateVnfRequest.vnfInstanceName
36     template_id = models.CharField(db_column='TEMPLATEID', max_length=200, blank=True, null=True)
37     vnf_id = models.CharField(db_column='VNFID', max_length=200, blank=True, null=True)
38     package_id = models.CharField(db_column='PACKAGEID', max_length=200, blank=True, null=True)
39     vnfm_inst_id = models.CharField(db_column='VNFMINSTID', max_length=200, blank=True, null=True)
40     multivim = models.IntegerField(db_column='MULTIVIM', default=0)
41     ns_inst_id = models.CharField(db_column='NSINSTID', max_length=200, blank=True, null=True)
42     status = models.CharField(db_column='STATUS', max_length=20, blank=True, null=True)
43     flavour_id = models.CharField(db_column='FLAVOURID', max_length=200, blank=True, null=True) #InstantiateVnfRequest.flavourId
44     vnf_level = models.CharField(db_column='VNFLEVEL', max_length=200, blank=True, null=True) #InstantiateVnfRequest.instantiationLevelId
45     location = models.CharField(db_column='LOCATION', max_length=200, blank=True, null=True)
46     deploy_environment = models.CharField(db_column='DEPLOYENVIRONMENT', max_length=100, blank=True, null=True)
47     max_vm = models.IntegerField(db_column='MAXVM', blank=True, null=True)
48     max_cpu = models.IntegerField(db_column='MAXCPU', blank=True, null=True)
49     max_ram = models.IntegerField(db_column='MAXRAM', blank=True, null=True)
50     max_hd = models.IntegerField(db_column='MAXHD', blank=True, null=True)
51     max_shd = models.IntegerField(db_column='MAXSHD', blank=True, null=True)
52     max_net = models.IntegerField(db_column='MAXNET', blank=True, null=True)
53     version = models.CharField(db_column='VERSION', max_length=255, null=True)
54     vendor = models.CharField(db_column='VENDOR', max_length=255, null=True, blank=True)
55     producttype = models.CharField(db_column='PRODUCTTYPE', max_length=255, null=True)
56     netype = models.CharField(db_column='NETYPE', max_length=255, null=True)
57     vnfd_model = models.TextField(db_column='VNFDMODEL', max_length=20000, blank=True, null=True)
58     input_params = models.TextField(db_column='INPUTPARAMS', max_length=2000, blank=True, null=True)  #InstantiateVnfRequest.additionalParams
59     scale_params = models.TextField(db_column='SCALEPARAMS', max_length=2000, null=True, blank=True)
60     create_time = models.CharField(db_column='CREATETIME', max_length=200, null=True, blank=True)
61     lastuptime = models.CharField(db_column='LASTUPTIME', max_length=200, blank=True, null=True)
62     extension = models.TextField(db_column='EXTENSION', max_length=65535, blank=True, null=True)
63     initallocatedata = models.TextField(db_column='INITALLOCATEDATA', max_length=20000, blank=True, null=True)
64     predefinedvm = models.TextField(db_column='PREDEFINEDVM', max_length=65535, blank=True, null=True)
65     vnfextendtype = models.CharField(db_column='VNFEXTENDTYPE', max_length=255, null=True)
66
67     instantiationState = models.CharField(db_column='INSTANTIATIONSTATE', max_length=200, blank=True, null=True)
68     nf_desc = models.CharField(db_column='VNFINSTANCEDESC', max_length=200, blank=True, null=True)
69     vnfdid = models.CharField(db_column='VNFDID', max_length=200, blank=True, null=True)
70     vnfSoftwareVersion = models.CharField(db_column='VNFSOFTWAREVER', max_length=200, blank=True, null=True)
71     vnfConfigurableProperties = models.TextField(db_column='VNFCONFIGURABLEPROPERTIES', max_length=20000, blank=True, null=True)
72     localizationLanguage = models.CharField(db_column='LOCALIZATIONLANGUAGE', max_length=255, null=True)
73
74 class JobModel(models.Model):
75     class Meta:
76         db_table = 'JOB'
77
78     _database = 'job'
79
80     jobid = models.CharField(db_column='JOBID', primary_key=True, max_length=255)
81     jobtype = models.CharField(db_column='JOBTYPE', max_length=255)
82     jobaction = models.CharField(db_column='JOBACTION', max_length=255)
83     resid = models.CharField(db_column='RESID', max_length=255)
84     status = models.IntegerField(db_column='STATUS', null=True, blank=True)
85     starttime = models.CharField(db_column='STARTTIME', max_length=255, null=True, blank=True)
86     endtime = models.CharField(db_column='ENDTIME', max_length=255, null=True, blank=True)
87     progress = models.IntegerField(db_column='PROGRESS', null=True, blank=True)
88     user = models.CharField(db_column='USER', max_length=255, null=True, blank=True)
89     parentjobid = models.CharField(db_column='PARENTJOBID', max_length=255, null=True, blank=True)
90     resname = models.CharField(db_column='RESNAME', max_length=255, null=True, blank=True)
91
92     def toJSON(self):
93         import json
94         return json.dumps(dict([(attr, getattr(self, attr)) for attr in [f.name for f in self._meta.fields]]))
95
96 class JobStatusModel(models.Model):
97     class Meta:
98         db_table = 'JOB_STATUS'
99
100     _database = 'job'
101
102     indexid = models.IntegerField(db_column='INDEXID')
103     jobid = models.CharField(db_column='JOBID', max_length=255)
104     status = models.CharField(db_column='STATUS', max_length=255)
105     progress = models.IntegerField(db_column='PROGRESS', null=True, blank=True)
106     descp = models.CharField(db_column='DESCP', max_length=1024)
107     errcode = models.CharField(db_column='ERRCODE', max_length=255, null=True, blank=True)
108     addtime = models.CharField(db_column='ADDTIME', max_length=255, null=True, blank=True)
109
110     def toJSON(self):
111         import json
112         return json.dumps(dict([(attr, getattr(self, attr)) for attr in [f.name for f in self._meta.fields]]))