From 8b5760eb7fbf090e2c636b33ebe6a6d2f0b4f4f3 Mon Sep 17 00:00:00 2001
From: Mathieu Velten <mathieu.velten@cern.ch>
Date: Wed, 10 Aug 2016 17:42:47 +0200
Subject: [PATCH] Add endpoint capability to Compute (cf spec)

Change-Id: I3b6fecd765b521210405581125f568e619b9f609
---
 .../elements/TOSCA_definition_1_0.yaml        |  2 ++
 .../tests/data/test_endpoint_on_compute.yaml  | 21 +++++++++++++++++++
 toscaparser/tests/test_toscadef.py            |  1 +
 toscaparser/tests/test_toscatpl.py            |  7 +++++++
 4 files changed, 31 insertions(+)
 create mode 100644 toscaparser/tests/data/test_endpoint_on_compute.yaml

diff --git a/toscaparser/elements/TOSCA_definition_1_0.yaml b/toscaparser/elements/TOSCA_definition_1_0.yaml
index 2f07e965..d6cb1522 100644
--- a/toscaparser/elements/TOSCA_definition_1_0.yaml
+++ b/toscaparser/elements/TOSCA_definition_1_0.yaml
@@ -70,6 +70,8 @@ node_types:
            type: tosca.capabilities.OperatingSystem
         scalable:
            type: tosca.capabilities.Scalable
+        endpoint:
+           type: tosca.capabilities.Endpoint.Admin
     requirements:
       - local_storage:
           capability: tosca.capabilities.Attachment
diff --git a/toscaparser/tests/data/test_endpoint_on_compute.yaml b/toscaparser/tests/data/test_endpoint_on_compute.yaml
new file mode 100644
index 00000000..cf2ec94f
--- /dev/null
+++ b/toscaparser/tests/data/test_endpoint_on_compute.yaml
@@ -0,0 +1,21 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+topology_template:
+  node_templates:
+    server:
+      type: tosca.nodes.Compute
+      capabilities:
+        host:
+          properties:
+            disk_size: 10 GB
+            num_cpus: 1
+            mem_size: 4096 MB
+        os:
+          properties:
+            architecture: x86_64
+            type: Linux
+            distribution: Ubuntu
+            version: 14.04
+        endpoint:
+          properties:
+            network_name: PUBLIC
diff --git a/toscaparser/tests/test_toscadef.py b/toscaparser/tests/test_toscadef.py
index 358bf28e..d65c84cc 100644
--- a/toscaparser/tests/test_toscadef.py
+++ b/toscaparser/tests/test_toscadef.py
@@ -71,6 +71,7 @@ class ToscaDefTest(TestCase):
         # we SHOULD test symbolic capability names as well
         self.assertEqual(
             ['tosca.capabilities.Container',
+             'tosca.capabilities.Endpoint.Admin',
              'tosca.capabilities.Node',
              'tosca.capabilities.OperatingSystem',
              'tosca.capabilities.Scalable',
diff --git a/toscaparser/tests/test_toscatpl.py b/toscaparser/tests/test_toscatpl.py
index 3d618e09..3fd5e39b 100644
--- a/toscaparser/tests/test_toscatpl.py
+++ b/toscaparser/tests/test_toscatpl.py
@@ -198,6 +198,7 @@ class ToscaTemplateTest(TestCase):
             compute_type = NodeType(tpl.type)
             self.assertEqual(
                 sorted(['tosca.capabilities.Container',
+                        'tosca.capabilities.Endpoint.Admin',
                         'tosca.capabilities.Node',
                         'tosca.capabilities.OperatingSystem',
                         'tosca.capabilities.network.Bindable',
@@ -805,3 +806,9 @@ class ToscaTemplateTest(TestCase):
             os.path.dirname(os.path.abspath(__file__)),
             "data/test_containers.yaml")
         ToscaTemplate(tosca_tpl)
+
+    def test_endpoint_on_compute(self):
+        tosca_tpl = os.path.join(
+            os.path.dirname(os.path.abspath(__file__)),
+            "data/test_endpoint_on_compute.yaml")
+        ToscaTemplate(tosca_tpl)