2 # -*- coding: utf-8 -*-
4 from constants import TESTBED_ID
5 from nepi.core import metadata
6 from nepi.core.attributes import Attribute
7 from nepi.util import validation
8 from nepi.util.constants import STATUS_FINISHED
14 ### Connection functions ####
16 ### Creation functions ###
18 def create_node(testbed_instance, guid):
20 testbed_instance.elements[guid] = element
22 def create_iface(testbed_instance, guid):
24 testbed_instance.elements[guid] = element
26 def create_application(testbed_instance, guid):
28 testbed_instance.elements[guid] = element
30 ### Start/Stop functions ###
32 ### Status functions ###
34 def status_application(testbed_instance, guid):
35 return 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",
68 "from": (TESTBED_ID, NODE, "devs"),
69 "to": (TESTBED_ID, IFACE, "node"),
74 "from": (TESTBED_ID, IFACE, "iface"),
75 "to": (TESTBED_ID, IFACE, "iface"),
80 "from": (TESTBED_ID, NODE, "apps"),
81 "to": (TESTBED_ID, APP, "node"),
90 "help": "fake attribute",
91 "type": Attribute.BOOL,
95 "validation_function": validation.is_bool
99 "help": "test attribute",
100 "type": Attribute.STRING,
101 "validation_function": validation.is_string
112 factories_order = [ NODE, IFACE, APP ]
114 factories_info = dict({
117 "category": "topology",
118 "create_function": create_node,
119 "start_function": None,
120 "stop_function": None,
121 "status_function": None,
122 "box_attributes": ["fake","test"],
123 "connector_types": ["devs", "apps"]
126 "help": "Fake iface",
127 "category": "devices",
128 "create_function": create_iface,
129 "start_function": None,
130 "stop_function": None,
131 "status_function": None,
132 "allow_addresses": True,
133 "factory_attributes": ["fake"],
134 "box_attributes": ["fake","test"],
135 "connector_types": ["node", "iface"]
138 "help": "Fake application",
139 "category": "applications",
140 "create_function": create_application,
141 "start_function": None,
142 "stop_function": None,
143 "status_function": status_application,
144 "box_attributes": ["fake","test"],
145 "connector_types": ["node"],
150 testbed_attributes = dict({
153 "help": "fake attribute",
154 "type": Attribute.BOOL,
158 "validation_function": validation.is_bool
162 class VersionedMetadataInfo(metadata.VersionedMetadataInfo):
164 def connector_types(self):
165 return connector_types
168 def connections(self):
172 def attributes(self):
180 def create_order(self):
181 return factories_order
184 def configure_order(self):
185 return factories_order
188 def factories_info(self):
189 return factories_info
192 def testbed_attributes(self):
193 return testbed_attributes