Implementation VNF instantiation interface
[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 JobModel(models.Model):
30     class Meta:
31         db_table = 'JOB'
32
33     _database = 'job'
34
35     jobid = models.CharField(db_column='JOBID', primary_key=True, max_length=255)
36     jobtype = models.CharField(db_column='JOBTYPE', max_length=255)
37     jobaction = models.CharField(db_column='JOBACTION', max_length=255)
38     resid = models.CharField(db_column='RESID', max_length=255)
39     status = models.IntegerField(db_column='STATUS', null=True, blank=True)
40     starttime = models.CharField(db_column='STARTTIME', max_length=255, null=True, blank=True)
41     endtime = models.CharField(db_column='ENDTIME', max_length=255, null=True, blank=True)
42     progress = models.IntegerField(db_column='PROGRESS', null=True, blank=True)
43     user = models.CharField(db_column='USER', max_length=255, null=True, blank=True)
44     parentjobid = models.CharField(db_column='PARENTJOBID', max_length=255, null=True, blank=True)
45     resname = models.CharField(db_column='RESNAME', max_length=255, null=True, blank=True)
46
47     def toJSON(self):
48         import json
49         return json.dumps(dict([(attr, getattr(self, attr)) for attr in [f.name for f in self._meta.fields]]))
50
51 class JobStatusModel(models.Model):
52     class Meta:
53         db_table = 'JOB_STATUS'
54
55     _database = 'job'
56
57     indexid = models.IntegerField(db_column='INDEXID')
58     jobid = models.CharField(db_column='JOBID', max_length=255)
59     status = models.CharField(db_column='STATUS', max_length=255)
60     progress = models.IntegerField(db_column='PROGRESS', null=True, blank=True)
61     descp = models.CharField(db_column='DESCP', max_length=1024)
62     errcode = models.CharField(db_column='ERRCODE', max_length=255, null=True, blank=True)
63     addtime = models.CharField(db_column='ADDTIME', max_length=255, null=True, blank=True)
64
65     def toJSON(self):
66         import json
67         return json.dumps(dict([(attr, getattr(self, attr)) for attr in [f.name for f in self._meta.fields]]))