1 # -*- coding: utf-8 -*-
3 from constants import TESTBED_ID, TESTBED_VERSION
4 from nepi.core import metadata
5 from nepi.core.attributes import Attribute
6 from nepi.util import tags, validation
7 from nepi.util.constants import ApplicationStatus as AS
13 ### Connection functions ####
15 def connect_cross(testbed_instance, guid, cross_data):
16 connected = cross_data["cross"]
17 testbed_instance.set(guid, "cross", connected)
19 ### Creation functions ###
21 def create_node(testbed_instance, guid):
22 testbed_instance.elements[guid] = NODE
24 def create_iface(testbed_instance, guid):
25 testbed_instance.elements[guid] = IFACE
27 def create_application(testbed_instance, guid):
28 testbed_instance.elements[guid] = APP
30 ### Start/Stop functions ###
32 ### Status functions ###
34 def status_application(testbed_instance, guid):
35 return AS.STATUS_FINISHED
37 ### Factory information ###
39 connector_types = dict({
41 "help": "Connector from node to applications",
47 "help": "Connector from node to network interfaces",
53 "help": "Connector to a Node",
59 "help": "Connector to a Interface",
65 "help": "Connector to an Interface in other testbed",
74 "from": (TESTBED_ID, NODE, "devs"),
75 "to": (TESTBED_ID, IFACE, "node"),
79 "from": (TESTBED_ID, IFACE, "iface"),
80 "to": (TESTBED_ID, IFACE, "iface"),
84 "from": (TESTBED_ID, NODE, "apps"),
85 "to": (TESTBED_ID, APP, "node"),
89 "from": (TESTBED_ID, IFACE, "cross"),
90 "to": ("mock", IFACE, "cross"),
91 "compl_code": connect_cross,
98 "help": "fake attribute",
99 "type": Attribute.BOOL,
101 "validation_function": validation.is_bool
105 "help": "test attribute",
106 "type": Attribute.STRING,
107 "validation_function": validation.is_string
111 "help": "Attribute that indicates if cross connection was performed",
112 "type": Attribute.BOOL,
114 "validation_function": validation.is_bool
125 factories_order = [ NODE, IFACE, APP ]
127 factories_info = dict({
130 "category": "topology",
131 "create_function": create_node,
132 "start_function": None,
133 "stop_function": None,
134 "status_function": None,
135 "box_attributes": ["fake","test"],
136 "connector_types": ["devs", "apps"],
137 "tags": [tags.NODE, tags.ALLOW_ROUTES],
140 "help": "Fake iface",
141 "category": "devices",
142 "create_function": create_iface,
143 "start_function": None,
144 "stop_function": None,
145 "status_function": None,
146 "allow_addresses": True,
147 "factory_attributes": ["fake"],
148 "box_attributes": ["fake", "test", "cross"],
149 "connector_types": ["node", "iface", "cross"],
150 "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
153 "help": "Fake application",
154 "category": "applications",
155 "create_function": create_application,
156 "start_function": None,
157 "stop_function": None,
158 "status_function": status_application,
159 "box_attributes": ["fake", "test"],
160 "connector_types": ["node"],
162 "tags": [tags.APPLICATION],
166 testbed_attributes = dict({
169 "help": "fake attribute",
170 "type": Attribute.BOOL,
174 "validation_function": validation.is_bool
178 "help": "test attribute",
179 "type": Attribute.STRING,
180 "validation_function": validation.is_string
184 class MetadataInfo(metadata.MetadataInfo):
186 def connector_types(self):
187 return connector_types
190 def connections(self):
194 def attributes(self):
202 def create_order(self):
203 return factories_order
206 def configure_order(self):
207 return factories_order
210 def factories_info(self):
211 return factories_info
214 def testbed_attributes(self):
215 return testbed_attributes
218 def testbed_id(self):
222 def testbed_version(self):
223 return TESTBED_VERSION