add Node to Tosca
diff --git a/xos/tosca/custom_types/xos.m4 b/xos/tosca/custom_types/xos.m4
index 0a68c9d..28df41e 100644
--- a/xos/tosca/custom_types/xos.m4
+++ b/xos/tosca/custom_types/xos.m4
@@ -377,6 +377,12 @@
slice:
type: tosca.capabilities.xos.Slice
+ tosca.nodes.Node:
+ derived_from: tosca.nodes.Root
+ capability:
+ node:
+ type: tosca.capabilities.xos.Node
+
tosca.relationships.MemberOfSlice:
derived_from: tosca.relationships.Root
valid_target_types: [ tosca.capabilities.xos.Slice ]
@@ -389,6 +395,10 @@
derived_from: tosca.relationships.Root
valid_target_types: [ tosca.capabilities.xos.Site ]
+ tosca.relationships.MemberOfDeployment:
+ derived_from: tosca.relationships.Root
+ valid_target_types: [ tosca.capabilities.xos.Deployment ]
+
tosca.relationships.TenantOfService:
derived_from: tosca.relationships.Root
valid_target_types: [ tosca.capabilities.xos.Service ]
@@ -478,3 +488,7 @@
derived_from: tosca.capabilities.Root
description: An XOS Subscriber
+ tosca.capabilities.xos.Node:
+ derived_from: tosca.capabilities.Root
+ description: An XOS Node
+
diff --git a/xos/tosca/custom_types/xos.yaml b/xos/tosca/custom_types/xos.yaml
index c59842f..92f73f4 100644
--- a/xos/tosca/custom_types/xos.yaml
+++ b/xos/tosca/custom_types/xos.yaml
@@ -439,6 +439,12 @@
slice:
type: tosca.capabilities.xos.Slice
+ tosca.nodes.Node:
+ derived_from: tosca.nodes.Root
+ capability:
+ node:
+ type: tosca.capabilities.xos.Node
+
tosca.relationships.MemberOfSlice:
derived_from: tosca.relationships.Root
valid_target_types: [ tosca.capabilities.xos.Slice ]
@@ -451,6 +457,10 @@
derived_from: tosca.relationships.Root
valid_target_types: [ tosca.capabilities.xos.Site ]
+ tosca.relationships.MemberOfDeployment:
+ derived_from: tosca.relationships.Root
+ valid_target_types: [ tosca.capabilities.xos.Deployment ]
+
tosca.relationships.TenantOfService:
derived_from: tosca.relationships.Root
valid_target_types: [ tosca.capabilities.xos.Service ]
@@ -540,3 +550,7 @@
derived_from: tosca.capabilities.Root
description: An XOS Subscriber
+ tosca.capabilities.xos.Node:
+ derived_from: tosca.capabilities.Root
+ description: An XOS Node
+
diff --git a/xos/tosca/resources/node.py b/xos/tosca/resources/node.py
new file mode 100644
index 0000000..ed39737
--- /dev/null
+++ b/xos/tosca/resources/node.py
@@ -0,0 +1,58 @@
+import os
+import pdb
+import sys
+import tempfile
+sys.path.append("/opt/tosca")
+from translator.toscalib.tosca_template import ToscaTemplate
+
+from core.models import Node, Site, Deployment, SiteDeployment
+
+from xosresource import XOSResource
+
+class XOSNode(XOSResource):
+ provides = "tosca.nodes.Node"
+ xos_model = Node
+
+ def get_xos_args(self):
+ args = {"name": self.nodetemplate.name}
+
+ site = None
+ siteName = self.get_requirement("tosca.relationships.MemberOfSite", throw_exception=False)
+ if siteName:
+ site = self.get_xos_object(Site, name=siteName)
+ args["site"] = site
+
+ deploymentName = self.get_requirement("tosca.relationships.MemberOfDeployment", throw_exception=False)
+ if deploymentName:
+ deployment = self.get_xos_object(Deployment, name=deploymentName)
+
+ if site:
+ siteDeployment = self.get_xos_object(SiteDeployment, site=site, deployment=deployment, throw_exception=True)
+ args["site_deployment"] = siteDeployment
+
+ return args
+
+ def create(self):
+ nodetemplate = self.nodetemplate
+ sliceName = nodetemplate.name
+
+ xos_args = self.get_xos_args()
+
+ if not xos_args.get("site", None):
+ raise Exception("Site is a required field of Node")
+ if not xos_args.get("site_deployment", None):
+ raise Exception("Deployment is a required field of Node")
+
+ node = Node(**xos_args)
+ node.caller = self.user
+ node.save()
+
+ self.postprocess(node)
+
+ self.info("Created Node '%s' on Site '%s' Deployment '%s'" % (str(node), str(node.site), str(node.site_deployment.deployment)))
+
+ def delete(self, obj):
+ super(XOSNode, self).delete(obj)
+
+
+