Merge branch 'master' of github.com:open-cloud/xos
diff --git a/xos/tosca/custom_types/xos.m4 b/xos/tosca/custom_types/xos.m4
index 790d5eb..70a0f6a 100644
--- a/xos/tosca/custom_types/xos.m4
+++ b/xos/tosca/custom_types/xos.m4
@@ -225,7 +225,7 @@
# In the data model, this is defaulted to false. However, to
# preserve Tosca semantics, we default it to true instead.
default: true
- capabilities:
+ capabilities:
link:
type: tosca.capabilities.network.Linkable
@@ -349,6 +349,9 @@
derived_from: tosca.relationships.Root
valid_target_types: [ tosca.capabilities.xos.Network ]
+ tosca.relationships.ConnectsToSlice:
+ derived_from: tosca.relationships.Root
+
# tosca.relationships.OwnsNetwork:
# derived_from: tosca.relationships.Root
# valid_target_types: [ tosca.capabilities.xos.Network ]
diff --git a/xos/tosca/resources/network.py b/xos/tosca/resources/network.py
index e5b8b80..8d7fca4 100644
--- a/xos/tosca/resources/network.py
+++ b/xos/tosca/resources/network.py
@@ -6,7 +6,7 @@
from translator.toscalib.tosca_template import ToscaTemplate
import pdb
-from core.models import Slice,User,Network,NetworkTemplate
+from core.models import Slice,User,Network,NetworkTemplate,NetworkSlice
from xosresource import XOSResource
@@ -40,7 +40,13 @@
return args
def postprocess(self, obj):
- pass
+ for sliceName in self.get_requirements("tosca.relationships.ConnectsToSlice"):
+ slice = self.get_xos_object(Slice, sliceName)
+ netSlices = NetworkSlice.objects.filter(network=obj, slice = slice)
+ if not netSlices:
+ self.info("Attached Network %s to Slice %s" % (obj, slice))
+ ns = NetworkSlice(network = obj, slice=slice)
+ ns.save()
# v = self.get_property("permitted_slices")
# if v: