3c7872fecec553fb61bcb410b249e101a4fe3850
[nepi.git] / src / nepi / testbeds / planetlab / metadata.py
1 # -*- coding: utf-8 -*-
2
3 import time
4
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
14
15 import functools
16 import os
17 import os.path
18 import weakref
19
20 NODE = "Node"
21 NODEIFACE = "NodeInterface"
22 TUNIFACE = "TunInterface"
23 TAPIFACE = "TapInterface"
24 APPLICATION = "Application"
25 CCNXDAEMON = "CCNxDaemon"
26 DEPENDENCY = "Dependency"
27 NEPIDEPENDENCY = "NepiDependency"
28 NS3DEPENDENCY = "NS3Dependency"
29 INTERNET = "Internet"
30 NETPIPE = "NetPipe"
31 TUNFILTER = "TunFilter"
32 CLASSQUEUEFILTER = "ClassQueueFilter"
33 LOGGINGCLASSQUEUEFILTER = "LoggingClassQueueFilter"
34 TOSQUEUEFILTER = "TosQueueFilter"
35 MULTICASTFORWARDER = "MulticastForwarder"
36 MULTICASTANNOUNCER = "MulticastAnnouncer"
37 MULTICASTROUTER = "MulticastRouter"
38
39 TUNFILTERS = (TUNFILTER, CLASSQUEUEFILTER, LOGGINGCLASSQUEUEFILTER, TOSQUEUEFILTER)
40 TAPFILTERS = (TUNFILTER, )
41 ALLFILTERS = (TUNFILTER, CLASSQUEUEFILTER, LOGGINGCLASSQUEUEFILTER, TOSQUEUEFILTER)
42
43 PL_TESTBED_ID = "planetlab"
44
45
46 ### Custom validation functions ###
47 def is_addrlist(attribute, value):
48     if not validation.is_string(attribute, value):
49         return False
50     
51     if not value:
52         # No empty strings
53         return False
54     
55     components = value.split(',')
56     
57     for component in components:
58         if '/' in component:
59             addr, mask = component.split('/',1)
60         else:
61             addr, mask = component, '32'
62         
63         if mask is not None and not (mask and mask.isdigit()):
64             # No empty or nonnumeric masks
65             return False
66         
67         if not validation.is_ip4_address(attribute, addr):
68             # Address part must be ipv4
69             return False
70         
71     return True
72
73 def is_portlist(attribute, value):
74     if not validation.is_string(attribute, value):
75         return False
76     
77     if not value:
78         # No empty strings
79         return False
80     
81     components = value.split(',')
82     
83     for component in components:
84         if '-' in component:
85             pfrom, pto = component.split('-',1)
86         else:
87             pfrom = pto = component
88         
89         if not pfrom or not pto or not pfrom.isdigit() or not pto.isdigit():
90             # No empty or nonnumeric ports
91             return False
92         
93     return True
94
95
96 ### Connection functions ####
97
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]
101     iface.node = node
102
103 def connect_node_iface_inet(testbed_instance, iface_guid, inet_guid):
104     iface = testbed_instance._elements[iface_guid]
105     iface.has_internet = True
106
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]
110     iface.node = node
111     node.required_vsys.update(('fd_tuntap', 'vif_up', 'vif_down'))
112     node.required_packages.update(('python', 'python-crypto', 'python-setuptools', 'gcc'))
113
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
119     iface.peer_proto = \
120     iface.tun_proto = \
121     peer_iface.peer_proto = \
122     peer_iface.tun_proto = proto
123     iface.tun_key = peer_iface.tun_key
124
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)
135
136     if filt.peer_guid:
137         connect_tun_iface_peer(filt.peer_proto, testbed_instance, filt.iface_guid, filt.peer_guid)
138
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
144     if filt.iface_guid:
145         connect_tun_iface_peer(filt.peer_proto, testbed_instance, filt.iface_guid, filt.peer_guid)
146
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
152     if filt.iface_guid:
153         peer.peer_guid = filt.iface_guid
154     if peer.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)
158
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
168     
169     preconfigure_tuniface(testbed_instance, iface_guid)
170
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")
178     
179     postconfigure_tuniface(testbed_instance, iface_guid)
180
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)
184
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)
189
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)
194
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)
198
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]
202     app.node = node
203     
204     if app.depends:
205         node.required_packages.update(set(
206             app.depends.split() ))
207    
208     if app.add_to_path:
209         if app.home_path and app.home_path not in node.pythonpath:
210             node.pythonpath.append(app.home_path)
211     
212     if app.env:
213         for envkey, envval in app.env.iteritems():
214             envval = app._replace_paths(envval)
215             node.env[envkey].append(envval)
216     
217     if app.rpmFusion:
218         node.rpmFusion = True
219
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
224     
225     if fwd.router:
226         connect_dep(testbed_instance, node_guid, None, app=fwd.router)
227
228     connect_dep(testbed_instance, node_guid, fwd_guid)
229
230 def connect_router(testbed_instance, fwd_guid, router_guid):
231     fwd = testbed_instance._elements[fwd_guid]
232     router = testbed_instance._elements[router_guid]
233     fwd.router = router
234     
235     if fwd.node:
236         connect_dep(testbed_instance, None, router_guid, node=fwd.node)
237
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]
241     netpipe.node = node
242     node.required_vsys.add('ipfw-be')
243     node.required_packages.add('ipfwslice')
244     
245
246 ### Creation functions ###
247
248 def create_node(testbed_instance, guid):
249     parameters = testbed_instance._get_parameters(guid)
250     
251     # create element with basic attributes
252     element = testbed_instance._make_node(parameters)
253     
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
261     
262     # require vroute vsys if we have routes to set up
263     routes = testbed_instance._add_route.get(guid)
264     if routes:
265         vsys = element.routing_method(routes,
266             testbed_instance.vsys_vnet)
267         element.required_vsys.add(vsys)
268     
269     testbed_instance.elements[guid] = element
270
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
275
276 def create_tuniface(testbed_instance, guid):
277     parameters = testbed_instance._get_parameters(guid)
278     element = testbed_instance._make_tun_iface(parameters)
279     
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)
287     
288     testbed_instance.elements[guid] = element
289
290 def create_tapiface(testbed_instance, guid):
291     parameters = testbed_instance._get_parameters(guid)
292     element = testbed_instance._make_tap_iface(parameters)
293     
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)
301     
302     testbed_instance.elements[guid] = element
303
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
308
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
313
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
318
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
323
324 def create_application(testbed_instance, guid):
325     parameters = testbed_instance._get_parameters(guid)
326     element = testbed_instance._make_application(parameters)
327     
328     # Just inject configuration stuff
329     element.home_path = "nepi-app-%s" % (guid,)
330     
331     testbed_instance.elements[guid] = element
332
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 )
337     
338     # Just inject configuration stuff
339     element.home_path = "nepi-ccnd-%s" % (guid,)
340     
341     testbed_instance.elements[guid] = element
342
343 def create_dependency(testbed_instance, guid):
344     parameters = testbed_instance._get_parameters(guid)
345     element = testbed_instance._make_dependency(parameters)
346     
347     # Just inject configuration stuff
348     element.home_path = "nepi-dep-%s" % (guid,)
349     
350     testbed_instance.elements[guid] = element
351
352 def create_nepi_dependency(testbed_instance, guid):
353     parameters = testbed_instance._get_parameters(guid)
354     element = testbed_instance._make_nepi_dependency(parameters)
355     
356     # Just inject configuration stuff
357     element.home_path = "nepi-nepi-%s" % (guid,)
358     
359     testbed_instance.elements[guid] = element
360
361 def create_ns3_dependency(testbed_instance, guid):
362     parameters = testbed_instance._get_parameters(guid)
363     element = testbed_instance._make_ns3_dependency(parameters)
364     
365     # Just inject configuration stuff
366     element.home_path = "nepi-ns3-%s" % (guid,)
367     
368     testbed_instance.elements[guid] = element
369
370 def create_multicast_forwarder(testbed_instance, guid):
371     parameters = testbed_instance._get_parameters(guid)
372     element = testbed_instance._make_multicast_forwarder(parameters)
373     
374     # Just inject configuration stuff
375     element.home_path = "nepi-mcfwd-%s" % (guid,)
376     
377     testbed_instance.elements[guid] = element
378
379 def create_multicast_announcer(testbed_instance, guid):
380     parameters = testbed_instance._get_parameters(guid)
381     element = testbed_instance._make_multicast_announcer(parameters)
382     
383     # Just inject configuration stuff
384     element.home_path = "nepi-mcann-%s" % (guid,)
385     
386     testbed_instance.elements[guid] = element
387
388 def create_multicast_router(testbed_instance, guid):
389     parameters = testbed_instance._get_parameters(guid)
390     element = testbed_instance._make_multicast_router(parameters)
391     
392     # Just inject configuration stuff
393     element.home_path = "nepi-mcrt-%s" % (guid,)
394     
395     testbed_instance.elements[guid] = element
396
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
401
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
406
407 ### Start/Stop functions ###
408
409 def prestart_ccnxdaemon(testbed_instance, guid):
410     # ccnx daemon needs to start before the rest of the
411     # ccn applications
412     start_application(testbed_instance, guid)
413
414 def stop_ccndaemon(testbed_instance, guid):
415     app = testbed_instance.elements[guid]
416     app.kill()
417
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]
422     
423     app.stdout = "stdout" in traces
424     app.stderr = "stderr" in traces
425     app.buildlog = "buildlog" in traces
426     app.outout = "output" in traces
427     
428     app.start()
429
430 def stop_application(testbed_instance, guid):
431     app = testbed_instance.elements[guid]
432     app.kill()
433
434 ### Status functions ###
435
436 def status_application(testbed_instance, guid):
437     if guid not in testbed_instance.elements.keys():
438         return AS.STATUS_NOT_STARTED
439     
440     app = testbed_instance.elements[guid]
441     return app.status()
442
443 ### Configure functions ###
444
445 def configure_nodeiface(testbed_instance, guid):
446     element = testbed_instance._elements[guid]
447     
448     # Cannot explicitly configure addresses
449     if guid in testbed_instance._add_address:
450         raise ValueError, "Cannot explicitly set address of public PlanetLab interface"
451     
452     # Get siblings
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 ]
458     
459     # Fetch address from PLC api
460     element.pick_iface(siblings)
461     
462     # Do some validations
463     element.validate()
464
465 def preconfigure_tuniface(testbed_instance, guid):
466     element = testbed_instance._elements[guid]
467     
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)
474     
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
479             break
480
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)
485
486     # Set enabled traces
487     traces = testbed_instance._get_traces(guid)
488     for capmode in ('pcap', 'packets'):
489         if capmode in traces:
490             element.capture = capmode
491             break
492     else:
493         element.capture = False
494     
495     # Do some validations
496     element.validate()
497     
498     # First-phase setup
499     element.prepare('tun-%s' % (guid,))
500
501 def postconfigure_tuniface(testbed_instance, guid):
502     element = testbed_instance._elements[guid]
503     
504     # Second-phase setup
505     element.launch()
506     
507 def prestart_tuniface(testbed_instance, guid):
508     element = testbed_instance._elements[guid]
509     
510     # Second-phase setup
511     element.wait()
512
513 def configure_node(testbed_instance, guid):
514     node = testbed_instance._elements[guid]
515     
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
520     
521     # Do some validations
522     node.validate()
523     
524     # this will be done in parallel in all nodes
525     # this call only spawns the process
526     node.install_dependencies()
527
528 def configure_node_routes(testbed_instance, guid):
529     node = testbed_instance._elements[guid]
530     routes = testbed_instance._add_route.get(guid)
531     
532     if routes:
533         devs = [ dev
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) ]
537     
538         vsys = testbed_instance.vsys_vnet
539         
540         node.configure_routes(routes, devs, vsys)
541
542 def configure_application(testbed_instance, guid):
543     app = testbed_instance._elements[guid]
544     
545     # Do some validations
546     app.validate()
547     
548     # Wait for dependencies
549     app.node.wait_dependencies()
550     
551     # Install stuff
552     app.async_setup()
553
554 def configure_dependency(testbed_instance, guid):
555     dep = testbed_instance._elements[guid]
556     
557     # Do some validations
558     dep.validate()
559     
560     # Wait for dependencies
561     dep.node.wait_dependencies()
562     
563     # Install stuff
564     dep.async_setup()
565
566 def configure_announcer(testbed_instance, guid):
567     # Link ifaces
568     fwd = testbed_instance._elements[guid]
569     fwd.ifaces = [ dev
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)
574             and dev.multicast ]
575     
576     # Install stuff
577     configure_dependency(testbed_instance, guid)
578
579 def configure_forwarder(testbed_instance, guid):
580     configure_announcer(testbed_instance, guid)
581     
582     # Link ifaces to forwarder
583     fwd = testbed_instance._elements[guid]
584     for iface in fwd.ifaces:
585         iface.multicast_forwarder = '/var/run/mcastfwd'
586
587 def configure_router(testbed_instance, guid):
588     # Link ifaces
589     rt = testbed_instance._elements[guid]
590     rt.nonifaces = [ dev
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 ]
597     
598     # Install stuff
599     configure_dependency(testbed_instance, guid)
600
601 def configure_netpipe(testbed_instance, guid):
602     netpipe = testbed_instance._elements[guid]
603     
604     # Do some validations
605     netpipe.validate()
606     
607     # Wait for dependencies
608     netpipe.node.wait_dependencies()
609     
610     # Install rules
611     netpipe.configure()
612
613 ### Factory information ###
614
615 connector_types = dict({
616     "apps": dict({
617                 "help": "Connector from node to applications", 
618                 "name": "apps",
619                 "max": -1, 
620                 "min": 0
621             }),
622     "devs": dict({
623                 "help": "Connector from node to network interfaces", 
624                 "name": "devs",
625                 "max": -1, 
626                 "min": 0
627             }),
628     "deps": dict({
629                 "help": "Connector from node to application dependencies "
630                         "(packages and applications that need to be installed)", 
631                 "name": "deps",
632                 "max": -1, 
633                 "min": 0
634             }),
635     "inet": dict({
636                 "help": "Connector from network interfaces to the internet", 
637                 "name": "inet",
638                 "max": 1, 
639                 "min": 1
640             }),
641     "node": dict({
642                 "help": "Connector to a Node", 
643                 "name": "node",
644                 "max": 1, 
645                 "min": 1
646             }),
647     "router": dict({
648                 "help": "Connector to a routing daemon", 
649                 "name": "router",
650                 "max": 1, 
651                 "min": 0
652             }),
653     "fwd": dict({
654                 "help": "Forwarder this routing daemon communicates with", 
655                 "name": "fwd",
656                 "max": 1, 
657                 "min": 1
658             }),
659     "pipes": dict({
660                 "help": "Connector to a NetPipe", 
661                 "name": "pipes",
662                 "max": 2, 
663                 "min": 0
664             }),
665     
666     "tcp": dict({
667                 "help": "ip-ip tunneling over TCP link", 
668                 "name": "tcp",
669                 "max": 1, 
670                 "min": 0
671             }),
672     "udp": dict({
673                 "help": "ip-ip tunneling over UDP datagrams", 
674                 "name": "udp",
675                 "max": 1, 
676                 "min": 0
677             }),
678     "gre": dict({
679                 "help": "IP or Ethernet tunneling using the GRE protocol", 
680                 "name": "gre",
681                 "max": 1, 
682                 "min": 0
683             }),
684     "fd->": dict({
685                 "help": "TUN device file descriptor provider", 
686                 "name": "fd->",
687                 "max": 1, 
688                 "min": 0
689             }),
690     "->fd": dict({
691                 "help": "TUN device file descriptor slot", 
692                 "name": "->fd",
693                 "max": 1, 
694                 "min": 0
695             }),
696    })
697
698 connections = [
699     dict({
700         "from": (TESTBED_ID, NODE, "devs"),
701         "to":   (TESTBED_ID, NODEIFACE, "node"),
702         "init_code": connect_node_iface_node,
703         "can_cross": False
704     }),
705     dict({
706         "from": (TESTBED_ID, NODE, "devs"),
707         "to":   (TESTBED_ID, TUNIFACE, "node"),
708         "init_code": connect_tun_iface_node,
709         "can_cross": False
710     }),
711     dict({
712         "from": (TESTBED_ID, NODE, "devs"),
713         "to":   (TESTBED_ID, TAPIFACE, "node"),
714         "init_code": connect_tun_iface_node,
715         "can_cross": False
716     }),
717     dict({
718         "from": (TESTBED_ID, NODEIFACE, "inet"),
719         "to":   (TESTBED_ID, INTERNET, "devs"),
720         "init_code": connect_node_iface_inet,
721         "can_cross": False
722     }),
723     dict({
724         "from": (TESTBED_ID, NODE, "apps"),
725         "to":   (TESTBED_ID, (APPLICATION, CCNXDAEMON, MULTICASTANNOUNCER), "node"),
726         "init_code": connect_dep,
727         "can_cross": False
728     }),
729     dict({
730         "from": (TESTBED_ID, NODE, "deps"),
731         "to":   (TESTBED_ID, (DEPENDENCY, NEPIDEPENDENCY, NS3DEPENDENCY), "node"),
732         "init_code": connect_dep,
733         "can_cross": False
734     }),
735     dict({
736         "from": (TESTBED_ID, NODE, "pipes"),
737         "to":   (TESTBED_ID, NETPIPE, "node"),
738         "init_code": connect_node_netpipe,
739         "can_cross": False
740     }),
741     dict({
742         "from": (TESTBED_ID, NODE, "apps"),
743         "to":   (TESTBED_ID, MULTICASTFORWARDER, "node"),
744         "init_code": connect_forwarder,
745         "can_cross": False
746     }),
747     dict({
748         "from": (TESTBED_ID, MULTICASTFORWARDER, "router"),
749         "to":   (TESTBED_ID, MULTICASTROUTER, "fwd"),
750         "init_code": connect_router,
751         "can_cross": False
752     }),
753     dict({
754         "from": (TESTBED_ID, TUNIFACE, "tcp"),
755         "to":   (TESTBED_ID, TUNIFACE, "tcp"),
756         "init_code": functools.partial(connect_tun_iface_peer,"tcp"),
757         "can_cross": False
758     }),
759     dict({
760         "from": (TESTBED_ID, TUNIFACE, "udp"),
761         "to":   (TESTBED_ID, TUNIFACE, "udp"),
762         "init_code": functools.partial(connect_tun_iface_peer,"udp"),
763         "can_cross": False
764     }),
765     dict({
766         "from": (TESTBED_ID, TUNIFACE, "gre"),
767         "to":   (TESTBED_ID, TUNIFACE, "gre"),
768         "init_code": functools.partial(connect_tun_iface_peer,"gre"),
769         "can_cross": False
770     }),
771     dict({
772         "from": (TESTBED_ID, TUNIFACE, "fd->"),
773         "to":   (TESTBED_ID, TUNFILTERS, "->fd"),
774         "init_code": connect_tun_iface_filter,
775         "can_cross": False
776     }),
777     dict({
778         "from": (TESTBED_ID, TUNFILTERS, "tcp"),
779         "to":   (TESTBED_ID, TUNIFACE, "tcp"),
780         "init_code": functools.partial(connect_filter_peer,"tcp"),
781         "can_cross": False
782     }),
783     dict({
784         "from": (TESTBED_ID, TUNFILTERS, "udp"),
785         "to":   (TESTBED_ID, TUNIFACE, "udp"),
786         "init_code": functools.partial(connect_filter_peer,"udp"),
787         "can_cross": False
788     }),
789     dict({
790         "from": (TESTBED_ID, TAPIFACE, "tcp"),
791         "to":   (TESTBED_ID, TAPIFACE, "tcp"),
792         "init_code": functools.partial(connect_tun_iface_peer,"tcp"),
793         "can_cross": False
794     }),
795     dict({
796         "from": (TESTBED_ID, TAPIFACE, "udp"),
797         "to":   (TESTBED_ID, TAPIFACE, "udp"),
798         "init_code": functools.partial(connect_tun_iface_peer,"udp"),
799         "can_cross": False
800     }),
801     dict({
802         "from": (TESTBED_ID, TAPIFACE, "gre"),
803         "to":   (TESTBED_ID, TAPIFACE, "gre"),
804         "init_code": functools.partial(connect_tun_iface_peer,"gre"),
805         "can_cross": False
806     }),
807     dict({
808         "from": (TESTBED_ID, TAPIFACE, "fd->"),
809         "to":   (TESTBED_ID, TAPFILTERS, "->fd"),
810         "init_code": connect_tun_iface_filter,
811         "can_cross": False
812     }),
813     dict({
814         "from": (TESTBED_ID, TAPFILTERS, "tcp"),
815         "to":   (TESTBED_ID, TAPIFACE, "tcp"),
816         "init_code": functools.partial(connect_filter_peer,"tcp"),
817         "can_cross": False
818     }),
819     dict({
820         "from": (TESTBED_ID, TAPFILTERS, "udp"),
821         "to":   (TESTBED_ID, TAPIFACE, "udp"),
822         "init_code": functools.partial(connect_filter_peer,"udp"),
823         "can_cross": False
824     }),
825     dict({
826         "from": (TESTBED_ID, TUNFILTERS, "tcp"),
827         "to":   (TESTBED_ID, TUNFILTERS, "tcp"),
828         "init_code": functools.partial(connect_filter_filter,"tcp"),
829         "can_cross": False
830     }),
831     dict({
832         "from": (TESTBED_ID, TUNFILTERS, "udp"),
833         "to":   (TESTBED_ID, TUNFILTERS, "udp"),
834         "init_code": functools.partial(connect_filter_filter,"udp"),
835         "can_cross": False
836     }),
837     dict({
838         "from": (TESTBED_ID, TAPFILTERS, "tcp"),
839         "to":   (TESTBED_ID, TAPFILTERS, "tcp"),
840         "init_code": functools.partial(connect_filter_filter,"tcp"),
841         "can_cross": False
842     }),
843     dict({
844         "from": (TESTBED_ID, TAPFILTERS, "udp"),
845         "to":   (TESTBED_ID, TAPFILTERS, "udp"),
846         "init_code": functools.partial(connect_filter_filter,"udp"),
847         "can_cross": False
848     }),
849     dict({
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"),
854         "can_cross": True
855     }),
856     dict({
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"),
861         "can_cross": True
862     }),
863     dict({
864         "from": (TESTBED_ID, TUNIFACE, "fd->"),
865         "to":   (None, None, "->fd"),
866         "compl_code": functools.partial(crossconnect_tun_iface_peer_both,"fd"),
867         "can_cross": True
868     }),
869     dict({
870         "from": (TESTBED_ID, TUNIFACE, "gre"),
871         "to":   (None, None, "gre"),
872         "compl_code": functools.partial(crossconnect_tun_iface_peer_both,"gre"),
873         "can_cross": True
874     }),
875     dict({
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"),
880         "can_cross": True
881     }),
882     dict({
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"),
887         "can_cross": True
888     }),
889     dict({
890         "from": (TESTBED_ID, TAPIFACE, "fd->"),
891         "to":   (None, None, "->fd"),
892         "compl_code": functools.partial(crossconnect_tun_iface_peer_both,"fd"),
893         "can_cross": True
894     }),
895     # EGRE is an extension of PlanetLab, so we can't connect externally
896     # if the other testbed isn't another PlanetLab
897     dict({
898         "from": (TESTBED_ID, TAPIFACE, "gre"),
899         "to":   (TESTBED_ID, None, "gre"),
900         "compl_code": functools.partial(crossconnect_tun_iface_peer_both,"gre"),
901         "can_cross": True
902     }),
903     dict({
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"),
908         "can_cross": True
909     }),
910     dict({
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"),
915         "can_cross": True
916     }),
917 ]
918
919 attributes = dict({
920     "forward_X11": dict({      
921                 "name": "forward_X11",
922                 "help": "Forward x11 from main namespace to the node",
923                 "type": Attribute.BOOL, 
924                 "value": False,
925                 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
926                 "validation_function": validation.is_bool,
927             }),
928     "hostname": dict({      
929                 "name": "hostname",
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,
934             }),
935     "city": dict({      
936                 "name": "city",
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,
941             }),
942     "country": dict({      
943                 "name": "hostname",
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,
948             }),
949     "region": dict({      
950                 "name": "hostname",
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,
955             }),
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",
962                             "i386"],
963                 "validation_function": validation.is_enum,
964             }),
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,
970                 "allowed": ["f8",
971                             "f12",
972                             "f14",
973                             "centos",
974                             "other"],
975                 "validation_function": validation.is_enum,
976             }),
977     "site": dict({      
978                 "name": "site",
979                 "help": "Constrain the PlanetLab site this node should reside on.",
980                 "type": Attribute.ENUM, 
981                 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
982                 "allowed": ["PLE",
983                             "PLC",
984                             "PLJ"],
985                 "validation_function": validation.is_enum,
986             }),
987     "min_reliability": dict({
988                 "name": "minReliability",
989                 "help": "Constrain reliability while picking PlanetLab nodes. Specifies a lower acceptable bound.",
990                 "type": Attribute.DOUBLE,
991                 "range": (0,100),
992                 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
993                 "validation_function": validation.is_number,
994             }),
995     "max_reliability": dict({
996                 "name": "maxReliability",
997                 "help": "Constrain reliability while picking PlanetLab nodes. Specifies an upper acceptable bound.",
998                 "type": Attribute.DOUBLE,
999                 "range": (0,100),
1000                 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1001                 "validation_function": validation.is_number,
1002             }),
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,
1007                 "range": (0,2**31),
1008                 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1009                 "validation_function": validation.is_number,
1010             }),
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,
1015                 "range": (0,2**31),
1016                 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1017                 "validation_function": validation.is_number,
1018             }),
1019     "min_load": dict({
1020                 "name": "minLoad",
1021                 "help": "Constrain node load average while picking PlanetLab nodes. Specifies a lower acceptable bound.",
1022                 "type": Attribute.DOUBLE,
1023                 "range": (0,2**31),
1024                 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1025                 "validation_function": validation.is_number,
1026             }),
1027     "max_load": dict({
1028                 "name": "maxLoad",
1029                 "help": "Constrain node load average while picking PlanetLab nodes. Specifies an upper acceptable bound.",
1030                 "type": Attribute.DOUBLE,
1031                 "range": (0,2**31),
1032                 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1033                 "validation_function": validation.is_number,
1034             }),
1035     "min_cpu": dict({
1036                 "name": "minCpu",
1037                 "help": "Constrain available cpu time while picking PlanetLab nodes. Specifies a lower acceptable bound.",
1038                 "type": Attribute.DOUBLE,
1039                 "range": (0,100),
1040                 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1041                 "validation_function": validation.is_number,
1042             }),
1043     "max_cpu": dict({
1044                 "name": "maxCpu",
1045                 "help": "Constrain available cpu time while picking PlanetLab nodes. Specifies an upper acceptable bound.",
1046                 "type": Attribute.DOUBLE,
1047                 "range": (0,100),
1048                 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1049                 "validation_function": validation.is_number,
1050             }),
1051      "timeframe": dict({
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, 
1055                 "value": "week",
1056                 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1057                 "allowed": ["latest",
1058                             "week",
1059                             "month",
1060                             "year"],
1061                 "validation_function": validation.is_enum,
1062             }),
1063            
1064     "up": dict({
1065                 "name": "up",
1066                 "help": "Link up",
1067                 "type": Attribute.BOOL,
1068                 "value": True,
1069                 "flags": Attribute.NoDefaultValue, 
1070                 "validation_function": validation.is_bool
1071             }),
1072     "primary": dict({
1073                 "name": "primary",
1074                 "help": "This is the primary interface for the attached node",
1075                 "type": Attribute.BOOL,
1076                 "value": True,
1077                 "validation_function": validation.is_bool
1078             }),
1079     "if_name": dict({
1080                 "name": "if_name",
1081                 "help": "Device name",
1082                 "type": Attribute.STRING,
1083                 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1084                 "validation_function": validation.is_string
1085             }),
1086     "mtu":  dict({
1087                 "name": "mtu", 
1088                 "help": "Maximum transmition unit for device",
1089                 "type": Attribute.INTEGER,
1090                 "range": (0,1500),
1091                 "validation_function": validation.is_integer_range(0,1500)
1092             }),
1093     "mask":  dict({
1094                 "name": "mask", 
1095                 "help": "Network mask for the device (eg: 24 for /24 network)",
1096                 "type": Attribute.INTEGER,
1097                 "validation_function": validation.is_integer_range(8,24)
1098             }),
1099     "snat":  dict({
1100                 "name": "snat", 
1101                 "help": "Enable SNAT (source NAT to the internet) no this device",
1102                 "type": Attribute.BOOL,
1103                 "value": False,
1104                 "validation_function": validation.is_bool
1105             }),
1106     "multicast":  dict({
1107                 "name": "multicast", 
1108                 "help": "Enable multicast forwarding on this device. "
1109                         "Note that you still need a multicast routing daemon "
1110                         "in the node.",
1111                 "type": Attribute.BOOL,
1112                 "value": False,
1113                 "validation_function": validation.is_bool
1114             }),
1115     "pointopoint":  dict({
1116                 "name": "pointopoint", 
1117                 "help": "If the interface is a P2P link, the remote endpoint's IP "
1118                         "should be set on this attribute.",
1119                 "type": Attribute.STRING,
1120                 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1121                 "validation_function": validation.is_string
1122             }),
1123     "bwlimit":  dict({
1124                 "name": "bwlimit", 
1125                 "help": "Emulated transmission speed (in kbytes per second)",
1126                 "type": Attribute.INTEGER,
1127                 "range" : (1,10*2**20),
1128                 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1129                 "validation_function": validation.is_integer
1130             }),
1131     "txqueuelen":  dict({
1132                 "name": "txqueuelen", 
1133                 "help": "Transmission queue length (in packets)",
1134                 "type": Attribute.INTEGER,
1135                 "value": 1000,
1136                 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1137                 "range" : (1,10000),
1138                 "validation_function": validation.is_integer
1139             }),
1140             
1141     "command": dict({
1142                 "name": "command",
1143                 "help": "Command line string",
1144                 "type": Attribute.STRING,
1145                 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1146                 "validation_function": validation.is_string
1147             }),
1148     "ccnroutes": dict({
1149                 "name": "ccnRoutes",
1150                 "help": "Route can be static (e.g. udp ip) or multicast (e.g. udp 224.0.0.204 2869). To separate different route use '|' ",
1151                 "type": Attribute.STRING,
1152                 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1153                 "validation_function": validation.is_string
1154             }),
1155      "sudo": dict({
1156                 "name": "sudo",
1157                 "help": "Run with root privileges",
1158                 "type": Attribute.BOOL,
1159                 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1160                 "value": False,
1161                 "validation_function": validation.is_bool
1162             }),
1163     "stdin": dict({
1164                 "name": "stdin",
1165                 "help": "Standard input",
1166                 "type": Attribute.STRING,
1167                 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1168                 "validation_function": validation.is_string
1169             }),
1170             
1171     "depends": dict({
1172                 "name": "depends",
1173                 "help": "Space-separated list of packages required to run the application",
1174                 "type": Attribute.STRING,
1175                 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1176                 "validation_function": validation.is_string
1177             }),
1178     "build-depends": dict({
1179                 "name": "buildDepends",
1180                 "help": "Space-separated list of packages required to build the application",
1181                 "type": Attribute.STRING,
1182                 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1183                 "validation_function": validation.is_string
1184             }),
1185     "rpm-fusion": dict({
1186                 "name": "rpmFusion",
1187                 "help": "True if required packages can be found in the RpmFusion repository",
1188                 "type": Attribute.BOOL,
1189                 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1190                 "value": False,
1191                 "validation_function": validation.is_bool
1192             }),
1193     "sources": dict({
1194                 "name": "sources",
1195                 "help": "Space-separated list of regular files to be deployed in the working path prior to building. "
1196                         "Archives won't be expanded automatically.",
1197                 "type": Attribute.STRING,
1198                 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1199                 "validation_function": validation.is_string
1200             }),
1201     "ccnxversion": dict({      
1202                 "name": "ccnxVersion",
1203                 "help": "Version of ccnx source code to install in the node.",
1204                 "type": Attribute.ENUM, 
1205                 "value": "ccnx-0.6.0",
1206                 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1207                 "allowed": ["ccnx-0.6.0",
1208                             "ccnx-0.5.1"],
1209                 "validation_function": validation.is_enum,
1210             }),
1211      "ccnlocalport" : dict({
1212             "name" : "ccnLocalPort", 
1213             "help" : "Local port to bind the ccn daemon. (i.e. CCN_LOCAL_PORT=)",
1214             "type" : Attribute.INTEGER,
1215             "flags" : Attribute.DesignInvisible | \
1216                     Attribute.ExecInvisible | \
1217                     Attribute.ExecImmutable | \
1218                     Attribute.Metadata,
1219             "validation_function" : validation.is_integer,
1220             }),
1221     "build": dict({
1222                 "name": "build",
1223                 "help": "Build commands to execute after deploying the sources. "
1224                         "Sources will be in the ${SOURCES} folder. "
1225                         "Example: tar xzf ${SOURCES}/my-app.tgz && cd my-app && ./configure && make && make clean.\n"
1226                         "Try to make the commands return with a nonzero exit code on error.\n"
1227                         "Also, do not install any programs here, use the 'install' attribute. This will "
1228                         "help keep the built files constrained to the build folder (which may "
1229                         "not be the home folder), and will result in faster deployment. Also, "
1230                         "make sure to clean up temporary files, to reduce bandwidth usage between "
1231                         "nodes when transferring built packages.",
1232                 "type": Attribute.STRING,
1233                 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1234                 "validation_function": validation.is_string
1235             }),
1236     "install": dict({
1237                 "name": "install",
1238                 "help": "Commands to transfer built files to their final destinations. "
1239                         "Sources will be in the initial working folder, and a special "
1240                         "tag ${SOURCES} can be used to reference the experiment's "
1241                         "home folder (where the application commands will run).\n"
1242                         "ALL sources and targets needed for execution must be copied there, "
1243                         "if building has been enabled.\n"
1244                         "That is, 'slave' nodes will not automatically get any source files. "
1245                         "'slave' nodes don't get build dependencies either, so if you need "
1246                         "make and other tools to install, be sure to provide them as "
1247                         "actual dependencies instead.",
1248                 "type": Attribute.STRING,
1249                 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1250                 "validation_function": validation.is_string
1251             }),
1252     
1253     "netpipe_mode": dict({      
1254                 "name": "mode",
1255                 "help": "Link mode:\n"
1256                         " * SERVER: applies to incoming connections\n"
1257                         " * CLIENT: applies to outgoing connections\n"
1258                         " * SERVICE: applies to both",
1259                 "type": Attribute.ENUM, 
1260                 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1261                 "allowed": ["SERVER",
1262                             "CLIENT",
1263                             "SERVICE"],
1264                 "validation_function": validation.is_enum,
1265             }),
1266     "port_list":  dict({
1267                 "name": "portList", 
1268                 "help": "Port list or range. Eg: '22', '22,23,27', '20-2000'",
1269                 "type": Attribute.STRING,
1270                 "validation_function": is_portlist,
1271             }),
1272     "addr_list":  dict({
1273                 "name": "addrList", 
1274                 "help": "Address list or range. Eg: '127.0.0.1', '127.0.0.1,127.0.1.1', '127.0.0.1/8'",
1275                 "type": Attribute.STRING,
1276                 "validation_function": is_addrlist,
1277             }),
1278     "bw_in":  dict({
1279                 "name": "bwIn", 
1280                 "help": "Inbound bandwidth limit (in Mbit/s)",
1281                 "type": Attribute.DOUBLE,
1282                 "validation_function": validation.is_number,
1283             }),
1284     "bw_out":  dict({
1285                 "name": "bwOut", 
1286                 "help": "Outbound bandwidth limit (in Mbit/s)",
1287                 "type": Attribute.DOUBLE,
1288                 "validation_function": validation.is_number,
1289             }),
1290     "plr_in":  dict({
1291                 "name": "plrIn", 
1292                 "help": "Inbound packet loss rate (0 = no loss, 1 = 100% loss)",
1293                 "type": Attribute.DOUBLE,
1294                 "validation_function": validation.is_number,
1295             }),
1296     "plr_out":  dict({
1297                 "name": "plrOut", 
1298                 "help": "Outbound packet loss rate (0 = no loss, 1 = 100% loss)",
1299                 "type": Attribute.DOUBLE,
1300                 "validation_function": validation.is_number,
1301             }),
1302     "delay_in":  dict({
1303                 "name": "delayIn", 
1304                 "help": "Inbound packet delay (in milliseconds)",
1305                 "type": Attribute.INTEGER,
1306                 "range": (0,60000),
1307                 "validation_function": validation.is_integer,
1308             }),
1309     "delay_out":  dict({
1310                 "name": "delayOut", 
1311                 "help": "Outbound packet delay (in milliseconds)",
1312                 "type": Attribute.INTEGER,
1313                 "range": (0,60000),
1314                 "validation_function": validation.is_integer,
1315             }),
1316     "module": dict({
1317                 "name": "module",
1318                 "help": "Path to a .c or .py source for a filter module, or a binary .so",
1319                 "type": Attribute.STRING,
1320                 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1321                 "validation_function": validation.is_string
1322             }),
1323     "args": dict({
1324                 "name": "args",
1325                 "help": "Module arguments - comma-separated list of name=value pairs",
1326                 "type": Attribute.STRING,
1327                 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1328                 "validation_function": validation.is_string
1329             }),
1330     "routing_algorithm": dict({      
1331             "name": "algorithm",
1332             "help": "Routing algorithm.",
1333             "value": "dvmrp",
1334             "type": Attribute.ENUM, 
1335             "allowed": ["dvmrp"],
1336             "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1337             "validation_function": validation.is_enum,
1338         }),
1339     })
1340
1341 traces = dict({
1342     "stdout": dict({
1343                 "name": "stdout",
1344                 "help": "Standard output stream"
1345               }),
1346     "stderr": dict({
1347                 "name": "stderr",
1348                 "help": "Application standard error",
1349               }),
1350     "buildlog": dict({
1351                 "name": "buildlog",
1352                 "help": "Output of the build process",
1353               }), 
1354     
1355     "netpipe_stats": dict({
1356                 "name": "netpipeStats",
1357                 "help": "Information about rule match counters, packets dropped, etc.",
1358               }),
1359
1360     "packets": dict({
1361                 "name": "packets",
1362                 "help": "Detailled log of all packets going through the interface",
1363               }),
1364     "pcap": dict({
1365                 "name": "pcap",
1366                 "help": "PCAP trace of all packets going through the interface",
1367               }),
1368     "output": dict({
1369                 "name": "output",
1370                 "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               }),
1372     "dropped_stats": dict({
1373                 "name": "dropped_stats",
1374                 "help": "Information on dropped packets on a filer or queue associated to a network interface",
1375             }),
1376     "queue_stats_f": dict({
1377                 "name": "queue_stats_f",
1378                 "help": "Detailled, fine-grained information on egress queue state, csv format.",
1379             }),
1380     "queue_stats_b": dict({
1381                 "name": "queue_stats_b",
1382                 "help": "Detailled, fine-grained information on ingress queue state, csv format.",
1383             }),
1384     })
1385
1386 create_order = [ 
1387     INTERNET, NODE, NODEIFACE, CLASSQUEUEFILTER, LOGGINGCLASSQUEUEFILTER, TOSQUEUEFILTER, 
1388     MULTICASTANNOUNCER, MULTICASTFORWARDER, MULTICASTROUTER, 
1389     TUNFILTER, TAPIFACE, TUNIFACE, NETPIPE, 
1390     NEPIDEPENDENCY, NS3DEPENDENCY, DEPENDENCY, CCNXDAEMON, APPLICATION ]
1391
1392 configure_order = [ 
1393     INTERNET, Parallel(NODE), 
1394     NODEIFACE, 
1395     Parallel(MULTICASTANNOUNCER), Parallel(MULTICASTFORWARDER), Parallel(MULTICASTROUTER), 
1396     Parallel(TAPIFACE), Parallel(TUNIFACE), NETPIPE, 
1397     Parallel(NEPIDEPENDENCY), Parallel(NS3DEPENDENCY), Parallel(DEPENDENCY), Parallel(CCNXDAEMON),
1398     Parallel(APPLICATION)]
1399
1400 # Start (and prestart) node after ifaces, because the node needs the ifaces in order to set up routes
1401 start_order = [ INTERNET, 
1402     NODEIFACE, 
1403     Parallel(TAPIFACE), Parallel(TUNIFACE), 
1404     Parallel(NODE), NETPIPE, 
1405     Parallel(MULTICASTANNOUNCER), Parallel(MULTICASTFORWARDER), Parallel(MULTICASTROUTER), 
1406     Parallel(NEPIDEPENDENCY), Parallel(NS3DEPENDENCY), Parallel(DEPENDENCY), Parallel(CCNXDAEMON),
1407     Parallel(APPLICATION)]
1408
1409 # cleanup order
1410 shutdown_order = [ 
1411     Parallel(APPLICATION), 
1412     Parallel (CCNXDAEMON),
1413     Parallel(MULTICASTROUTER), Parallel(MULTICASTFORWARDER), Parallel(MULTICASTANNOUNCER), 
1414     Parallel(TAPIFACE), Parallel(TUNIFACE), Parallel(NETPIPE), 
1415     Parallel(NEPIDEPENDENCY), Parallel(NS3DEPENDENCY), Parallel(DEPENDENCY), 
1416     NODEIFACE, Parallel(NODE) ]
1417
1418 factories_info = dict({
1419     NODE: dict({
1420             "help": "Virtualized Node (V-Server style)",
1421             "category": FC.CATEGORY_NODES,
1422             "create_function": create_node,
1423             "preconfigure_function": configure_node,
1424             "prestart_function": configure_node_routes,
1425             "box_attributes": [
1426                 "forward_X11",
1427                 "hostname",
1428                 "architecture",
1429                 "operating_system",
1430                 "site",
1431                 "min_reliability",
1432                 "max_reliability",
1433                 "min_bandwidth",
1434                 "max_bandwidth",
1435                 "min_load",
1436                 "max_load",
1437                 "min_cpu",
1438                 "max_cpu",
1439                 "timeframe",
1440                 
1441                 # NEPI-in-NEPI attributes
1442                 ATTR_NEPI_TESTBED_ENVIRONMENT_SETUP,
1443             ],
1444             "connector_types": ["devs", "apps", "pipes", "deps"],
1445             "tags": [tags.NODE, tags.ALLOW_ROUTES],
1446        }),
1447     NODEIFACE: dict({
1448             "help": "External network interface - they cannot be brought up or down, and they MUST be connected to the internet.",
1449             "category": FC.CATEGORY_DEVICES,
1450             "create_function": create_nodeiface,
1451             "preconfigure_function": configure_nodeiface,
1452             "box_attributes": [ ],
1453             "connector_types": ["node", "inet"],
1454             "tags": [tags.INTERFACE, tags.HAS_ADDRESSES],
1455         }),
1456     TUNIFACE: dict({
1457             "help": "Virtual TUN network interface (layer 3)",
1458             "category": FC.CATEGORY_DEVICES,
1459             "create_function": create_tuniface,
1460             "preconfigure_function": preconfigure_tuniface,
1461             "configure_function": postconfigure_tuniface,
1462             "prestart_function": prestart_tuniface,
1463             "box_attributes": [
1464                 "up", "if_name", "mtu", "snat", "pointopoint", "multicast", "bwlimit",
1465                 "txqueuelen",
1466                 "tun_proto", "tun_addr", "tun_port", "tun_key", "tun_cipher",
1467             ],
1468             "traces": ["packets", "pcap"],
1469             "connector_types": ["node","udp","tcp","fd->","gre"],
1470             "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
1471         }),
1472     TAPIFACE: dict({
1473             "help": "Virtual TAP network interface (layer 2)",
1474             "category": FC.CATEGORY_DEVICES,
1475             "create_function": create_tapiface,
1476             "preconfigure_function": preconfigure_tuniface,
1477             "configure_function": postconfigure_tuniface,
1478             "prestart_function": prestart_tuniface,
1479             "box_attributes": [
1480                 "up", "if_name", "mtu", "snat", "pointopoint", "multicast", "bwlimit",
1481                 "txqueuelen",
1482                 "tun_proto", "tun_addr", "tun_port", "tun_key", "tun_cipher",
1483             ],
1484             "traces": ["packets", "pcap"],
1485             "connector_types": ["node","udp","tcp","fd->","gre"],
1486             "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
1487         }),
1488     TUNFILTER: dict({
1489             "help": "TUN/TAP stream filter\n\n"
1490                     "If specified, it should be either a .py or .so module. "
1491                     "It will be loaded, and all incoming and outgoing packets "
1492                     "will be routed through it. The filter will not be responsible "
1493                     "for buffering, packet queueing is performed in tun_connect "
1494                     "already, so it should not concern itself with it. It should "
1495                     "not, however, block in one direction if the other is congested.\n"
1496                     "\n"
1497                     "Modules are expected to have the following methods:\n"
1498                     "\tinit(**args)\n"
1499                     "\t\tIf arguments are given, this method will be called with the\n"
1500                     "\t\tgiven arguments (as keyword args in python modules, or a single\n"
1501                     "\taccept_packet(packet, direction):\n"
1502                     "\t\tDecide whether to drop the packet. Direction is 0 for packets "
1503                         "coming from the local side to the remote, and 1 is for packets "
1504                         "coming from the remote side to the local. Return a boolean, "
1505                         "true if the packet is not to be dropped.\n"
1506                     "\tfilter_init():\n"
1507                     "\t\tInitializes a filtering pipe (filter_run). It should "
1508                         "return two file descriptors to use as a bidirectional "
1509                         "pipe: local and remote. 'local' is where packets from the "
1510                         "local side will be written to. After filtering, those packets "
1511                         "should be written to 'remote', where tun_connect will read "
1512                         "from, and it will forward them to the remote peer. "
1513                         "Packets from the remote peer will be written to 'remote', "
1514                         "where the filter is expected to read from, and eventually "
1515                         "forward them to the local side. If the file descriptors are "
1516                         "not nonblocking, they will be set to nonblocking. So it's "
1517                         "better to set them from the start like that.\n"
1518                     "\tfilter_run(local, remote):\n"
1519                     "\t\tIf filter_init is provided, it will be called repeatedly, "
1520                         "in a separate thread until the process is killed. It should "
1521                         "sleep at most for a second.\n"
1522                     "\tfilter_close(local, remote):\n"
1523                     "\t\tCalled then the process is killed, if filter_init was provided. "
1524                         "It should, among other things, close the file descriptors.\n"
1525                     "\n"
1526                     "Python modules are expected to return a tuple in filter_init, "
1527                     "either of file descriptors or file objects, while native ones "
1528                     "will receive two int*.\n"
1529                     "\n"
1530                     "Python modules can additionally contain a custom queue class "
1531                     "that will replace the FIFO used by default. The class should "
1532                     "be named 'queueclass' and contain an interface compatible with "
1533                     "collections.deque. That is, indexing (especiall for q[0]), "
1534                     "bool(q), popleft, appendleft, pop (right), append (right), "
1535                     "len(q) and clear.",
1536             "category": FC.CATEGORY_CHANNELS,
1537             "create_function": create_tunfilter,
1538             "box_attributes": [
1539                 "module", "args",
1540                 "tun_proto", "tun_addr", "tun_port", "tun_key", "tun_cipher",
1541             ],
1542             "connector_types": ["->fd","udp","tcp"],
1543         }),
1544     CLASSQUEUEFILTER : dict({
1545             "help": "TUN classful queue, uses a separate queue for each user-definable class.\n\n"
1546                     "It takes two arguments, both of which have sensible defaults:\n"
1547                     "\tsize: the base size of each class' queue\n"
1548                     "\tclasses: the class definitions, which follow the following syntax:\n"
1549                     '\t   <CLASSLIST> ::= <CLASS> ":" CLASSLIST\n'
1550                     '\t                |  <CLASS>\n'
1551                     '\t   <CLASS>     ::= <PROTOLIST> "*" <PRIORITYSPEC>\n'
1552                     '\t                |  <DFLTCLASS>\n'
1553                     '\t   <DFLTCLASS> ::= "*" <PRIORITYSPEC>\n'
1554                     '\t   <PROTOLIST> ::= <PROTO> "." <PROTOLIST>\n'
1555                     '\t                |  <PROTO>\n'
1556                     '\t   <PROTO>     ::= <NAME> | <NUMBER>\n'
1557                     '\t   <NAME>      ::= --see http://en.wikipedia.org/wiki/List_of_IP_protocol_numbers --\n'
1558                     '\t                   --only in lowercase, with special characters removed--\n'
1559                     '\t                   --or see below--\n'
1560                     '\t   <NUMBER>    ::= [0-9]+\n'
1561                     '\t   <PRIORITYSPEC> ::= <THOUGHPUT> [ "#" <SIZE> ] [ "p" <PRIORITY> ]\n'
1562                     '\t   <THOUGHPUT> ::= NUMBER -- default 1\n'
1563                     '\t   <PRIORITY>  ::= NUMBER -- default 0\n'
1564                     '\t   <SIZE>      ::= NUMBER -- default 1\n'
1565                     "\n"
1566                     "Size, thoughput and priority are all relative terms. "
1567                     "Sizes are multipliers for the size argument, thoughput "
1568                     "is applied relative to other classes and the same with "
1569                     "priority.",
1570             "category": FC.CATEGORY_CHANNELS,
1571             "create_function": create_classqueuefilter,
1572             "box_attributes": [
1573                 "args",
1574                 "tun_proto", "tun_addr", "tun_port", "tun_key", "tun_cipher",
1575             ],
1576             "connector_types": ["->fd","udp","tcp"],
1577             "traces": ["dropped_stats"],
1578         }),
1579     LOGGINGCLASSQUEUEFILTER : dict({
1580             "help": "TUN classful queue, uses a separate queue for each user-definable class.\n"
1581                     "See ClassQueueFilter. This version adds detailled queue state tracing.",
1582             "category": FC.CATEGORY_CHANNELS,
1583             "create_function": create_loggingclassqueuefilter,
1584             "box_attributes": [
1585                 "args",
1586                 "tun_proto", "tun_addr", "tun_port", "tun_key", "tun_cipher",
1587             ],
1588             "connector_types": ["->fd","udp","tcp"],
1589             "traces": ["dropped_stats","queue_stats_f","queue_stats_b"],
1590         }),
1591     TOSQUEUEFILTER : dict({
1592             "help": "TUN classfull queue that classifies according to the TOS (RFC 791) IP field.\n\n"
1593                     "It takes a size argument that specifies the size of each class. As TOS is a "
1594                     "subset of DiffServ, this queue half-implements DiffServ.",
1595             "category": FC.CATEGORY_CHANNELS,
1596             "create_function": create_tosqueuefilter,
1597             "box_attributes": [
1598                 "args",
1599                 "tun_proto", "tun_addr", "tun_port", "tun_key", "tun_cipher",
1600             ],
1601             "connector_types": ["->fd","udp","tcp"],
1602         }),
1603
1604     APPLICATION: dict({
1605             "help": "Generic executable command line application",
1606             "category": FC.CATEGORY_APPLICATIONS,
1607             "create_function": create_application,
1608             "start_function": start_application,
1609             "status_function": status_application,
1610             "stop_function": stop_application,
1611             "configure_function": configure_application,
1612             "box_attributes": ["command", "sudo", "stdin",
1613                                "depends", "build-depends", "build", "install",
1614                                "sources", "rpm-fusion" ],
1615             "connector_types": ["node"],
1616             "traces": ["stdout", "stderr", "buildlog", "output"],
1617             "tags": [tags.APPLICATION],
1618         }),
1619
1620     CCNXDAEMON: dict({
1621             "help": "CCNx daemon",
1622             "category": FC.CATEGORY_APPLICATIONS,
1623             "create_function": create_ccnxdaemon,
1624             "prestart_function": prestart_ccnxdaemon,
1625             "status_function": status_application,
1626             "stop_function": stop_application,
1627             "configure_function": configure_application,
1628             "box_attributes": ["ccnroutes", "build", "ccnlocalport",
1629                 "install", "ccnxversion", "sources"],
1630             "connector_types": ["node"],
1631             "traces": ["stdout", "stderr", "buildlog", "output"],
1632             "tags": [tags.APPLICATION],
1633         }),
1634     DEPENDENCY: dict({
1635             "help": "Requirement for package or application to be installed on some node",
1636             "category": FC.CATEGORY_APPLICATIONS,
1637             "create_function": create_dependency,
1638             "preconfigure_function": configure_dependency,
1639             "box_attributes": ["depends", "build-depends", "build", "install",
1640                                "sources", "rpm-fusion" ],
1641             "connector_types": ["node"],
1642             "traces": ["buildlog"],
1643         }),
1644     NEPIDEPENDENCY: dict({
1645             "help": "Requirement for NEPI inside NEPI - required to run testbed instances inside a node",
1646             "category": FC.CATEGORY_APPLICATIONS,
1647             "create_function": create_nepi_dependency,
1648             "preconfigure_function": configure_dependency,
1649             "box_attributes": [],
1650             "connector_types": ["node"],
1651             "traces": ["buildlog"],
1652         }),
1653     NS3DEPENDENCY: dict({
1654             "help": "Requirement for NS3 inside NEPI - required to run NS3 testbed instances inside a node. It also needs NepiDependency.",
1655             "category": FC.CATEGORY_APPLICATIONS,
1656             "create_function": create_ns3_dependency,
1657             "preconfigure_function": configure_dependency,
1658             "box_attributes": [ ],
1659             "connector_types": ["node"],
1660             "traces": ["buildlog"],
1661         }),
1662     MULTICASTFORWARDER: dict({
1663             "help": "This application installs a userspace packet forwarder "
1664                     "that, when connected to a node, filters all packets "
1665                     "flowing through multicast-capable virtual interfaces "
1666                     "and applies custom-specified routing policies.",
1667             "category": FC.CATEGORY_APPLICATIONS,
1668             "create_function": create_multicast_forwarder,
1669             "preconfigure_function": configure_forwarder,
1670             "start_function": start_application,
1671             "status_function": status_application,
1672             "stop_function": stop_application,
1673             "box_attributes": [ ],
1674             "connector_types": ["node","router"],
1675             "traces": ["buildlog","stderr"],
1676         }),
1677     MULTICASTANNOUNCER: dict({
1678             "help": "This application installs a userspace daemon that "
1679                     "monitors multicast membership and announces it on all "
1680                     "multicast-capable interfaces.\n"
1681                     "This does not usually happen automatically on PlanetLab slivers.",
1682             "category": FC.CATEGORY_APPLICATIONS,
1683             "create_function": create_multicast_announcer,
1684             "preconfigure_function": configure_announcer,
1685             "start_function": start_application,
1686             "status_function": status_application,
1687             "stop_function": stop_application,
1688             "box_attributes": [ ],
1689             "connector_types": ["node"],
1690             "traces": ["buildlog","stderr"],
1691         }),
1692     MULTICASTROUTER: dict({
1693             "help": "This application installs a userspace daemon that "
1694                     "monitors multicast membership and announces it on all "
1695                     "multicast-capable interfaces.\n"
1696                     "This does not usually happen automatically on PlanetLab slivers.",
1697             "category": FC.CATEGORY_APPLICATIONS,
1698             "create_function": create_multicast_router,
1699             "preconfigure_function": configure_router,
1700             "start_function": start_application,
1701             "status_function": status_application,
1702             "stop_function": stop_application,
1703             "box_attributes": ["routing_algorithm"],
1704             "connector_types": ["fwd"],
1705             "traces": ["buildlog","stdout","stderr"],
1706         }),
1707     INTERNET: dict({
1708             "help": "Internet routing",
1709             "category": FC.CATEGORY_CHANNELS,
1710             "create_function": create_internet,
1711             "connector_types": ["devs"],
1712             "tags": [tags.INTERNET],
1713         }),
1714     NETPIPE: dict({
1715             "help": "Link emulation",
1716             "category": FC.CATEGORY_CHANNELS,
1717             "create_function": create_netpipe,
1718             "configure_function": configure_netpipe,
1719             "box_attributes": ["netpipe_mode",
1720                                "addr_list", "port_list",
1721                                "bw_in","plr_in","delay_in",
1722                                "bw_out","plr_out","delay_out"],
1723             "connector_types": ["node"],
1724             "traces": ["netpipe_stats"],
1725         }),
1726 })
1727
1728 testbed_attributes = dict({
1729         "slice_hrn": dict({
1730             "name": "sliceHrn",
1731             "help": "The hierarchical Resource Name (HRN) for the PlanetLab slice.",
1732             "type": Attribute.STRING,
1733             "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable | Attribute.NoDefaultValue,
1734             "validation_function": validation.is_string
1735         }),
1736         "sfa": dict({
1737             "name": "sfa",
1738             "help": "Activates the use of SFA for node reservation.",
1739             "type": Attribute.BOOL,
1740             "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable | Attribute.NoDefaultValue,
1741             "validation_function": validation.is_bool
1742         }),
1743         "slice": dict({
1744             "name": "slice",
1745             "help": "The name of the PlanetLab slice to use",
1746             "type": Attribute.STRING,
1747             "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable | Attribute.NoDefaultValue,
1748             "validation_function": validation.is_string
1749         }),
1750         "auth_user": dict({
1751             "name": "authUser",
1752             "help": "The name of the PlanetLab user to use for API calls - it must have at least a User role.",
1753             "type": Attribute.STRING,
1754             "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable | Attribute.NoDefaultValue,
1755             "validation_function": validation.is_string
1756         }),
1757         "auth_pass": dict({
1758             "name": "authPass",
1759             "help": "The PlanetLab user's password.",
1760             "type": Attribute.STRING,
1761             "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable | Attribute.NoDefaultValue,
1762             "validation_function": validation.is_string
1763         }),
1764         "plc_host": dict({
1765             "name": "plcHost",
1766             "help": "The PlanetLab PLC API host",
1767             "type": Attribute.STRING,
1768             "value": "www.planet-lab.eu",
1769             "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1770             "validation_function": validation.is_string
1771         }),
1772         "plc_url": dict({
1773             "name": "plcUrl",
1774             "help": "The PlanetLab PLC API url pattern - %(hostname)s is replaced by plcHost.",
1775             "type": Attribute.STRING,
1776             "value": "https://%(hostname)s:443/PLCAPI/",
1777             "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1778             "validation_function": validation.is_string
1779         }),
1780         "p2p_deployment": dict({
1781             "name": "p2pDeployment",
1782             "help": "Enable peer-to-peer deployment of applications and dependencies. "
1783                     "When enabled, dependency packages and applications are "
1784                     "deployed in a P2P fashion, picking a single node to do "
1785                     "the building or repo download, while all the others "
1786                     "cooperatively exchange resulting binaries or rpms. "
1787                     "When deploying to many nodes, this is a far more efficient "
1788                     "use of resources. It does require re-encrypting and distributing "
1789                     "the slice's private key. Though it is implemented in a secure "
1790                     "fashion, if they key's sole purpose is not PlanetLab, then this "
1791                     "feature should be disabled.",
1792             "type": Attribute.BOOL,
1793             "value": True,
1794             "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1795             "validation_function": validation.is_bool
1796         }),
1797         "slice_ssh_key": dict({
1798             "name": "sliceSSHKey",
1799             "help": "The controller-local path to the slice user's ssh private key. "
1800                     "It is the user's responsability to deploy this file where the controller "
1801                     "will run, it won't be done automatically because it's sensitive information. "
1802                     "It is recommended that a NEPI-specific user be created for this purpose and "
1803                     "this purpose alone.",
1804             "type": Attribute.STRING,
1805             "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable | Attribute.NoDefaultValue,
1806             "validation_function": validation.is_string
1807         }),
1808         "pl_log_level": dict({      
1809             "name": "plLogLevel",
1810             "help": "Verbosity of logging of planetlab events.",
1811             "value": "INFO",
1812             "type": Attribute.ENUM, 
1813             "allowed": ["DEBUG",
1814                         "INFO",
1815                         "WARNING",
1816                         "ERROR",
1817                         "CRITICAL"],
1818             "validation_function": validation.is_enum,
1819         }),
1820         "tap_port_base":  dict({
1821             "name": "tapPortBase", 
1822             "help": "Base port to use when connecting TUN/TAPs. Effective port will be BASE + GUID.",
1823             "type": Attribute.INTEGER,
1824             "value": 15000,
1825             "range": (2000,30000),
1826             "validation_function": validation.is_integer_range(2000,30000)
1827         }),
1828         "clean_proc": dict({
1829             "name": "cleanProc",
1830             "help": "Set to True if the slice will be dedicated to this experiment. "
1831                     "NEPI will perform node and slice process cleanup, making sure slices are "
1832                     "in a clean, repeatable state before running the experiment.",
1833             "type": Attribute.BOOL,
1834             "value": False,
1835             "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1836             "validation_function": validation.is_bool
1837         }),
1838         "clean_home": dict({
1839             "name": "cleanHome",
1840             "help": "Set to True all preexistent directories in the home "
1841                     "directory of each sliver will be removed before the "
1842                     "start of the experiment.",
1843             "type": Attribute.BOOL,
1844             "value": False,
1845             "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1846             "validation_function": validation.is_bool
1847         }),
1848     })
1849
1850 supported_recovery_policies = [
1851         DC.POLICY_FAIL,
1852         DC.POLICY_RESTART,
1853         DC.POLICY_RECOVER,
1854     ]
1855
1856 class MetadataInfo(metadata.MetadataInfo):
1857     @property
1858     def connector_types(self):
1859         return connector_types
1860
1861     @property
1862     def connections(self):
1863         return connections
1864
1865     @property
1866     def attributes(self):
1867         return attributes
1868
1869     @property
1870     def traces(self):
1871         return traces
1872
1873     @property
1874     def create_order(self):
1875         return create_order
1876
1877     @property
1878     def configure_order(self):
1879         return configure_order
1880
1881     @property
1882     def prestart_order(self):
1883         return start_order
1884
1885     @property
1886     def start_order(self):
1887         return start_order
1888
1889     @property
1890     def factories_info(self):
1891         return factories_info
1892
1893     @property
1894     def testbed_attributes(self):
1895         return testbed_attributes
1896
1897     @property
1898     def testbed_id(self):
1899         return TESTBED_ID
1900
1901     @property
1902     def testbed_version(self):
1903         return TESTBED_VERSION
1904
1905     @property
1906     def supported_recovery_policies(self):
1907         return supported_recovery_policies
1908
1909