start bringing XOS and Tosca networking together
diff --git a/xos/tosca/custom_types/xos.m4 b/xos/tosca/custom_types/xos.m4
index 2d3cf22..0200938 100644
--- a/xos/tosca/custom_types/xos.m4
+++ b/xos/tosca/custom_types/xos.m4
@@ -128,15 +128,78 @@
type: string
required: false
- tosca.nodes.XOSNetwork:
- derived_from: tosca.nodes.Root
-
- capabilities:
- network:
- type: tosca.capabilities.xos.Network
-
- properties:
- ports:
+ tosca.nodes.network.Network.XOS:
+ # Due to bug? in implementation, we have to copy everything from
+ # tosca definitions tosca.nodes.network.Network here rather than
+ # using derived_from.
+ derived_from: tosca.nodes.Root
+ description: >
+ The TOSCA Network node represents a simple, logical network service.
+ properties:
+ ip_version:
+ type: integer
+ required: no
+ default: 4
+ constraints:
+ - valid_values: [ 4, 6 ]
+ description: >
+ The IP version of the requested network. Valid values are 4 for ipv4
+ or 6 for ipv6.
+ cidr:
+ type: string
+ required: no
+ description: >
+ The cidr block of the requested network.
+ start_ip:
+ type: string
+ required: no
+ description: >
+ The IP address to be used as the start of a pool of addresses within
+ the full IP range derived from the cidr block.
+ end_ip:
+ type: string
+ required: no
+ description: >
+ The IP address to be used as the end of a pool of addresses within
+ the full IP range derived from the cidr block.
+ gateway_ip:
+ type: string
+ required: no
+ description: >
+ The gateway IP address.
+ network_name:
+ type: string
+ required: no
+ description: >
+ An identifier that represents an existing Network instance in the
+ underlying cloud infrastructure or can be used as the name of the
+ newly created network. If network_name is provided and no other
+ properties are provided (with exception of network_id), then an
+ existing network instance will be used. If network_name is provided
+ alongside with more properties then a new network with this name will
+ be created.
+ network_id:
+ type: string
+ required: no
+ description: >
+ An identifier that represents an existing Network instance in the
+ underlying cloud infrastructure. This property is mutually exclusive
+ with all other properties except network_name. This can be used alone
+ or together with network_name to identify an existing network.
+ segmentation_id:
+ type: string
+ required: no
+ description: >
+ A segmentation identifier in the underlying cloud infrastructure.
+ E.g. VLAN ID, GRE tunnel ID, etc..
+ dhcp_enabled:
+ type: boolean
+ required: no
+ default: true
+ description: >
+ Indicates should DHCP service be enabled on the network or not.
+ # XOS-specific
+ ports:
type: string
required: false
labels:
@@ -144,10 +207,33 @@
required: false
permit_all_slices:
type: boolean
- default: false
- permitted_slices:
- type: string
- required: false
+ # In the data model, this is defaulted to false. However, to
+ # preserve Tosca semantics, we default it to true instead.
+ default: true
+ capabilities:
+ link:
+ type: tosca.capabilities.network.Linkable
+
+# tosca.nodes.XOSNetwork:
+# derived_from: tosca.nodes.Root
+#
+# capabilities:
+# network:
+# type: tosca.capabilities.xos.Network
+#
+# properties:
+# ports:
+# type: string
+# required: false
+# labels:
+# type: string
+# required: false
+# permit_all_slices:
+# type: boolean
+# default: false
+# permitted_slices:
+# type: string
+# required: false
tosca.nodes.Deployment:
derived_from: tosca.nodes.Root
@@ -296,9 +382,9 @@
derived_from: tosca.capabilities.Root
description: An XOS network template
- tosca.capabilities.xos.Network:
- derived_from: tosca.capabilities.Root
- description: An XOS network
+# tosca.capabilities.xos.Network:
+# derived_from: tosca.capabilities.Root
+# description: An XOS network
tosca.capabilities.xos.User:
derived_from: tosca.capabilities.Root
diff --git a/xos/tosca/custom_types/xos.yaml b/xos/tosca/custom_types/xos.yaml
index 22419c5..3a7e133 100644
--- a/xos/tosca/custom_types/xos.yaml
+++ b/xos/tosca/custom_types/xos.yaml
@@ -142,15 +142,78 @@
type: string
required: false
- tosca.nodes.XOSNetwork:
- derived_from: tosca.nodes.Root
-
- capabilities:
- network:
- type: tosca.capabilities.xos.Network
-
- properties:
- ports:
+ tosca.nodes.network.Network.XOS:
+ # Due to bug? in implementation, we have to copy everything from
+ # tosca definitions tosca.nodes.network.Network here rather than
+ # using derived_from.
+ derived_from: tosca.nodes.Root
+ description: >
+ The TOSCA Network node represents a simple, logical network service.
+ properties:
+ ip_version:
+ type: integer
+ required: no
+ default: 4
+ constraints:
+ - valid_values: [ 4, 6 ]
+ description: >
+ The IP version of the requested network. Valid values are 4 for ipv4
+ or 6 for ipv6.
+ cidr:
+ type: string
+ required: no
+ description: >
+ The cidr block of the requested network.
+ start_ip:
+ type: string
+ required: no
+ description: >
+ The IP address to be used as the start of a pool of addresses within
+ the full IP range derived from the cidr block.
+ end_ip:
+ type: string
+ required: no
+ description: >
+ The IP address to be used as the end of a pool of addresses within
+ the full IP range derived from the cidr block.
+ gateway_ip:
+ type: string
+ required: no
+ description: >
+ The gateway IP address.
+ network_name:
+ type: string
+ required: no
+ description: >
+ An identifier that represents an existing Network instance in the
+ underlying cloud infrastructure or can be used as the name of the
+ newly created network. If network_name is provided and no other
+ properties are provided (with exception of network_id), then an
+ existing network instance will be used. If network_name is provided
+ alongside with more properties then a new network with this name will
+ be created.
+ network_id:
+ type: string
+ required: no
+ description: >
+ An identifier that represents an existing Network instance in the
+ underlying cloud infrastructure. This property is mutually exclusive
+ with all other properties except network_name. This can be used alone
+ or together with network_name to identify an existing network.
+ segmentation_id:
+ type: string
+ required: no
+ description: >
+ A segmentation identifier in the underlying cloud infrastructure.
+ E.g. VLAN ID, GRE tunnel ID, etc..
+ dhcp_enabled:
+ type: boolean
+ required: no
+ default: true
+ description: >
+ Indicates should DHCP service be enabled on the network or not.
+ # XOS-specific
+ ports:
type: string
required: false
labels:
@@ -158,10 +221,33 @@
required: false
permit_all_slices:
type: boolean
- default: false
- permitted_slices:
- type: string
- required: false
+ # In the data model, this is defaulted to false. However, to
+ # preserve Tosca semantics, we default it to true instead.
+ default: true
+ capabilities:
+ link:
+ type: tosca.capabilities.network.Linkable
+
+# tosca.nodes.XOSNetwork:
+# derived_from: tosca.nodes.Root
+#
+# capabilities:
+# network:
+# type: tosca.capabilities.xos.Network
+#
+# properties:
+# ports:
+# type: string
+# required: false
+# labels:
+# type: string
+# required: false
+# permit_all_slices:
+# type: boolean
+# default: false
+# permitted_slices:
+# type: string
+# required: false
tosca.nodes.Deployment:
derived_from: tosca.nodes.Root
@@ -310,9 +396,9 @@
derived_from: tosca.capabilities.Root
description: An XOS network template
- tosca.capabilities.xos.Network:
- derived_from: tosca.capabilities.Root
- description: An XOS network
+# tosca.capabilities.xos.Network:
+# derived_from: tosca.capabilities.Root
+# description: An XOS network
tosca.capabilities.xos.User:
derived_from: tosca.capabilities.Root
diff --git a/xos/tosca/resources/__init__.py b/xos/tosca/resources/__init__.py
index fb0a695..9be1591 100644
--- a/xos/tosca/resources/__init__.py
+++ b/xos/tosca/resources/__init__.py
@@ -32,6 +32,11 @@
provides = getattr(c, "provides", None)
if provides:
globals()[classname] = c
- resources[provides] = c
+ if isinstance(provides, basestring):
+ resources[provides] = c
+ else:
+ # allow provides= to be a list
+ for p in provides:
+ resources[p] = c
finally:
sys.path = sys_path_save
diff --git a/xos/tosca/resources/network.py b/xos/tosca/resources/network.py
index d8a93f8..57180ae 100644
--- a/xos/tosca/resources/network.py
+++ b/xos/tosca/resources/network.py
@@ -10,7 +10,7 @@
from xosresource import XOSResource
class XOSNetwork(XOSResource):
- provides = "tosca.nodes.XOSNetwork"
+ provides = ["tosca.nodes.network.Network", "tosca.nodes.network.Network.XOS"]
xos_model = Network
def get_xos_args(self):
@@ -33,13 +33,15 @@
return args
def postprocess(self, obj):
- v = self.get_property("permitted_slices")
- if v:
- for slicename in v.split(","):
- slice = self.get_xos_object(Slice, name = slicename.strip())
+ pass
- if not obj.permitted_slices.filter(id = slice.id).exists():
- obj.permitted_slices.add(slice)
+# v = self.get_property("permitted_slices")
+# if v:
+# for slicename in v.split(","):
+# slice = self.get_xos_object(Slice, name = slicename.strip())
+#
+# if not obj.permitted_slices.filter(id = slice.id).exists():
+# obj.permitted_slices.add(slice)
def create(self):
nodetemplate = self.nodetemplate
diff --git a/xos/tosca/resources/xosresource.py b/xos/tosca/resources/xosresource.py
index 7599a5f..11a4958 100644
--- a/xos/tosca/resources/xosresource.py
+++ b/xos/tosca/resources/xosresource.py
@@ -100,10 +100,10 @@
xos_obj.caller = self.user
xos_obj.save()
- self.postprocess(xos_obj)
-
self.info("Created %s '%s'" % (self.xos_model.__name__,str(xos_obj)))
+ self.postprocess(xos_obj)
+
def update(self, obj):
pass
diff --git a/xos/tosca/samples/cord.yaml b/xos/tosca/samples/cord.yaml
index c5fc81c..83c9584 100644
--- a/xos/tosca/samples/cord.yaml
+++ b/xos/tosca/samples/cord.yaml
@@ -1,6 +1,6 @@
tosca_definitions_version: tosca_simple_yaml_1_0
-description: Template for deploying a single server with predefined properties.
+description: Setup CORD-related services -- vOLT, vCPE, vBNG.
imports:
- custom_types/xos.yaml
diff --git a/xos/tosca/samples/two_slices_shared_private_net.yaml b/xos/tosca/samples/two_slices_shared_private_net.yaml
index 203144d..abd4d4e 100644
--- a/xos/tosca/samples/two_slices_shared_private_net.yaml
+++ b/xos/tosca/samples/two_slices_shared_private_net.yaml
@@ -14,7 +14,9 @@
type: tosca.nodes.NetworkTemplate
producer_private_network:
- type: tosca.nodes.XOSNetwork
+ type: tosca.nodes.network.Network.XOS
+ properties:
+ ip_version: 4
requirements:
- network_template:
node: Private
@@ -22,12 +24,6 @@
- slice:
node: mysite_producer
relationship: tosca.relationships.MemberOfSlice
- properties:
- permit_all_slices: true
- # TODO: We can't use permitted_slices due to a cycle in the dependency
- # graph. Slices connect to networks, but networks have slices
- # in whitelists. Oops.
- #permitted_slices: mysite_consumer
mysite_producer:
type: tosca.nodes.Slice
@@ -90,3 +86,21 @@
node: mysite_consumer
relationship: tosca.relationships.MemberOfSlice
+ producer_pvt_net_port:
+ type: tosca.nodes.network.Port
+ requirements:
+ - link:
+ node: producer_private_network
+ relationship: tosca.relationships.network.LinksTo
+ - binding:
+ node: producer_server
+ relationship: tosca.relationships.network.BindsTo
+
+# consumer_pvt_net_port:
+# type: tosca.nodes.network.Port
+# requirements:
+# - link: producer_private_network
+# - binding: consumer_server
+
+
+