Fix vHSS proxy model display
Change-Id: Ia01540198fb782e004eb5e72841a5fca22f23510
diff --git a/xos/admin.py b/xos/admin.py
index a9ac2df..df1ad24 100644
--- a/xos/admin.py
+++ b/xos/admin.py
@@ -1,4 +1,4 @@
-# admin.py - ExampleService Django Admin
+# admin.py - VHSSService Django Admin
from core.admin import ReadOnlyAwareAdmin, SliceInline
from core.middleware import get_request
@@ -46,7 +46,7 @@
extracontext_registered_admins = True
suit_form_tabs = (
- ('general', 'Example Service Details', ),
+ ('general', 'vHSS Service Details', ),
('slices', 'Slices',),
)
@@ -91,7 +91,7 @@
return super(VHSSTenantForm, self).save(commit=commit)
-class ExampleTenantAdmin(ReadOnlyAwareAdmin):
+class VHSSTenantAdmin(ReadOnlyAwareAdmin):
verbose_name = "vHSS Service Tenant"
verbose_name_plural = "vHSS Service Tenants"
diff --git a/xos/header.py b/xos/header.py
new file mode 100644
index 0000000..4a699d2
--- /dev/null
+++ b/xos/header.py
@@ -0,0 +1,21 @@
+from django.db import models
+from core.models import Service, PlCoreBase, Slice, Instance, Tenant, TenantWithContainer, Node, Image, User, Flavor, NetworkParameter, NetworkParameterType, Port, AddressPool
+from core.models.plcorebase import StrippedCharField
+import os
+from django.db import models, transaction
+from django.forms.models import model_to_dict
+from django.db.models import *
+from operator import itemgetter, attrgetter, methodcaller
+from core.models import Tag
+from core.models.service import LeastLoadedNodeScheduler
+import traceback
+from xos.exceptions import *
+from xos.config import Config
+from django.contrib.contenttypes.models import ContentType
+from django.contrib.contenttypes.fields import GenericForeignKey
+
+MCORD_KIND = "vEPC"
+SERVICE_NAME_VERBOSE = 'Virtual Home Subscriber Server Service'
+SERVICE_NAME_VERBOSE_PLURAL = 'Virtual Home Suscriber Server Services'
+TENANT_NAME_VERBOSE = 'Virtual Home Subscriber Server Tenant'
+TENANT_NAME_VERBOSE_PLURAL = 'Virtual Home Subscriber Server Tenants'
diff --git a/xos/models.py b/xos/models.py
deleted file mode 100644
index f36af40..0000000
--- a/xos/models.py
+++ /dev/null
@@ -1,64 +0,0 @@
-# models.py - VHSSService Models
-
-from core.models import Service, TenantWithContainer, Image
-from django.db import models, transaction
-
-MCORD_KIND = "EPC" # added from vBBU
-
-# these macros are currently not used, names hard-coded manually
-SERVICE_NAME = 'vhss'
-SERVICE_NAME_VERBOSE = 'VHSS Service'
-SERVICE_NAME_VERBOSE_PLURAL = 'VHSS Services'
-TENANT_NAME_VERBOSE = 'VHSS Service Tenant'
-TENANT_NAME_VERBOSE_PLURAL = 'VHSS Service Tenants'
-
-
-class VHSSService(Service):
- KIND = MCORD_KIND
-
- class Meta:
- proxy = True
- app_label = "vhss"
- verbose_name = "VHSS Service"
-
-
-class VHSSTenant(TenantWithContainer):
- KIND = 'vhss'
-
- class Meta:
- verbose_name = "VHSS Service Tenant"
-
- tenant_message = models.CharField(max_length=254, help_text="vHSS message")
- image_name = models.CharField(max_length=254, help_text="Name of VM image")
-
- def __init__(self, *args, **kwargs):
- vhss_services = VHSSService.get_service_objects().all()
- if vhss_services:
- self._meta.get_field('provider_service').default = vhss_services[0].id
- super(VHSSTenant, self).__init__(*args, **kwargs)
-
- def save(self, *args, **kwargs):
- super(VHSSTenant, self).save(*args, **kwargs)
- model_policy_vhsstenant(self.pk) # defined below
-
- def delete(self, *args, **kwargs):
- self.cleanup_container()
- super(VHSSTenant, self).delete(*args, **kwargs)
-
- @property
- def image(self):
- img = self.image_name.strip()
- if img.lower() != "default":
- return Image.objects.get(name=img)
- else:
- return super(VHSSTenant, self).image
-
-
-def model_policy_vhsstenant(pk):
- with transaction.atomic():
- tenant = VHSSTenant.objects.select_for_update().filter(pk=pk)
- if not tenant:
- return
- tenant = tenant[0]
- tenant.manage_container()
-
diff --git a/xos/synchronizer/steps/sync_vhsstenant.py b/xos/synchronizer/steps/sync_vhsstenant.py
index 88a3efb..78167f8 100644
--- a/xos/synchronizer/steps/sync_vhsstenant.py
+++ b/xos/synchronizer/steps/sync_vhsstenant.py
@@ -2,12 +2,12 @@
import sys
from synchronizers.new_base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
from synchronizers.new_base.modelaccessor import *
-from xos.logger import Logger, logging
+#from xos.logger import Logger, logging
parentdir = os.path.join(os.path.dirname(__file__), "..")
sys.path.insert(0, parentdir)
-logger = Logger(level=logging.INFO)
+#logger = Logger(level=logging.INFO)
class SyncVHSSTenant(SyncInstanceUsingAnsible):
@@ -37,19 +37,18 @@
return vhss[0]
- # Gets the attributes that are used by the Ansible template but are not
- # part of the set of default attributes.
- #def get_extra_attributes(self, o):
- # fields = {}
- # fields['tenant_message'] = o.tenant_message
- # vhss = self.get_vhss(o)
- # fields['service_message'] = vhss.service_message
- # return fields
+ #Gets the attributes that are used by the Ansible template but are not
+ #part of the set of default attributes.
- #def delete_record(self, port):
- # # Nothing needs to be done to delete an exampleservice; it goes away
- # # when the instance holding the exampleservice is deleted.
- # pass
+ def get_extra_attributes(self, o):
+ fields = {}
+ fields['tenant_message'] = o.tenant_message
+ vhss = self.get_vhss(o)
+ fields['service_message'] = vhss.service_message
+ return fields
+
+ def delete_record(self, port):
+ pass
#def handle_service_monitoringagentinfo_watch_notification(self, monitoring_agent_info):
# if not monitoring_agent_info.service:
diff --git a/xos/synchronizer/vhss_from_api_config b/xos/synchronizer/vhss_from_api_config
index 4e34eac..65539c0 100644
--- a/xos/synchronizer/vhss_from_api_config
+++ b/xos/synchronizer/vhss_from_api_config
@@ -17,6 +17,5 @@
accessor_kind=api
accessor_password=@/opt/xos/services/vhss/credentials/xosadmin@opencord.org
#required_models=VHSSService, VHSSTenant, ServiceDependency, ServiceMonitoringAgentInfo
-
[networking]
use_vtn=True
diff --git a/xos/templates/vhssadmin.html b/xos/templates/vhssadmin.html
new file mode 100644
index 0000000..9952a95
--- /dev/null
+++ b/xos/templates/vhssadmin.html
@@ -0,0 +1,9 @@
+<div class = "left-nav">
+ <ul>
+ <li>
+ <a href="/admin/mcordservice/vhsscomponent/">
+ vHSS Service Components>
+ </a>
+ </li>
+ </ul>
+</div>
diff --git a/xos/tosca/resources/vhsstenant.py b/xos/tosca/resources/vhsstenant.py
index 0bbeec6..aa027a1 100644
--- a/xos/tosca/resources/vhsstenant.py
+++ b/xos/tosca/resources/vhsstenant.py
@@ -1,6 +1,6 @@
from xosresource import XOSResource
from core.models import Tenant, Service
-from services.vhss.models import * #ExampleTenant, SERVICE_NAME as EXAMPLETENANT_KIND
+from services.vhss.models import VHSSTenant
class XOSVHSSTenant(XOSResource):
provides = "tosca.nodes.VHSSTenant"
@@ -11,7 +11,6 @@
def get_xos_args(self, throw_exception=True):
args = super(XOSVHSSTenant, self).get_xos_args()
- # ExampleTenant must always have a provider_service
provider_name = self.get_requirement("tosca.relationships.TenantOfService", throw_exception=True)
if provider_name:
args["provider_service"] = self.get_xos_object(Service, throw_exception=True, name=provider_name)
diff --git a/xos/vhss-onboard.yaml b/xos/vhss-onboard.yaml
index 49d2741..13f6005 100644
--- a/xos/vhss-onboard.yaml
+++ b/xos/vhss-onboard.yaml
@@ -7,7 +7,7 @@
topology_template:
node_templates:
- vhss:
+ servicecontroller#vhss:
type: tosca.nodes.ServiceController
properties:
base_url: file:///opt/xos_services/vhss/xos/
@@ -15,6 +15,9 @@
# base_url is non-null.
xproto: ./
admin: admin.py
+ admin_template: templates/vhssadmin.html
+ #synchronizer: synchronizer/manifest
+ #synchronizer_run: vhss-synchronizer.py
tosca_custom_types: tosca/custom_types/vhss.yaml
tosca_resource: tosca/resources/vhssservice.py, tosca/resources/vhsstenant.py
private_key: file:///opt/xos/key_import/mcord_rsa
diff --git a/xos/vhss.xproto b/xos/vhss.xproto
index b4d9846..77cf464 100644
--- a/xos/vhss.xproto
+++ b/xos/vhss.xproto
@@ -1,15 +1,15 @@
option name = "vHSS";
-option verbose_name = "VHSSService";
-
-option legacy = "True";
+option verbose_name = "Virtual Home Subscriber Server";
message VHSSService (Service){
- required string service_message = 1 [help_text = "Service Message to Display", max_length = 254, null = False, db_index = False, blank = False];
+ option name = "VHSSService";
+ option verbose_name = "Virtual Home Subscriber Server Service";
+ required string service_message = 1 [help_text = "Service Message to Display", max_length = 254, null = False, db_index = False, blank = False];
}
message VHSSTenant (TenantWithContainer){
- option name = "VHSS";
+ option name = "VHSSTenant";
option verbose_name = "Virtual Home Subscriber Server Tenant";
required string tenant_message = 1 [help_text = "Tenant Message to Display", max_length = 254, null = False, db_index = False, blank = False];
}