Scott Baker | 87eb740 | 2016-06-20 17:21:50 -0700 | [diff] [blame] | 1 | from service import XOSService |
Matteo Scandolo | a4e6e9a | 2016-08-23 12:04:45 -0700 | [diff] [blame^] | 2 | from services.vrouter.models import * |
| 3 | |
Scott Baker | 87eb740 | 2016-06-20 17:21:50 -0700 | [diff] [blame] | 4 | |
| 5 | class XOSVRouterService(XOSService): |
| 6 | provides = "tosca.nodes.VRouterService" |
| 7 | xos_model = VRouterService |
Matteo Scandolo | a4e6e9a | 2016-08-23 12:04:45 -0700 | [diff] [blame^] | 8 | copyin_props = ["view_url", "icon_url", "enabled", "published", "public_key", "versionNumber", |
| 9 | "rest_hostname", "rest_port", "rest_user", "rest_pass"] |
Scott Baker | 87eb740 | 2016-06-20 17:21:50 -0700 | [diff] [blame] | 10 | |
Matteo Scandolo | a4e6e9a | 2016-08-23 12:04:45 -0700 | [diff] [blame^] | 11 | |
| 12 | class XOSVRouterDevice(XOSService): |
| 13 | provides = "tosca.nodes.VRouterDevice" |
| 14 | xos_model = VRouterDevice |
| 15 | copyin_props = ['openflow_id', 'config_key', 'driver'] |
| 16 | |
| 17 | def get_xos_args(self): |
| 18 | args = super(XOSVRouterDevice, self).get_xos_args() |
| 19 | |
| 20 | serviceName = self.get_requirement("tosca.relationships.MemberOfService", throw_exception=False) |
| 21 | if serviceName: |
| 22 | service = self.get_xos_object(Service, name=serviceName) |
| 23 | args["vrouter_service_id"] = service.id |
| 24 | return args |
| 25 | |
| 26 | |
| 27 | class XOSVRouterPort(XOSService): |
| 28 | provides = "tosca.nodes.VRouterPort" |
| 29 | xos_model = VRouterPort |
| 30 | copyin_props = ['openflow_id'] |
| 31 | |
| 32 | def get_xos_args(self): |
| 33 | args = super(XOSVRouterPort, self).get_xos_args() |
| 34 | |
| 35 | deviceName = self.get_requirement("tosca.relationships.PortOfDevice", throw_exception=False) |
| 36 | if deviceName: |
| 37 | device = self.get_xos_object(VRouterDevice, name=deviceName) |
| 38 | args["vrouter_device"] = device |
| 39 | |
| 40 | serviceName = self.get_requirement("tosca.relationships.MemberOfService", throw_exception=False) |
| 41 | if serviceName: |
| 42 | service = self.get_xos_object(Service, name=serviceName) |
| 43 | args["vrouter_service_id"] = service.id |
| 44 | |
| 45 | return args |
| 46 | |
| 47 | |
| 48 | class XOSVRouterInterface(XOSService): |
| 49 | provides = "tosca.nodes.VRouterInterface" |
| 50 | xos_model = VRouterInterface |
| 51 | copyin_props = ['name', 'mac', 'vlan'] |
| 52 | |
| 53 | def get_xos_args(self): |
| 54 | args = super(XOSVRouterInterface, self).get_xos_args() |
| 55 | |
| 56 | portName = self.get_requirement("tosca.relationships.InterfaceOfPort", throw_exception=False) |
| 57 | if portName: |
| 58 | port = self.get_xos_object(VRouterPort, name=portName) |
| 59 | args["vrouter_port"] = port |
| 60 | return args |
| 61 | |
| 62 | |
| 63 | class XOSVRouterIp(XOSService): |
| 64 | provides = "tosca.nodes.VRouterIp" |
| 65 | xos_model = VRouterIp |
| 66 | copyin_props = ['ip'] |
| 67 | |
| 68 | def get_xos_args(self): |
| 69 | args = super(XOSVRouterIp, self).get_xos_args() |
| 70 | |
| 71 | interfaceName = self.get_requirement("tosca.relationships.IpOfInterface", throw_exception=False) |
| 72 | if interfaceName: |
| 73 | interface = self.get_xos_object(VRouterInterface, name=interfaceName) |
| 74 | args["vrouter_interface"] = interface |
| 75 | return args |
| 76 | |
| 77 | |
| 78 | class XOSVRouterApp(XOSService): |
| 79 | provides = "tosca.nodes.VRouterApp" |
| 80 | xos_model = VRouterApp |
| 81 | copyin_props = ['name', 'control_plane_connect_point', 'ospf_enabled'] |
| 82 | |
| 83 | def get_xos_args(self): |
| 84 | args = super(XOSVRouterApp, self).get_xos_args() |
| 85 | |
| 86 | serviceName = self.get_requirement("tosca.relationships.MemberOfService", throw_exception=True) |
| 87 | if serviceName: |
| 88 | service = self.get_xos_object(Service, name=serviceName) |
| 89 | args["vrouter_service_id"] = service.id |
| 90 | return args |