support for setting node labels for nodes in tosca
diff --git a/xos/tosca/custom_types/xos.m4 b/xos/tosca/custom_types/xos.m4
index fbbb7b9..9773822 100644
--- a/xos/tosca/custom_types/xos.m4
+++ b/xos/tosca/custom_types/xos.m4
@@ -862,6 +862,10 @@
derived_from: tosca.relationships.Root
valid_target_types: [ tosca.capabilities.xos.DashboardView ]
+ tosca.relationships.HasLabel:
+ derived_from: tosca.relationships.Root
+ valid_target_types: [ tosca.capabilities.xos.NodeLabel ]
+
tosca.capabilities.xos.Service:
derived_from: tosca.capabilities.Root
description: An XOS Service
diff --git a/xos/tosca/custom_types/xos.yaml b/xos/tosca/custom_types/xos.yaml
index a9babb0..21e8b8b 100644
--- a/xos/tosca/custom_types/xos.yaml
+++ b/xos/tosca/custom_types/xos.yaml
@@ -1174,6 +1174,10 @@
derived_from: tosca.relationships.Root
valid_target_types: [ tosca.capabilities.xos.DashboardView ]
+ tosca.relationships.HasLabel:
+ derived_from: tosca.relationships.Root
+ valid_target_types: [ tosca.capabilities.xos.NodeLabel ]
+
tosca.capabilities.xos.Service:
derived_from: tosca.capabilities.Root
description: An XOS Service
diff --git a/xos/tosca/resources/node.py b/xos/tosca/resources/node.py
index 59b915b..b7f426d 100644
--- a/xos/tosca/resources/node.py
+++ b/xos/tosca/resources/node.py
@@ -5,7 +5,7 @@
sys.path.append("/opt/tosca")
from translator.toscalib.tosca_template import ToscaTemplate
-from core.models import Node, Site, Deployment, SiteDeployment
+from core.models import Node, NodeLabel, Site, Deployment, SiteDeployment
from xosresource import XOSResource
@@ -30,6 +30,12 @@
siteDeployment = self.get_xos_object(SiteDeployment, site=site, deployment=deployment, throw_exception=True)
args["site_deployment"] = siteDeployment
+ labels=[]
+ for label_name in self.get_requirements("tosca.relationships.HasLabel"):
+ labels.append(self.get_xos_object(NodeLabel, name=label_name))
+ if labels:
+ args["labels"] = labels
+
return args
def create(self):