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 validation, tags
7 from nepi.util.constants import ApplicationStatus as AS
13 ### Connection functions ####
15 def connect_cross(testbed_instance, guid, cross_data):
17 testbed_instance.set(guid, "cross", True)
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": ("mock2", IFACE, "cross"),
91 "init_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
116 "maxAddresses": dict({
117 "name": "maxAddresses",
118 "help": "Attribute that indicates the maximum number of addresses for an interface",
119 "type": Attribute.INTEGER,
121 "flags" : Attribute.DesignReadOnly |\
122 Attribute.ExecInvisible |\
124 "validation_function": validation.is_integer
135 factories_order = [ NODE, IFACE, APP ]
137 factories_info = dict({
140 "category": "topology",
141 "create_function": create_node,
142 "start_function": None,
143 "stop_function": None,
144 "status_function": None,
145 "box_attributes": ["fake","test"],
146 "connector_types": ["devs", "apps"],
147 "tags": [tags.MOBILE, tags.NODE, tags.ALLOW_ROUTES],
150 "help": "Fake iface",
151 "category": "devices",
152 "create_function": create_iface,
153 "start_function": None,
154 "stop_function": None,
155 "status_function": None,
156 "allow_addresses": True,
157 "factory_attributes": ["fake", "maxAddresses"],
158 "box_attributes": ["fake", "test", "cross"],
159 "connector_types": ["node", "iface", "cross"],
160 "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
163 "help": "Fake application",
164 "category": "applications",
165 "create_function": create_application,
166 "start_function": None,
167 "stop_function": None,
168 "status_function": status_application,
169 "box_attributes": ["fake", "test"],
170 "connector_types": ["node"],
172 "tags": [tags.APPLICATION],
176 testbed_attributes = dict({
179 "help": "fake attribute",
180 "type": Attribute.BOOL,
184 "validation_function": validation.is_bool
188 "help": "test attribute",
189 "type": Attribute.STRING,
190 "validation_function": validation.is_string
194 class MetadataInfo(metadata.MetadataInfo):
196 def connector_types(self):
197 return connector_types
200 def connections(self):
204 def attributes(self):
212 def create_order(self):
213 return factories_order
216 def configure_order(self):
217 return factories_order
220 def factories_info(self):
221 return factories_info
224 def testbed_attributes(self):
225 return testbed_attributes
228 def testbed_id(self):
232 def testbed_version(self):
233 return TESTBED_VERSION