2 # -*- coding: utf-8 -*-
6 from constants import TESTBED_ID, TESTBED_VERSION
7 from nepi.core import metadata
8 from nepi.core.metadata import Parallel
9 from nepi.core.attributes import Attribute
10 from nepi.util import tags, validation
11 from nepi.util.constants import ApplicationStatus as AS, \
12 FactoryCategories as FC, \
13 ATTR_NEPI_TESTBED_ENVIRONMENT_SETUP, \
14 DeploymentConfiguration as DC
22 NODEIFACE = "NodeInterface"
23 TUNIFACE = "TunInterface"
24 TAPIFACE = "TapInterface"
25 APPLICATION = "Application"
26 DEPENDENCY = "Dependency"
27 NEPIDEPENDENCY = "NepiDependency"
28 NS3DEPENDENCY = "NS3Dependency"
31 TUNFILTER = "TunFilter"
32 CLASSQUEUEFILTER = "ClassQueueFilter"
33 TOSQUEUEFILTER = "TosQueueFilter"
34 MULTICASTFORWARDER = "MulticastForwarder"
35 MULTICASTANNOUNCER = "MulticastAnnouncer"
36 MULTICASTROUTER = "MulticastRouter"
38 TUNFILTERS = (TUNFILTER, CLASSQUEUEFILTER, TOSQUEUEFILTER)
39 TAPFILTERS = (TUNFILTER, )
40 ALLFILTERS = (TUNFILTER, CLASSQUEUEFILTER, TOSQUEUEFILTER)
42 PL_TESTBED_ID = "planetlab"
45 ### Custom validation functions ###
46 def is_addrlist(attribute, value):
47 if not validation.is_string(attribute, value):
54 components = value.split(',')
56 for component in components:
58 addr, mask = component.split('/',1)
60 addr, mask = component, '32'
62 if mask is not None and not (mask and mask.isdigit()):
63 # No empty or nonnumeric masks
66 if not validation.is_ip4_address(attribute, addr):
67 # Address part must be ipv4
72 def is_portlist(attribute, value):
73 if not validation.is_string(attribute, value):
80 components = value.split(',')
82 for component in components:
84 pfrom, pto = component.split('-',1)
86 pfrom = pto = component
88 if not pfrom or not pto or not pfrom.isdigit() or not pto.isdigit():
89 # No empty or nonnumeric ports
95 ### Connection functions ####
97 def connect_node_iface_node(testbed_instance, node_guid, iface_guid):
98 node = testbed_instance._elements[node_guid]
99 iface = testbed_instance._elements[iface_guid]
102 def connect_node_iface_inet(testbed_instance, iface_guid, inet_guid):
103 iface = testbed_instance._elements[iface_guid]
104 iface.has_internet = True
106 def connect_tun_iface_node(testbed_instance, node_guid, iface_guid):
107 node = testbed_instance._elements[node_guid]
108 iface = testbed_instance._elements[iface_guid]
110 node.required_vsys.update(('fd_tuntap', 'vif_up', 'vif_down'))
111 node.required_packages.update(('python', 'python-crypto', 'python-setuptools', 'gcc'))
113 def connect_tun_iface_peer(proto, testbed_instance, iface_guid, peer_iface_guid):
114 iface = testbed_instance._elements[iface_guid]
115 peer_iface = testbed_instance._elements[peer_iface_guid]
116 iface.peer_iface = peer_iface
117 peer_iface.peer_iface = iface
120 peer_iface.peer_proto = \
121 peer_iface.tun_proto = proto
122 iface.tun_key = peer_iface.tun_key
124 def connect_tun_iface_filter(testbed_instance, iface_guid, filter_guid):
125 iface = testbed_instance._elements[iface_guid]
126 filt = testbed_instance._elements[filter_guid]
127 traces = testbed_instance._get_traces(filter_guid)
128 if 'dropped_stats' in traces:
129 args = filt.args if filt.args else ""
130 filt.args = ','.join(filt.args.split(',') + ["logdropped=true",])
131 iface.filter_module = filt
132 filt.iface_guid = iface_guid
133 filt.iface = weakref.ref(iface)
136 connect_tun_iface_peer(filt.peer_proto, testbed_instance, filt.iface_guid, filt.peer_guid)
138 def connect_filter_peer(proto, testbed_instance, filter_guid, peer_guid):
139 peer = testbed_instance._elements[peer_guid]
140 filt = testbed_instance._elements[filter_guid]
141 filt.peer_proto = proto
142 filt.peer_guid = peer_guid
144 connect_tun_iface_peer(filt.peer_proto, testbed_instance, filt.iface_guid, filt.peer_guid)
146 def connect_filter_filter(proto, testbed_instance, filter_guid, peer_guid):
147 peer = testbed_instance._elements[peer_guid]
148 filt = testbed_instance._elements[filter_guid]
149 filt.peer_proto = proto
150 peer.peer_proto = proto
152 peer.peer_guid = filt.iface_guid
154 filt.peer_guid = peer.iface_guid
155 if filt.iface_guid and filt.peer_guid:
156 connect_tun_iface_peer(filt.peer_proto, testbed_instance, filt.iface_guid, filt.peer_guid)
158 def crossconnect_tun_iface_peer_init(proto, testbed_instance, iface_guid, peer_iface_data):
159 iface = testbed_instance._elements[iface_guid]
160 iface.peer_iface = None
161 iface.peer_addr = peer_iface_data.get("tun_addr")
162 iface.peer_proto = peer_iface_data.get("tun_proto") or proto
163 iface.peer_port = peer_iface_data.get("tun_port")
164 iface.peer_cipher = peer_iface_data.get("tun_cipher")
165 iface.tun_key = min(iface.tun_key, peer_iface_data.get("tun_key"))
166 iface.tun_proto = proto
168 preconfigure_tuniface(testbed_instance, iface_guid)
170 def crossconnect_tun_iface_peer_compl(proto, testbed_instance, iface_guid, peer_iface_data):
171 # refresh (refreshable) attributes for second-phase
172 iface = testbed_instance._elements[iface_guid]
173 iface.peer_addr = peer_iface_data.get("tun_addr")
174 iface.peer_proto = peer_iface_data.get("tun_proto") or proto
175 iface.peer_port = peer_iface_data.get("tun_port")
176 iface.peer_cipher = peer_iface_data.get("tun_cipher")
178 postconfigure_tuniface(testbed_instance, iface_guid)
180 def crossconnect_tun_iface_peer_both(proto, testbed_instance, iface_guid, peer_iface_data):
181 crossconnect_tun_iface_peer_init(proto, testbed_instance, iface_guid, peer_iface_data)
182 crossconnect_tun_iface_peer_compl(proto, testbed_instance, iface_guid, peer_iface_data)
184 def crossconnect_filter_peer_init(proto, testbed_instance, filter_guid, peer_data):
185 filt = testbed_instance._elements[filter_guid]
186 filt.peer_proto = proto
187 crossconnect_tun_iface_peer_init(filt.peer_proto, testbed_instance, filt.iface_guid, peer_data)
189 def crossconnect_filter_peer_compl(proto, testbed_instance, filter_guid, peer_data):
190 filt = testbed_instance._elements[filter_guid]
191 filt.peer_proto = proto
192 crossconnect_tun_iface_peer_compl(filt.peer_proto, testbed_instance, filt.iface_guid, peer_data)
194 def crossconnect_filter_peer_both(proto, testbed_instance, filter_guid, peer_data):
195 crossconnect_filter_peer_init(proto, testbed_instance, iface_guid, peer_iface_data)
196 crossconnect_filter_peer_compl(proto, testbed_instance, iface_guid, peer_iface_data)
198 def connect_dep(testbed_instance, node_guid, app_guid, node=None, app=None):
199 node = node or testbed_instance._elements[node_guid]
200 app = app or testbed_instance._elements[app_guid]
204 node.required_packages.update(set(
205 app.depends.split() ))
208 if app.home_path and app.home_path not in node.pythonpath:
209 node.pythonpath.append(app.home_path)
212 for envkey, envval in app.env.iteritems():
213 envval = app._replace_paths(envval)
214 node.env[envkey].append(envval)
217 node.rpmFusion = True
219 def connect_forwarder(testbed_instance, node_guid, fwd_guid):
220 node = testbed_instance._elements[node_guid]
221 fwd = testbed_instance._elements[fwd_guid]
222 node.multicast_forwarder = fwd
225 connect_dep(testbed_instance, node_guid, None, app=fwd.router)
227 connect_dep(testbed_instance, node_guid, fwd_guid)
229 def connect_router(testbed_instance, fwd_guid, router_guid):
230 fwd = testbed_instance._elements[fwd_guid]
231 router = testbed_instance._elements[router_guid]
235 connect_dep(testbed_instance, None, router_guid, node=fwd.node)
237 def connect_node_netpipe(testbed_instance, node_guid, netpipe_guid):
238 node = testbed_instance._elements[node_guid]
239 netpipe = testbed_instance._elements[netpipe_guid]
241 node.required_vsys.add('ipfw-be')
242 node.required_packages.add('ipfwslice')
245 ### Creation functions ###
247 def create_node(testbed_instance, guid):
248 parameters = testbed_instance._get_parameters(guid)
250 # create element with basic attributes
251 element = testbed_instance._make_node(parameters)
253 # add constraint on number of (real) interfaces
254 # by counting connected devices
255 dev_guids = testbed_instance.get_connected(guid, "devs", "node")
256 num_open_ifaces = sum( # count True values
257 NODEIFACE == testbed_instance._get_factory_id(guid)
258 for guid in dev_guids )
259 element.min_num_external_ifaces = num_open_ifaces
261 # require vroute vsys if we have routes to set up
262 routes = testbed_instance._add_route.get(guid)
264 vsys = element.routing_method(routes,
265 testbed_instance.vsys_vnet)
266 element.required_vsys.add(vsys)
268 testbed_instance.elements[guid] = element
270 def create_nodeiface(testbed_instance, guid):
271 parameters = testbed_instance._get_parameters(guid)
272 element = testbed_instance._make_node_iface(parameters)
273 testbed_instance.elements[guid] = element
275 def create_tuniface(testbed_instance, guid):
276 parameters = testbed_instance._get_parameters(guid)
277 element = testbed_instance._make_tun_iface(parameters)
279 # Set custom addresses, if there are any already
280 # Setting this early helps set up P2P links
281 if guid in testbed_instance._add_address and not (element.address or element.netmask or element.netprefix):
282 addresses = testbed_instance._add_address[guid]
283 for address in addresses:
284 (address, netprefix, broadcast) = address
285 element.add_address(address, netprefix, broadcast)
287 testbed_instance.elements[guid] = element
289 def create_tapiface(testbed_instance, guid):
290 parameters = testbed_instance._get_parameters(guid)
291 element = testbed_instance._make_tap_iface(parameters)
293 # Set custom addresses, if there are any already
294 # Setting this early helps set up P2P links
295 if guid in testbed_instance._add_address and not (element.address or element.netmask or element.netprefix):
296 addresses = testbed_instance._add_address[guid]
297 for address in addresses:
298 (address, netprefix, broadcast) = address
299 element.add_address(address, netprefix, broadcast)
301 testbed_instance.elements[guid] = element
303 def create_tunfilter(testbed_instance, guid):
304 parameters = testbed_instance._get_parameters(guid)
305 element = testbed_instance._make_tun_filter(parameters)
306 testbed_instance.elements[guid] = element
308 def create_classqueuefilter(testbed_instance, guid):
309 parameters = testbed_instance._get_parameters(guid)
310 element = testbed_instance._make_class_queue_filter(parameters)
311 testbed_instance.elements[guid] = element
313 def create_tosqueuefilter(testbed_instance, guid):
314 parameters = testbed_instance._get_parameters(guid)
315 element = testbed_instance._make_tos_queue_filter(parameters)
316 testbed_instance.elements[guid] = element
318 def create_application(testbed_instance, guid):
319 parameters = testbed_instance._get_parameters(guid)
320 element = testbed_instance._make_application(parameters)
322 # Just inject configuration stuff
323 element.home_path = "nepi-app-%s" % (guid,)
325 testbed_instance.elements[guid] = element
327 def create_dependency(testbed_instance, guid):
328 parameters = testbed_instance._get_parameters(guid)
329 element = testbed_instance._make_dependency(parameters)
331 # Just inject configuration stuff
332 element.home_path = "nepi-dep-%s" % (guid,)
334 testbed_instance.elements[guid] = element
336 def create_nepi_dependency(testbed_instance, guid):
337 parameters = testbed_instance._get_parameters(guid)
338 element = testbed_instance._make_nepi_dependency(parameters)
340 # Just inject configuration stuff
341 element.home_path = "nepi-nepi-%s" % (guid,)
343 testbed_instance.elements[guid] = element
345 def create_ns3_dependency(testbed_instance, guid):
346 parameters = testbed_instance._get_parameters(guid)
347 element = testbed_instance._make_ns3_dependency(parameters)
349 # Just inject configuration stuff
350 element.home_path = "nepi-ns3-%s" % (guid,)
352 testbed_instance.elements[guid] = element
354 def create_multicast_forwarder(testbed_instance, guid):
355 parameters = testbed_instance._get_parameters(guid)
356 element = testbed_instance._make_multicast_forwarder(parameters)
358 # Just inject configuration stuff
359 element.home_path = "nepi-mcfwd-%s" % (guid,)
361 testbed_instance.elements[guid] = element
363 def create_multicast_announcer(testbed_instance, guid):
364 parameters = testbed_instance._get_parameters(guid)
365 element = testbed_instance._make_multicast_announcer(parameters)
367 # Just inject configuration stuff
368 element.home_path = "nepi-mcann-%s" % (guid,)
370 testbed_instance.elements[guid] = element
372 def create_multicast_router(testbed_instance, guid):
373 parameters = testbed_instance._get_parameters(guid)
374 element = testbed_instance._make_multicast_router(parameters)
376 # Just inject configuration stuff
377 element.home_path = "nepi-mcrt-%s" % (guid,)
379 testbed_instance.elements[guid] = element
381 def create_internet(testbed_instance, guid):
382 parameters = testbed_instance._get_parameters(guid)
383 element = testbed_instance._make_internet(parameters)
384 testbed_instance.elements[guid] = element
386 def create_netpipe(testbed_instance, guid):
387 parameters = testbed_instance._get_parameters(guid)
388 element = testbed_instance._make_netpipe(parameters)
389 testbed_instance.elements[guid] = element
391 ### Start/Stop functions ###
393 def start_application(testbed_instance, guid):
394 parameters = testbed_instance._get_parameters(guid)
395 traces = testbed_instance._get_traces(guid)
396 app = testbed_instance.elements[guid]
398 app.stdout = "stdout" in traces
399 app.stderr = "stderr" in traces
400 app.buildlog = "buildlog" in traces
401 app.outout = "output" in traces
405 def stop_application(testbed_instance, guid):
406 app = testbed_instance.elements[guid]
409 ### Status functions ###
411 def status_application(testbed_instance, guid):
412 if guid not in testbed_instance.elements.keys():
413 return AS.STATUS_NOT_STARTED
415 app = testbed_instance.elements[guid]
418 ### Configure functions ###
420 def configure_nodeiface(testbed_instance, guid):
421 element = testbed_instance._elements[guid]
423 # Cannot explicitly configure addresses
424 if guid in testbed_instance._add_address:
425 raise ValueError, "Cannot explicitly set address of public PlanetLab interface"
428 node_guid = testbed_instance.get_connected(guid, "node", "devs")[0]
429 dev_guids = testbed_instance.get_connected(node_guid, "node", "devs")
430 siblings = [ self._element[dev_guid]
431 for dev_guid in dev_guids
432 if dev_guid != guid ]
434 # Fetch address from PLC api
435 element.pick_iface(siblings)
437 # Do some validations
440 def preconfigure_tuniface(testbed_instance, guid):
441 element = testbed_instance._elements[guid]
443 # Set custom addresses if any, and if not set already
444 if guid in testbed_instance._add_address and not (element.address or element.netmask or element.netprefix):
445 addresses = testbed_instance._add_address[guid]
446 for address in addresses:
447 (address, netprefix, broadcast) = address
448 element.add_address(address, netprefix, broadcast)
450 # Link to external interface, if any
451 for iface in testbed_instance._elements.itervalues():
452 if isinstance(iface, testbed_instance._interfaces.NodeIface) and iface.node is element.node and iface.has_internet:
453 element.external_iface = iface
456 # Set standard TUN attributes
457 if (not element.tun_addr or not element.tun_port) and element.external_iface:
458 element.tun_addr = element.external_iface.address
459 element.tun_port = testbed_instance.tapPortBase + int(guid)
462 traces = testbed_instance._get_traces(guid)
463 for capmode in ('pcap', 'packets'):
464 if capmode in traces:
465 element.capture = capmode
468 element.capture = False
470 # Do some validations
474 element.prepare('tun-%s' % (guid,))
476 def postconfigure_tuniface(testbed_instance, guid):
477 element = testbed_instance._elements[guid]
482 def prestart_tuniface(testbed_instance, guid):
483 element = testbed_instance._elements[guid]
488 def configure_node(testbed_instance, guid):
489 node = testbed_instance._elements[guid]
491 # Just inject configuration stuff
492 node.home_path = "nepi-node-%s" % (guid,)
493 node.ident_path = testbed_instance.sliceSSHKey
494 node.slicename = testbed_instance.slicename
496 # Do some validations
499 # this will be done in parallel in all nodes
500 # this call only spawns the process
501 node.install_dependencies()
503 def configure_node_routes(testbed_instance, guid):
504 node = testbed_instance._elements[guid]
505 routes = testbed_instance._add_route.get(guid)
509 for dev_guid in testbed_instance.get_connected(guid, "devs", "node")
510 for dev in ( testbed_instance._elements.get(dev_guid) ,)
511 if dev and isinstance(dev, testbed_instance._interfaces.TunIface) ]
513 vsys = testbed_instance.vsys_vnet
515 node.configure_routes(routes, devs, vsys)
517 def configure_application(testbed_instance, guid):
518 app = testbed_instance._elements[guid]
520 # Do some validations
523 # Wait for dependencies
524 app.node.wait_dependencies()
529 def configure_dependency(testbed_instance, guid):
530 dep = testbed_instance._elements[guid]
532 # Do some validations
535 # Wait for dependencies
536 dep.node.wait_dependencies()
541 def configure_announcer(testbed_instance, guid):
543 fwd = testbed_instance._elements[guid]
545 for node_guid in testbed_instance.get_connected(guid, "node", "apps")
546 for dev_guid in testbed_instance.get_connected(node_guid, "devs", "node")
547 for dev in ( testbed_instance._elements.get(dev_guid) ,)
548 if dev and isinstance(dev, testbed_instance._interfaces.TunIface)
552 configure_dependency(testbed_instance, guid)
554 def configure_forwarder(testbed_instance, guid):
555 configure_announcer(testbed_instance, guid)
557 # Link ifaces to forwarder
558 fwd = testbed_instance._elements[guid]
559 for iface in fwd.ifaces:
560 iface.multicast_forwarder = '/var/run/mcastfwd'
562 def configure_router(testbed_instance, guid):
564 rt = testbed_instance._elements[guid]
566 for fwd_guid in testbed_instance.get_connected(guid, "fwd", "router")
567 for node_guid in testbed_instance.get_connected(fwd_guid, "node", "apps")
568 for dev_guid in testbed_instance.get_connected(node_guid, "devs", "node")
569 for dev in ( testbed_instance._elements.get(dev_guid) ,)
570 if dev and isinstance(dev, testbed_instance._interfaces.TunIface)
571 and not dev.multicast ]
574 configure_dependency(testbed_instance, guid)
576 def configure_netpipe(testbed_instance, guid):
577 netpipe = testbed_instance._elements[guid]
579 # Do some validations
582 # Wait for dependencies
583 netpipe.node.wait_dependencies()
588 ### Factory information ###
590 connector_types = dict({
592 "help": "Connector from node to applications",
598 "help": "Connector from node to network interfaces",
604 "help": "Connector from node to application dependencies "
605 "(packages and applications that need to be installed)",
611 "help": "Connector from network interfaces to the internet",
617 "help": "Connector to a Node",
623 "help": "Connector to a routing daemon",
629 "help": "Forwarder this routing daemon communicates with",
635 "help": "Connector to a NetPipe",
642 "help": "ip-ip tunneling over TCP link",
648 "help": "ip-ip tunneling over UDP datagrams",
654 "help": "IP or Ethernet tunneling using the GRE protocol",
660 "help": "TUN device file descriptor provider",
666 "help": "TUN device file descriptor slot",
675 "from": (TESTBED_ID, NODE, "devs"),
676 "to": (TESTBED_ID, NODEIFACE, "node"),
677 "init_code": connect_node_iface_node,
681 "from": (TESTBED_ID, NODE, "devs"),
682 "to": (TESTBED_ID, TUNIFACE, "node"),
683 "init_code": connect_tun_iface_node,
687 "from": (TESTBED_ID, NODE, "devs"),
688 "to": (TESTBED_ID, TAPIFACE, "node"),
689 "init_code": connect_tun_iface_node,
693 "from": (TESTBED_ID, NODEIFACE, "inet"),
694 "to": (TESTBED_ID, INTERNET, "devs"),
695 "init_code": connect_node_iface_inet,
699 "from": (TESTBED_ID, NODE, "apps"),
700 "to": (TESTBED_ID, (APPLICATION, DEPENDENCY, NEPIDEPENDENCY, NS3DEPENDENCY, MULTICASTANNOUNCER), "node"),
701 "init_code": connect_dep,
705 "from": (TESTBED_ID, NODE, "apps"),
706 "to": (TESTBED_ID, MULTICASTFORWARDER, "node"),
707 "init_code": connect_forwarder,
711 "from": (TESTBED_ID, MULTICASTFORWARDER, "router"),
712 "to": (TESTBED_ID, MULTICASTROUTER, "fwd"),
713 "init_code": connect_router,
717 "from": (TESTBED_ID, TUNIFACE, "tcp"),
718 "to": (TESTBED_ID, TUNIFACE, "tcp"),
719 "init_code": functools.partial(connect_tun_iface_peer,"tcp"),
723 "from": (TESTBED_ID, TUNIFACE, "udp"),
724 "to": (TESTBED_ID, TUNIFACE, "udp"),
725 "init_code": functools.partial(connect_tun_iface_peer,"udp"),
729 "from": (TESTBED_ID, TUNIFACE, "gre"),
730 "to": (TESTBED_ID, TUNIFACE, "gre"),
731 "init_code": functools.partial(connect_tun_iface_peer,"gre"),
735 "from": (TESTBED_ID, TUNIFACE, "fd->"),
736 "to": (TESTBED_ID, TUNFILTERS, "->fd"),
737 "init_code": connect_tun_iface_filter,
741 "from": (TESTBED_ID, TUNFILTERS, "tcp"),
742 "to": (TESTBED_ID, TUNIFACE, "tcp"),
743 "init_code": functools.partial(connect_filter_peer,"tcp"),
747 "from": (TESTBED_ID, TUNFILTERS, "udp"),
748 "to": (TESTBED_ID, TUNIFACE, "udp"),
749 "init_code": functools.partial(connect_filter_peer,"udp"),
753 "from": (TESTBED_ID, TAPIFACE, "tcp"),
754 "to": (TESTBED_ID, TAPIFACE, "tcp"),
755 "init_code": functools.partial(connect_tun_iface_peer,"tcp"),
759 "from": (TESTBED_ID, TAPIFACE, "udp"),
760 "to": (TESTBED_ID, TAPIFACE, "udp"),
761 "init_code": functools.partial(connect_tun_iface_peer,"udp"),
765 "from": (TESTBED_ID, TAPIFACE, "gre"),
766 "to": (TESTBED_ID, TAPIFACE, "gre"),
767 "init_code": functools.partial(connect_tun_iface_peer,"gre"),
771 "from": (TESTBED_ID, TAPIFACE, "fd->"),
772 "to": (TESTBED_ID, TAPFILTERS, "->fd"),
773 "init_code": connect_tun_iface_filter,
777 "from": (TESTBED_ID, TAPFILTERS, "tcp"),
778 "to": (TESTBED_ID, TAPIFACE, "tcp"),
779 "init_code": functools.partial(connect_filter_peer,"tcp"),
783 "from": (TESTBED_ID, TAPFILTERS, "udp"),
784 "to": (TESTBED_ID, TAPIFACE, "udp"),
785 "init_code": functools.partial(connect_filter_peer,"udp"),
789 "from": (TESTBED_ID, TUNFILTERS, "tcp"),
790 "to": (TESTBED_ID, TUNFILTERS, "tcp"),
791 "init_code": functools.partial(connect_filter_filter,"tcp"),
795 "from": (TESTBED_ID, TUNFILTERS, "udp"),
796 "to": (TESTBED_ID, TUNFILTERS, "udp"),
797 "init_code": functools.partial(connect_filter_filter,"udp"),
801 "from": (TESTBED_ID, TAPFILTERS, "tcp"),
802 "to": (TESTBED_ID, TAPFILTERS, "tcp"),
803 "init_code": functools.partial(connect_filter_filter,"tcp"),
807 "from": (TESTBED_ID, TAPFILTERS, "udp"),
808 "to": (TESTBED_ID, TAPFILTERS, "udp"),
809 "init_code": functools.partial(connect_filter_filter,"udp"),
813 "from": (TESTBED_ID, TUNIFACE, "tcp"),
814 "to": (None, None, "tcp"),
815 "init_code": functools.partial(crossconnect_tun_iface_peer_init,"tcp"),
816 "compl_code": functools.partial(crossconnect_tun_iface_peer_compl,"tcp"),
820 "from": (TESTBED_ID, TUNIFACE, "udp"),
821 "to": (None, None, "udp"),
822 "init_code": functools.partial(crossconnect_tun_iface_peer_init,"udp"),
823 "compl_code": functools.partial(crossconnect_tun_iface_peer_compl,"udp"),
827 "from": (TESTBED_ID, TUNIFACE, "fd->"),
828 "to": (None, None, "->fd"),
829 "compl_code": functools.partial(crossconnect_tun_iface_peer_both,"fd"),
833 "from": (TESTBED_ID, TUNIFACE, "gre"),
834 "to": (None, None, "gre"),
835 "compl_code": functools.partial(crossconnect_tun_iface_peer_both,"gre"),
839 "from": (TESTBED_ID, TAPIFACE, "tcp"),
840 "to": (None, None, "tcp"),
841 "init_code": functools.partial(crossconnect_tun_iface_peer_init,"tcp"),
842 "compl_code": functools.partial(crossconnect_tun_iface_peer_compl,"tcp"),
846 "from": (TESTBED_ID, TAPIFACE, "udp"),
847 "to": (None, None, "udp"),
848 "init_code": functools.partial(crossconnect_tun_iface_peer_init,"udp"),
849 "compl_code": functools.partial(crossconnect_tun_iface_peer_compl,"udp"),
853 "from": (TESTBED_ID, TAPIFACE, "fd->"),
854 "to": (None, None, "->fd"),
855 "compl_code": functools.partial(crossconnect_tun_iface_peer_both,"fd"),
858 # EGRE is an extension of PlanetLab, so we can't connect externally
859 # if the other testbed isn't another PlanetLab
861 "from": (TESTBED_ID, TAPIFACE, "gre"),
862 "to": (TESTBED_ID, None, "gre"),
863 "compl_code": functools.partial(crossconnect_tun_iface_peer_both,"gre"),
867 "from": (TESTBED_ID, ALLFILTERS, "tcp"),
868 "to": (None, None, "tcp"),
869 "init_code": functools.partial(crossconnect_filter_peer_init,"tcp"),
870 "compl_code": functools.partial(crossconnect_filter_peer_compl,"tcp"),
874 "from": (TESTBED_ID, ALLFILTERS, "udp"),
875 "to": (None, None, "udp"),
876 "init_code": functools.partial(crossconnect_filter_peer_init,"udp"),
877 "compl_code": functools.partial(crossconnect_filter_peer_compl,"udp"),
883 "forward_X11": dict({
884 "name": "forward_X11",
885 "help": "Forward x11 from main namespace to the node",
886 "type": Attribute.BOOL,
888 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
889 "validation_function": validation.is_bool,
893 "help": "Constrain hostname during resource discovery. May use wildcards.",
894 "type": Attribute.STRING,
895 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
896 "validation_function": validation.is_string,
900 "help": "Constrain location (city) during resource discovery. May use wildcards.",
901 "type": Attribute.STRING,
902 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
903 "validation_function": validation.is_string,
907 "help": "Constrain location (country) during resource discovery. May use wildcards.",
908 "type": Attribute.STRING,
909 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
910 "validation_function": validation.is_string,
914 "help": "Constrain location (region) during resource discovery. May use wildcards.",
915 "type": Attribute.STRING,
916 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
917 "validation_function": validation.is_string,
919 "architecture": dict({
920 "name": "architecture",
921 "help": "Constrain architexture during resource discovery.",
922 "type": Attribute.ENUM,
923 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
924 "allowed": ["x86_64",
926 "validation_function": validation.is_enum,
928 "operating_system": dict({
929 "name": "operatingSystem",
930 "help": "Constrain operating system during resource discovery.",
931 "type": Attribute.ENUM,
932 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
938 "validation_function": validation.is_enum,
942 "help": "Constrain the PlanetLab site this node should reside on.",
943 "type": Attribute.ENUM,
944 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
948 "validation_function": validation.is_enum,
950 "min_reliability": dict({
951 "name": "minReliability",
952 "help": "Constrain reliability while picking PlanetLab nodes. Specifies a lower acceptable bound.",
953 "type": Attribute.DOUBLE,
955 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
956 "validation_function": validation.is_number,
958 "max_reliability": dict({
959 "name": "maxReliability",
960 "help": "Constrain reliability while picking PlanetLab nodes. Specifies an upper acceptable bound.",
961 "type": Attribute.DOUBLE,
963 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
964 "validation_function": validation.is_number,
966 "min_bandwidth": dict({
967 "name": "minBandwidth",
968 "help": "Constrain available bandwidth while picking PlanetLab nodes. Specifies a lower acceptable bound.",
969 "type": Attribute.DOUBLE,
971 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
972 "validation_function": validation.is_number,
974 "max_bandwidth": dict({
975 "name": "maxBandwidth",
976 "help": "Constrain available bandwidth while picking PlanetLab nodes. Specifies an upper acceptable bound.",
977 "type": Attribute.DOUBLE,
979 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
980 "validation_function": validation.is_number,
984 "help": "Constrain node load average while picking PlanetLab nodes. Specifies a lower acceptable bound.",
985 "type": Attribute.DOUBLE,
987 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
988 "validation_function": validation.is_number,
992 "help": "Constrain node load average while picking PlanetLab nodes. Specifies an upper acceptable bound.",
993 "type": Attribute.DOUBLE,
995 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
996 "validation_function": validation.is_number,
1000 "help": "Constrain available cpu time while picking PlanetLab nodes. Specifies a lower acceptable bound.",
1001 "type": Attribute.DOUBLE,
1003 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1004 "validation_function": validation.is_number,
1008 "help": "Constrain available cpu time while picking PlanetLab nodes. Specifies an upper acceptable bound.",
1009 "type": Attribute.DOUBLE,
1011 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1012 "validation_function": validation.is_number,
1018 "type": Attribute.BOOL,
1020 "validation_function": validation.is_bool
1024 "help": "This is the primary interface for the attached node",
1025 "type": Attribute.BOOL,
1027 "validation_function": validation.is_bool
1031 "help": "Device name",
1032 "type": Attribute.STRING,
1033 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1034 "validation_function": validation.is_string
1038 "help": "Maximum transmition unit for device",
1039 "type": Attribute.INTEGER,
1041 "validation_function": validation.is_integer_range(0,1500)
1045 "help": "Network mask for the device (eg: 24 for /24 network)",
1046 "type": Attribute.INTEGER,
1047 "validation_function": validation.is_integer_range(8,24)
1051 "help": "Enable SNAT (source NAT to the internet) no this device",
1052 "type": Attribute.BOOL,
1054 "validation_function": validation.is_bool
1057 "name": "multicast",
1058 "help": "Enable multicast forwarding on this device. "
1059 "Note that you still need a multicast routing daemon "
1061 "type": Attribute.BOOL,
1063 "validation_function": validation.is_bool
1065 "pointopoint": dict({
1066 "name": "pointopoint",
1067 "help": "If the interface is a P2P link, the remote endpoint's IP "
1068 "should be set on this attribute.",
1069 "type": Attribute.STRING,
1070 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1071 "validation_function": validation.is_string
1075 "help": "Emulated transmission speed (in kbytes per second)",
1076 "type": Attribute.INTEGER,
1077 "range" : (1,10*2**20),
1078 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1079 "validation_function": validation.is_integer
1081 "txqueuelen": dict({
1082 "name": "txqueuelen",
1083 "help": "Transmission queue length (in packets)",
1084 "type": Attribute.INTEGER,
1086 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1087 "range" : (1,10000),
1088 "validation_function": validation.is_integer
1093 "help": "Command line string",
1094 "type": Attribute.STRING,
1095 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1096 "validation_function": validation.is_string
1100 "help": "Run with root privileges",
1101 "type": Attribute.BOOL,
1102 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1104 "validation_function": validation.is_bool
1108 "help": "Standard input",
1109 "type": Attribute.STRING,
1110 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1111 "validation_function": validation.is_string
1116 "help": "Space-separated list of packages required to run the application",
1117 "type": Attribute.STRING,
1118 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1119 "validation_function": validation.is_string
1121 "build-depends": dict({
1122 "name": "buildDepends",
1123 "help": "Space-separated list of packages required to build the application",
1124 "type": Attribute.STRING,
1125 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1126 "validation_function": validation.is_string
1128 "rpm-fusion": dict({
1129 "name": "rpmFusion",
1130 "help": "True if required packages can be found in the RpmFusion repository",
1131 "type": Attribute.BOOL,
1132 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1134 "validation_function": validation.is_bool
1138 "help": "Space-separated list of regular files to be deployed in the working path prior to building. "
1139 "Archives won't be expanded automatically.",
1140 "type": Attribute.STRING,
1141 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1142 "validation_function": validation.is_string
1146 "help": "Build commands to execute after deploying the sources. "
1147 "Sources will be in the ${SOURCES} folder. "
1148 "Example: tar xzf ${SOURCES}/my-app.tgz && cd my-app && ./configure && make && make clean.\n"
1149 "Try to make the commands return with a nonzero exit code on error.\n"
1150 "Also, do not install any programs here, use the 'install' attribute. This will "
1151 "help keep the built files constrained to the build folder (which may "
1152 "not be the home folder), and will result in faster deployment. Also, "
1153 "make sure to clean up temporary files, to reduce bandwidth usage between "
1154 "nodes when transferring built packages.",
1155 "type": Attribute.STRING,
1156 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1157 "validation_function": validation.is_string
1161 "help": "Commands to transfer built files to their final destinations. "
1162 "Sources will be in the initial working folder, and a special "
1163 "tag ${SOURCES} can be used to reference the experiment's "
1164 "home folder (where the application commands will run).\n"
1165 "ALL sources and targets needed for execution must be copied there, "
1166 "if building has been enabled.\n"
1167 "That is, 'slave' nodes will not automatically get any source files. "
1168 "'slave' nodes don't get build dependencies either, so if you need "
1169 "make and other tools to install, be sure to provide them as "
1170 "actual dependencies instead.",
1171 "type": Attribute.STRING,
1172 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1173 "validation_function": validation.is_string
1176 "netpipe_mode": dict({
1178 "help": "Link mode:\n"
1179 " * SERVER: applies to incoming connections\n"
1180 " * CLIENT: applies to outgoing connections\n"
1181 " * SERVICE: applies to both",
1182 "type": Attribute.ENUM,
1183 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1184 "allowed": ["SERVER",
1187 "validation_function": validation.is_enum,
1191 "help": "Port list or range. Eg: '22', '22,23,27', '20-2000'",
1192 "type": Attribute.STRING,
1193 "validation_function": is_portlist,
1197 "help": "Address list or range. Eg: '127.0.0.1', '127.0.0.1,127.0.1.1', '127.0.0.1/8'",
1198 "type": Attribute.STRING,
1199 "validation_function": is_addrlist,
1203 "help": "Inbound bandwidth limit (in Mbit/s)",
1204 "type": Attribute.DOUBLE,
1205 "validation_function": validation.is_number,
1209 "help": "Outbound bandwidth limit (in Mbit/s)",
1210 "type": Attribute.DOUBLE,
1211 "validation_function": validation.is_number,
1215 "help": "Inbound packet loss rate (0 = no loss, 1 = 100% loss)",
1216 "type": Attribute.DOUBLE,
1217 "validation_function": validation.is_number,
1221 "help": "Outbound packet loss rate (0 = no loss, 1 = 100% loss)",
1222 "type": Attribute.DOUBLE,
1223 "validation_function": validation.is_number,
1227 "help": "Inbound packet delay (in milliseconds)",
1228 "type": Attribute.INTEGER,
1230 "validation_function": validation.is_integer,
1234 "help": "Outbound packet delay (in milliseconds)",
1235 "type": Attribute.INTEGER,
1237 "validation_function": validation.is_integer,
1241 "help": "Path to a .c or .py source for a filter module, or a binary .so",
1242 "type": Attribute.STRING,
1243 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1244 "validation_function": validation.is_string
1248 "help": "Module arguments - comma-separated list of name=value pairs",
1249 "type": Attribute.STRING,
1250 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1251 "validation_function": validation.is_string
1253 "routing_algorithm": dict({
1254 "name": "algorithm",
1255 "help": "Routing algorithm.",
1257 "type": Attribute.ENUM,
1258 "allowed": ["dvmrp"],
1259 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1260 "validation_function": validation.is_enum,
1267 "help": "Standard output stream"
1271 "help": "Application standard error",
1275 "help": "Output of the build process",
1278 "netpipe_stats": dict({
1279 "name": "netpipeStats",
1280 "help": "Information about rule match counters, packets dropped, etc.",
1285 "help": "Detailled log of all packets going through the interface",
1289 "help": "PCAP trace of all packets going through the interface",
1293 "help": "Extra output trace for applications. When activated this trace can be referenced with wildcard a reference from an Application command line. Ex: command: 'tcpdump -w {#[elemet-label].trace[trace-id].[name|path]#}' ",
1295 "dropped_stats": dict({
1296 "name": "dropped_stats",
1297 "help": "Information on dropped packets on a filer or queue associated to a network interface",
1302 INTERNET, NODE, NODEIFACE, CLASSQUEUEFILTER, TOSQUEUEFILTER,
1303 MULTICASTANNOUNCER, MULTICASTFORWARDER, MULTICASTROUTER,
1304 TUNFILTER, TAPIFACE, TUNIFACE, NETPIPE,
1305 NEPIDEPENDENCY, NS3DEPENDENCY, DEPENDENCY, APPLICATION ]
1308 INTERNET, Parallel(NODE),
1310 Parallel(MULTICASTANNOUNCER), Parallel(MULTICASTFORWARDER), Parallel(MULTICASTROUTER),
1311 Parallel(TAPIFACE), Parallel(TUNIFACE), NETPIPE,
1312 Parallel(NEPIDEPENDENCY), Parallel(NS3DEPENDENCY), Parallel(DEPENDENCY), Parallel(APPLICATION) ]
1314 # Start (and prestart) node after ifaces, because the node needs the ifaces in order to set up routes
1315 start_order = [ INTERNET,
1317 Parallel(TAPIFACE), Parallel(TUNIFACE),
1318 Parallel(NODE), NETPIPE,
1319 Parallel(MULTICASTANNOUNCER), Parallel(MULTICASTFORWARDER), Parallel(MULTICASTROUTER),
1320 Parallel(NEPIDEPENDENCY), Parallel(NS3DEPENDENCY), Parallel(DEPENDENCY), Parallel(APPLICATION) ]
1324 Parallel(APPLICATION),
1325 Parallel(MULTICASTROUTER), Parallel(MULTICASTFORWARDER), Parallel(MULTICASTANNOUNCER),
1326 Parallel(TAPIFACE), Parallel(TUNIFACE), Parallel(NETPIPE),
1327 Parallel(NEPIDEPENDENCY), Parallel(NS3DEPENDENCY), Parallel(DEPENDENCY),
1328 NODEIFACE, Parallel(NODE) ]
1330 factories_info = dict({
1332 "help": "Virtualized Node (V-Server style)",
1333 "category": FC.CATEGORY_NODES,
1334 "create_function": create_node,
1335 "preconfigure_function": configure_node,
1336 "prestart_function": configure_node_routes,
1348 # NEPI-in-NEPI attributes
1349 ATTR_NEPI_TESTBED_ENVIRONMENT_SETUP,
1351 "connector_types": ["devs", "apps", "pipes", "deps"],
1352 "tags": [tags.NODE, tags.ALLOW_ROUTES],
1355 "help": "External network interface - they cannot be brought up or down, and they MUST be connected to the internet.",
1356 "category": FC.CATEGORY_DEVICES,
1357 "create_function": create_nodeiface,
1358 "preconfigure_function": configure_nodeiface,
1359 "box_attributes": [ ],
1360 "connector_types": ["node", "inet"],
1361 "tags": [tags.INTERFACE, tags.HAS_ADDRESSES],
1364 "help": "Virtual TUN network interface (layer 3)",
1365 "category": FC.CATEGORY_DEVICES,
1366 "create_function": create_tuniface,
1367 "preconfigure_function": preconfigure_tuniface,
1368 "configure_function": postconfigure_tuniface,
1369 "prestart_function": prestart_tuniface,
1371 "up", "if_name", "mtu", "snat", "pointopoint", "multicast", "bwlimit",
1373 "tun_proto", "tun_addr", "tun_port", "tun_key", "tun_cipher",
1375 "traces": ["packets", "pcap"],
1376 "connector_types": ["node","udp","tcp","fd->","gre"],
1377 "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
1380 "help": "Virtual TAP network interface (layer 2)",
1381 "category": FC.CATEGORY_DEVICES,
1382 "create_function": create_tapiface,
1383 "preconfigure_function": preconfigure_tuniface,
1384 "configure_function": postconfigure_tuniface,
1385 "prestart_function": prestart_tuniface,
1387 "up", "if_name", "mtu", "snat", "pointopoint", "multicast", "bwlimit",
1389 "tun_proto", "tun_addr", "tun_port", "tun_key", "tun_cipher",
1391 "traces": ["packets", "pcap"],
1392 "connector_types": ["node","udp","tcp","fd->","gre"],
1393 "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
1396 "help": "TUN/TAP stream filter\n\n"
1397 "If specified, it should be either a .py or .so module. "
1398 "It will be loaded, and all incoming and outgoing packets "
1399 "will be routed through it. The filter will not be responsible "
1400 "for buffering, packet queueing is performed in tun_connect "
1401 "already, so it should not concern itself with it. It should "
1402 "not, however, block in one direction if the other is congested.\n"
1404 "Modules are expected to have the following methods:\n"
1406 "\t\tIf arguments are given, this method will be called with the\n"
1407 "\t\tgiven arguments (as keyword args in python modules, or a single\n"
1408 "\taccept_packet(packet, direction):\n"
1409 "\t\tDecide whether to drop the packet. Direction is 0 for packets "
1410 "coming from the local side to the remote, and 1 is for packets "
1411 "coming from the remote side to the local. Return a boolean, "
1412 "true if the packet is not to be dropped.\n"
1413 "\tfilter_init():\n"
1414 "\t\tInitializes a filtering pipe (filter_run). It should "
1415 "return two file descriptors to use as a bidirectional "
1416 "pipe: local and remote. 'local' is where packets from the "
1417 "local side will be written to. After filtering, those packets "
1418 "should be written to 'remote', where tun_connect will read "
1419 "from, and it will forward them to the remote peer. "
1420 "Packets from the remote peer will be written to 'remote', "
1421 "where the filter is expected to read from, and eventually "
1422 "forward them to the local side. If the file descriptors are "
1423 "not nonblocking, they will be set to nonblocking. So it's "
1424 "better to set them from the start like that.\n"
1425 "\tfilter_run(local, remote):\n"
1426 "\t\tIf filter_init is provided, it will be called repeatedly, "
1427 "in a separate thread until the process is killed. It should "
1428 "sleep at most for a second.\n"
1429 "\tfilter_close(local, remote):\n"
1430 "\t\tCalled then the process is killed, if filter_init was provided. "
1431 "It should, among other things, close the file descriptors.\n"
1433 "Python modules are expected to return a tuple in filter_init, "
1434 "either of file descriptors or file objects, while native ones "
1435 "will receive two int*.\n"
1437 "Python modules can additionally contain a custom queue class "
1438 "that will replace the FIFO used by default. The class should "
1439 "be named 'queueclass' and contain an interface compatible with "
1440 "collections.deque. That is, indexing (especiall for q[0]), "
1441 "bool(q), popleft, appendleft, pop (right), append (right), "
1442 "len(q) and clear.",
1443 "category": FC.CATEGORY_CHANNELS,
1444 "create_function": create_tunfilter,
1447 "tun_proto", "tun_addr", "tun_port", "tun_key", "tun_cipher",
1449 "connector_types": ["->fd","udp","tcp"],
1451 CLASSQUEUEFILTER : dict({
1452 "help": "TUN classfull queue, uses a separate queue for each user-definable class.\n\n"
1453 "It takes two arguments, both of which have sensible defaults:\n"
1454 "\tsize: the base size of each class' queue\n"
1455 "\tclasses: the class definitions, which follow the following syntax:\n"
1456 '\t <CLASSLIST> ::= <CLASS> ":" CLASSLIST\n'
1458 '\t <CLASS> ::= <PROTOLIST> "*" <PRIORITYSPEC>\n'
1459 '\t | <DFLTCLASS>\n'
1460 '\t <DFLTCLASS> ::= "*" <PRIORITYSPEC>\n'
1461 '\t <PROTOLIST> ::= <PROTO> "." <PROTOLIST>\n'
1463 '\t <PROTO> ::= <NAME> | <NUMBER>\n'
1464 '\t <NAME> ::= --see http://en.wikipedia.org/wiki/List_of_IP_protocol_numbers --\n'
1465 '\t --only in lowercase, with special characters removed--\n'
1466 '\t --or see below--\n'
1467 '\t <NUMBER> ::= [0-9]+\n'
1468 '\t <PRIORITYSPEC> ::= <THOUGHPUT> [ "#" <SIZE> ] [ "p" <PRIORITY> ]\n'
1469 '\t <THOUGHPUT> ::= NUMBER -- default 1\n'
1470 '\t <PRIORITY> ::= NUMBER -- default 0\n'
1471 '\t <SIZE> ::= NUMBER -- default 1\n'
1473 "Size, thoughput and priority are all relative terms. "
1474 "Sizes are multipliers for the size argument, thoughput "
1475 "is applied relative to other classes and the same with "
1477 "category": FC.CATEGORY_CHANNELS,
1478 "create_function": create_classqueuefilter,
1481 "tun_proto", "tun_addr", "tun_port", "tun_key", "tun_cipher",
1483 "connector_types": ["->fd","udp","tcp"],
1484 "traces": ["dropped_stats"],
1486 TOSQUEUEFILTER : dict({
1487 "help": "TUN classfull queue that classifies according to the TOS (RFC 791) IP field.\n\n"
1488 "It takes a size argument that specifies the size of each class. As TOS is a "
1489 "subset of DiffServ, this queue half-implements DiffServ.",
1490 "category": FC.CATEGORY_CHANNELS,
1491 "create_function": create_tosqueuefilter,
1494 "tun_proto", "tun_addr", "tun_port", "tun_key", "tun_cipher",
1496 "connector_types": ["->fd","udp","tcp"],
1500 "help": "Generic executable command line application",
1501 "category": FC.CATEGORY_APPLICATIONS,
1502 "create_function": create_application,
1503 "start_function": start_application,
1504 "status_function": status_application,
1505 "stop_function": stop_application,
1506 "configure_function": configure_application,
1507 "box_attributes": ["command", "sudo", "stdin",
1508 "depends", "build-depends", "build", "install",
1509 "sources", "rpm-fusion" ],
1510 "connector_types": ["node"],
1511 "traces": ["stdout", "stderr", "buildlog", "output"],
1512 "tags": [tags.APPLICATION],
1515 "help": "Requirement for package or application to be installed on some node",
1516 "category": FC.CATEGORY_APPLICATIONS,
1517 "create_function": create_dependency,
1518 "preconfigure_function": configure_dependency,
1519 "box_attributes": ["depends", "build-depends", "build", "install",
1520 "sources", "rpm-fusion" ],
1521 "connector_types": ["node"],
1522 "traces": ["buildlog"],
1524 NEPIDEPENDENCY: dict({
1525 "help": "Requirement for NEPI inside NEPI - required to run testbed instances inside a node",
1526 "category": FC.CATEGORY_APPLICATIONS,
1527 "create_function": create_nepi_dependency,
1528 "preconfigure_function": configure_dependency,
1529 "box_attributes": [],
1530 "connector_types": ["node"],
1531 "traces": ["buildlog"],
1533 NS3DEPENDENCY: dict({
1534 "help": "Requirement for NS3 inside NEPI - required to run NS3 testbed instances inside a node. It also needs NepiDependency.",
1535 "category": FC.CATEGORY_APPLICATIONS,
1536 "create_function": create_ns3_dependency,
1537 "preconfigure_function": configure_dependency,
1538 "box_attributes": [ ],
1539 "connector_types": ["node"],
1540 "traces": ["buildlog"],
1542 MULTICASTFORWARDER: dict({
1543 "help": "This application installs a userspace packet forwarder "
1544 "that, when connected to a node, filters all packets "
1545 "flowing through multicast-capable virtual interfaces "
1546 "and applies custom-specified routing policies.",
1547 "category": FC.CATEGORY_APPLICATIONS,
1548 "create_function": create_multicast_forwarder,
1549 "preconfigure_function": configure_forwarder,
1550 "start_function": start_application,
1551 "status_function": status_application,
1552 "stop_function": stop_application,
1553 "box_attributes": [ ],
1554 "connector_types": ["node","router"],
1555 "traces": ["buildlog","stderr"],
1557 MULTICASTANNOUNCER: dict({
1558 "help": "This application installs a userspace daemon that "
1559 "monitors multicast membership and announces it on all "
1560 "multicast-capable interfaces.\n"
1561 "This does not usually happen automatically on PlanetLab slivers.",
1562 "category": FC.CATEGORY_APPLICATIONS,
1563 "create_function": create_multicast_announcer,
1564 "preconfigure_function": configure_announcer,
1565 "start_function": start_application,
1566 "status_function": status_application,
1567 "stop_function": stop_application,
1568 "box_attributes": [ ],
1569 "connector_types": ["node"],
1570 "traces": ["buildlog","stderr"],
1572 MULTICASTROUTER: dict({
1573 "help": "This application installs a userspace daemon that "
1574 "monitors multicast membership and announces it on all "
1575 "multicast-capable interfaces.\n"
1576 "This does not usually happen automatically on PlanetLab slivers.",
1577 "category": FC.CATEGORY_APPLICATIONS,
1578 "create_function": create_multicast_router,
1579 "preconfigure_function": configure_router,
1580 "start_function": start_application,
1581 "status_function": status_application,
1582 "stop_function": stop_application,
1583 "box_attributes": ["routing_algorithm"],
1584 "connector_types": ["fwd"],
1585 "traces": ["buildlog","stdout","stderr"],
1588 "help": "Internet routing",
1589 "category": FC.CATEGORY_CHANNELS,
1590 "create_function": create_internet,
1591 "connector_types": ["devs"],
1592 "tags": [tags.INTERNET],
1595 "help": "Link emulation",
1596 "category": FC.CATEGORY_CHANNELS,
1597 "create_function": create_netpipe,
1598 "configure_function": configure_netpipe,
1599 "box_attributes": ["netpipe_mode",
1600 "addr_list", "port_list",
1601 "bw_in","plr_in","delay_in",
1602 "bw_out","plr_out","delay_out"],
1603 "connector_types": ["node"],
1604 "traces": ["netpipe_stats"],
1608 testbed_attributes = dict({
1611 "help": "The name of the PlanetLab slice to use",
1612 "type": Attribute.STRING,
1613 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable | Attribute.NoDefaultValue,
1614 "validation_function": validation.is_string
1618 "help": "The name of the PlanetLab user to use for API calls - it must have at least a User role.",
1619 "type": Attribute.STRING,
1620 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable | Attribute.NoDefaultValue,
1621 "validation_function": validation.is_string
1625 "help": "The PlanetLab user's password.",
1626 "type": Attribute.STRING,
1627 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable | Attribute.NoDefaultValue,
1628 "validation_function": validation.is_string
1632 "help": "The PlanetLab PLC API host",
1633 "type": Attribute.STRING,
1634 "value": "www.planet-lab.eu",
1635 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1636 "validation_function": validation.is_string
1640 "help": "The PlanetLab PLC API url pattern - %(hostname)s is replaced by plcHost.",
1641 "type": Attribute.STRING,
1642 "value": "https://%(hostname)s:443/PLCAPI/",
1643 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1644 "validation_function": validation.is_string
1646 "p2p_deployment": dict({
1647 "name": "p2pDeployment",
1648 "help": "Enable peer-to-peer deployment of applications and dependencies. "
1649 "When enabled, dependency packages and applications are "
1650 "deployed in a P2P fashion, picking a single node to do "
1651 "the building or repo download, while all the others "
1652 "cooperatively exchange resulting binaries or rpms. "
1653 "When deploying to many nodes, this is a far more efficient "
1654 "use of resources. It does require re-encrypting and distributing "
1655 "the slice's private key. Though it is implemented in a secure "
1656 "fashion, if they key's sole purpose is not PlanetLab, then this "
1657 "feature should be disabled.",
1658 "type": Attribute.BOOL,
1660 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1661 "validation_function": validation.is_bool
1663 "slice_ssh_key": dict({
1664 "name": "sliceSSHKey",
1665 "help": "The controller-local path to the slice user's ssh private key. "
1666 "It is the user's responsability to deploy this file where the controller "
1667 "will run, it won't be done automatically because it's sensitive information. "
1668 "It is recommended that a NEPI-specific user be created for this purpose and "
1669 "this purpose alone.",
1670 "type": Attribute.STRING,
1671 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable | Attribute.NoDefaultValue,
1672 "validation_function": validation.is_string
1674 "pl_log_level": dict({
1675 "name": "plLogLevel",
1676 "help": "Verbosity of logging of planetlab events.",
1678 "type": Attribute.ENUM,
1679 "allowed": ["DEBUG",
1684 "validation_function": validation.is_enum,
1686 "tap_port_base": dict({
1687 "name": "tapPortBase",
1688 "help": "Base port to use when connecting TUN/TAPs. Effective port will be BASE + GUID.",
1689 "type": Attribute.INTEGER,
1691 "range": (2000,30000),
1692 "validation_function": validation.is_integer_range(2000,30000)
1694 "dedicated_slice": dict({
1695 "name": "dedicatedSlice",
1696 "help": "Set to True if the slice will be dedicated to this experiment. "
1697 "NEPI will perform node and slice cleanup, making sure slices are "
1698 "in a clean, repeatable state before running the experiment.",
1699 "type": Attribute.BOOL,
1701 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1702 "validation_function": validation.is_bool
1706 supported_recovery_policies = [
1712 class MetadataInfo(metadata.MetadataInfo):
1714 def connector_types(self):
1715 return connector_types
1718 def connections(self):
1722 def attributes(self):
1730 def create_order(self):
1734 def configure_order(self):
1735 return configure_order
1738 def prestart_order(self):
1742 def start_order(self):
1746 def factories_info(self):
1747 return factories_info
1750 def testbed_attributes(self):
1751 return testbed_attributes
1754 def testbed_id(self):
1758 def testbed_version(self):
1759 return TESTBED_VERSION
1762 def supported_recovery_policies(self):
1763 return supported_recovery_policies