more props for slice; write slice test case
diff --git a/xos/tosca/custom_types/xos.m4 b/xos/tosca/custom_types/xos.m4
index 629c378..1f48f58 100644
--- a/xos/tosca/custom_types/xos.m4
+++ b/xos/tosca/custom_types/xos.m4
@@ -379,6 +379,19 @@
capability:
slice:
type: tosca.capabilities.xos.Slice
+ properties:
+ enabled:
+ type: boolean
+ default: true
+ description:
+ type: string
+ required: false
+ slice_url:
+ type: string
+ required: false
+ max_instances:
+ type: integer
+ default: 10
tosca.nodes.Node:
derived_from: tosca.nodes.Root
diff --git a/xos/tosca/custom_types/xos.yaml b/xos/tosca/custom_types/xos.yaml
index 6611198..f66dbc6 100644
--- a/xos/tosca/custom_types/xos.yaml
+++ b/xos/tosca/custom_types/xos.yaml
@@ -441,6 +441,19 @@
capability:
slice:
type: tosca.capabilities.xos.Slice
+ properties:
+ enabled:
+ type: boolean
+ default: true
+ description:
+ type: string
+ required: false
+ slice_url:
+ type: string
+ required: false
+ max_instances:
+ type: integer
+ default: 10
tosca.nodes.Node:
derived_from: tosca.nodes.Root
diff --git a/xos/tosca/resources/slice.py b/xos/tosca/resources/slice.py
index d9684f2..e4b7ba3 100644
--- a/xos/tosca/resources/slice.py
+++ b/xos/tosca/resources/slice.py
@@ -12,9 +12,10 @@
class XOSSlice(XOSResource):
provides = "tosca.nodes.Slice"
xos_model = Slice
+ copyin_props = ["enabled", "description", "slice_url", "max_instances"]
def get_xos_args(self):
- args = {"name": self.nodetemplate.name}
+ args = super(XOSSlice, self).get_xos_args()
site_name = self.get_requirement("tosca.relationships.MemberOfSite", throw_exception=True)
site = self.get_xos_object(Site, login_base=site_name)
diff --git a/xos/tosca/tests/alltests.py b/xos/tosca/tests/alltests.py
index 04c4ade..4ff19fc 100644
--- a/xos/tosca/tests/alltests.py
+++ b/xos/tosca/tests/alltests.py
@@ -7,6 +7,7 @@
from sitetest import SiteTest
from deploymenttest import DeploymentTest
from nodetest import NodeTest
+from slicetest import SliceTest
if __name__ == "__main__":
SiteTest()
@@ -17,4 +18,5 @@
CoarseTenancyTest()
ServiceTest()
UserTest()
+ SliceTest()
ComputeTest()
diff --git a/xos/tosca/tests/slicetest.py b/xos/tosca/tests/slicetest.py
new file mode 100644
index 0000000..484d7c8
--- /dev/null
+++ b/xos/tosca/tests/slicetest.py
@@ -0,0 +1,46 @@
+from basetest import BaseToscaTest
+
+from core.models import Slice, Site
+
+class SliceTest(BaseToscaTest):
+ tests = ["create_slice_minimal",
+ "create_slice_maximal",
+ "destroy_slice"]
+
+ def cleanup(self):
+ self.try_to_delete(Slice, name="testsite_testslice")
+ self.try_to_delete(Site, name="testsite")
+
+ def get_base_templates(self):
+ return self.make_nodetemplate("testsite", "tosca.nodes.Site")
+
+ def create_slice_minimal(self):
+ self.assert_noobj(Slice, "testsite_testslice")
+ self.execute(self.get_base_templates() +
+ self.make_nodetemplate("testsite_testslice", "tosca.nodes.Slice",
+ reqs=[("testsite", "tosca.relationships.MemberOfSite")]))
+ self.assert_obj(Slice, "testsite_testslice", enabled=True, description="", slice_url="", max_instances=10)
+
+ def create_slice_maximal(self):
+ self.assert_noobj(Slice, "testsite_testslice")
+ self.execute(self.get_base_templates() +
+ self.make_nodetemplate("testsite_testslice", "tosca.nodes.Slice",
+ props={"enabled": False, "description": "foo", "slice_url": "http://foo.com/", "max_instances": 11},
+ reqs=[("testsite", "tosca.relationships.MemberOfSite")]))
+ self.assert_obj(Slice, "testsite_testslice", enabled=False, description="foo", slice_url="http://foo.com/", max_instances=11)
+
+ def destroy_slice(self):
+ self.assert_noobj(Slice, "testsite_testslice")
+ self.execute(self.get_base_templates() +
+ self.make_nodetemplate("testsite_testslice", "tosca.nodes.Slice",
+ reqs=[("testsite", "tosca.relationships.MemberOfSite")]))
+ self.assert_obj(Slice, "testsite_testslice", enabled=True, description="", slice_url="", max_instances=10)
+ self.destroy(self.get_base_templates() +
+ self.make_nodetemplate("testsite_testslice", "tosca.nodes.Slice",
+ reqs=[("testsite", "tosca.relationships.MemberOfSite")]))
+ self.assert_noobj(Slice, "testsite_testslice")
+
+if __name__ == "__main__":
+ SliceTest()
+
+