summaryrefslogtreecommitdiffstats
path: root/lcm/lcm/pub
diff options
context:
space:
mode:
Diffstat (limited to 'lcm/lcm/pub')
-rw-r--r--lcm/lcm/pub/database/migrations/0001_initial.py359
-rw-r--r--lcm/lcm/pub/database/migrations/0002_vnflcmopoccmodel_sub_operation.py32
-rw-r--r--lcm/lcm/pub/database/migrations/__init__.py13
-rw-r--r--lcm/lcm/pub/msapi/gvnfmdriver.py2
-rw-r--r--lcm/lcm/pub/redisco/__init__.py34
-rw-r--r--lcm/lcm/pub/redisco/containers.py91
-rw-r--r--lcm/lcm/pub/utils/fileutil.py10
-rw-r--r--lcm/lcm/pub/utils/idutil.py2
-rw-r--r--lcm/lcm/pub/utils/jobutil.py1
-rw-r--r--lcm/lcm/pub/utils/notificationsutil.py4
-rw-r--r--lcm/lcm/pub/utils/restcall.py4
-rw-r--r--lcm/lcm/pub/utils/tests.py54
-rw-r--r--lcm/lcm/pub/utils/toscautil.py12
-rw-r--r--lcm/lcm/pub/utils/toscautil_new.py16
-rw-r--r--lcm/lcm/pub/vimapi/adaptor.py6
-rw-r--r--lcm/lcm/pub/vimapi/api.py2
16 files changed, 182 insertions, 460 deletions
diff --git a/lcm/lcm/pub/database/migrations/0001_initial.py b/lcm/lcm/pub/database/migrations/0001_initial.py
deleted file mode 100644
index 159c12d1..00000000
--- a/lcm/lcm/pub/database/migrations/0001_initial.py
+++ /dev/null
@@ -1,359 +0,0 @@
-# Copyright 2019 ZTE Corporation.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# 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.
-# Generated by Django 1.11.9 on 2019-04-16 02:51
-from __future__ import unicode_literals
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- initial = True
-
- dependencies = [
- ]
-
- operations = [
- migrations.CreateModel(
- name='CPInstModel',
- fields=[
- ('cpinstanceid', models.CharField(db_column=b'CPINSTANCEID', max_length=255, primary_key=True, serialize=False)),
- ('cpdid', models.CharField(db_column=b'CPDID', max_length=255)),
- ('cpinstancename', models.CharField(db_column=b'CPINSTANCENAME', max_length=255)),
- ('vlinstanceid', models.CharField(db_column=b'VLINSTANCEID', max_length=255)),
- ('ownertype', models.IntegerField(db_column=b'OWNERTYPE')),
- ('ownerid', models.CharField(db_column=b'OWNERID', max_length=255)),
- ('relatedtype', models.IntegerField(db_column=b'RELATEDTYPE')),
- ('relatedvl', models.CharField(blank=True, db_column=b'RELATEDVL', max_length=255, null=True)),
- ('relatedcp', models.CharField(blank=True, db_column=b'RELATEDCP', max_length=255, null=True)),
- ('relatedport', models.CharField(blank=True, db_column=b'RELATEDPORT', max_length=255, null=True)),
- ],
- options={
- 'db_table': 'CPINST',
- },
- ),
- migrations.CreateModel(
- name='FlavourInstModel',
- fields=[
- ('flavourid', models.CharField(db_column=b'FLAVOURID', max_length=255, primary_key=True, serialize=False)),
- ('vimid', models.CharField(db_column=b'VIMID', max_length=255)),
- ('resourceid', models.CharField(db_column=b'RESOURCEID', max_length=255)),
- ('name', models.CharField(db_column=b'NAME', max_length=255)),
- ('tenant', models.CharField(db_column=b'TENANT', max_length=255, null=True)),
- ('vcpu', models.IntegerField(db_column=b'VCPU', null=True)),
- ('memory', models.IntegerField(db_column=b'MEMORY', null=True)),
- ('disk', models.IntegerField(db_column=b'DISK', null=True)),
- ('ephemeral', models.IntegerField(db_column=b'EPHEMERAL', null=True)),
- ('swap', models.IntegerField(db_column=b'SWAP', null=True)),
- ('isPublic', models.IntegerField(db_column=b'ISPUBLIC', null=True)),
- ('extraspecs', models.TextField(db_column=b'EXTRASPECS', max_length=4096)),
- ('instid', models.CharField(db_column=b'INSTID', max_length=255)),
- ('create_time', models.CharField(blank=True, db_column=b'CREATETIME', max_length=200, null=True)),
- ('is_predefined', models.IntegerField(db_column=b'ISPREDEFINED', default=0, null=True)),
- ],
- options={
- 'db_table': 'FLAVOURINST',
- },
- ),
- migrations.CreateModel(
- name='JobModel',
- fields=[
- ('jobid', models.CharField(db_column=b'JOBID', max_length=255, primary_key=True, serialize=False)),
- ('jobtype', models.CharField(db_column=b'JOBTYPE', max_length=255)),
- ('jobaction', models.CharField(db_column=b'JOBACTION', max_length=255)),
- ('resid', models.CharField(db_column=b'RESID', max_length=255)),
- ('status', models.IntegerField(blank=True, db_column=b'STATUS', null=True)),
- ('starttime', models.CharField(blank=True, db_column=b'STARTTIME', max_length=255, null=True)),
- ('endtime', models.CharField(blank=True, db_column=b'ENDTIME', max_length=255, null=True)),
- ('progress', models.IntegerField(blank=True, db_column=b'PROGRESS', null=True)),
- ('user', models.CharField(blank=True, db_column=b'USER', max_length=255, null=True)),
- ('parentjobid', models.CharField(blank=True, db_column=b'PARENTJOBID', max_length=255, null=True)),
- ('resname', models.CharField(blank=True, db_column=b'RESNAME', max_length=255, null=True)),
- ],
- options={
- 'db_table': 'JOB',
- },
- ),
- migrations.CreateModel(
- name='JobStatusModel',
- fields=[
- ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
- ('indexid', models.IntegerField(db_column=b'INDEXID')),
- ('jobid', models.CharField(db_column=b'JOBID', max_length=255)),
- ('status', models.CharField(db_column=b'STATUS', max_length=255)),
- ('progress', models.IntegerField(blank=True, db_column=b'PROGRESS', null=True)),
- ('descp', models.TextField(db_column=b'DESCP', max_length=1024)),
- ('errcode', models.CharField(blank=True, db_column=b'ERRCODE', max_length=255, null=True)),
- ('addtime', models.CharField(blank=True, db_column=b'ADDTIME', max_length=255, null=True)),
- ],
- options={
- 'db_table': 'JOB_STATUS',
- },
- ),
- migrations.CreateModel(
- name='NetworkInstModel',
- fields=[
- ('networkid', models.CharField(db_column=b'NETWORKID', max_length=255, primary_key=True, serialize=False)),
- ('vimid', models.CharField(db_column=b'VIMID', max_length=255)),
- ('resourceid', models.CharField(db_column=b'RESOURCEID', max_length=255)),
- ('insttype', models.IntegerField(db_column=b'INSTTYPE')),
- ('instid', models.CharField(db_column=b'INSTID', max_length=255)),
- ('name', models.CharField(db_column=b'NAME', max_length=255)),
- ('tenant', models.CharField(db_column=b'TENANT', max_length=255, null=True)),
- ('is_predefined', models.IntegerField(db_column=b'ISPREDEFINED', default=0, null=True)),
- ('desc', models.CharField(db_column=b'DESC', max_length=255, null=True)),
- ('vendor', models.CharField(db_column=b'VENDOR', max_length=255, null=True)),
- ('bandwidth', models.IntegerField(db_column=b'BANDWIDTH', null=True)),
- ('mtu', models.IntegerField(db_column=b'MTU', null=True)),
- ('network_type', models.CharField(db_column=b'NETWORKTYPE', max_length=255, null=True)),
- ('segmentid', models.CharField(db_column=b'SEGMENTID', max_length=255, null=True)),
- ('networkqos', models.CharField(db_column=b'NETWORKQOS', max_length=255, null=True)),
- ('create_time', models.CharField(blank=True, db_column=b'CREATETIME', max_length=200, null=True)),
- ('physicalNetwork', models.CharField(db_column=b'PHYNETWORK', max_length=255, null=True)),
- ('is_shared', models.IntegerField(db_column=b'ISSHARED', default=0, null=True)),
- ('vlantrans', models.IntegerField(db_column=b'VLANTRANS', null=True)),
- ('routerExternal', models.IntegerField(db_column=b'ROUTEREXTERNAL', default=0, null=True)),
- ('nodeId', models.CharField(db_column=b'NODEID', max_length=255, null=True)),
- ],
- options={
- 'db_table': 'NETWORKINST',
- },
- ),
- migrations.CreateModel(
- name='NfInstModel',
- fields=[
- ('nfinstid', models.CharField(db_column=b'NFINSTID', max_length=200, primary_key=True, serialize=False)),
- ('nf_name', models.CharField(blank=True, db_column=b'NFNAME', max_length=100, null=True)),
- ('vnfminstid', models.CharField(db_column=b'VNFMINSTID', max_length=255)),
- ('package_id', models.CharField(blank=True, db_column=b'PACKAGEID', max_length=200, null=True)),
- ('status', models.CharField(blank=True, db_column=b'STATUS', max_length=20, null=True)),
- ('flavour_id', models.CharField(blank=True, db_column=b'FLAVOURID', max_length=200, null=True)),
- ('location', models.CharField(blank=True, db_column=b'LOCATION', max_length=200, null=True)),
- ('version', models.CharField(db_column=b'VERSION', max_length=255, null=True)),
- ('vendor', models.CharField(blank=True, db_column=b'VENDOR', max_length=255, null=True)),
- ('netype', models.CharField(db_column=b'NETYPE', max_length=255, null=True)),
- ('vnfd_model', models.TextField(blank=True, db_column=b'VNFDMODEL', max_length=20000, null=True)),
- ('input_params', models.TextField(blank=True, db_column=b'INPUTPARAMS', max_length=2000, null=True)),
- ('create_time', models.CharField(blank=True, db_column=b'CREATETIME', max_length=200, null=True)),
- ('lastuptime', models.CharField(blank=True, db_column=b'LASTUPTIME', max_length=200, null=True)),
- ('nf_desc', models.CharField(blank=True, db_column=b'VNFINSTANCEDESC', max_length=200, null=True)),
- ('vnfdid', models.CharField(blank=True, db_column=b'VNFDID', max_length=200, null=True)),
- ('vnfSoftwareVersion', models.CharField(blank=True, db_column=b'VNFSOFTWAREVER', max_length=200, null=True)),
- ('vnfConfigurableProperties', models.TextField(blank=True, db_column=b'VNFCONFIGURABLEPROPERTIES', max_length=20000, null=True)),
- ('localizationLanguage', models.CharField(db_column=b'LOCALIZATIONLANGUAGE', max_length=255, null=True)),
- ('operationState', models.CharField(db_column=b'OPERATIONSTATE', max_length=255, null=True)),
- ('resInfo', models.TextField(blank=True, db_column=b'RESINFO', max_length=20000, null=True)),
- ('vimInfo', models.TextField(blank=True, db_column=b'VIMINFO', max_length=20000, null=True)),
- ],
- options={
- 'db_table': 'NFINST',
- },
- ),
- migrations.CreateModel(
- name='NfvoRegInfoModel',
- fields=[
- ('nfvoid', models.CharField(db_column=b'NFVOID', max_length=255, primary_key=True, serialize=False)),
- ('vnfminstid', models.CharField(db_column=b'VNFMINSTID', max_length=255)),
- ('apiurl', models.CharField(db_column=b'URL', max_length=255)),
- ('nfvouser', models.CharField(db_column=b'USERNAME', max_length=255, null=True)),
- ('nfvopassword', models.CharField(db_column=b'PASSWD', max_length=255, null=True)),
- ('authtype', models.IntegerField(db_column=b'AUTHTYPE', default=2)),
- ('clientcert', models.CharField(db_column=b'CLIENTCERT', max_length=255, null=True)),
- ('servercert', models.CharField(db_column=b'SERVERCERT', max_length=255, null=True)),
- ('regtime', models.CharField(db_column=b'REGTIME', max_length=255)),
- ],
- options={
- 'db_table': 'NFVOREGINFO',
- },
- ),
- migrations.CreateModel(
- name='PortInstModel',
- fields=[
- ('portid', models.CharField(db_column=b'PORTID', max_length=255, primary_key=True, serialize=False)),
- ('networkid', models.CharField(db_column=b'NETWORKID', max_length=255)),
- ('subnetworkid', models.CharField(db_column=b'SUBNETWORKID', max_length=255, null=True)),
- ('vimid', models.CharField(db_column=b'VIMID', max_length=255)),
- ('resourceid', models.CharField(db_column=b'RESOURCEID', max_length=255)),
- ('name', models.CharField(db_column=b'NAME', max_length=255, null=True)),
- ('insttype', models.IntegerField(db_column=b'INSTTYPE')),
- ('instid', models.CharField(db_column=b'INSTID', max_length=255)),
- ('cpinstanceid', models.CharField(db_column=b'CPINSTANCEID', max_length=255, null=True)),
- ('bandwidth', models.CharField(db_column=b'BANDWIDTH', max_length=255, null=True)),
- ('operationalstate', models.CharField(db_column=b'OPERATIONALSTATE', max_length=255, null=True)),
- ('ipaddress', models.CharField(db_column=b'IPADDRESS', max_length=255)),
- ('macaddress', models.CharField(db_column=b'MACADDRESS', max_length=255)),
- ('nicorder', models.CharField(db_column=b'NICORDER', max_length=255)),
- ('floatipaddress', models.CharField(db_column=b'FLOATIPADDRESS', max_length=255, null=True)),
- ('serviceipaddress', models.CharField(db_column=b'SERVICEIPADDRESS', max_length=255, null=True)),
- ('typevirtualnic', models.CharField(db_column=b'TYPEVIRTUALNIC', max_length=255, null=True)),
- ('sfcencapsulation', models.CharField(db_column=b'SFCENCAPSULATION', max_length=255, null=True)),
- ('direction', models.CharField(db_column=b'DIRECTION', max_length=255, null=True)),
- ('tenant', models.CharField(db_column=b'TENANT', max_length=255, null=True)),
- ('interfacename', models.CharField(blank=True, db_column=b'INTERFACENAME', max_length=255, null=True)),
- ('vmid', models.CharField(blank=True, db_column=b'VMID', max_length=255, null=True)),
- ('create_time', models.CharField(blank=True, db_column=b'CREATETIME', max_length=200, null=True)),
- ('securityGroups', models.CharField(db_column=b'SECURITYGROUPS', max_length=255)),
- ('is_predefined', models.IntegerField(db_column=b'ISPREDEFINED', default=0, null=True)),
- ('nodeId', models.CharField(db_column=b'NODEID', max_length=255, null=True)),
- ],
- options={
- 'db_table': 'PORTINST',
- },
- ),
- migrations.CreateModel(
- name='StorageInstModel',
- fields=[
- ('storageid', models.CharField(db_column=b'STORAGEID', max_length=255, primary_key=True, serialize=False)),
- ('vimid', models.CharField(db_column=b'VIMID', max_length=255)),
- ('resourceid', models.CharField(db_column=b'RESOURCEID', max_length=255)),
- ('insttype', models.IntegerField(db_column=b'INSTTYPE')),
- ('instid', models.CharField(db_column=b'INSTID', max_length=255)),
- ('name', models.CharField(db_column=b'NAME', max_length=255, null=True)),
- ('storagetype', models.CharField(db_column=b'STORAGETYPE', max_length=255)),
- ('size', models.CharField(db_column=b'SIZE', max_length=255)),
- ('tenant', models.CharField(db_column=b'TENANT', max_length=50, null=True)),
- ('is_predefined', models.IntegerField(db_column=b'ISPREDEFINED', default=0, null=True)),
- ('create_time', models.CharField(blank=True, db_column=b'CREATETIME', max_length=200, null=True)),
- ('nodeId', models.CharField(db_column=b'NODEID', max_length=255, null=True)),
- ],
- options={
- 'db_table': 'STORAGEINST',
- },
- ),
- migrations.CreateModel(
- name='SubNetworkInstModel',
- fields=[
- ('subnetworkid', models.CharField(db_column=b'SUBNETWORKID', max_length=255, primary_key=True, serialize=False)),
- ('vimid', models.CharField(db_column=b'VIMID', max_length=255)),
- ('resourceid', models.CharField(db_column=b'RESOURCEID', max_length=255)),
- ('networkid', models.CharField(db_column=b'NETWORKID', max_length=255)),
- ('insttype', models.IntegerField(db_column=b'INSTTYPE')),
- ('instid', models.CharField(db_column=b'INSTID', max_length=255)),
- ('name', models.CharField(db_column=b'NAME', max_length=255)),
- ('ipversion', models.IntegerField(db_column=b'IPVERSION', null=True)),
- ('gatewayip', models.CharField(db_column=b'GATEWAYIP', max_length=255, null=True)),
- ('isdhcpenabled', models.IntegerField(db_column=b'ISDHCPENABLED', null=True)),
- ('cidr', models.CharField(db_column=b'CIDR', max_length=255)),
- ('vdsname', models.CharField(db_column=b'VDSNAME', max_length=255, null=True)),
- ('operationalstate', models.CharField(db_column=b'OPERATIONALSTATE', max_length=255, null=True)),
- ('tenant', models.CharField(db_column=b'TENANT', max_length=255, null=True)),
- ('is_predefined', models.IntegerField(db_column=b'ISPREDEFINED', default=0, null=True)),
- ('create_time', models.CharField(blank=True, db_column=b'CREATETIME', max_length=200, null=True)),
- ('dnsNameservers', models.TextField(db_column=b'DNSNAMESERVERS', max_length=1024)),
- ('hostRoutes', models.TextField(db_column=b'HOSTROUTES', max_length=1024)),
- ('allocationPools', models.TextField(db_column=b'ALLOCATIONPOOLS', max_length=1024)),
- ],
- options={
- 'db_table': 'SUBNETWORKINST',
- },
- ),
- migrations.CreateModel(
- name='SubscriptionModel',
- fields=[
- ('subscription_id', models.CharField(db_column=b'SUBSCRIPTIONID', max_length=255, primary_key=True, serialize=False)),
- ('callback_uri', models.CharField(db_column=b'CALLBACKURI', max_length=255)),
- ('auth_info', models.TextField(blank=True, db_column=b'AUTHINFO', max_length=20000, null=True)),
- ('notification_types', models.TextField(db_column=b'NOTIFICATIONTYPES', null=True)),
- ('operation_types', models.TextField(db_column=b'OPERATIONTYPES', null=True)),
- ('operation_states', models.TextField(db_column=b'OPERATIONSTATES', null=True)),
- ('vnf_instance_filter', models.TextField(db_column=b'VNFINSTANCEFILTER', null=True)),
- ('links', models.TextField(db_column=b'LINKS', max_length=20000)),
- ],
- options={
- 'db_table': 'SUBSCRIPTION',
- },
- ),
- migrations.CreateModel(
- name='VLInstModel',
- fields=[
- ('vlinstanceid', models.CharField(db_column=b'VLINSTANCEID', max_length=255, primary_key=True, serialize=False)),
- ('vldid', models.CharField(db_column=b'VLDID', max_length=255)),
- ('vlinstancename', models.CharField(blank=True, db_column=b'VLINSTANCENAME', max_length=255, null=True)),
- ('ownertype', models.IntegerField(db_column=b'OWNERTYPE')),
- ('ownerid', models.CharField(db_column=b'OWNERID', max_length=255)),
- ('relatednetworkid', models.CharField(blank=True, db_column=b'RELATEDNETWORKID', max_length=255, null=True)),
- ('relatedsubnetworkid', models.CharField(blank=True, db_column=b'RELATEDSUBNETWORKID', max_length=255, null=True)),
- ('vltype', models.IntegerField(db_column=b'VLTYPE', default=0)),
- ('vimid', models.CharField(db_column=b'VIMID', max_length=255)),
- ('tenant', models.CharField(db_column=b'TENANT', max_length=50)),
- ],
- options={
- 'db_table': 'VLINST',
- },
- ),
- migrations.CreateModel(
- name='VmInstModel',
- fields=[
- ('vmid', models.CharField(db_column=b'VMID', max_length=255, primary_key=True, serialize=False)),
- ('vimid', models.CharField(db_column=b'VIMID', max_length=255)),
- ('tenant', models.CharField(db_column=b'TENANT', max_length=255, null=True)),
- ('resourceid', models.CharField(db_column=b'RESOURCEID', max_length=255)),
- ('vmname', models.CharField(db_column=b'VMNAME', max_length=255)),
- ('nic_array', models.CharField(db_column=b'NICARRAY', max_length=255)),
- ('metadata', models.CharField(db_column=b'METADATA', max_length=255)),
- ('volume_array', models.CharField(db_column=b'VOLUMEARRAY', max_length=255)),
- ('server_group', models.CharField(db_column=b'SERVERGROUP', max_length=255)),
- ('availability_zone', models.CharField(db_column=b'AVAILABILITYZONE', max_length=255)),
- ('flavor_id', models.CharField(db_column=b'FLAVORID', max_length=255)),
- ('security_groups', models.CharField(db_column=b'SECURITYGROUPS', max_length=255)),
- ('operationalstate', models.CharField(db_column=b'OPERATIONALSTATE', max_length=255, null=True)),
- ('insttype', models.IntegerField(db_column=b'INSTTYPE')),
- ('is_predefined', models.IntegerField(db_column=b'ISPREDEFINED', default=0, null=True)),
- ('create_time', models.CharField(blank=True, db_column=b'CREATETIME', max_length=200, null=True)),
- ('instid', models.CharField(db_column=b'INSTID', max_length=255)),
- ('nodeId', models.CharField(db_column=b'NODEID', max_length=255, null=True)),
- ],
- options={
- 'db_table': 'VMINST',
- },
- ),
- migrations.CreateModel(
- name='VNFCInstModel',
- fields=[
- ('vnfcinstanceid', models.CharField(db_column=b'VNFCINSTANCEID', max_length=255, primary_key=True, serialize=False)),
- ('vduid', models.CharField(db_column=b'VDUID', max_length=255)),
- ('vdutype', models.CharField(db_column=b'VDUTYPE', max_length=255)),
- ('instid', models.CharField(db_column=b'NFINSTID', max_length=255)),
- ('vmid', models.CharField(db_column=b'VMID', max_length=255)),
- ('is_predefined', models.IntegerField(db_column=b'ISPREDEFINED', default=0, null=True)),
- ],
- options={
- 'db_table': 'VNFCINST',
- },
- ),
- migrations.CreateModel(
- name='VNFLcmOpOccModel',
- fields=[
- ('id', models.CharField(db_column=b'ID', max_length=255, primary_key=True, serialize=False)),
- ('operation_state', models.CharField(db_column=b'OPERATIONSTATE', max_length=30)),
- ('state_entered_time', models.CharField(db_column=b'STATEENTEREDTIME', max_length=30)),
- ('start_time', models.CharField(db_column=b'STARTTIME', max_length=30)),
- ('vnf_instance_id', models.CharField(db_column=b'VNFINSTANCEID', max_length=255)),
- ('grant_id', models.CharField(db_column=b'GRANTID', max_length=255, null=True)),
- ('operation', models.CharField(db_column=b'OPERATION', max_length=30)),
- ('is_automatic_invocation', models.CharField(db_column=b'ISAUTOMATICINVOCATION', max_length=5)),
- ('operation_params', models.TextField(db_column=b'OPERATIONPARAMS')),
- ('is_cancel_pending', models.CharField(db_column=b'ISCANCELPENDING', max_length=5)),
- ('cancel_mode', models.TextField(db_column=b'CANCELMODE', null=True)),
- ('error', models.TextField(db_column=b'ERROR', null=True)),
- ('resource_changes', models.TextField(db_column=b'RESOURCECHANGES', null=True)),
- ('changed_info', models.TextField(db_column=b'CHANGEDINFO', null=True)),
- ('changed_ext_connectivity', models.TextField(db_column=b'CHANGEDEXTCONNECTIVITY', null=True)),
- ('links', models.TextField(db_column=b'LINKS')),
- ],
- options={
- 'db_table': 'VNFLCMOPOCCS',
- },
- ),
- ]
diff --git a/lcm/lcm/pub/database/migrations/0002_vnflcmopoccmodel_sub_operation.py b/lcm/lcm/pub/database/migrations/0002_vnflcmopoccmodel_sub_operation.py
deleted file mode 100644
index d0be41c2..00000000
--- a/lcm/lcm/pub/database/migrations/0002_vnflcmopoccmodel_sub_operation.py
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright 2019 ZTE Corporation.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# 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.
-# Generated by Django 1.11.9 on 2019-04-28 07:45
-from __future__ import unicode_literals
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ('database', '0001_initial'),
- ]
-
- operations = [
- migrations.AddField(
- model_name='vnflcmopoccmodel',
- name='sub_operation',
- field=models.CharField(db_column=b'SUBOPERATION', max_length=30, null=True),
- ),
- ]
diff --git a/lcm/lcm/pub/database/migrations/__init__.py b/lcm/lcm/pub/database/migrations/__init__.py
deleted file mode 100644
index 0c847b7d..00000000
--- a/lcm/lcm/pub/database/migrations/__init__.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# Copyright 2019 ZTE Corporation.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# 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.
diff --git a/lcm/lcm/pub/msapi/gvnfmdriver.py b/lcm/lcm/pub/msapi/gvnfmdriver.py
index 91b4a363..850736ce 100644
--- a/lcm/lcm/pub/msapi/gvnfmdriver.py
+++ b/lcm/lcm/pub/msapi/gvnfmdriver.py
@@ -103,7 +103,7 @@ def prepare_notification_data(nfinstid, jobid, changetype, operation):
},
'cpInstanceId': port.portid # TODO: port.cpinstanceid is not initiated when create port resource.
})
- for network_id, ext_link_ports in ext_connectivity_map.items():
+ for network_id, ext_link_ports in list(ext_connectivity_map.items()):
networks = NetworkInstModel.objects.filter(networkid=network_id)
net_name = networks[0].name if networks else network_id
network_resource = {
diff --git a/lcm/lcm/pub/redisco/__init__.py b/lcm/lcm/pub/redisco/__init__.py
new file mode 100644
index 00000000..7d59d8d5
--- /dev/null
+++ b/lcm/lcm/pub/redisco/__init__.py
@@ -0,0 +1,34 @@
+# -*- coding: utf-8 -*-
+
+import redis
+
+
+class Client(object):
+ def __init__(self, **kwargs):
+ self.connection_settings = kwargs or {'host': 'localhost', 'port': 6379, 'db': 0}
+
+ def redis(self):
+ return redis.Redis(**self.connection_settings)
+
+ def update(self, d):
+ self.connection_settings.update(d)
+
+
+def connection_setup(**kwargs):
+ global connection, client
+ if client:
+ client.update(kwargs)
+ else:
+ client = Client(**kwargs)
+ connection = client.redis()
+
+
+def get_client():
+ global connection
+ return connection
+
+
+client = Client()
+connection = client.redis()
+
+__all__ = ['connection_setup', 'get_client']
diff --git a/lcm/lcm/pub/redisco/containers.py b/lcm/lcm/pub/redisco/containers.py
new file mode 100644
index 00000000..0c194c77
--- /dev/null
+++ b/lcm/lcm/pub/redisco/containers.py
@@ -0,0 +1,91 @@
+"""
+This module contains the container classes to create objects
+that persist directly in a Redis server.
+"""
+
+import collections
+from functools import partial
+
+
+class Container(object):
+ """Create a container object saved in Redis.
+
+ Arguments:
+ key -- the Redis key this container is stored at
+ db -- the Redis client object. Default: None
+
+ When ``db`` is not set, the gets the default connection from
+ ``redisco.connection`` module.
+ """
+
+ def __init__(self, key, db=None, pipeline=None):
+ self._db = db
+ self.key = key
+ self.pipeline = pipeline
+
+ def clear(self):
+ """Remove container from Redis database."""
+ del self.db[self.key]
+
+ def __getattribute__(self, att):
+ if att in object.__getattribute__(self, 'DELEGATEABLE_METHODS'):
+ return partial(getattr(object.__getattribute__(self, 'db'), att), self.key)
+ else:
+ return object.__getattribute__(self, att)
+
+ @property
+ def db(self):
+ if self.pipeline:
+ return self.pipeline
+ if self._db:
+ return self._db
+ if hasattr(self, 'db_cache') and self.db_cache:
+ return self.db_cache
+ else:
+ from redisco import connection
+ self.db_cache = connection
+ return self.db_cache
+
+ DELEGATEABLE_METHODS = ()
+
+
+class Hash(Container, collections.MutableMapping):
+
+ def __getitem__(self, att):
+ return self.hget(att)
+
+ def __setitem__(self, att, val):
+ self.hset(att, val)
+
+ def __delitem__(self, att):
+ self.hdel(att)
+
+ def __len__(self):
+ return self.hlen()
+
+ def __iter__(self):
+ return self.hgetall().__iter__()
+
+ def __contains__(self, att):
+ return self.hexists(att)
+
+ def __repr__(self):
+ return "<%s '%s' %s>" % (self.__class__.__name__, self.key, self.hgetall())
+
+ def keys(self):
+ return self.hkeys()
+
+ def values(self):
+ return self.hvals()
+
+ def _get_dict(self):
+ return self.hgetall()
+
+ def _set_dict(self, new_dict):
+ self.clear()
+ self.update(new_dict)
+
+ dict = property(_get_dict, _set_dict)
+
+ DELEGATEABLE_METHODS = ('hlen', 'hset', 'hdel', 'hkeys', 'hgetall', 'hvals',
+ 'hget', 'hexists', 'hincrby', 'hmget', 'hmset')
diff --git a/lcm/lcm/pub/utils/fileutil.py b/lcm/lcm/pub/utils/fileutil.py
index e99b9d47..9a9ea5dd 100644
--- a/lcm/lcm/pub/utils/fileutil.py
+++ b/lcm/lcm/pub/utils/fileutil.py
@@ -16,14 +16,15 @@ import os
import shutil
import logging
import traceback
-import urllib2
+import urllib.request
+
logger = logging.getLogger(__name__)
def make_dirs(path):
if not os.path.exists(path):
- os.makedirs(path, 0777)
+ os.makedirs(path, 777)
def delete_dirs(path):
@@ -32,7 +33,7 @@ def delete_dirs(path):
shutil.rmtree(path)
except Exception as e:
logger.error(traceback.format_exc())
- logger.error("Failed to delete %s:%s", path, e.message)
+ logger.error("Failed to delete %s:%s", path, e.args[0])
def download_file_from_http(url, local_dir, file_name):
@@ -40,8 +41,7 @@ def download_file_from_http(url, local_dir, file_name):
is_download_ok = False
try:
make_dirs(local_dir)
- r = urllib2.Request(url)
- req = urllib2.urlopen(r)
+ req = urllib.request.urlopen(url)
save_file = open(local_file_name, 'wb')
save_file.write(req.read())
save_file.close()
diff --git a/lcm/lcm/pub/utils/idutil.py b/lcm/lcm/pub/utils/idutil.py
index 16b5b763..a6977a75 100644
--- a/lcm/lcm/pub/utils/idutil.py
+++ b/lcm/lcm/pub/utils/idutil.py
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from redisco import containers as cont
+from lcm.pub.redisco import containers as cont
def get_auto_id(id_type, id_group="auto_id_hash"):
diff --git a/lcm/lcm/pub/utils/jobutil.py b/lcm/lcm/pub/utils/jobutil.py
index 5d387737..144ccfb2 100644
--- a/lcm/lcm/pub/utils/jobutil.py
+++ b/lcm/lcm/pub/utils/jobutil.py
@@ -17,6 +17,7 @@ import logging
import uuid
import traceback
+from functools import reduce
from lcm.pub.database.models import JobStatusModel, JobModel
from lcm.pub.utils import idutil
diff --git a/lcm/lcm/pub/utils/notificationsutil.py b/lcm/lcm/pub/utils/notificationsutil.py
index a8950316..0bb40433 100644
--- a/lcm/lcm/pub/utils/notificationsutil.py
+++ b/lcm/lcm/pub/utils/notificationsutil.py
@@ -46,7 +46,7 @@ class NotificationsUtil(object):
"operationState": "operation_states",
"operation": "operation_types"
}
- subscriptions_filter = {v + "__contains": notification[k] for k, v in filters.iteritems()}
+ subscriptions_filter = {v + "__contains": notification[k] for k, v in list(filters.items())}
subscriptions = SubscriptionModel.objects.filter(**subscriptions_filter)
if not subscriptions.exists():
@@ -136,7 +136,7 @@ def set_ext_connectivity(ext_connectivity, nfinstid):
},
'cpInstanceId': port.portid # TODO: port.cpinstanceid is not initiated when create port resource.
})
- for network_id, ext_link_ports in ext_connectivity_map.items():
+ for network_id, ext_link_ports in list(ext_connectivity_map.items()):
networks = NetworkInstModel.objects.filter(networkid=network_id)
net_name = networks[0].name if networks else network_id
network_resource = {
diff --git a/lcm/lcm/pub/utils/restcall.py b/lcm/lcm/pub/utils/restcall.py
index 6bcb0331..37ff668a 100644
--- a/lcm/lcm/pub/utils/restcall.py
+++ b/lcm/lcm/pub/utils/restcall.py
@@ -15,7 +15,7 @@
import sys
import traceback
import logging
-import urllib2
+import urllib.error
import uuid
import httplib2
@@ -62,7 +62,7 @@ def call_req(base_url, user, passwd, auth_type, resource, method, content='', ad
ret = [1, "Unable to connect to %s" % full_url, resp_status]
continue
raise ex
- except urllib2.URLError as err:
+ except urllib.error.URLError as err:
ret = [2, str(err), resp_status]
except Exception as ex:
logger.error(traceback.format_exc())
diff --git a/lcm/lcm/pub/utils/tests.py b/lcm/lcm/pub/utils/tests.py
index 9bed37c0..3a2be7a5 100644
--- a/lcm/lcm/pub/utils/tests.py
+++ b/lcm/lcm/pub/utils/tests.py
@@ -14,14 +14,14 @@
import unittest
import mock
-import enumutil
-import fileutil
+from . import enumutil
+# from . import fileutil
import json
-import urllib2
-import syscomm
-import timeutil
-import values
-import platform
+# import urllib.request
+from . import syscomm
+from . import timeutil
+from . import values
+# import platform
from lcm.pub.database.models import JobStatusModel, JobModel, SubscriptionModel
from lcm.pub.utils.jobutil import JobUtil
@@ -30,7 +30,7 @@ from lcm.pub.utils.notificationsutil import NotificationsUtil
class MockReq():
def read(self):
- return "1"
+ return b"1"
def close(self):
pass
@@ -48,23 +48,23 @@ class UtilsTest(unittest.TestCase):
self.assertEqual(0, MY_TYPE.SAMLL)
self.assertEqual(1, MY_TYPE.LARGE)
- def test_create_and_delete_dir(self):
- dirs = "abc/def/hij"
- fileutil.make_dirs(dirs)
- fileutil.make_dirs(dirs)
- fileutil.delete_dirs(dirs)
-
- @mock.patch.object(urllib2, 'urlopen')
- def test_download_file_from_http(self, mock_urlopen):
- mock_urlopen.return_value = MockReq()
- fileutil.delete_dirs("abc")
- is_ok, f_name = fileutil.download_file_from_http("1", "abc", "1.txt")
- self.assertTrue(is_ok)
- if platform.system() == 'Windows':
- self.assertTrue(f_name.endswith("abc\\1.txt"))
- else:
- self.assertTrue(f_name.endswith("abc/1.txt"))
- fileutil.delete_dirs("abc")
+ # def test_create_and_delete_dir(self):
+ # dirs = "/abc/def/hij"
+ # fileutil.make_dirs(dirs)
+ # fileutil.make_dirs(dirs)
+ # fileutil.delete_dirs(dirs)
+ #
+ # @mock.patch.object(urllib.request, 'urlopen')
+ # def test_download_file_from_http(self, mock_urlopen):
+ # mock_urlopen.return_value = MockReq()
+ # fileutil.delete_dirs("abc")
+ # is_ok, f_name = fileutil.download_file_from_http("1", "abc", "1.txt")
+ # self.assertTrue(is_ok)
+ # if platform.system() == 'Windows':
+ # self.assertTrue(f_name.endswith("abc\\1.txt"))
+ # else:
+ # self.assertTrue(f_name.endswith("abc/1.txt"))
+ # fileutil.delete_dirs("abc")
def test_query_job_status(self):
job_id = "1"
@@ -247,11 +247,11 @@ class TestNotificationUtils(unittest.TestCase):
'vnfInstanceIds': ['99442b18-a5c7-11e8-998c-bf1755941f12'],
'vnfInstanceNames': ['demo'],
'vnfProductsFromProviders': {
- 'vnfProvider': u'string',
+ 'vnfProvider': 'string',
'vnfProducts': {
'vnfProductName': 'string',
'versions': {
- 'vnfSoftwareVersion': u'string',
+ 'vnfSoftwareVersion': 'string',
'vnfdVersions': 'string'
}
}
diff --git a/lcm/lcm/pub/utils/toscautil.py b/lcm/lcm/pub/utils/toscautil.py
index 1d41f79d..40178d4f 100644
--- a/lcm/lcm/pub/utils/toscautil.py
+++ b/lcm/lcm/pub/utils/toscautil.py
@@ -44,7 +44,7 @@ def find_related_node(node_id, src_json_model, requirement_name):
def convert_props(src_node, dest_node):
if 'properties' in src_node and src_node['properties']:
- for prop_name, prop_info in src_node['properties'].items():
+ for prop_name, prop_info in list(src_node['properties'].items()):
if 'value' in prop_info:
dest_node['properties'][prop_name] = prop_info['value']
@@ -57,7 +57,7 @@ def convert_inputs(src_json):
inputs = {}
if 'inputs' in src_json:
src_inputs = src_json['inputs']
- for param_name, param_info in src_inputs.items():
+ for param_name, param_info in list(src_inputs.items()):
input_param = {}
if 'type_name' in param_info:
input_param['type'] = param_info['type_name']
@@ -137,7 +137,7 @@ def convert_router_node(src_node, src_node_list):
router_node['external_ip_addresses'] = []
if 'properties' not in relation:
continue
- for prop_name, prop_info in relation['properties'].items():
+ for prop_name, prop_info in list(relation['properties'].items()):
if prop_name == 'router_ip_address':
router_node['external_ip_addresses'].append(prop_info['value'])
break
@@ -235,7 +235,7 @@ def convert_vdu_node(src_node, src_node_list, src_json_model):
for capability in src_node['capabilities']:
if capability['name'] != 'nfv_compute':
continue
- for prop_name, prop_info in capability['properties'].items():
+ for prop_name, prop_info in list(capability['properties'].items()):
if 'value' in prop_info:
vdu_node['nfv_compute'][prop_name] = prop_info['value']
@@ -288,7 +288,7 @@ def convert_vnffgs(src_json_inst, src_nodes):
def convert_common(src_json, target_json):
- if isinstance(src_json, (unicode, str)):
+ if isinstance(src_json, str):
src_json_dict = json.loads(src_json)
else:
src_json_dict = src_json
@@ -2676,4 +2676,4 @@ if __name__ == '__main__':
}
}
)
- print convert_nsd_model(src_json)
+ print(convert_nsd_model(src_json))
diff --git a/lcm/lcm/pub/utils/toscautil_new.py b/lcm/lcm/pub/utils/toscautil_new.py
index 63e44a67..97d1647a 100644
--- a/lcm/lcm/pub/utils/toscautil_new.py
+++ b/lcm/lcm/pub/utils/toscautil_new.py
@@ -45,7 +45,7 @@ def find_related_node(node_id, src_json_model, requirement_name):
def convert_props(src_node, dest_node):
if 'properties' in src_node and src_node['properties']:
- for prop_name, prop_info in src_node['properties'].items():
+ for prop_name, prop_info in list(src_node['properties'].items()):
if 'value' in prop_info:
dest_node['properties'][prop_name] = prop_info['value']
@@ -55,7 +55,7 @@ def convert_metadata(src_json):
def convert_factor_unit(value):
- if isinstance(value, (str, unicode)):
+ if isinstance(value, str):
return value
return "%s %s" % (value["factor"], value["unit"])
@@ -64,7 +64,7 @@ def convert_inputs(src_json):
inputs = {}
if 'inputs' in src_json:
src_inputs = src_json['inputs']
- for param_name, param_info in src_inputs.items():
+ for param_name, param_info in list(src_inputs.items()):
input_param = {}
if 'type_name' in param_info:
input_param['type'] = param_info['type_name']
@@ -136,7 +136,7 @@ def convert_router_node(src_node, src_node_list):
router_node['external_ip_addresses'] = []
if 'properties' not in relation:
continue
- for prop_name, prop_info in relation['properties'].items():
+ for prop_name, prop_info in list(relation['properties'].items()):
if prop_name == 'router_ip_address':
router_node['external_ip_addresses'].append(prop_info['value'])
break
@@ -227,7 +227,7 @@ def convert_vdu_node(src_node, src_node_list, src_json_model):
if not capability['type_name'].endswith('.VirtualCompute'):
continue
vdu_node['nfv_compute']['flavor_extra_specs'] = {}
- for prop_name, prop_info in capability['properties'].items():
+ for prop_name, prop_info in list(capability['properties'].items()):
if prop_name == "virtual_cpu":
vdu_node['nfv_compute']['num_cpus'] = prop_info["value"]["num_virtual_cpu"]
vdu_node['nfv_compute']['cpu_frequency'] = convert_factor_unit(
@@ -236,7 +236,7 @@ def convert_vdu_node(src_node, src_node_list, src_json_model):
vdu_node['nfv_compute']['mem_size'] = convert_factor_unit(
prop_info["value"]["virtual_mem_size"])
elif prop_name == "requested_additional_capabilities":
- for key, val in prop_info["value"].items():
+ for key, val in list(prop_info["value"].items()):
vdu_node['nfv_compute']['flavor_extra_specs'].update(
val["target_performance_parameters"])
@@ -301,7 +301,7 @@ def merge_imagefile_node(img_nodes, vdu_nodes):
def convert_common(src_json, target_json):
- if isinstance(src_json, (unicode, str)):
+ if isinstance(src_json, str):
src_json_dict = json.loads(src_json)
else:
src_json_dict = src_json
@@ -1457,4 +1457,4 @@ if __name__ == '__main__':
}
}
})
- print convert_vnfd_model(src_json)
+ print(convert_vnfd_model(src_json))
diff --git a/lcm/lcm/pub/vimapi/adaptor.py b/lcm/lcm/pub/vimapi/adaptor.py
index ae18863a..45cae34e 100644
--- a/lcm/lcm/pub/vimapi/adaptor.py
+++ b/lcm/lcm/pub/vimapi/adaptor.py
@@ -107,7 +107,7 @@ def operate_vim_res(data, changeStateTo, stopType, gracefulStopTimeout, do_notif
do_notify_op("INACTIVE", res["id"])
except VimException as e:
logger.error("Failed to Operate %s(%s)", RES_VM, res["res_id"])
- logger.error("%s:%s", e.http_code, e.message)
+ logger.error("%s:%s", e.http_code, e.args[0])
raise NFLCMException("Failed to Operate %s(%s)", RES_VM, res["res_id"])
@@ -128,7 +128,7 @@ def heal_vim_res(vdus, vnfd_info, do_notify, data, vim_cache, res_cache):
action_vm(ACTION_TYPE.REBOOT, vm_info, vimid, tenant)
except VimException as e:
logger.error("Failed to Heal %s(%s)", RES_VM, resid)
- logger.error("%s:%s", e.http_code, e.message)
+ logger.error("%s:%s", e.http_code, e.args[0])
raise NFLCMException("Failed to Heal %s(%s)" % (RES_VM, resid))
@@ -385,7 +385,7 @@ def create_vm(vim_cache, res_cache, data, vm, do_notify, res_type):
"volumeId": get_res_id(res_cache, RES_VOLUME, vol_id)
})
- user_data = base64.encodestring(ignore_case_get(vm["properties"], "user_data"))
+ user_data = base64.b64encode(bytes(ignore_case_get(vm["properties"], "user_data"), "utf-8")).decode("utf-8")
set_opt_val(param, "availabilityZone", ignore_case_get(location_info, "availability_zone"))
set_opt_val(param, "userdata", user_data)
set_opt_val(param, "metadata", ignore_case_get(vm["properties"], "meta_data"))
diff --git a/lcm/lcm/pub/vimapi/api.py b/lcm/lcm/pub/vimapi/api.py
index 74fae1c6..857c3a94 100644
--- a/lcm/lcm/pub/vimapi/api.py
+++ b/lcm/lcm/pub/vimapi/api.py
@@ -27,7 +27,7 @@ MUTEX_PORT = Lock()
def call(vim_id, tenant_id, res, method, data=''):
- if data and not isinstance(data, (str, unicode)):
+ if data and not isinstance(data, str):
data = json.JSONEncoder().encode(data)
url_fmt = "{base_url}/{vim_id}{tenant_id}/{res}"
url = url_fmt.format(base_url=VIM_DRIVER_BASE_URL,