Defined Models and REST APIs
TOSCA specs
Synchronizer
Change-Id: Icd9dde1b456711ca7e5f0c69ae547072ff5b3120
diff --git a/xos/tosca/resources/vrouterservice.py b/xos/tosca/resources/vrouterservice.py
index 64ee455..6b422c2 100644
--- a/xos/tosca/resources/vrouterservice.py
+++ b/xos/tosca/resources/vrouterservice.py
@@ -1,8 +1,90 @@
from service import XOSService
-from services.vrouter.models import VRouterService
+from services.vrouter.models import *
+
class XOSVRouterService(XOSService):
provides = "tosca.nodes.VRouterService"
xos_model = VRouterService
- copyin_props = ["view_url", "icon_url", "enabled", "published", "public_key", "versionNumber"]
+ copyin_props = ["view_url", "icon_url", "enabled", "published", "public_key", "versionNumber",
+ "rest_hostname", "rest_port", "rest_user", "rest_pass"]
+
+class XOSVRouterDevice(XOSService):
+ provides = "tosca.nodes.VRouterDevice"
+ xos_model = VRouterDevice
+ copyin_props = ['openflow_id', 'config_key', 'driver']
+
+ def get_xos_args(self):
+ args = super(XOSVRouterDevice, self).get_xos_args()
+
+ serviceName = self.get_requirement("tosca.relationships.MemberOfService", throw_exception=False)
+ if serviceName:
+ service = self.get_xos_object(Service, name=serviceName)
+ args["vrouter_service_id"] = service.id
+ return args
+
+
+class XOSVRouterPort(XOSService):
+ provides = "tosca.nodes.VRouterPort"
+ xos_model = VRouterPort
+ copyin_props = ['openflow_id']
+
+ def get_xos_args(self):
+ args = super(XOSVRouterPort, self).get_xos_args()
+
+ deviceName = self.get_requirement("tosca.relationships.PortOfDevice", throw_exception=False)
+ if deviceName:
+ device = self.get_xos_object(VRouterDevice, name=deviceName)
+ args["vrouter_device"] = device
+
+ serviceName = self.get_requirement("tosca.relationships.MemberOfService", throw_exception=False)
+ if serviceName:
+ service = self.get_xos_object(Service, name=serviceName)
+ args["vrouter_service_id"] = service.id
+
+ return args
+
+
+class XOSVRouterInterface(XOSService):
+ provides = "tosca.nodes.VRouterInterface"
+ xos_model = VRouterInterface
+ copyin_props = ['name', 'mac', 'vlan']
+
+ def get_xos_args(self):
+ args = super(XOSVRouterInterface, self).get_xos_args()
+
+ portName = self.get_requirement("tosca.relationships.InterfaceOfPort", throw_exception=False)
+ if portName:
+ port = self.get_xos_object(VRouterPort, name=portName)
+ args["vrouter_port"] = port
+ return args
+
+
+class XOSVRouterIp(XOSService):
+ provides = "tosca.nodes.VRouterIp"
+ xos_model = VRouterIp
+ copyin_props = ['ip']
+
+ def get_xos_args(self):
+ args = super(XOSVRouterIp, self).get_xos_args()
+
+ interfaceName = self.get_requirement("tosca.relationships.IpOfInterface", throw_exception=False)
+ if interfaceName:
+ interface = self.get_xos_object(VRouterInterface, name=interfaceName)
+ args["vrouter_interface"] = interface
+ return args
+
+
+class XOSVRouterApp(XOSService):
+ provides = "tosca.nodes.VRouterApp"
+ xos_model = VRouterApp
+ copyin_props = ['name', 'control_plane_connect_point', 'ospf_enabled']
+
+ def get_xos_args(self):
+ args = super(XOSVRouterApp, self).get_xos_args()
+
+ serviceName = self.get_requirement("tosca.relationships.MemberOfService", throw_exception=True)
+ if serviceName:
+ service = self.get_xos_object(Service, name=serviceName)
+ args["vrouter_service_id"] = service.id
+ return args
diff --git a/xos/tosca/sample.yaml b/xos/tosca/sample.yaml
new file mode 100644
index 0000000..f1131f2
--- /dev/null
+++ b/xos/tosca/sample.yaml
@@ -0,0 +1,74 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: Just enough Tosca to get the vSG slice running on the CORD POD
+
+imports:
+ - custom_types/xos.yaml
+ - custom_types/vrouter.yaml
+
+topology_template:
+ node_templates:
+
+ service#vRouterSample:
+ type: tosca.nodes.VRouterService
+ properties:
+ view_url: /admin/vrouter/vrouterservice/$id$/
+ rest_hostname: 10.0.2.2
+ rest_port: 8181
+ rest_user: onos
+ rest_pass: rocks
+
+ device#switch:
+ type: tosca.nodes.VRouterDevice
+ properties:
+ openflow_id: of:000000000001
+ driver: softrouter
+ # config_key: basic
+ requirements:
+ - service#vRouterSample:
+ node: service#vRouterSample
+ relationship: tosca.relationships.MemberOfService
+
+ port#sample_port:
+ type: tosca.nodes.VRouterPort
+ properties:
+ openflow_id: of:000000000001/1
+ requirements:
+ - device#switch:
+ node: device#switch
+ relationship: tosca.relationships.PortOfDevice
+ - service#vRouterSample:
+ node: service#vRouterSample
+ relationship: tosca.relationships.MemberOfService
+
+ interface#b1-1:
+ type: tosca.nodes.VRouterInterface
+ properties:
+ name: b1-1
+ mac: 00:00:00:00:00:01
+ vlan: 100
+ requirements:
+ - port#sample_port:
+ node: port#sample_port
+ relationship: tosca.relationships.InterfaceOfPort
+
+ vrouter_ips:
+ type: tosca.nodes.VRouterIp
+ properties:
+ ip: 10.0.4.2/24
+ requirements:
+ - interface#b1-1:
+ node: interface#b1-1
+ relationship: tosca.relationships.IpOfInterface
+
+ app#vrouterApp:
+ type: tosca.nodes.VRouterApp
+ properties:
+ name: org.onosproject.router
+ # can we use a relation to specify the connect point port?
+ control_plane_connect_point: of:00000000000000b1/5
+ ospf_enabled: true
+ requirements:
+ - service#vRouterSample:
+ node: service#vRouterSample
+ relationship: tosca.relationships.MemberOfService