1 # -*- coding: utf-8 -*-
5 from constants import TESTBED_ID, TESTBED_VERSION
6 from nepi.core import metadata
7 from nepi.core.metadata import Parallel
8 from nepi.core.attributes import Attribute
9 from nepi.util import tags, validation
10 from nepi.util.constants import ApplicationStatus as AS, \
11 FactoryCategories as FC, \
12 ATTR_NEPI_TESTBED_ENVIRONMENT_SETUP, \
13 DeploymentConfiguration as DC
21 NODEIFACE = "NodeInterface"
22 TUNIFACE = "TunInterface"
23 TAPIFACE = "TapInterface"
24 APPLICATION = "Application"
25 CCNXDAEMON = "CCNxDaemon"
26 DEPENDENCY = "Dependency"
27 NEPIDEPENDENCY = "NepiDependency"
28 NS3DEPENDENCY = "NS3Dependency"
31 TUNFILTER = "TunFilter"
32 CLASSQUEUEFILTER = "ClassQueueFilter"
33 LOGGINGCLASSQUEUEFILTER = "LoggingClassQueueFilter"
34 TOSQUEUEFILTER = "TosQueueFilter"
35 MULTICASTFORWARDER = "MulticastForwarder"
36 MULTICASTANNOUNCER = "MulticastAnnouncer"
37 MULTICASTROUTER = "MulticastRouter"
39 TUNFILTERS = (TUNFILTER, CLASSQUEUEFILTER, LOGGINGCLASSQUEUEFILTER, TOSQUEUEFILTER)
40 TAPFILTERS = (TUNFILTER, )
41 ALLFILTERS = (TUNFILTER, CLASSQUEUEFILTER, LOGGINGCLASSQUEUEFILTER, TOSQUEUEFILTER)
43 PL_TESTBED_ID = "planetlab"
46 ### Custom validation functions ###
47 def is_addrlist(attribute, value):
48 if not validation.is_string(attribute, value):
55 components = value.split(',')
57 for component in components:
59 addr, mask = component.split('/',1)
61 addr, mask = component, '32'
63 if mask is not None and not (mask and mask.isdigit()):
64 # No empty or nonnumeric masks
67 if not validation.is_ip4_address(attribute, addr):
68 # Address part must be ipv4
73 def is_portlist(attribute, value):
74 if not validation.is_string(attribute, value):
81 components = value.split(',')
83 for component in components:
85 pfrom, pto = component.split('-',1)
87 pfrom = pto = component
89 if not pfrom or not pto or not pfrom.isdigit() or not pto.isdigit():
90 # No empty or nonnumeric ports
96 ### Connection functions ####
98 def connect_node_iface_node(testbed_instance, node_guid, iface_guid):
99 node = testbed_instance._elements[node_guid]
100 iface = testbed_instance._elements[iface_guid]
103 def connect_node_iface_inet(testbed_instance, iface_guid, inet_guid):
104 iface = testbed_instance._elements[iface_guid]
105 iface.has_internet = True
107 def connect_tun_iface_node(testbed_instance, node_guid, iface_guid):
108 node = testbed_instance._elements[node_guid]
109 iface = testbed_instance._elements[iface_guid]
111 node.required_vsys.update(('fd_tuntap', 'vif_up', 'vif_down'))
112 node.required_packages.update(('python', 'python-crypto', 'python-setuptools', 'gcc'))
114 def connect_tun_iface_peer(proto, testbed_instance, iface_guid, peer_iface_guid):
115 iface = testbed_instance._elements[iface_guid]
116 peer_iface = testbed_instance._elements[peer_iface_guid]
117 iface.peer_iface = peer_iface
118 peer_iface.peer_iface = iface
121 peer_iface.peer_proto = \
122 peer_iface.tun_proto = proto
123 iface.tun_key = peer_iface.tun_key
125 def connect_tun_iface_filter(testbed_instance, iface_guid, filter_guid):
126 iface = testbed_instance._elements[iface_guid]
127 filt = testbed_instance._elements[filter_guid]
128 traces = testbed_instance._get_traces(filter_guid)
129 if 'dropped_stats' in traces:
130 args = filt.args if filt.args else ""
131 filt.args = ','.join(filt.args.split(',') + ["logdropped=true",])
132 iface.filter_module = filt
133 filt.iface_guid = iface_guid
134 filt.iface = weakref.ref(iface)
137 connect_tun_iface_peer(filt.peer_proto, testbed_instance, filt.iface_guid, filt.peer_guid)
139 def connect_filter_peer(proto, testbed_instance, filter_guid, peer_guid):
140 peer = testbed_instance._elements[peer_guid]
141 filt = testbed_instance._elements[filter_guid]
142 filt.peer_proto = proto
143 filt.peer_guid = peer_guid
145 connect_tun_iface_peer(filt.peer_proto, testbed_instance, filt.iface_guid, filt.peer_guid)
147 def connect_filter_filter(proto, testbed_instance, filter_guid, peer_guid):
148 peer = testbed_instance._elements[peer_guid]
149 filt = testbed_instance._elements[filter_guid]
150 filt.peer_proto = proto
151 peer.peer_proto = proto
153 peer.peer_guid = filt.iface_guid
155 filt.peer_guid = peer.iface_guid
156 if filt.iface_guid and filt.peer_guid:
157 connect_tun_iface_peer(filt.peer_proto, testbed_instance, filt.iface_guid, filt.peer_guid)
159 def crossconnect_tun_iface_peer_init(proto, testbed_instance, iface_guid, peer_iface_data):
160 iface = testbed_instance._elements[iface_guid]
161 iface.peer_iface = None
162 iface.peer_addr = peer_iface_data.get("tun_addr")
163 iface.peer_proto = peer_iface_data.get("tun_proto") or proto
164 iface.peer_port = peer_iface_data.get("tun_port")
165 iface.peer_cipher = peer_iface_data.get("tun_cipher")
166 iface.tun_key = min(iface.tun_key, peer_iface_data.get("tun_key"))
167 iface.tun_proto = proto
169 preconfigure_tuniface(testbed_instance, iface_guid)
171 def crossconnect_tun_iface_peer_compl(proto, testbed_instance, iface_guid, peer_iface_data):
172 # refresh (refreshable) attributes for second-phase
173 iface = testbed_instance._elements[iface_guid]
174 iface.peer_addr = peer_iface_data.get("tun_addr")
175 iface.peer_proto = peer_iface_data.get("tun_proto") or proto
176 iface.peer_port = peer_iface_data.get("tun_port")
177 iface.peer_cipher = peer_iface_data.get("tun_cipher")
179 postconfigure_tuniface(testbed_instance, iface_guid)
181 def crossconnect_tun_iface_peer_both(proto, testbed_instance, iface_guid, peer_iface_data):
182 crossconnect_tun_iface_peer_init(proto, testbed_instance, iface_guid, peer_iface_data)
183 crossconnect_tun_iface_peer_compl(proto, testbed_instance, iface_guid, peer_iface_data)
185 def crossconnect_filter_peer_init(proto, testbed_instance, filter_guid, peer_data):
186 filt = testbed_instance._elements[filter_guid]
187 filt.peer_proto = proto
188 crossconnect_tun_iface_peer_init(filt.peer_proto, testbed_instance, filt.iface_guid, peer_data)
190 def crossconnect_filter_peer_compl(proto, testbed_instance, filter_guid, peer_data):
191 filt = testbed_instance._elements[filter_guid]
192 filt.peer_proto = proto
193 crossconnect_tun_iface_peer_compl(filt.peer_proto, testbed_instance, filt.iface_guid, peer_data)
195 def crossconnect_filter_peer_both(proto, testbed_instance, filter_guid, peer_data):
196 crossconnect_filter_peer_init(proto, testbed_instance, iface_guid, peer_iface_data)
197 crossconnect_filter_peer_compl(proto, testbed_instance, iface_guid, peer_iface_data)
199 def connect_dep(testbed_instance, node_guid, app_guid, node=None, app=None):
200 node = node or testbed_instance._elements[node_guid]
201 app = app or testbed_instance._elements[app_guid]
205 node.required_packages.update(set(
206 app.depends.split() ))
209 if app.home_path and app.home_path not in node.pythonpath:
210 node.pythonpath.append(app.home_path)
213 for envkey, envval in app.env.iteritems():
214 envval = app._replace_paths(envval)
215 node.env[envkey].append(envval)
218 node.rpmFusion = True
220 def connect_forwarder(testbed_instance, node_guid, fwd_guid):
221 node = testbed_instance._elements[node_guid]
222 fwd = testbed_instance._elements[fwd_guid]
223 node.multicast_forwarder = fwd
226 connect_dep(testbed_instance, node_guid, None, app=fwd.router)
228 connect_dep(testbed_instance, node_guid, fwd_guid)
230 def connect_router(testbed_instance, fwd_guid, router_guid):
231 fwd = testbed_instance._elements[fwd_guid]
232 router = testbed_instance._elements[router_guid]
236 connect_dep(testbed_instance, None, router_guid, node=fwd.node)
238 def connect_node_netpipe(testbed_instance, node_guid, netpipe_guid):
239 node = testbed_instance._elements[node_guid]
240 netpipe = testbed_instance._elements[netpipe_guid]
242 node.required_vsys.add('ipfw-be')
243 node.required_packages.add('ipfwslice')
246 ### Creation functions ###
248 def create_node(testbed_instance, guid):
249 parameters = testbed_instance._get_parameters(guid)
251 # create element with basic attributes
252 element = testbed_instance._make_node(parameters)
254 # add constraint on number of (real) interfaces
255 # by counting connected devices
256 dev_guids = testbed_instance.get_connected(guid, "devs", "node")
257 num_open_ifaces = sum( # count True values
258 NODEIFACE == testbed_instance._get_factory_id(guid)
259 for guid in dev_guids )
260 element.min_num_external_ifaces = num_open_ifaces
262 # require vroute vsys if we have routes to set up
263 routes = testbed_instance._add_route.get(guid)
265 vsys = element.routing_method(routes,
266 testbed_instance.vsys_vnet)
267 element.required_vsys.add(vsys)
269 testbed_instance.elements[guid] = element
271 def create_nodeiface(testbed_instance, guid):
272 parameters = testbed_instance._get_parameters(guid)
273 element = testbed_instance._make_node_iface(parameters)
274 testbed_instance.elements[guid] = element
276 def create_tuniface(testbed_instance, guid):
277 parameters = testbed_instance._get_parameters(guid)
278 element = testbed_instance._make_tun_iface(parameters)
280 # Set custom addresses, if there are any already
281 # Setting this early helps set up P2P links
282 if guid in testbed_instance._add_address and not (element.address or element.netmask or element.netprefix):
283 addresses = testbed_instance._add_address[guid]
284 for address in addresses:
285 (address, netprefix, broadcast) = address
286 element.add_address(address, netprefix, broadcast)
288 testbed_instance.elements[guid] = element
290 def create_tapiface(testbed_instance, guid):
291 parameters = testbed_instance._get_parameters(guid)
292 element = testbed_instance._make_tap_iface(parameters)
294 # Set custom addresses, if there are any already
295 # Setting this early helps set up P2P links
296 if guid in testbed_instance._add_address and not (element.address or element.netmask or element.netprefix):
297 addresses = testbed_instance._add_address[guid]
298 for address in addresses:
299 (address, netprefix, broadcast) = address
300 element.add_address(address, netprefix, broadcast)
302 testbed_instance.elements[guid] = element
304 def create_tunfilter(testbed_instance, guid):
305 parameters = testbed_instance._get_parameters(guid)
306 element = testbed_instance._make_tun_filter(parameters)
307 testbed_instance.elements[guid] = element
309 def create_classqueuefilter(testbed_instance, guid):
310 parameters = testbed_instance._get_parameters(guid)
311 element = testbed_instance._make_class_queue_filter(parameters)
312 testbed_instance.elements[guid] = element
314 def create_loggingclassqueuefilter(testbed_instance, guid):
315 parameters = testbed_instance._get_parameters(guid)
316 element = testbed_instance._make_logging_class_queue_filter(parameters)
317 testbed_instance.elements[guid] = element
319 def create_tosqueuefilter(testbed_instance, guid):
320 parameters = testbed_instance._get_parameters(guid)
321 element = testbed_instance._make_tos_queue_filter(parameters)
322 testbed_instance.elements[guid] = element
324 def create_application(testbed_instance, guid):
325 parameters = testbed_instance._get_parameters(guid)
326 element = testbed_instance._make_application(parameters)
328 # Just inject configuration stuff
329 element.home_path = "nepi-app-%s" % (guid,)
331 testbed_instance.elements[guid] = element
333 def create_ccnxdaemon(testbed_instance, guid):
334 parameters = testbed_instance._get_parameters(guid)
335 element = testbed_instance._make_application(parameters,
336 clazz = testbed_instance._app.CCNxDaemon )
338 # Just inject configuration stuff
339 element.home_path = "nepi-ccnd-%s" % (guid,)
341 testbed_instance.elements[guid] = element
343 def create_dependency(testbed_instance, guid):
344 parameters = testbed_instance._get_parameters(guid)
345 element = testbed_instance._make_dependency(parameters)
347 # Just inject configuration stuff
348 element.home_path = "nepi-dep-%s" % (guid,)
350 testbed_instance.elements[guid] = element
352 def create_nepi_dependency(testbed_instance, guid):
353 parameters = testbed_instance._get_parameters(guid)
354 element = testbed_instance._make_nepi_dependency(parameters)
356 # Just inject configuration stuff
357 element.home_path = "nepi-nepi-%s" % (guid,)
359 testbed_instance.elements[guid] = element
361 def create_ns3_dependency(testbed_instance, guid):
362 parameters = testbed_instance._get_parameters(guid)
363 element = testbed_instance._make_ns3_dependency(parameters)
365 # Just inject configuration stuff
366 element.home_path = "nepi-ns3-%s" % (guid,)
368 testbed_instance.elements[guid] = element
370 def create_multicast_forwarder(testbed_instance, guid):
371 parameters = testbed_instance._get_parameters(guid)
372 element = testbed_instance._make_multicast_forwarder(parameters)
374 # Just inject configuration stuff
375 element.home_path = "nepi-mcfwd-%s" % (guid,)
377 testbed_instance.elements[guid] = element
379 def create_multicast_announcer(testbed_instance, guid):
380 parameters = testbed_instance._get_parameters(guid)
381 element = testbed_instance._make_multicast_announcer(parameters)
383 # Just inject configuration stuff
384 element.home_path = "nepi-mcann-%s" % (guid,)
386 testbed_instance.elements[guid] = element
388 def create_multicast_router(testbed_instance, guid):
389 parameters = testbed_instance._get_parameters(guid)
390 element = testbed_instance._make_multicast_router(parameters)
392 # Just inject configuration stuff
393 element.home_path = "nepi-mcrt-%s" % (guid,)
395 testbed_instance.elements[guid] = element
397 def create_internet(testbed_instance, guid):
398 parameters = testbed_instance._get_parameters(guid)
399 element = testbed_instance._make_internet(parameters)
400 testbed_instance.elements[guid] = element
402 def create_netpipe(testbed_instance, guid):
403 parameters = testbed_instance._get_parameters(guid)
404 element = testbed_instance._make_netpipe(parameters)
405 testbed_instance.elements[guid] = element
407 ### Start/Stop functions ###
409 def prestart_ccnxdaemon(testbed_instance, guid):
410 # ccnx daemon needs to start before the rest of the
412 start_application(testbed_instance, guid)
414 def stop_ccndaemon(testbed_instance, guid):
415 app = testbed_instance.elements[guid]
418 def start_application(testbed_instance, guid):
419 parameters = testbed_instance._get_parameters(guid)
420 traces = testbed_instance._get_traces(guid)
421 app = testbed_instance.elements[guid]
423 app.stdout = "stdout" in traces
424 app.stderr = "stderr" in traces
425 app.buildlog = "buildlog" in traces
426 app.outout = "output" in traces
430 def stop_application(testbed_instance, guid):
431 app = testbed_instance.elements[guid]
434 ### Status functions ###
436 def status_application(testbed_instance, guid):
437 if guid not in testbed_instance.elements.keys():
438 return AS.STATUS_NOT_STARTED
440 app = testbed_instance.elements[guid]
443 ### Configure functions ###
445 def configure_nodeiface(testbed_instance, guid):
446 element = testbed_instance._elements[guid]
448 # Cannot explicitly configure addresses
449 if guid in testbed_instance._add_address:
450 raise ValueError, "Cannot explicitly set address of public PlanetLab interface"
453 node_guid = testbed_instance.get_connected(guid, "node", "devs")[0]
454 dev_guids = testbed_instance.get_connected(node_guid, "node", "devs")
455 siblings = [ self._element[dev_guid]
456 for dev_guid in dev_guids
457 if dev_guid != guid ]
459 # Fetch address from PLC api
460 element.pick_iface(siblings)
462 # Do some validations
465 def preconfigure_tuniface(testbed_instance, guid):
466 element = testbed_instance._elements[guid]
468 # Set custom addresses if any, and if not set already
469 if guid in testbed_instance._add_address and not (element.address or element.netmask or element.netprefix):
470 addresses = testbed_instance._add_address[guid]
471 for address in addresses:
472 (address, netprefix, broadcast) = address
473 element.add_address(address, netprefix, broadcast)
475 # Link to external interface, if any
476 for iface in testbed_instance._elements.itervalues():
477 if isinstance(iface, testbed_instance._interfaces.NodeIface) and iface.node is element.node and iface.has_internet:
478 element.external_iface = iface
481 # Set standard TUN attributes
482 if (not element.tun_addr or not element.tun_port) and element.external_iface:
483 element.tun_addr = element.external_iface.address
484 element.tun_port = testbed_instance.tapPortBase + int(guid)
487 traces = testbed_instance._get_traces(guid)
488 for capmode in ('pcap', 'packets'):
489 if capmode in traces:
490 element.capture = capmode
493 element.capture = False
495 # Do some validations
499 element.prepare('tun-%s' % (guid,))
501 def postconfigure_tuniface(testbed_instance, guid):
502 element = testbed_instance._elements[guid]
507 def prestart_tuniface(testbed_instance, guid):
508 element = testbed_instance._elements[guid]
513 def configure_node(testbed_instance, guid):
514 node = testbed_instance._elements[guid]
516 # Just inject configuration stuff
517 node.home_path = "nepi-node-%s" % (guid,)
518 node.ident_path = testbed_instance.sliceSSHKey
519 node.slicename = testbed_instance.slicename
521 # Do some validations
524 # this will be done in parallel in all nodes
525 # this call only spawns the process
526 node.install_dependencies()
528 def configure_node_routes(testbed_instance, guid):
529 node = testbed_instance._elements[guid]
530 routes = testbed_instance._add_route.get(guid)
534 for dev_guid in testbed_instance.get_connected(guid, "devs", "node")
535 for dev in ( testbed_instance._elements.get(dev_guid) ,)
536 if dev and isinstance(dev, testbed_instance._interfaces.TunIface) ]
538 vsys = testbed_instance.vsys_vnet
540 node.configure_routes(routes, devs, vsys)
542 def configure_application(testbed_instance, guid):
543 app = testbed_instance._elements[guid]
545 # Do some validations
548 # Wait for dependencies
549 app.node.wait_dependencies()
554 def configure_dependency(testbed_instance, guid):
555 dep = testbed_instance._elements[guid]
557 # Do some validations
560 # Wait for dependencies
561 dep.node.wait_dependencies()
566 def configure_announcer(testbed_instance, guid):
568 fwd = testbed_instance._elements[guid]
570 for node_guid in testbed_instance.get_connected(guid, "node", "apps")
571 for dev_guid in testbed_instance.get_connected(node_guid, "devs", "node")
572 for dev in ( testbed_instance._elements.get(dev_guid) ,)
573 if dev and isinstance(dev, testbed_instance._interfaces.TunIface)
577 configure_dependency(testbed_instance, guid)
579 def configure_forwarder(testbed_instance, guid):
580 configure_announcer(testbed_instance, guid)
582 # Link ifaces to forwarder
583 fwd = testbed_instance._elements[guid]
584 for iface in fwd.ifaces:
585 iface.multicast_forwarder = '/var/run/mcastfwd'
587 def configure_router(testbed_instance, guid):
589 rt = testbed_instance._elements[guid]
591 for fwd_guid in testbed_instance.get_connected(guid, "fwd", "router")
592 for node_guid in testbed_instance.get_connected(fwd_guid, "node", "apps")
593 for dev_guid in testbed_instance.get_connected(node_guid, "devs", "node")
594 for dev in ( testbed_instance._elements.get(dev_guid) ,)
595 if dev and isinstance(dev, testbed_instance._interfaces.TunIface)
596 and not dev.multicast ]
599 configure_dependency(testbed_instance, guid)
601 def configure_netpipe(testbed_instance, guid):
602 netpipe = testbed_instance._elements[guid]
604 # Do some validations
607 # Wait for dependencies
608 netpipe.node.wait_dependencies()
613 ### Factory information ###
615 connector_types = dict({
617 "help": "Connector from node to applications",
623 "help": "Connector from node to network interfaces",
629 "help": "Connector from node to application dependencies "
630 "(packages and applications that need to be installed)",
636 "help": "Connector from network interfaces to the internet",
642 "help": "Connector to a Node",
648 "help": "Connector to a routing daemon",
654 "help": "Forwarder this routing daemon communicates with",
660 "help": "Connector to a NetPipe",
667 "help": "ip-ip tunneling over TCP link",
673 "help": "ip-ip tunneling over UDP datagrams",
679 "help": "IP or Ethernet tunneling using the GRE protocol",
685 "help": "TUN device file descriptor provider",
691 "help": "TUN device file descriptor slot",
700 "from": (TESTBED_ID, NODE, "devs"),
701 "to": (TESTBED_ID, NODEIFACE, "node"),
702 "init_code": connect_node_iface_node,
706 "from": (TESTBED_ID, NODE, "devs"),
707 "to": (TESTBED_ID, TUNIFACE, "node"),
708 "init_code": connect_tun_iface_node,
712 "from": (TESTBED_ID, NODE, "devs"),
713 "to": (TESTBED_ID, TAPIFACE, "node"),
714 "init_code": connect_tun_iface_node,
718 "from": (TESTBED_ID, NODEIFACE, "inet"),
719 "to": (TESTBED_ID, INTERNET, "devs"),
720 "init_code": connect_node_iface_inet,
724 "from": (TESTBED_ID, NODE, "apps"),
725 "to": (TESTBED_ID, (APPLICATION, CCNXDAEMON, MULTICASTANNOUNCER), "node"),
726 "init_code": connect_dep,
730 "from": (TESTBED_ID, NODE, "deps"),
731 "to": (TESTBED_ID, (DEPENDENCY, NEPIDEPENDENCY, NS3DEPENDENCY), "node"),
732 "init_code": connect_dep,
736 "from": (TESTBED_ID, NODE, "pipes"),
737 "to": (TESTBED_ID, NETPIPE, "node"),
738 "init_code": connect_node_netpipe,
742 "from": (TESTBED_ID, NODE, "apps"),
743 "to": (TESTBED_ID, MULTICASTFORWARDER, "node"),
744 "init_code": connect_forwarder,
748 "from": (TESTBED_ID, MULTICASTFORWARDER, "router"),
749 "to": (TESTBED_ID, MULTICASTROUTER, "fwd"),
750 "init_code": connect_router,
754 "from": (TESTBED_ID, TUNIFACE, "tcp"),
755 "to": (TESTBED_ID, TUNIFACE, "tcp"),
756 "init_code": functools.partial(connect_tun_iface_peer,"tcp"),
760 "from": (TESTBED_ID, TUNIFACE, "udp"),
761 "to": (TESTBED_ID, TUNIFACE, "udp"),
762 "init_code": functools.partial(connect_tun_iface_peer,"udp"),
766 "from": (TESTBED_ID, TUNIFACE, "gre"),
767 "to": (TESTBED_ID, TUNIFACE, "gre"),
768 "init_code": functools.partial(connect_tun_iface_peer,"gre"),
772 "from": (TESTBED_ID, TUNIFACE, "fd->"),
773 "to": (TESTBED_ID, TUNFILTERS, "->fd"),
774 "init_code": connect_tun_iface_filter,
778 "from": (TESTBED_ID, TUNFILTERS, "tcp"),
779 "to": (TESTBED_ID, TUNIFACE, "tcp"),
780 "init_code": functools.partial(connect_filter_peer,"tcp"),
784 "from": (TESTBED_ID, TUNFILTERS, "udp"),
785 "to": (TESTBED_ID, TUNIFACE, "udp"),
786 "init_code": functools.partial(connect_filter_peer,"udp"),
790 "from": (TESTBED_ID, TAPIFACE, "tcp"),
791 "to": (TESTBED_ID, TAPIFACE, "tcp"),
792 "init_code": functools.partial(connect_tun_iface_peer,"tcp"),
796 "from": (TESTBED_ID, TAPIFACE, "udp"),
797 "to": (TESTBED_ID, TAPIFACE, "udp"),
798 "init_code": functools.partial(connect_tun_iface_peer,"udp"),
802 "from": (TESTBED_ID, TAPIFACE, "gre"),
803 "to": (TESTBED_ID, TAPIFACE, "gre"),
804 "init_code": functools.partial(connect_tun_iface_peer,"gre"),
808 "from": (TESTBED_ID, TAPIFACE, "fd->"),
809 "to": (TESTBED_ID, TAPFILTERS, "->fd"),
810 "init_code": connect_tun_iface_filter,
814 "from": (TESTBED_ID, TAPFILTERS, "tcp"),
815 "to": (TESTBED_ID, TAPIFACE, "tcp"),
816 "init_code": functools.partial(connect_filter_peer,"tcp"),
820 "from": (TESTBED_ID, TAPFILTERS, "udp"),
821 "to": (TESTBED_ID, TAPIFACE, "udp"),
822 "init_code": functools.partial(connect_filter_peer,"udp"),
826 "from": (TESTBED_ID, TUNFILTERS, "tcp"),
827 "to": (TESTBED_ID, TUNFILTERS, "tcp"),
828 "init_code": functools.partial(connect_filter_filter,"tcp"),
832 "from": (TESTBED_ID, TUNFILTERS, "udp"),
833 "to": (TESTBED_ID, TUNFILTERS, "udp"),
834 "init_code": functools.partial(connect_filter_filter,"udp"),
838 "from": (TESTBED_ID, TAPFILTERS, "tcp"),
839 "to": (TESTBED_ID, TAPFILTERS, "tcp"),
840 "init_code": functools.partial(connect_filter_filter,"tcp"),
844 "from": (TESTBED_ID, TAPFILTERS, "udp"),
845 "to": (TESTBED_ID, TAPFILTERS, "udp"),
846 "init_code": functools.partial(connect_filter_filter,"udp"),
850 "from": (TESTBED_ID, TUNIFACE, "tcp"),
851 "to": (None, None, "tcp"),
852 "init_code": functools.partial(crossconnect_tun_iface_peer_init,"tcp"),
853 "compl_code": functools.partial(crossconnect_tun_iface_peer_compl,"tcp"),
857 "from": (TESTBED_ID, TUNIFACE, "udp"),
858 "to": (None, None, "udp"),
859 "init_code": functools.partial(crossconnect_tun_iface_peer_init,"udp"),
860 "compl_code": functools.partial(crossconnect_tun_iface_peer_compl,"udp"),
864 "from": (TESTBED_ID, TUNIFACE, "fd->"),
865 "to": (None, None, "->fd"),
866 "compl_code": functools.partial(crossconnect_tun_iface_peer_both,"fd"),
870 "from": (TESTBED_ID, TUNIFACE, "gre"),
871 "to": (None, None, "gre"),
872 "compl_code": functools.partial(crossconnect_tun_iface_peer_both,"gre"),
876 "from": (TESTBED_ID, TAPIFACE, "tcp"),
877 "to": (None, None, "tcp"),
878 "init_code": functools.partial(crossconnect_tun_iface_peer_init,"tcp"),
879 "compl_code": functools.partial(crossconnect_tun_iface_peer_compl,"tcp"),
883 "from": (TESTBED_ID, TAPIFACE, "udp"),
884 "to": (None, None, "udp"),
885 "init_code": functools.partial(crossconnect_tun_iface_peer_init,"udp"),
886 "compl_code": functools.partial(crossconnect_tun_iface_peer_compl,"udp"),
890 "from": (TESTBED_ID, TAPIFACE, "fd->"),
891 "to": (None, None, "->fd"),
892 "compl_code": functools.partial(crossconnect_tun_iface_peer_both,"fd"),
895 # EGRE is an extension of PlanetLab, so we can't connect externally
896 # if the other testbed isn't another PlanetLab
898 "from": (TESTBED_ID, TAPIFACE, "gre"),
899 "to": (TESTBED_ID, None, "gre"),
900 "compl_code": functools.partial(crossconnect_tun_iface_peer_both,"gre"),
904 "from": (TESTBED_ID, ALLFILTERS, "tcp"),
905 "to": (None, None, "tcp"),
906 "init_code": functools.partial(crossconnect_filter_peer_init,"tcp"),
907 "compl_code": functools.partial(crossconnect_filter_peer_compl,"tcp"),
911 "from": (TESTBED_ID, ALLFILTERS, "udp"),
912 "to": (None, None, "udp"),
913 "init_code": functools.partial(crossconnect_filter_peer_init,"udp"),
914 "compl_code": functools.partial(crossconnect_filter_peer_compl,"udp"),
920 "forward_X11": dict({
921 "name": "forward_X11",
922 "help": "Forward x11 from main namespace to the node",
923 "type": Attribute.BOOL,
925 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
926 "validation_function": validation.is_bool,
930 "help": "Constrain hostname during resource discovery. May use wildcards.",
931 "type": Attribute.STRING,
932 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
933 "validation_function": validation.is_string,
937 "help": "Constrain location (city) during resource discovery. May use wildcards.",
938 "type": Attribute.STRING,
939 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
940 "validation_function": validation.is_string,
944 "help": "Constrain location (country) during resource discovery. May use wildcards.",
945 "type": Attribute.STRING,
946 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
947 "validation_function": validation.is_string,
951 "help": "Constrain location (region) during resource discovery. May use wildcards.",
952 "type": Attribute.STRING,
953 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
954 "validation_function": validation.is_string,
956 "architecture": dict({
957 "name": "architecture",
958 "help": "Constrain architexture during resource discovery.",
959 "type": Attribute.ENUM,
960 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
961 "allowed": ["x86_64",
963 "validation_function": validation.is_enum,
965 "operating_system": dict({
966 "name": "operatingSystem",
967 "help": "Constrain operating system during resource discovery.",
968 "type": Attribute.ENUM,
969 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
975 "validation_function": validation.is_enum,
979 "help": "Constrain the PlanetLab site this node should reside on.",
980 "type": Attribute.ENUM,
981 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
985 "validation_function": validation.is_enum,
987 "min_reliability": dict({
988 "name": "minReliability",
989 "help": "Constrain reliability while picking PlanetLab nodes. Specifies a lower acceptable bound.",
990 "type": Attribute.DOUBLE,
992 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
993 "validation_function": validation.is_number,
995 "max_reliability": dict({
996 "name": "maxReliability",
997 "help": "Constrain reliability while picking PlanetLab nodes. Specifies an upper acceptable bound.",
998 "type": Attribute.DOUBLE,
1000 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1001 "validation_function": validation.is_number,
1003 "min_bandwidth": dict({
1004 "name": "minBandwidth",
1005 "help": "Constrain available bandwidth while picking PlanetLab nodes. Specifies a lower acceptable bound.",
1006 "type": Attribute.DOUBLE,
1008 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1009 "validation_function": validation.is_number,
1011 "max_bandwidth": dict({
1012 "name": "maxBandwidth",
1013 "help": "Constrain available bandwidth while picking PlanetLab nodes. Specifies an upper acceptable bound.",
1014 "type": Attribute.DOUBLE,
1016 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1017 "validation_function": validation.is_number,
1021 "help": "Constrain node load average while picking PlanetLab nodes. Specifies a lower acceptable bound.",
1022 "type": Attribute.DOUBLE,
1024 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1025 "validation_function": validation.is_number,
1029 "help": "Constrain node load average while picking PlanetLab nodes. Specifies an upper acceptable bound.",
1030 "type": Attribute.DOUBLE,
1032 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1033 "validation_function": validation.is_number,
1037 "help": "Constrain available cpu time while picking PlanetLab nodes. Specifies a lower acceptable bound.",
1038 "type": Attribute.DOUBLE,
1040 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1041 "validation_function": validation.is_number,
1045 "help": "Constrain available cpu time while picking PlanetLab nodes. Specifies an upper acceptable bound.",
1046 "type": Attribute.DOUBLE,
1048 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1049 "validation_function": validation.is_number,
1052 "name": "timeframe",
1053 "help": "Past time period in which to check information about the node. Values are year,month, week, latest",
1054 "type": Attribute.ENUM,
1056 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1057 "allowed": ["latest",
1061 "validation_function": validation.is_enum,
1067 "type": Attribute.BOOL,
1069 "validation_function": validation.is_bool
1073 "help": "This is the primary interface for the attached node",
1074 "type": Attribute.BOOL,
1076 "validation_function": validation.is_bool
1080 "help": "Device name",
1081 "type": Attribute.STRING,
1082 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1083 "validation_function": validation.is_string
1087 "help": "Maximum transmition unit for device",
1088 "type": Attribute.INTEGER,
1090 "validation_function": validation.is_integer_range(0,1500)
1094 "help": "Network mask for the device (eg: 24 for /24 network)",
1095 "type": Attribute.INTEGER,
1096 "validation_function": validation.is_integer_range(8,24)
1100 "help": "Enable SNAT (source NAT to the internet) no this device",
1101 "type": Attribute.BOOL,
1103 "validation_function": validation.is_bool
1106 "name": "multicast",
1107 "help": "Enable multicast forwarding on this device. "
1108 "Note that you still need a multicast routing daemon "
1110 "type": Attribute.BOOL,
1112 "validation_function": validation.is_bool
1114 "pointopoint": dict({
1115 "name": "pointopoint",
1116 "help": "If the interface is a P2P link, the remote endpoint's IP "
1117 "should be set on this attribute.",
1118 "type": Attribute.STRING,
1119 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1120 "validation_function": validation.is_string
1124 "help": "Emulated transmission speed (in kbytes per second)",
1125 "type": Attribute.INTEGER,
1126 "range" : (1,10*2**20),
1127 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1128 "validation_function": validation.is_integer
1130 "txqueuelen": dict({
1131 "name": "txqueuelen",
1132 "help": "Transmission queue length (in packets)",
1133 "type": Attribute.INTEGER,
1135 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1136 "range" : (1,10000),
1137 "validation_function": validation.is_integer
1142 "help": "Command line string",
1143 "type": Attribute.STRING,
1144 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1145 "validation_function": validation.is_string
1148 "name": "ccnRoutes",
1149 "help": "Route can be static (e.g. udp ip) or multicast (e.g. udp 224.0.0.204 2869). To separate different route use '|' ",
1150 "type": Attribute.STRING,
1151 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1152 "validation_function": validation.is_string
1156 "help": "Run with root privileges",
1157 "type": Attribute.BOOL,
1158 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1160 "validation_function": validation.is_bool
1164 "help": "Standard input",
1165 "type": Attribute.STRING,
1166 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1167 "validation_function": validation.is_string
1172 "help": "Space-separated list of packages required to run the application",
1173 "type": Attribute.STRING,
1174 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1175 "validation_function": validation.is_string
1177 "build-depends": dict({
1178 "name": "buildDepends",
1179 "help": "Space-separated list of packages required to build the application",
1180 "type": Attribute.STRING,
1181 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1182 "validation_function": validation.is_string
1184 "rpm-fusion": dict({
1185 "name": "rpmFusion",
1186 "help": "True if required packages can be found in the RpmFusion repository",
1187 "type": Attribute.BOOL,
1188 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1190 "validation_function": validation.is_bool
1194 "help": "Space-separated list of regular files to be deployed in the working path prior to building. "
1195 "Archives won't be expanded automatically.",
1196 "type": Attribute.STRING,
1197 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1198 "validation_function": validation.is_string
1200 "ccnxversion": dict({
1201 "name": "ccnxVersion",
1202 "help": "Version of ccnx source code to install in the node.",
1203 "type": Attribute.ENUM,
1204 "value": "ccnx-0.6.0",
1205 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1206 "allowed": ["ccnx-0.6.0",
1208 "validation_function": validation.is_enum,
1210 "ccnlocalport" : dict({
1211 "name" : "ccnLocalPort",
1212 "help" : "Local port to bind the ccn daemon. (i.e. CCN_LOCAL_PORT=)",
1213 "type" : Attribute.INTEGER,
1214 "flags" : Attribute.DesignInvisible | \
1215 Attribute.ExecInvisible | \
1216 Attribute.ExecImmutable | \
1218 "validation_function" : validation.is_integer,
1222 "help": "Build commands to execute after deploying the sources. "
1223 "Sources will be in the ${SOURCES} folder. "
1224 "Example: tar xzf ${SOURCES}/my-app.tgz && cd my-app && ./configure && make && make clean.\n"
1225 "Try to make the commands return with a nonzero exit code on error.\n"
1226 "Also, do not install any programs here, use the 'install' attribute. This will "
1227 "help keep the built files constrained to the build folder (which may "
1228 "not be the home folder), and will result in faster deployment. Also, "
1229 "make sure to clean up temporary files, to reduce bandwidth usage between "
1230 "nodes when transferring built packages.",
1231 "type": Attribute.STRING,
1232 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1233 "validation_function": validation.is_string
1237 "help": "Commands to transfer built files to their final destinations. "
1238 "Sources will be in the initial working folder, and a special "
1239 "tag ${SOURCES} can be used to reference the experiment's "
1240 "home folder (where the application commands will run).\n"
1241 "ALL sources and targets needed for execution must be copied there, "
1242 "if building has been enabled.\n"
1243 "That is, 'slave' nodes will not automatically get any source files. "
1244 "'slave' nodes don't get build dependencies either, so if you need "
1245 "make and other tools to install, be sure to provide them as "
1246 "actual dependencies instead.",
1247 "type": Attribute.STRING,
1248 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1249 "validation_function": validation.is_string
1252 "netpipe_mode": dict({
1254 "help": "Link mode:\n"
1255 " * SERVER: applies to incoming connections\n"
1256 " * CLIENT: applies to outgoing connections\n"
1257 " * SERVICE: applies to both",
1258 "type": Attribute.ENUM,
1259 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1260 "allowed": ["SERVER",
1263 "validation_function": validation.is_enum,
1267 "help": "Port list or range. Eg: '22', '22,23,27', '20-2000'",
1268 "type": Attribute.STRING,
1269 "validation_function": is_portlist,
1273 "help": "Address list or range. Eg: '127.0.0.1', '127.0.0.1,127.0.1.1', '127.0.0.1/8'",
1274 "type": Attribute.STRING,
1275 "validation_function": is_addrlist,
1279 "help": "Inbound bandwidth limit (in Mbit/s)",
1280 "type": Attribute.DOUBLE,
1281 "validation_function": validation.is_number,
1285 "help": "Outbound bandwidth limit (in Mbit/s)",
1286 "type": Attribute.DOUBLE,
1287 "validation_function": validation.is_number,
1291 "help": "Inbound packet loss rate (0 = no loss, 1 = 100% loss)",
1292 "type": Attribute.DOUBLE,
1293 "validation_function": validation.is_number,
1297 "help": "Outbound packet loss rate (0 = no loss, 1 = 100% loss)",
1298 "type": Attribute.DOUBLE,
1299 "validation_function": validation.is_number,
1303 "help": "Inbound packet delay (in milliseconds)",
1304 "type": Attribute.INTEGER,
1306 "validation_function": validation.is_integer,
1310 "help": "Outbound packet delay (in milliseconds)",
1311 "type": Attribute.INTEGER,
1313 "validation_function": validation.is_integer,
1317 "help": "Path to a .c or .py source for a filter module, or a binary .so",
1318 "type": Attribute.STRING,
1319 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1320 "validation_function": validation.is_string
1324 "help": "Module arguments - comma-separated list of name=value pairs",
1325 "type": Attribute.STRING,
1326 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1327 "validation_function": validation.is_string
1329 "routing_algorithm": dict({
1330 "name": "algorithm",
1331 "help": "Routing algorithm.",
1333 "type": Attribute.ENUM,
1334 "allowed": ["dvmrp"],
1335 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1336 "validation_function": validation.is_enum,
1343 "help": "Standard output stream"
1347 "help": "Application standard error",
1351 "help": "Output of the build process",
1354 "netpipe_stats": dict({
1355 "name": "netpipeStats",
1356 "help": "Information about rule match counters, packets dropped, etc.",
1361 "help": "Detailled log of all packets going through the interface",
1365 "help": "PCAP trace of all packets going through the interface",
1369 "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]#}' ",
1371 "dropped_stats": dict({
1372 "name": "dropped_stats",
1373 "help": "Information on dropped packets on a filer or queue associated to a network interface",
1375 "queue_stats": dict({
1376 "name": "queue_stats",
1377 "help": "Detailled, fine-grained information on queue state, csv format.",
1382 INTERNET, NODE, NODEIFACE, CLASSQUEUEFILTER, LOGGINGCLASSQUEUEFILTER, TOSQUEUEFILTER,
1383 MULTICASTANNOUNCER, MULTICASTFORWARDER, MULTICASTROUTER,
1384 TUNFILTER, TAPIFACE, TUNIFACE, NETPIPE,
1385 NEPIDEPENDENCY, NS3DEPENDENCY, DEPENDENCY, CCNXDAEMON, APPLICATION ]
1388 INTERNET, Parallel(NODE),
1390 Parallel(MULTICASTANNOUNCER), Parallel(MULTICASTFORWARDER), Parallel(MULTICASTROUTER),
1391 Parallel(TAPIFACE), Parallel(TUNIFACE), NETPIPE,
1392 Parallel(NEPIDEPENDENCY), Parallel(NS3DEPENDENCY), Parallel(DEPENDENCY), Parallel(CCNXDAEMON),
1393 Parallel(APPLICATION)]
1395 # Start (and prestart) node after ifaces, because the node needs the ifaces in order to set up routes
1396 start_order = [ INTERNET,
1398 Parallel(TAPIFACE), Parallel(TUNIFACE),
1399 Parallel(NODE), NETPIPE,
1400 Parallel(MULTICASTANNOUNCER), Parallel(MULTICASTFORWARDER), Parallel(MULTICASTROUTER),
1401 Parallel(NEPIDEPENDENCY), Parallel(NS3DEPENDENCY), Parallel(DEPENDENCY), Parallel(CCNXDAEMON),
1402 Parallel(APPLICATION)]
1406 Parallel(APPLICATION),
1407 Parallel (CCNXDAEMON),
1408 Parallel(MULTICASTROUTER), Parallel(MULTICASTFORWARDER), Parallel(MULTICASTANNOUNCER),
1409 Parallel(TAPIFACE), Parallel(TUNIFACE), Parallel(NETPIPE),
1410 Parallel(NEPIDEPENDENCY), Parallel(NS3DEPENDENCY), Parallel(DEPENDENCY),
1411 NODEIFACE, Parallel(NODE) ]
1413 factories_info = dict({
1415 "help": "Virtualized Node (V-Server style)",
1416 "category": FC.CATEGORY_NODES,
1417 "create_function": create_node,
1418 "preconfigure_function": configure_node,
1419 "prestart_function": configure_node_routes,
1436 # NEPI-in-NEPI attributes
1437 ATTR_NEPI_TESTBED_ENVIRONMENT_SETUP,
1439 "connector_types": ["devs", "apps", "pipes", "deps"],
1440 "tags": [tags.NODE, tags.ALLOW_ROUTES],
1443 "help": "External network interface - they cannot be brought up or down, and they MUST be connected to the internet.",
1444 "category": FC.CATEGORY_DEVICES,
1445 "create_function": create_nodeiface,
1446 "preconfigure_function": configure_nodeiface,
1447 "box_attributes": [ ],
1448 "connector_types": ["node", "inet"],
1449 "tags": [tags.INTERFACE, tags.HAS_ADDRESSES],
1452 "help": "Virtual TUN network interface (layer 3)",
1453 "category": FC.CATEGORY_DEVICES,
1454 "create_function": create_tuniface,
1455 "preconfigure_function": preconfigure_tuniface,
1456 "configure_function": postconfigure_tuniface,
1457 "prestart_function": prestart_tuniface,
1459 "up", "if_name", "mtu", "snat", "pointopoint", "multicast", "bwlimit",
1461 "tun_proto", "tun_addr", "tun_port", "tun_key", "tun_cipher",
1463 "traces": ["packets", "pcap"],
1464 "connector_types": ["node","udp","tcp","fd->","gre"],
1465 "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
1468 "help": "Virtual TAP network interface (layer 2)",
1469 "category": FC.CATEGORY_DEVICES,
1470 "create_function": create_tapiface,
1471 "preconfigure_function": preconfigure_tuniface,
1472 "configure_function": postconfigure_tuniface,
1473 "prestart_function": prestart_tuniface,
1475 "up", "if_name", "mtu", "snat", "pointopoint", "multicast", "bwlimit",
1477 "tun_proto", "tun_addr", "tun_port", "tun_key", "tun_cipher",
1479 "traces": ["packets", "pcap"],
1480 "connector_types": ["node","udp","tcp","fd->","gre"],
1481 "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
1484 "help": "TUN/TAP stream filter\n\n"
1485 "If specified, it should be either a .py or .so module. "
1486 "It will be loaded, and all incoming and outgoing packets "
1487 "will be routed through it. The filter will not be responsible "
1488 "for buffering, packet queueing is performed in tun_connect "
1489 "already, so it should not concern itself with it. It should "
1490 "not, however, block in one direction if the other is congested.\n"
1492 "Modules are expected to have the following methods:\n"
1494 "\t\tIf arguments are given, this method will be called with the\n"
1495 "\t\tgiven arguments (as keyword args in python modules, or a single\n"
1496 "\taccept_packet(packet, direction):\n"
1497 "\t\tDecide whether to drop the packet. Direction is 0 for packets "
1498 "coming from the local side to the remote, and 1 is for packets "
1499 "coming from the remote side to the local. Return a boolean, "
1500 "true if the packet is not to be dropped.\n"
1501 "\tfilter_init():\n"
1502 "\t\tInitializes a filtering pipe (filter_run). It should "
1503 "return two file descriptors to use as a bidirectional "
1504 "pipe: local and remote. 'local' is where packets from the "
1505 "local side will be written to. After filtering, those packets "
1506 "should be written to 'remote', where tun_connect will read "
1507 "from, and it will forward them to the remote peer. "
1508 "Packets from the remote peer will be written to 'remote', "
1509 "where the filter is expected to read from, and eventually "
1510 "forward them to the local side. If the file descriptors are "
1511 "not nonblocking, they will be set to nonblocking. So it's "
1512 "better to set them from the start like that.\n"
1513 "\tfilter_run(local, remote):\n"
1514 "\t\tIf filter_init is provided, it will be called repeatedly, "
1515 "in a separate thread until the process is killed. It should "
1516 "sleep at most for a second.\n"
1517 "\tfilter_close(local, remote):\n"
1518 "\t\tCalled then the process is killed, if filter_init was provided. "
1519 "It should, among other things, close the file descriptors.\n"
1521 "Python modules are expected to return a tuple in filter_init, "
1522 "either of file descriptors or file objects, while native ones "
1523 "will receive two int*.\n"
1525 "Python modules can additionally contain a custom queue class "
1526 "that will replace the FIFO used by default. The class should "
1527 "be named 'queueclass' and contain an interface compatible with "
1528 "collections.deque. That is, indexing (especiall for q[0]), "
1529 "bool(q), popleft, appendleft, pop (right), append (right), "
1530 "len(q) and clear.",
1531 "category": FC.CATEGORY_CHANNELS,
1532 "create_function": create_tunfilter,
1535 "tun_proto", "tun_addr", "tun_port", "tun_key", "tun_cipher",
1537 "connector_types": ["->fd","udp","tcp"],
1539 CLASSQUEUEFILTER : dict({
1540 "help": "TUN classful queue, uses a separate queue for each user-definable class.\n\n"
1541 "It takes two arguments, both of which have sensible defaults:\n"
1542 "\tsize: the base size of each class' queue\n"
1543 "\tclasses: the class definitions, which follow the following syntax:\n"
1544 '\t <CLASSLIST> ::= <CLASS> ":" CLASSLIST\n'
1546 '\t <CLASS> ::= <PROTOLIST> "*" <PRIORITYSPEC>\n'
1547 '\t | <DFLTCLASS>\n'
1548 '\t <DFLTCLASS> ::= "*" <PRIORITYSPEC>\n'
1549 '\t <PROTOLIST> ::= <PROTO> "." <PROTOLIST>\n'
1551 '\t <PROTO> ::= <NAME> | <NUMBER>\n'
1552 '\t <NAME> ::= --see http://en.wikipedia.org/wiki/List_of_IP_protocol_numbers --\n'
1553 '\t --only in lowercase, with special characters removed--\n'
1554 '\t --or see below--\n'
1555 '\t <NUMBER> ::= [0-9]+\n'
1556 '\t <PRIORITYSPEC> ::= <THOUGHPUT> [ "#" <SIZE> ] [ "p" <PRIORITY> ]\n'
1557 '\t <THOUGHPUT> ::= NUMBER -- default 1\n'
1558 '\t <PRIORITY> ::= NUMBER -- default 0\n'
1559 '\t <SIZE> ::= NUMBER -- default 1\n'
1561 "Size, thoughput and priority are all relative terms. "
1562 "Sizes are multipliers for the size argument, thoughput "
1563 "is applied relative to other classes and the same with "
1565 "category": FC.CATEGORY_CHANNELS,
1566 "create_function": create_classqueuefilter,
1569 "tun_proto", "tun_addr", "tun_port", "tun_key", "tun_cipher",
1571 "connector_types": ["->fd","udp","tcp"],
1572 "traces": ["dropped_stats"],
1574 LOGGINGCLASSQUEUEFILTER : dict({
1575 "help": "TUN classful queue, uses a separate queue for each user-definable class.\n"
1576 "See ClassQueueFilter. This version adds detailled queue state tracing.",
1577 "category": FC.CATEGORY_CHANNELS,
1578 "create_function": create_loggingclassqueuefilter,
1581 "tun_proto", "tun_addr", "tun_port", "tun_key", "tun_cipher",
1583 "connector_types": ["->fd","udp","tcp"],
1584 "traces": ["dropped_stats","queue_stats"],
1586 TOSQUEUEFILTER : dict({
1587 "help": "TUN classfull queue that classifies according to the TOS (RFC 791) IP field.\n\n"
1588 "It takes a size argument that specifies the size of each class. As TOS is a "
1589 "subset of DiffServ, this queue half-implements DiffServ.",
1590 "category": FC.CATEGORY_CHANNELS,
1591 "create_function": create_tosqueuefilter,
1594 "tun_proto", "tun_addr", "tun_port", "tun_key", "tun_cipher",
1596 "connector_types": ["->fd","udp","tcp"],
1600 "help": "Generic executable command line application",
1601 "category": FC.CATEGORY_APPLICATIONS,
1602 "create_function": create_application,
1603 "start_function": start_application,
1604 "status_function": status_application,
1605 "stop_function": stop_application,
1606 "configure_function": configure_application,
1607 "box_attributes": ["command", "sudo", "stdin",
1608 "depends", "build-depends", "build", "install",
1609 "sources", "rpm-fusion" ],
1610 "connector_types": ["node"],
1611 "traces": ["stdout", "stderr", "buildlog", "output"],
1612 "tags": [tags.APPLICATION],
1616 "help": "CCNx daemon",
1617 "category": FC.CATEGORY_APPLICATIONS,
1618 "create_function": create_ccnxdaemon,
1619 "prestart_function": prestart_ccnxdaemon,
1620 "status_function": status_application,
1621 "stop_function": stop_application,
1622 "configure_function": configure_application,
1623 "box_attributes": ["ccnroutes", "build", "ccnlocalport",
1624 "install", "ccnxversion", "sources"],
1625 "connector_types": ["node"],
1626 "traces": ["stdout", "stderr", "buildlog", "output"],
1627 "tags": [tags.APPLICATION],
1630 "help": "Requirement for package or application to be installed on some node",
1631 "category": FC.CATEGORY_APPLICATIONS,
1632 "create_function": create_dependency,
1633 "preconfigure_function": configure_dependency,
1634 "box_attributes": ["depends", "build-depends", "build", "install",
1635 "sources", "rpm-fusion" ],
1636 "connector_types": ["node"],
1637 "traces": ["buildlog"],
1639 NEPIDEPENDENCY: dict({
1640 "help": "Requirement for NEPI inside NEPI - required to run testbed instances inside a node",
1641 "category": FC.CATEGORY_APPLICATIONS,
1642 "create_function": create_nepi_dependency,
1643 "preconfigure_function": configure_dependency,
1644 "box_attributes": [],
1645 "connector_types": ["node"],
1646 "traces": ["buildlog"],
1648 NS3DEPENDENCY: dict({
1649 "help": "Requirement for NS3 inside NEPI - required to run NS3 testbed instances inside a node. It also needs NepiDependency.",
1650 "category": FC.CATEGORY_APPLICATIONS,
1651 "create_function": create_ns3_dependency,
1652 "preconfigure_function": configure_dependency,
1653 "box_attributes": [ ],
1654 "connector_types": ["node"],
1655 "traces": ["buildlog"],
1657 MULTICASTFORWARDER: dict({
1658 "help": "This application installs a userspace packet forwarder "
1659 "that, when connected to a node, filters all packets "
1660 "flowing through multicast-capable virtual interfaces "
1661 "and applies custom-specified routing policies.",
1662 "category": FC.CATEGORY_APPLICATIONS,
1663 "create_function": create_multicast_forwarder,
1664 "preconfigure_function": configure_forwarder,
1665 "start_function": start_application,
1666 "status_function": status_application,
1667 "stop_function": stop_application,
1668 "box_attributes": [ ],
1669 "connector_types": ["node","router"],
1670 "traces": ["buildlog","stderr"],
1672 MULTICASTANNOUNCER: dict({
1673 "help": "This application installs a userspace daemon that "
1674 "monitors multicast membership and announces it on all "
1675 "multicast-capable interfaces.\n"
1676 "This does not usually happen automatically on PlanetLab slivers.",
1677 "category": FC.CATEGORY_APPLICATIONS,
1678 "create_function": create_multicast_announcer,
1679 "preconfigure_function": configure_announcer,
1680 "start_function": start_application,
1681 "status_function": status_application,
1682 "stop_function": stop_application,
1683 "box_attributes": [ ],
1684 "connector_types": ["node"],
1685 "traces": ["buildlog","stderr"],
1687 MULTICASTROUTER: dict({
1688 "help": "This application installs a userspace daemon that "
1689 "monitors multicast membership and announces it on all "
1690 "multicast-capable interfaces.\n"
1691 "This does not usually happen automatically on PlanetLab slivers.",
1692 "category": FC.CATEGORY_APPLICATIONS,
1693 "create_function": create_multicast_router,
1694 "preconfigure_function": configure_router,
1695 "start_function": start_application,
1696 "status_function": status_application,
1697 "stop_function": stop_application,
1698 "box_attributes": ["routing_algorithm"],
1699 "connector_types": ["fwd"],
1700 "traces": ["buildlog","stdout","stderr"],
1703 "help": "Internet routing",
1704 "category": FC.CATEGORY_CHANNELS,
1705 "create_function": create_internet,
1706 "connector_types": ["devs"],
1707 "tags": [tags.INTERNET],
1710 "help": "Link emulation",
1711 "category": FC.CATEGORY_CHANNELS,
1712 "create_function": create_netpipe,
1713 "configure_function": configure_netpipe,
1714 "box_attributes": ["netpipe_mode",
1715 "addr_list", "port_list",
1716 "bw_in","plr_in","delay_in",
1717 "bw_out","plr_out","delay_out"],
1718 "connector_types": ["node"],
1719 "traces": ["netpipe_stats"],
1723 testbed_attributes = dict({
1726 "help": "The hierarchical Resource Name (HRN) for the PlanetLab slice.",
1727 "type": Attribute.STRING,
1728 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable | Attribute.NoDefaultValue,
1729 "validation_function": validation.is_string
1733 "help": "Activates the use of SFA for node reservation.",
1734 "type": Attribute.BOOL,
1735 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable | Attribute.NoDefaultValue,
1736 "validation_function": validation.is_bool
1740 "help": "The name of the PlanetLab slice to use",
1741 "type": Attribute.STRING,
1742 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable | Attribute.NoDefaultValue,
1743 "validation_function": validation.is_string
1747 "help": "The name of the PlanetLab user to use for API calls - it must have at least a User role.",
1748 "type": Attribute.STRING,
1749 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable | Attribute.NoDefaultValue,
1750 "validation_function": validation.is_string
1754 "help": "The PlanetLab user's password.",
1755 "type": Attribute.STRING,
1756 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable | Attribute.NoDefaultValue,
1757 "validation_function": validation.is_string
1761 "help": "The PlanetLab PLC API host",
1762 "type": Attribute.STRING,
1763 "value": "www.planet-lab.eu",
1764 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1765 "validation_function": validation.is_string
1769 "help": "The PlanetLab PLC API url pattern - %(hostname)s is replaced by plcHost.",
1770 "type": Attribute.STRING,
1771 "value": "https://%(hostname)s:443/PLCAPI/",
1772 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1773 "validation_function": validation.is_string
1775 "p2p_deployment": dict({
1776 "name": "p2pDeployment",
1777 "help": "Enable peer-to-peer deployment of applications and dependencies. "
1778 "When enabled, dependency packages and applications are "
1779 "deployed in a P2P fashion, picking a single node to do "
1780 "the building or repo download, while all the others "
1781 "cooperatively exchange resulting binaries or rpms. "
1782 "When deploying to many nodes, this is a far more efficient "
1783 "use of resources. It does require re-encrypting and distributing "
1784 "the slice's private key. Though it is implemented in a secure "
1785 "fashion, if they key's sole purpose is not PlanetLab, then this "
1786 "feature should be disabled.",
1787 "type": Attribute.BOOL,
1789 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1790 "validation_function": validation.is_bool
1792 "slice_ssh_key": dict({
1793 "name": "sliceSSHKey",
1794 "help": "The controller-local path to the slice user's ssh private key. "
1795 "It is the user's responsability to deploy this file where the controller "
1796 "will run, it won't be done automatically because it's sensitive information. "
1797 "It is recommended that a NEPI-specific user be created for this purpose and "
1798 "this purpose alone.",
1799 "type": Attribute.STRING,
1800 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable | Attribute.NoDefaultValue,
1801 "validation_function": validation.is_string
1803 "pl_log_level": dict({
1804 "name": "plLogLevel",
1805 "help": "Verbosity of logging of planetlab events.",
1807 "type": Attribute.ENUM,
1808 "allowed": ["DEBUG",
1813 "validation_function": validation.is_enum,
1815 "tap_port_base": dict({
1816 "name": "tapPortBase",
1817 "help": "Base port to use when connecting TUN/TAPs. Effective port will be BASE + GUID.",
1818 "type": Attribute.INTEGER,
1820 "range": (2000,30000),
1821 "validation_function": validation.is_integer_range(2000,30000)
1823 "clean_proc": dict({
1824 "name": "cleanProc",
1825 "help": "Set to True if the slice will be dedicated to this experiment. "
1826 "NEPI will perform node and slice process cleanup, making sure slices are "
1827 "in a clean, repeatable state before running the experiment.",
1828 "type": Attribute.BOOL,
1830 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1831 "validation_function": validation.is_bool
1833 "clean_home": dict({
1834 "name": "cleanHome",
1835 "help": "Set to True all preexistent directories in the home "
1836 "directory of each sliver will be removed before the "
1837 "start of the experiment.",
1838 "type": Attribute.BOOL,
1840 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1841 "validation_function": validation.is_bool
1845 supported_recovery_policies = [
1851 class MetadataInfo(metadata.MetadataInfo):
1853 def connector_types(self):
1854 return connector_types
1857 def connections(self):
1861 def attributes(self):
1869 def create_order(self):
1873 def configure_order(self):
1874 return configure_order
1877 def prestart_order(self):
1881 def start_order(self):
1885 def factories_info(self):
1886 return factories_info
1889 def testbed_attributes(self):
1890 return testbed_attributes
1893 def testbed_id(self):
1897 def testbed_version(self):
1898 return TESTBED_VERSION
1901 def supported_recovery_policies(self):
1902 return supported_recovery_policies