allow slices to be attached to services, fix CORD sample mysite_vcpe slice
diff --git a/xos/tosca/resources/slice.py b/xos/tosca/resources/slice.py
index 073e205..5c576be 100644
--- a/xos/tosca/resources/slice.py
+++ b/xos/tosca/resources/slice.py
@@ -5,7 +5,7 @@
sys.path.append("/opt/tosca")
from translator.toscalib.tosca_template import ToscaTemplate
-from core.models import Slice,User,Site,Network,NetworkSlice,SliceRole,SlicePrivilege
+from core.models import Slice,User,Site,Network,NetworkSlice,SliceRole,SlicePrivilege,Service
from xosresource import XOSResource
@@ -14,10 +14,18 @@
xos_model = Slice
def get_xos_args(self):
+ args = {"name": self.nodetemplate.name}
+
site_name = self.get_requirement("tosca.relationships.MemberOfSite", throw_exception=True)
site = self.get_xos_object(Site, login_base=site_name)
- return {"name": self.nodetemplate.name,
- "site": site}
+ args["site"] = site
+
+ serviceName = self.get_requirement("tosca.relationships.MemberOfService", throw_exception=False)
+ if serviceName:
+ service = self.get_xos_object(Service, name=serviceName)
+ args["service"] = service
+
+ return args
def postprocess(self, obj):
for net_name in self.get_requirements("tosca.relationships.ConnectsToNetwork"):
diff --git a/xos/tosca/samples/cord.yaml b/xos/tosca/samples/cord.yaml
index 72a069d..f160cb6 100644
--- a/xos/tosca/samples/cord.yaml
+++ b/xos/tosca/samples/cord.yaml
@@ -42,7 +42,7 @@
type: tosca.nodes.Slice
requirements:
- vcpe_service:
- node: service_volt
+ node: service_vcpe
relationship: tosca.relationships.MemberOfService
- site:
node: mysite