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
106 factories_order = [ NODE, IFACE, APP ]
108 factories_info = dict({
111 "category": "topology",
112 "create_function": create_node,
113 "start_function": None,
114 "stop_function": None,
115 "status_function": None,
116 "box_attributes": ["fake"],
117 "connector_types": ["devs", "apps"]
120 "help": "Fake iface",
121 "category": "devices",
122 "create_function": create_iface,
123 "start_function": None,
124 "stop_function": None,
125 "status_function": None,
126 "factory_attributes": ["fake"],
127 "box_attributes": ["fake"],
128 "connector_types": ["node", "iface"]
131 "help": "Fake application",
132 "category": "applications",
133 "create_function": create_application,
134 "start_function": None,
135 "stop_function": None,
136 "status_function": status_application,
137 "box_attributes": ["fake"],
138 "connector_types": ["node"],
143 testbed_attributes = dict({
146 "help": "fake attribute",
147 "type": Attribute.BOOL,
151 "validation_function": validation.is_bool
155 class VersionedMetadataInfo(metadata.VersionedMetadataInfo):
157 def connector_types(self):
158 return connector_types
161 def connections(self):
165 def attributes(self):
173 def factories_order(self):
174 return factories_order
177 def factories_info(self):
178 return factories_info
181 def testbed_attributes(self):
182 return testbed_attributes