From 669ef8d8b4f9b9170d0710bc92ac621fe27fcb81 Mon Sep 17 00:00:00 2001 From: fujinhua Date: Mon, 29 Apr 2019 10:54:46 +0800 Subject: Add nslcm admin db management Change-Id: Ia94c41f32019cdad2b1e15dd49c6f0660a8defd0 Issue-ID: VFC-1306 Signed-off-by: fujinhua --- lcm/pub/database/admin.py | 340 ++++++++++++++++++++++++++++++++++++++++++++++ lcm/settings.py | 1 + lcm/urls.py | 2 + 3 files changed, 343 insertions(+) create mode 100644 lcm/pub/database/admin.py diff --git a/lcm/pub/database/admin.py b/lcm/pub/database/admin.py new file mode 100644 index 00000000..90dad5db --- /dev/null +++ b/lcm/pub/database/admin.py @@ -0,0 +1,340 @@ +# 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. + +from django.contrib import admin + +from lcm.pub.database.models import NSDModel +from lcm.pub.database.models import NSInstModel +from lcm.pub.database.models import NfPackageModel +from lcm.pub.database.models import VnfPackageFileModel +from lcm.pub.database.models import FPInstModel +from lcm.pub.database.models import VNFFGInstModel +from lcm.pub.database.models import NfInstModel +from lcm.pub.database.models import VmInstModel +from lcm.pub.database.models import VNFCInstModel +from lcm.pub.database.models import CPInstModel +from lcm.pub.database.models import VLInstModel +from lcm.pub.database.models import PortInstModel +from lcm.pub.database.models import JobModel +from lcm.pub.database.models import JobStatusModel +from lcm.pub.database.models import DefPkgMappingModel +from lcm.pub.database.models import InputParamMappingModel +from lcm.pub.database.models import ServiceBaseInfoModel +from lcm.pub.database.models import WFPlanModel +from lcm.pub.database.models import OOFDataModel +from lcm.pub.database.models import SubscriptionModel +from lcm.pub.database.models import NSLcmOpOccModel +from lcm.pub.database.models import PNFInstModel + + +@admin.register(NSDModel) +class NSDModelAdmin(admin.ModelAdmin): + list_display_links = ('id', 'name') + fields = [ + "id", + "nsd_id", + "name", + "vendor", + "description", + "version", + "nsd_model", + "nsd_path" + ] + + list_display = [ + "id", + "nsd_id", + "name", + "vendor", + "description", + "version", + "nsd_model", + "nsd_path" + ] + + search_fields = ( + "id", + "nsd_id", + "name" + ) + + +@admin.register(NSInstModel) +class NSInstModelAdmin(admin.ModelAdmin): + list_display_links = ('id', 'name') + fields = [ + "id", + "name", + "nspackage_id", + "nsd_id", + "nsd_invariant_id", + "description", + "sdncontroller_id", + "flavour_id", + "ns_level", + "status", + "nsd_model", + "input_params", + "scale_params", + "create_time", + "lastuptime", + "global_customer_id", + "service_type" + ] + + list_display = [ + "id", + "name", + "nspackage_id", + "nsd_id", + "nsd_invariant_id", + "description", + "sdncontroller_id", + "flavour_id", + "ns_level", + "status", + "nsd_model", + "input_params", + "scale_params", + "create_time", + "lastuptime", + "global_customer_id", + "service_type" + ] + + search_fields = ( + "id", + "name", + "nsd_id" + ) + + +@admin.register(NfInstModel) +class NfInstModelAdmin(admin.ModelAdmin): + list_display_links = ('nfinstid', 'nf_name') + fields = [ + "nfinstid", + "mnfinstid", + "nf_name", + "template_id", + "vnf_id", + "package_id", + "vnfm_inst_id", + "ns_inst_id", + "status", + "flavour_id", + "vnf_level", + "location", + "max_vm", + "max_cpu", + "max_ram", + "max_hd", + "max_shd", + "max_net", + "version", + "vendor", + "vnfd_model", + "input_params", + "scale_params", + "create_time", + "lastuptime", + "extension" + ] + + list_display = [ + "nfinstid", + "mnfinstid", + "nf_name", + "template_id", + "vnf_id", + "package_id", + "vnfm_inst_id", + "ns_inst_id", + "status", + "flavour_id", + "vnf_level", + "location", + "max_vm", + "max_cpu", + "max_ram", + "max_hd", + "max_shd", + "max_net", + "version", + "vendor", + "vnfd_model", + "input_params", + "scale_params", + "create_time", + "lastuptime", + "extension" + ] + + search_fields = ( + "nfinstid", + "nf_name", + "ns_inst_id" + ) + + +@admin.register(VmInstModel) +class VmInstModelAdmin(admin.ModelAdmin): + list_display_links = ('vmid', 'resouceid') + fields = [ + "vmid", + "vimid", + "resouceid", + "insttype", + "instid", + "vmname", + "operationalstate", + "zoneid", + "tenant", + "hostid", + "detailinfo" + ] + + list_display = [ + "vmid", + "vimid", + "resouceid", + "insttype", + "instid", + "vmname", + "operationalstate", + "zoneid", + "tenant", + "hostid", + "detailinfo" + ] + + search_fields = ( + "vmid", + "vimid", + "resouceid" + ) + + +@admin.register(VNFCInstModel) +class VNFCInstModelAdmin(admin.ModelAdmin): + list_display_links = ('vnfcinstanceid', 'vduid') + fields = [ + "vnfcinstanceid", + "vduid", + "nfinstid", + "vmid", + "status" + ] + + list_display = [ + "vnfcinstanceid", + "vduid", + "nfinstid", + "vmid", + "status" + ] + + search_fields = ( + "vnfcinstanceid", + "vduid", + "nfinstid" + ) + + +@admin.register(VLInstModel) +class VLInstModelAdmin(admin.ModelAdmin): + list_display_links = ('vlinstanceid', 'vldid') + fields = [ + "vlinstanceid", + "vldid", + "vlinstancename", + "ownertype", + "ownerid", + "relatednetworkid", + "relatedsubnetworkid", + "vltype", + "vimid", + "tenant", + "status", + ] + + list_display = [ + "vlinstanceid", + "vldid", + "vlinstancename", + "ownertype", + "ownerid", + "relatednetworkid", + "relatedsubnetworkid", + "vltype", + "vimid", + "tenant", + "status", + ] + + search_fields = ( + "vlinstanceid", + "vldid", + "vlinstancename" + ) + + +@admin.register(OOFDataModel) +class OOFDataModelAdmin(admin.ModelAdmin): + list_display_links = ('request_id', 'transaction_id') + fields = [ + "request_id", + "transaction_id", + "request_status", + "request_module_name", + "service_resource_id", + "vim_id", + "cloud_owner", + "cloud_region_id", + "vdu_info" + ] + + list_display = [ + "request_id", + "transaction_id", + "request_status", + "request_module_name", + "service_resource_id", + "vim_id", + "cloud_owner", + "cloud_region_id", + "vdu_info" + ] + + search_fields = ( + "request_id", + "transaction_id" + ) + + +admin.site.register(NfPackageModel) +admin.site.register(VnfPackageFileModel) +admin.site.register(FPInstModel) +admin.site.register(CPInstModel) +admin.site.register(VNFFGInstModel) +admin.site.register(PortInstModel) +admin.site.register(JobModel) +admin.site.register(JobStatusModel) +admin.site.register(DefPkgMappingModel) +admin.site.register(InputParamMappingModel) +admin.site.register(ServiceBaseInfoModel) +admin.site.register(WFPlanModel) +admin.site.register(SubscriptionModel) +admin.site.register(NSLcmOpOccModel) +admin.site.register(PNFInstModel) diff --git a/lcm/settings.py b/lcm/settings.py index 71e609b4..b5a5e15a 100644 --- a/lcm/settings.py +++ b/lcm/settings.py @@ -47,6 +47,7 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'django.contrib.admin', 'rest_framework', 'lcm.pub.database', 'lcm.swagger', diff --git a/lcm/urls.py b/lcm/urls.py index 4f2c5e70..67268ea7 100644 --- a/lcm/urls.py +++ b/lcm/urls.py @@ -13,12 +13,14 @@ # limitations under the License. from django.conf.urls import include, url +from django.contrib import admin from lcm.pub.config.config import DEPLOY_WORKFLOW_WHEN_START from lcm.pub.config.config import REG_TO_MSB_WHEN_START, REG_TO_MSB_REG_URL, REG_TO_MSB_REG_PARAM urlpatterns = [ + url(r'^api/nslcm/v1/admin', admin.site.urls), url(r'^', include('lcm.samples.urls')), url(r'^', include('lcm.ns_vnfs.urls')), url(r'^', include('lcm.ns_pnfs.urls')), -- cgit 1.2.3-korg