add exampleservice to tosca
diff --git a/xos/configurations/cord-pod/pod-exampleservice.yaml b/xos/configurations/cord-pod/pod-exampleservice.yaml
index 2abe484..56261e5 100644
--- a/xos/configurations/cord-pod/pod-exampleservice.yaml
+++ b/xos/configurations/cord-pod/pod-exampleservice.yaml
@@ -49,4 +49,17 @@
- management:
node: management
relationship: tosca.relationships.ConnectsToNetwork
+ - exmapleserver:
+ node: service_exampleservice
+ relationship: tosca.relationships.MemberOfService
+
+ service_exampleservice:
+ type: tosca.nodes.ExampleService
+ requirements:
+ - management:
+ node: management
+ relationship: tosca.relationships.UsesNetwork
+ properties:
+ view_url: /admin/exampleservice/exampleservice/$id$/
+ kind: exampleservice
diff --git a/xos/tosca/custom_types/xos.m4 b/xos/tosca/custom_types/xos.m4
index bb919e2..d903190 100644
--- a/xos/tosca/custom_types/xos.m4
+++ b/xos/tosca/custom_types/xos.m4
@@ -258,6 +258,17 @@
xos_base_props
xos_base_service_props
+ tosca.nodes.ExampleService:
+ derived_from: tosca.nodes.Root
+ description: >
+ Example Service
+ capabilities:
+ xos_base_service_caps
+ properties:
+ xos_base_props
+ xos_base_service_props
+
+
tosca.nodes.Subscriber:
derived_from: tosca.nodes.Root
description: XOS subscriber base class.
diff --git a/xos/tosca/custom_types/xos.yaml b/xos/tosca/custom_types/xos.yaml
index 530e534..adc1bf1 100644
--- a/xos/tosca/custom_types/xos.yaml
+++ b/xos/tosca/custom_types/xos.yaml
@@ -448,6 +448,61 @@
required: false
description: Version number of Service.
+ tosca.nodes.ExampleService:
+ derived_from: tosca.nodes.Root
+ description: >
+ Example 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
+ 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.
+
+
tosca.nodes.Subscriber:
derived_from: tosca.nodes.Root
description: XOS subscriber base class.
diff --git a/xos/tosca/resources/exampleservice.py b/xos/tosca/resources/exampleservice.py
new file mode 100644
index 0000000..447ff4d
--- /dev/null
+++ b/xos/tosca/resources/exampleservice.py
@@ -0,0 +1,38 @@
+import os
+import pdb
+import sys
+import tempfile
+sys.path.append("/opt/tosca")
+from translator.toscalib.tosca_template import ToscaTemplate
+import pdb
+
+from core.models import Service,User,CoarseTenant
+from services.exampleservice import ExampleService
+
+from xosresource import XOSResource
+
+class XOSExampleService(XOSResource):
+ provides = "tosca.nodes.ExampleService"
+ xos_model = ExampleService
+ copyin_props = ["view_url", "icon_url", "enabled", "published", "public_key", "private_key_fn", "versionNumber"]
+
+ def postprocess(self, obj):
+ for provider_service_name in self.get_requirements("tosca.relationships.TenantOfService"):
+ provider_service = self.get_xos_object(ExampleService, name=provider_service_name)
+
+ existing_tenancy = CoarseTenant.get_tenant_objects().filter(provider_service = provider_service, subscriber_service = obj)
+ if existing_tenancy:
+ self.info("Tenancy relationship from %s to %s already exists" % (str(obj), str(provider_service)))
+ else:
+ tenancy = CoarseTenant(provider_service = provider_service,
+ subscriber_service = obj)
+ tenancy.save()
+
+ self.info("Created Tenancy relationship from %s to %s" % (str(obj), str(provider_service)))
+
+ def can_delete(self, obj):
+ if obj.slices.exists():
+ self.info("Service %s has active slices; skipping delete" % obj.name)
+ return False
+ return super(XOSExampleService, self).can_delete(obj)
+