update xproto class name & let mme show up in service list in GUI with custom_types
Change-Id: I466058d298453a7323f2cb63cb588e34e626b41b
diff --git a/xos/header.py b/xos/header.py
new file mode 100644
index 0000000..98c7297
--- /dev/null
+++ b/xos/header.py
@@ -0,0 +1,23 @@
+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
+
+class ConfigurationError(Exception):
+ pass
+
+VMME_KIND = "vEPC"
+
+CORD_USE_VTN = getattr(Config(), "networking_use_vtn", False)
+
diff --git a/xos/models.py b/xos/models.py
deleted file mode 100644
index e49a93f..0000000
--- a/xos/models.py
+++ /dev/null
@@ -1,65 +0,0 @@
-# models.py - ExampleService 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 = 'vmme'
-SERVICE_NAME_VERBOSE = 'VMME Service'
-SERVICE_NAME_VERBOSE_PLURAL = 'VMME Services'
-TENANT_NAME_VERBOSE = 'VMME Service Tenant'
-TENANT_NAME_VERBOSE_PLURAL = 'VMME Service Tenants'
-
-class VMMEService(Service):
-
- KIND = MCORD_KIND
-
- class Meta:
- proxy = True
- app_label = "vmme"
- verbose_name = "VMME Service"
-
-class VMMETenant(TenantWithContainer):
-
- KIND = 'vmme'
- class Meta:
- verbose_name = "VMME Service Tenant"
-
- tenant_message = models.CharField(max_length=254, help_text="vMME message")
- image_name = models.CharField(max_length=254, help_text="Name of VM image")
-
- def __init__(self, *args, **kwargs):
- vmme_services = VMMEService.get_service_objects().all()
- if vmme_services:
- self._meta.get_field('provider_service').default = vmme_services[0].id
- super(VMMETenant, self).__init__(*args, **kwargs)
-
- def save(self, *args, **kwargs):
- super(VMMETenant, self).save(*args, **kwargs)
- model_policy_vmmetenant(self.pk) #defined below
-
- def delete(self, *args, **kwargs):
- self.cleanup_container()
- super(VMMETenant, 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(VMMETenant, self).image
-
-
-
-def model_policy_vmmetenant(pk):
- with transaction.atomic():
- tenant = VMMETenant.objects.select_for_update().filter(pk=pk)
- if not tenant:
- return
- tenant = tenant[0]
- tenant.manage_container()
-
diff --git a/xos/tosca/custom_types/macros.m4 b/xos/tosca/custom_types/macros.m4
new file mode 100644
index 0000000..1f48f10
--- /dev/null
+++ b/xos/tosca/custom_types/macros.m4
@@ -0,0 +1,84 @@
+# Note: Tosca derived_from isn't working the way I think it should, it's not
+# inheriting from the parent template. Until we get that figured out, use
+# m4 macros do our inheritance
+
+define(xos_base_props,
+ no-delete:
+ type: boolean
+ default: false
+ description: Do not allow Tosca to delete this object
+ no-create:
+ type: boolean
+ default: false
+ description: Do not allow Tosca to create this object
+ no-update:
+ type: boolean
+ default: false
+ description: Do not allow Tosca to update this object
+ replaces:
+ type: string
+ required: false
+ descrption: Replaces/renames this object)
+# Service
+define(xos_base_service_caps,
+ scalable:
+ type: tosca.capabilities.Scalable
+ service:
+ type: tosca.capabilities.xos.Service)
+define(xos_base_service_props,
+ kind:
+ type: string
+ default: generic
+ description: Type of service.
+ view_url:
+ type: string
+ required: false
+ description: URL to follow when icon is clicked in the Service Directory.
+ icon_url:
+ type: string
+ required: false
+ description: ICON to display in the Service Directory.
+ enabled:
+ type: boolean
+ default: true
+ published:
+ type: boolean
+ default: true
+ description: If True then display this Service in the Service Directory.
+ public_key:
+ type: string
+ required: false
+ description: Public key to install into Instances to allows Services to SSH into them.
+ private_key_fn:
+ type: string
+ required: false
+ description: Location of private key file
+ versionNumber:
+ type: string
+ required: false
+ description: Version number of Service.)
+# Subscriber
+define(xos_base_subscriber_caps,
+ subscriber:
+ type: tosca.capabilities.xos.Subscriber)
+define(xos_base_subscriber_props,
+ kind:
+ type: string
+ default: generic
+ description: Kind of subscriber
+ service_specific_id:
+ type: string
+ required: false
+ description: Service specific ID opaque to XOS but meaningful to service)
+define(xos_base_tenant_props,
+ kind:
+ type: string
+ default: generic
+ description: Kind of tenant
+ service_specific_id:
+ type: string
+ required: false
+ description: Service specific ID opaque to XOS but meaningful to service)
+
+# end m4 macros
+
diff --git a/xos/tosca/custom_types/vmme.m4 b/xos/tosca/custom_types/vmme.m4
new file mode 100644
index 0000000..3b8133e
--- /dev/null
+++ b/xos/tosca/custom_types/vmme.m4
@@ -0,0 +1,18 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+# compile this with "m4 vmme.m4 > vmme.yaml"
+
+# include macros
+include(macros.m4)
+
+node_types:
+ tosca.nodes.VMMEService:
+ derived_from: tosca.nodes.Root
+ description: >
+ VMME Service
+ capabilities:
+ xos_base_service_caps
+ properties:
+ xos_base_props
+ xos_base_service_props
+
diff --git a/xos/tosca/custom_types/vmme.yaml b/xos/tosca/custom_types/vmme.yaml
new file mode 100644
index 0000000..766a1cb
--- /dev/null
+++ b/xos/tosca/custom_types/vmme.yaml
@@ -0,0 +1,81 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+# compile this with "m4 vmme.m4 > vmme.yaml"
+
+# include macros
+# Note: Tosca derived_from isn't working the way I think it should, it's not
+# inheriting from the parent template. Until we get that figured out, use
+# m4 macros do our inheritance
+
+
+# Service
+
+
+# Subscriber
+
+
+
+
+# end m4 macros
+
+
+
+node_types:
+ tosca.nodes.VMMEService:
+ derived_from: tosca.nodes.Root
+ description: >
+ VMME Service
+ capabilities:
+ scalable:
+ type: tosca.capabilities.Scalable
+ service:
+ type: tosca.capabilities.xos.Service
+ properties:
+ no-delete:
+ type: boolean
+ default: false
+ description: Do not allow Tosca to delete this object
+ no-create:
+ type: boolean
+ default: false
+ description: Do not allow Tosca to create this object
+ no-update:
+ type: boolean
+ default: false
+ description: Do not allow Tosca to update this object
+ replaces:
+ type: string
+ required: false
+ descrption: Replaces/renames this object
+ kind:
+ type: string
+ default: generic
+ description: Type of service.
+ view_url:
+ type: string
+ required: false
+ description: URL to follow when icon is clicked in the Service Directory.
+ icon_url:
+ type: string
+ required: false
+ description: ICON to display in the Service Directory.
+ enabled:
+ type: boolean
+ default: true
+ published:
+ type: boolean
+ default: true
+ description: If True then display this Service in the Service Directory.
+ public_key:
+ type: string
+ required: false
+ description: Public key to install into Instances to allows Services to SSH into them.
+ private_key_fn:
+ type: string
+ required: false
+ description: Location of private key file
+ versionNumber:
+ type: string
+ required: false
+ description: Version number of Service.
+
diff --git a/xos/vmme-onboard.yaml b/xos/vmme-onboard.yaml
index 214d576..98d49e8 100644
--- a/xos/vmme-onboard.yaml
+++ b/xos/vmme-onboard.yaml
@@ -13,9 +13,10 @@
base_url: file:///opt/xos_services/vmme/xos/
# The following will concatenate with base_url automatically, if
# base_url is non-null.
- models: models.py
+ xproto: ./
admin: admin.py
admin_template: templates/mcordadmin.html
+ tosca_custom_types: tosca/custom_types/vmme.yaml
synchronizer: synchronizer/manifest
synchronizer_run: vmme-synchronizer.py
tosca_resource: tosca/resources/vmmetenant.py, tosca/resources/vmmeservice.py
diff --git a/xos/vmme.xproto b/xos/vmme.xproto
index 6fa136a..c06f480 100644
--- a/xos/vmme.xproto
+++ b/xos/vmme.xproto
@@ -3,13 +3,13 @@
option verbose_name = "vMME Service";
option kind = "vEPC";
-message VmmeService (Service){
+message VMMEService (Service){
required string service_message = 1 [help_text = "Service Message to Display", max_length = 254, null = False, db_index = False, blank = False];
}
-message VmmeTenant (TenantWithContainer){
+message VMMETenant (TenantWithContainer){
option name = "vmmetenant";
option verbose_name = "vMME Tenant";
required string tenant_message = 1 [help_text = "Tenant Message to Display", max_length = 254, null = False, db_index = False, blank = False];
-}
\ No newline at end of file
+}