2 # -*- coding: utf-8 -*-
6 from constants import TESTBED_ID, TESTBED_VERSION
7 from nepi.core import metadata
8 from nepi.core.metadata import Parallel
9 from nepi.core.attributes import Attribute
10 from nepi.util import tags, validation
11 from nepi.util.constants import ApplicationStatus as AS, \
12 FactoryCategories as FC, \
13 ATTR_NEPI_TESTBED_ENVIRONMENT_SETUP, \
14 DeploymentConfiguration as DC
21 NODEIFACE = "NodeInterface"
22 TUNIFACE = "TunInterface"
23 TAPIFACE = "TapInterface"
24 APPLICATION = "Application"
25 DEPENDENCY = "Dependency"
26 NEPIDEPENDENCY = "NepiDependency"
27 NS3DEPENDENCY = "NS3Dependency"
31 PL_TESTBED_ID = "planetlab"
34 ### Custom validation functions ###
35 def is_addrlist(attribute, value):
36 if not validation.is_string(attribute, value):
43 components = value.split(',')
45 for component in components:
47 addr, mask = component.split('/',1)
49 addr, mask = component, '32'
51 if mask is not None and not (mask and mask.isdigit()):
52 # No empty or nonnumeric masks
55 if not validation.is_ip4_address(attribute, addr):
56 # Address part must be ipv4
61 def is_portlist(attribute, value):
62 if not validation.is_string(attribute, value):
69 components = value.split(',')
71 for component in components:
73 pfrom, pto = component.split('-',1)
75 pfrom = pto = component
77 if not pfrom or not pto or not pfrom.isdigit() or not pto.isdigit():
78 # No empty or nonnumeric ports
84 ### Connection functions ####
86 def connect_node_iface_node(testbed_instance, node_guid, iface_guid):
87 node = testbed_instance._elements[node_guid]
88 iface = testbed_instance._elements[iface_guid]
91 def connect_node_iface_inet(testbed_instance, iface_guid, inet_guid):
92 iface = testbed_instance._elements[iface_guid]
93 iface.has_internet = True
95 def connect_tun_iface_node(testbed_instance, node_guid, iface_guid):
96 node = testbed_instance._elements[node_guid]
97 iface = testbed_instance._elements[iface_guid]
99 node.required_vsys.update(('fd_tuntap', 'vif_up', 'vif_down'))
100 node.required_packages.update(('python', 'python-crypto', 'python-setuptools', 'gcc'))
102 def connect_tun_iface_peer(proto, testbed_instance, iface_guid, peer_iface_guid):
103 iface = testbed_instance._elements[iface_guid]
104 peer_iface = testbed_instance._elements[peer_iface_guid]
105 iface.peer_iface = peer_iface
107 iface.tun_proto = proto
108 iface.tun_key = peer_iface.tun_key
110 def crossconnect_tun_iface_peer_init(proto, testbed_instance, iface_guid, peer_iface_data):
111 iface = testbed_instance._elements[iface_guid]
112 iface.peer_iface = None
113 iface.peer_addr = peer_iface_data.get("tun_addr")
114 iface.peer_proto = peer_iface_data.get("tun_proto") or proto
115 iface.peer_port = peer_iface_data.get("tun_port")
116 iface.tun_key = min(iface.tun_key, peer_iface_data.get("tun_key"))
117 iface.tun_proto = proto
119 preconfigure_tuniface(testbed_instance, iface_guid)
121 def crossconnect_tun_iface_peer_compl(proto, testbed_instance, iface_guid, peer_iface_data):
122 # refresh (refreshable) attributes for second-phase
123 iface = testbed_instance._elements[iface_guid]
124 iface.peer_addr = peer_iface_data.get("tun_addr")
125 iface.peer_proto = peer_iface_data.get("tun_proto") or proto
126 iface.peer_port = peer_iface_data.get("tun_port")
128 postconfigure_tuniface(testbed_instance, iface_guid)
130 def crossconnect_tun_iface_peer_both(proto, testbed_instance, iface_guid, peer_iface_data):
131 crossconnect_tun_iface_peer_init(proto, testbed_instance, iface_guid, peer_iface_data)
132 crossconnect_tun_iface_peer_compl(proto, testbed_instance, iface_guid, peer_iface_data)
134 def connect_dep(testbed_instance, node_guid, app_guid):
135 node = testbed_instance._elements[node_guid]
136 app = testbed_instance._elements[app_guid]
140 node.required_packages.update(set(
141 app.depends.split() ))
144 if app.home_path and app.home_path not in node.pythonpath:
145 node.pythonpath.append(app.home_path)
148 for envkey, envval in app.env.iteritems():
149 envval = app._replace_paths(envval)
150 node.env[envkey].append(envval)
153 node.rpmFusion = True
155 def connect_node_netpipe(testbed_instance, node_guid, netpipe_guid):
156 node = testbed_instance._elements[node_guid]
157 netpipe = testbed_instance._elements[netpipe_guid]
159 node.required_vsys.add('ipfw-be')
160 node.required_packages.add('ipfwslice')
163 ### Creation functions ###
165 def create_node(testbed_instance, guid):
166 parameters = testbed_instance._get_parameters(guid)
168 # create element with basic attributes
169 element = testbed_instance._make_node(parameters)
171 # add constraint on number of (real) interfaces
172 # by counting connected devices
173 dev_guids = testbed_instance.get_connected(guid, "devs", "node")
174 num_open_ifaces = sum( # count True values
175 NODEIFACE == testbed_instance._get_factory_id(guid)
176 for guid in dev_guids )
177 element.min_num_external_ifaces = num_open_ifaces
179 # require vroute vsys if we have routes to set up
180 routes = testbed_instance._add_route.get(guid)
182 element.required_vsys.add("vroute")
184 testbed_instance.elements[guid] = element
186 def create_nodeiface(testbed_instance, guid):
187 parameters = testbed_instance._get_parameters(guid)
188 element = testbed_instance._make_node_iface(parameters)
189 testbed_instance.elements[guid] = element
191 def create_tuniface(testbed_instance, guid):
192 parameters = testbed_instance._get_parameters(guid)
193 element = testbed_instance._make_tun_iface(parameters)
195 # Set custom addresses, if there are any already
196 # Setting this early helps set up P2P links
197 if guid in testbed_instance._add_address and not (element.address or element.netmask or element.netprefix):
198 addresses = testbed_instance._add_address[guid]
199 for address in addresses:
200 (address, netprefix, broadcast) = address
201 element.add_address(address, netprefix, broadcast)
203 testbed_instance.elements[guid] = element
205 def create_tapiface(testbed_instance, guid):
206 parameters = testbed_instance._get_parameters(guid)
207 element = testbed_instance._make_tap_iface(parameters)
209 # Set custom addresses, if there are any already
210 # Setting this early helps set up P2P links
211 if guid in testbed_instance._add_address and not (element.address or element.netmask or element.netprefix):
212 addresses = testbed_instance._add_address[guid]
213 for address in addresses:
214 (address, netprefix, broadcast) = address
215 element.add_address(address, netprefix, broadcast)
217 testbed_instance.elements[guid] = element
219 def create_application(testbed_instance, guid):
220 parameters = testbed_instance._get_parameters(guid)
221 element = testbed_instance._make_application(parameters)
223 # Just inject configuration stuff
224 element.home_path = "nepi-app-%s" % (guid,)
226 testbed_instance.elements[guid] = element
228 def create_dependency(testbed_instance, guid):
229 parameters = testbed_instance._get_parameters(guid)
230 element = testbed_instance._make_dependency(parameters)
232 # Just inject configuration stuff
233 element.home_path = "nepi-dep-%s" % (guid,)
235 testbed_instance.elements[guid] = element
237 def create_nepi_dependency(testbed_instance, guid):
238 parameters = testbed_instance._get_parameters(guid)
239 element = testbed_instance._make_nepi_dependency(parameters)
241 # Just inject configuration stuff
242 element.home_path = "nepi-nepi-%s" % (guid,)
244 testbed_instance.elements[guid] = element
246 def create_ns3_dependency(testbed_instance, guid):
247 parameters = testbed_instance._get_parameters(guid)
248 element = testbed_instance._make_ns3_dependency(parameters)
250 # Just inject configuration stuff
251 element.home_path = "nepi-ns3-%s" % (guid,)
253 testbed_instance.elements[guid] = element
255 def create_internet(testbed_instance, guid):
256 parameters = testbed_instance._get_parameters(guid)
257 element = testbed_instance._make_internet(parameters)
258 testbed_instance.elements[guid] = element
260 def create_netpipe(testbed_instance, guid):
261 parameters = testbed_instance._get_parameters(guid)
262 element = testbed_instance._make_netpipe(parameters)
263 testbed_instance.elements[guid] = element
265 ### Start/Stop functions ###
267 def start_application(testbed_instance, guid):
268 parameters = testbed_instance._get_parameters(guid)
269 traces = testbed_instance._get_traces(guid)
270 app = testbed_instance.elements[guid]
272 app.stdout = "stdout" in traces
273 app.stderr = "stderr" in traces
274 app.buildlog = "buildlog" in traces
278 def stop_application(testbed_instance, guid):
279 app = testbed_instance.elements[guid]
282 ### Status functions ###
284 def status_application(testbed_instance, guid):
285 if guid not in testbed_instance.elements.keys():
286 return AS.STATUS_NOT_STARTED
288 app = testbed_instance.elements[guid]
291 ### Configure functions ###
293 def configure_nodeiface(testbed_instance, guid):
294 element = testbed_instance._elements[guid]
296 # Cannot explicitly configure addresses
297 if guid in testbed_instance._add_address:
298 raise ValueError, "Cannot explicitly set address of public PlanetLab interface"
301 node_guid = testbed_instance.get_connected(guid, "node", "devs")[0]
302 dev_guids = testbed_instance.get_connected(node_guid, "node", "devs")
303 siblings = [ self._element[dev_guid]
304 for dev_guid in dev_guids
305 if dev_guid != guid ]
307 # Fetch address from PLC api
308 element.pick_iface(siblings)
310 # Do some validations
313 def preconfigure_tuniface(testbed_instance, guid):
314 element = testbed_instance._elements[guid]
316 # Set custom addresses if any, and if not set already
317 if guid in testbed_instance._add_address and not (element.address or element.netmask or element.netprefix):
318 addresses = testbed_instance._add_address[guid]
319 for address in addresses:
320 (address, netprefix, broadcast) = address
321 element.add_address(address, netprefix, broadcast)
323 # Link to external interface, if any
324 for iface in testbed_instance._elements.itervalues():
325 if isinstance(iface, testbed_instance._interfaces.NodeIface) and iface.node is element.node and iface.has_internet:
326 element.external_iface = iface
329 # Set standard TUN attributes
330 if (not element.tun_addr or not element.tun_port) and element.external_iface:
331 element.tun_addr = element.external_iface.address
332 element.tun_port = testbed_instance.tapPortBase + int(guid)
335 traces = testbed_instance._get_traces(guid)
336 for capmode in ('pcap', 'packets'):
337 if capmode in traces:
338 element.capture = capmode
341 element.capture = False
343 # Do some validations
347 if element.peer_proto:
348 if element.peer_iface and isinstance(element.peer_iface, testbed_instance._interfaces.TunIface):
350 listening = id(element) < id(element.peer_iface)
353 if not element.tun_addr or not element.tun_port:
355 elif not element.peer_addr or not element.peer_port:
358 # both have addresses...
359 # ...the one with the lesser address listens
360 listening = element.tun_addr < element.peer_addr
365 def postconfigure_tuniface(testbed_instance, guid):
366 element = testbed_instance._elements[guid]
371 def wait_tuniface(testbed_instance, guid):
372 element = testbed_instance._elements[guid]
375 element.async_launch_wait()
378 def configure_node(testbed_instance, guid):
379 node = testbed_instance._elements[guid]
381 # Just inject configuration stuff
382 node.home_path = "nepi-node-%s" % (guid,)
383 node.ident_path = testbed_instance.sliceSSHKey
384 node.slicename = testbed_instance.slicename
386 # Do some validations
389 # this will be done in parallel in all nodes
390 # this call only spawns the process
391 node.install_dependencies()
393 def configure_node_routes(testbed_instance, guid):
394 node = testbed_instance._elements[guid]
395 routes = testbed_instance._add_route.get(guid)
399 for dev_guid in testbed_instance.get_connected(guid, "devs", "node")
400 for dev in ( testbed_instance._elements.get(dev_guid) ,)
401 if dev and isinstance(dev, testbed_instance._interfaces.TunIface) ]
403 node.configure_routes(routes, devs)
405 def configure_application(testbed_instance, guid):
406 app = testbed_instance._elements[guid]
408 # Do some validations
411 # Wait for dependencies
412 app.node.wait_dependencies()
417 def configure_dependency(testbed_instance, guid):
418 dep = testbed_instance._elements[guid]
420 # Do some validations
423 # Wait for dependencies
424 dep.node.wait_dependencies()
429 def configure_netpipe(testbed_instance, guid):
430 netpipe = testbed_instance._elements[guid]
432 # Do some validations
435 # Wait for dependencies
436 netpipe.node.wait_dependencies()
441 ### Factory information ###
443 connector_types = dict({
445 "help": "Connector from node to applications",
451 "help": "Connector from node to network interfaces",
457 "help": "Connector from node to application dependencies "
458 "(packages and applications that need to be installed)",
464 "help": "Connector from network interfaces to the internet",
470 "help": "Connector to a Node",
476 "help": "Connector to a NetPipe",
483 "help": "ip-ip tunneling over TCP link",
489 "help": "ip-ip tunneling over UDP datagrams",
495 "help": "TUN device file descriptor provider",
504 "from": (TESTBED_ID, NODE, "devs"),
505 "to": (TESTBED_ID, NODEIFACE, "node"),
506 "init_code": connect_node_iface_node,
510 "from": (TESTBED_ID, NODE, "devs"),
511 "to": (TESTBED_ID, TUNIFACE, "node"),
512 "init_code": connect_tun_iface_node,
516 "from": (TESTBED_ID, NODE, "devs"),
517 "to": (TESTBED_ID, TAPIFACE, "node"),
518 "init_code": connect_tun_iface_node,
522 "from": (TESTBED_ID, NODEIFACE, "inet"),
523 "to": (TESTBED_ID, INTERNET, "devs"),
524 "init_code": connect_node_iface_inet,
528 "from": (TESTBED_ID, NODE, "apps"),
529 "to": (TESTBED_ID, APPLICATION, "node"),
530 "init_code": connect_dep,
534 "from": (TESTBED_ID, NODE, "deps"),
535 "to": (TESTBED_ID, DEPENDENCY, "node"),
536 "init_code": connect_dep,
540 "from": (TESTBED_ID, NODE, "deps"),
541 "to": (TESTBED_ID, NEPIDEPENDENCY, "node"),
542 "init_code": connect_dep,
546 "from": (TESTBED_ID, NODE, "deps"),
547 "to": (TESTBED_ID, NS3DEPENDENCY, "node"),
548 "init_code": connect_dep,
552 "from": (TESTBED_ID, NODE, "pipes"),
553 "to": (TESTBED_ID, NETPIPE, "node"),
554 "init_code": connect_node_netpipe,
558 "from": (TESTBED_ID, TUNIFACE, "tcp"),
559 "to": (TESTBED_ID, TUNIFACE, "tcp"),
560 "init_code": functools.partial(connect_tun_iface_peer,"tcp"),
564 "from": (TESTBED_ID, TUNIFACE, "udp"),
565 "to": (TESTBED_ID, TUNIFACE, "udp"),
566 "init_code": functools.partial(connect_tun_iface_peer,"udp"),
570 "from": (TESTBED_ID, TAPIFACE, "tcp"),
571 "to": (TESTBED_ID, TAPIFACE, "tcp"),
572 "init_code": functools.partial(connect_tun_iface_peer,"tcp"),
576 "from": (TESTBED_ID, TAPIFACE, "udp"),
577 "to": (TESTBED_ID, TAPIFACE, "udp"),
578 "init_code": functools.partial(connect_tun_iface_peer,"udp"),
582 "from": (TESTBED_ID, TUNIFACE, "tcp"),
583 "to": (None, None, "tcp"),
584 "init_code": functools.partial(crossconnect_tun_iface_peer_init,"tcp"),
585 "compl_code": functools.partial(crossconnect_tun_iface_peer_compl,"tcp"),
589 "from": (TESTBED_ID, TUNIFACE, "udp"),
590 "to": (None, None, "udp"),
591 "init_code": functools.partial(crossconnect_tun_iface_peer_init,"udp"),
592 "compl_code": functools.partial(crossconnect_tun_iface_peer_compl,"udp"),
596 "from": (TESTBED_ID, TUNIFACE, "fd->"),
597 "to": (None, None, "->fd"),
598 "compl_code": functools.partial(crossconnect_tun_iface_peer_both,"fd"),
602 "from": (TESTBED_ID, TAPIFACE, "tcp"),
603 "to": (None, None, "tcp"),
604 "init_code": functools.partial(crossconnect_tun_iface_peer_init,"tcp"),
605 "compl_code": functools.partial(crossconnect_tun_iface_peer_compl,"tcp"),
609 "from": (TESTBED_ID, TAPIFACE, "udp"),
610 "to": (None, None, "udp"),
611 "init_code": functools.partial(crossconnect_tun_iface_peer_init,"udp"),
612 "compl_code": functools.partial(crossconnect_tun_iface_peer_compl,"udp"),
616 "from": (TESTBED_ID, TAPIFACE, "fd->"),
617 "to": (None, None, "->fd"),
618 "compl_code": functools.partial(crossconnect_tun_iface_peer_both,"fd"),
624 "forward_X11": dict({
625 "name": "forward_X11",
626 "help": "Forward x11 from main namespace to the node",
627 "type": Attribute.BOOL,
629 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
630 "validation_function": validation.is_bool,
634 "help": "Constrain hostname during resource discovery. May use wildcards.",
635 "type": Attribute.STRING,
636 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
637 "validation_function": validation.is_string,
639 "architecture": dict({
640 "name": "architecture",
641 "help": "Constrain architexture during resource discovery.",
642 "type": Attribute.ENUM,
643 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
644 "allowed": ["x86_64",
646 "validation_function": validation.is_enum,
648 "operating_system": dict({
649 "name": "operatingSystem",
650 "help": "Constrain operating system during resource discovery.",
651 "type": Attribute.ENUM,
652 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
658 "validation_function": validation.is_enum,
662 "help": "Constrain the PlanetLab site this node should reside on.",
663 "type": Attribute.ENUM,
664 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
668 "validation_function": validation.is_enum,
670 "min_reliability": dict({
671 "name": "minReliability",
672 "help": "Constrain reliability while picking PlanetLab nodes. Specifies a lower acceptable bound.",
673 "type": Attribute.DOUBLE,
675 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
676 "validation_function": validation.is_double,
678 "max_reliability": dict({
679 "name": "maxReliability",
680 "help": "Constrain reliability while picking PlanetLab nodes. Specifies an upper acceptable bound.",
681 "type": Attribute.DOUBLE,
683 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
684 "validation_function": validation.is_double,
686 "min_bandwidth": dict({
687 "name": "minBandwidth",
688 "help": "Constrain available bandwidth while picking PlanetLab nodes. Specifies a lower acceptable bound.",
689 "type": Attribute.DOUBLE,
691 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
692 "validation_function": validation.is_double,
694 "max_bandwidth": dict({
695 "name": "maxBandwidth",
696 "help": "Constrain available bandwidth while picking PlanetLab nodes. Specifies an upper acceptable bound.",
697 "type": Attribute.DOUBLE,
699 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
700 "validation_function": validation.is_double,
706 "type": Attribute.BOOL,
708 "validation_function": validation.is_bool
712 "help": "This is the primary interface for the attached node",
713 "type": Attribute.BOOL,
715 "validation_function": validation.is_bool
717 "device_name": dict({
719 "help": "Device name",
720 "type": Attribute.STRING,
721 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
722 "validation_function": validation.is_string
726 "help": "Maximum transmition unit for device",
727 "type": Attribute.INTEGER,
729 "validation_function": validation.is_integer_range(0,1500)
733 "help": "Network mask for the device (eg: 24 for /24 network)",
734 "type": Attribute.INTEGER,
735 "validation_function": validation.is_integer_range(8,24)
739 "help": "Enable SNAT (source NAT to the internet) no this device",
740 "type": Attribute.BOOL,
742 "validation_function": validation.is_bool
744 "pointopoint": dict({
745 "name": "pointopoint",
746 "help": "If the interface is a P2P link, the remote endpoint's IP "
747 "should be set on this attribute.",
748 "type": Attribute.STRING,
749 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
750 "validation_function": validation.is_string
754 "help": "Transmission queue length (in packets)",
755 "type": Attribute.INTEGER,
756 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
758 "validation_function": validation.is_integer
763 "help": "Command line string",
764 "type": Attribute.STRING,
765 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
766 "validation_function": validation.is_string
770 "help": "Run with root privileges",
771 "type": Attribute.BOOL,
772 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
774 "validation_function": validation.is_bool
778 "help": "Standard input",
779 "type": Attribute.STRING,
780 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
781 "validation_function": validation.is_string
786 "help": "Space-separated list of packages required to run the application",
787 "type": Attribute.STRING,
788 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
789 "validation_function": validation.is_string
791 "build-depends": dict({
792 "name": "buildDepends",
793 "help": "Space-separated list of packages required to build the application",
794 "type": Attribute.STRING,
795 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
796 "validation_function": validation.is_string
800 "help": "True if required packages can be found in the RpmFusion repository",
801 "type": Attribute.BOOL,
802 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
804 "validation_function": validation.is_bool
808 "help": "Space-separated list of regular files to be deployed in the working path prior to building. "
809 "Archives won't be expanded automatically.",
810 "type": Attribute.STRING,
811 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
812 "validation_function": validation.is_string
816 "help": "Build commands to execute after deploying the sources. "
817 "Sources will be in the ${SOURCES} folder. "
818 "Example: tar xzf ${SOURCES}/my-app.tgz && cd my-app && ./configure && make && make clean.\n"
819 "Try to make the commands return with a nonzero exit code on error.\n"
820 "Also, do not install any programs here, use the 'install' attribute. This will "
821 "help keep the built files constrained to the build folder (which may "
822 "not be the home folder), and will result in faster deployment. Also, "
823 "make sure to clean up temporary files, to reduce bandwidth usage between "
824 "nodes when transferring built packages.",
825 "type": Attribute.STRING,
826 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
827 "validation_function": validation.is_string
831 "help": "Commands to transfer built files to their final destinations. "
832 "Sources will be in the initial working folder, and a special "
833 "tag ${SOURCES} can be used to reference the experiment's "
834 "home folder (where the application commands will run).\n"
835 "ALL sources and targets needed for execution must be copied there, "
836 "if building has been enabled.\n"
837 "That is, 'slave' nodes will not automatically get any source files. "
838 "'slave' nodes don't get build dependencies either, so if you need "
839 "make and other tools to install, be sure to provide them as "
840 "actual dependencies instead.",
841 "type": Attribute.STRING,
842 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
843 "validation_function": validation.is_string
846 "netpipe_mode": dict({
848 "help": "Link mode:\n"
849 " * SERVER: applies to incoming connections\n"
850 " * CLIENT: applies to outgoing connections\n"
851 " * SERVICE: applies to both",
852 "type": Attribute.ENUM,
853 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
854 "allowed": ["SERVER",
857 "validation_function": validation.is_enum,
861 "help": "Port list or range. Eg: '22', '22,23,27', '20-2000'",
862 "type": Attribute.STRING,
863 "validation_function": is_portlist,
867 "help": "Address list or range. Eg: '127.0.0.1', '127.0.0.1,127.0.1.1', '127.0.0.1/8'",
868 "type": Attribute.STRING,
869 "validation_function": is_addrlist,
873 "help": "Inbound bandwidth limit (in Mbit/s)",
874 "type": Attribute.DOUBLE,
875 "validation_function": validation.is_double,
879 "help": "Outbound bandwidth limit (in Mbit/s)",
880 "type": Attribute.DOUBLE,
881 "validation_function": validation.is_double,
885 "help": "Inbound packet loss rate (0 = no loss, 1 = 100% loss)",
886 "type": Attribute.DOUBLE,
887 "validation_function": validation.is_double,
891 "help": "Outbound packet loss rate (0 = no loss, 1 = 100% loss)",
892 "type": Attribute.DOUBLE,
893 "validation_function": validation.is_double,
897 "help": "Inbound packet delay (in milliseconds)",
898 "type": Attribute.INTEGER,
900 "validation_function": validation.is_integer,
904 "help": "Outbound packet delay (in milliseconds)",
905 "type": Attribute.INTEGER,
907 "validation_function": validation.is_integer,
914 "help": "Standard output stream"
918 "help": "Application standard error",
922 "help": "Output of the build process",
925 "netpipe_stats": dict({
926 "name": "netpipeStats",
927 "help": "Information about rule match counters, packets dropped, etc.",
932 "help": "Detailled log of all packets going through the interface",
936 "help": "PCAP trace of all packets going through the interface",
940 create_order = [ INTERNET, NODE, NODEIFACE, TAPIFACE, TUNIFACE, NETPIPE, NEPIDEPENDENCY, NS3DEPENDENCY, DEPENDENCY, APPLICATION ]
942 configure_order = [ INTERNET, Parallel(NODE), NODEIFACE, Parallel(TAPIFACE), Parallel(TUNIFACE), NETPIPE, Parallel(NEPIDEPENDENCY), Parallel(NS3DEPENDENCY), Parallel(DEPENDENCY), Parallel(APPLICATION) ]
944 # Start (and prestart) node after ifaces, because the node needs the ifaces in order to set up routes
945 start_order = [ INTERNET, NODEIFACE, Parallel(TAPIFACE), Parallel(TUNIFACE), Parallel(NODE), NETPIPE, Parallel(NEPIDEPENDENCY), Parallel(NS3DEPENDENCY), Parallel(DEPENDENCY), Parallel(APPLICATION) ]
947 factories_info = dict({
949 "help": "Virtualized Node (V-Server style)",
950 "category": FC.CATEGORY_NODES,
951 "create_function": create_node,
952 "preconfigure_function": configure_node,
953 "prestart_function": configure_node_routes,
965 # NEPI-in-NEPI attributes
966 ATTR_NEPI_TESTBED_ENVIRONMENT_SETUP,
968 "connector_types": ["devs", "apps", "pipes", "deps"],
969 "tags": [tags.NODE, tags.ALLOW_ROUTES],
972 "help": "External network interface - they cannot be brought up or down, and they MUST be connected to the internet.",
973 "category": FC.CATEGORY_DEVICES,
974 "create_function": create_nodeiface,
975 "preconfigure_function": configure_nodeiface,
976 "box_attributes": [ ],
977 "connector_types": ["node", "inet"],
978 "tags": [tags.INTERFACE, tags.HAS_ADDRESSES],
981 "help": "Virtual TUN network interface (layer 3)",
982 "category": FC.CATEGORY_DEVICES,
983 "create_function": create_tuniface,
984 "preconfigure_function": preconfigure_tuniface,
985 "configure_function": postconfigure_tuniface,
986 "prestart_function": wait_tuniface,
988 "up", "device_name", "mtu", "snat", "pointopoint",
990 "tun_proto", "tun_addr", "tun_port", "tun_key"
992 "traces": ["packets", "pcap"],
993 "connector_types": ["node","udp","tcp","fd->"],
994 "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
997 "help": "Virtual TAP network interface (layer 2)",
998 "category": FC.CATEGORY_DEVICES,
999 "create_function": create_tapiface,
1000 "preconfigure_function": preconfigure_tuniface,
1001 "configure_function": postconfigure_tuniface,
1002 "prestart_function": wait_tuniface,
1004 "up", "device_name", "mtu", "snat", "pointopoint",
1006 "tun_proto", "tun_addr", "tun_port", "tun_key"
1008 "traces": ["packets", "pcap"],
1009 "connector_types": ["node","udp","tcp","fd->"],
1010 "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
1013 "help": "Generic executable command line application",
1014 "category": FC.CATEGORY_APPLICATIONS,
1015 "create_function": create_application,
1016 "start_function": start_application,
1017 "status_function": status_application,
1018 "stop_function": stop_application,
1019 "configure_function": configure_application,
1020 "box_attributes": ["command", "sudo", "stdin",
1021 "depends", "build-depends", "build", "install",
1022 "sources", "rpm-fusion" ],
1023 "connector_types": ["node"],
1024 "traces": ["stdout", "stderr", "buildlog"],
1025 "tags": [tags.APPLICATION],
1028 "help": "Requirement for package or application to be installed on some node",
1029 "category": FC.CATEGORY_APPLICATIONS,
1030 "create_function": create_dependency,
1031 "preconfigure_function": configure_dependency,
1032 "box_attributes": ["depends", "build-depends", "build", "install",
1033 "sources", "rpm-fusion" ],
1034 "connector_types": ["node"],
1035 "traces": ["buildlog"],
1037 NEPIDEPENDENCY: dict({
1038 "help": "Requirement for NEPI inside NEPI - required to run testbed instances inside a node",
1039 "category": FC.CATEGORY_APPLICATIONS,
1040 "create_function": create_nepi_dependency,
1041 "preconfigure_function": configure_dependency,
1042 "box_attributes": [],
1043 "connector_types": ["node"],
1044 "traces": ["buildlog"],
1046 NS3DEPENDENCY: dict({
1047 "help": "Requirement for NS3 inside NEPI - required to run NS3 testbed instances inside a node. It also needs NepiDependency.",
1048 "category": FC.CATEGORY_APPLICATIONS,
1049 "create_function": create_ns3_dependency,
1050 "preconfigure_function": configure_dependency,
1051 "box_attributes": [ ],
1052 "connector_types": ["node"],
1053 "traces": ["buildlog"],
1056 "help": "Internet routing",
1057 "category": FC.CATEGORY_CHANNELS,
1058 "create_function": create_internet,
1059 "connector_types": ["devs"],
1060 "tags": [tags.INTERNET],
1063 "help": "Link emulation",
1064 "category": FC.CATEGORY_CHANNELS,
1065 "create_function": create_netpipe,
1066 "configure_function": configure_netpipe,
1067 "box_attributes": ["netpipe_mode",
1068 "addr_list", "port_list",
1069 "bw_in","plr_in","delay_in",
1070 "bw_out","plr_out","delay_out"],
1071 "connector_types": ["node"],
1072 "traces": ["netpipe_stats"],
1076 testbed_attributes = dict({
1079 "help": "The name of the PlanetLab slice to use",
1080 "type": Attribute.STRING,
1081 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable | Attribute.NoDefaultValue,
1082 "validation_function": validation.is_string
1086 "help": "The name of the PlanetLab user to use for API calls - it must have at least a User role.",
1087 "type": Attribute.STRING,
1088 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable | Attribute.NoDefaultValue,
1089 "validation_function": validation.is_string
1093 "help": "The PlanetLab user's password.",
1094 "type": Attribute.STRING,
1095 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable | Attribute.NoDefaultValue,
1096 "validation_function": validation.is_string
1100 "help": "The PlanetLab PLC API host",
1101 "type": Attribute.STRING,
1102 "value": "www.planet-lab.eu",
1103 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1104 "validation_function": validation.is_string
1108 "help": "The PlanetLab PLC API url pattern - %(hostname)s is replaced by plcHost.",
1109 "type": Attribute.STRING,
1110 "value": "https://%(hostname)s:443/PLCAPI/",
1111 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1112 "validation_function": validation.is_string
1114 "p2p_deployment": dict({
1115 "name": "p2pDeployment",
1116 "help": "Enable peer-to-peer deployment of applications and dependencies. "
1117 "When enabled, dependency packages and applications are "
1118 "deployed in a P2P fashion, picking a single node to do "
1119 "the building or repo download, while all the others "
1120 "cooperatively exchange resulting binaries or rpms. "
1121 "When deploying to many nodes, this is a far more efficient "
1122 "use of resources. It does require re-encrypting and distributing "
1123 "the slice's private key. Though it is implemented in a secure "
1124 "fashion, if they key's sole purpose is not PlanetLab, then this "
1125 "feature should be disabled.",
1126 "type": Attribute.BOOL,
1128 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable,
1129 "validation_function": validation.is_bool
1131 "slice_ssh_key": dict({
1132 "name": "sliceSSHKey",
1133 "help": "The controller-local path to the slice user's ssh private key. "
1134 "It is the user's responsability to deploy this file where the controller "
1135 "will run, it won't be done automatically because it's sensitive information. "
1136 "It is recommended that a NEPI-specific user be created for this purpose and "
1137 "this purpose alone.",
1138 "type": Attribute.STRING,
1139 "flags": Attribute.ExecReadOnly | Attribute.ExecImmutable | Attribute.NoDefaultValue,
1140 "validation_function": validation.is_string
1142 "pl_log_level": dict({
1143 "name": "plLogLevel",
1144 "help": "Verbosity of logging of planetlab events.",
1146 "type": Attribute.ENUM,
1147 "allowed": ["DEBUG",
1152 "validation_function": validation.is_enum,
1154 "tap_port_base": dict({
1155 "name": "tapPortBase",
1156 "help": "Base port to use when connecting TUN/TAPs. Effective port will be BASE + GUID.",
1157 "type": Attribute.INTEGER,
1159 "range": (2000,30000),
1160 "validation_function": validation.is_integer_range(2000,30000)
1164 supported_recovery_policies = [
1170 class MetadataInfo(metadata.MetadataInfo):
1172 def connector_types(self):
1173 return connector_types
1176 def connections(self):
1180 def attributes(self):
1188 def create_order(self):
1192 def configure_order(self):
1193 return configure_order
1196 def prestart_order(self):
1200 def start_order(self):
1204 def factories_info(self):
1205 return factories_info
1208 def testbed_attributes(self):
1209 return testbed_attributes
1212 def testbed_id(self):
1216 def testbed_version(self):
1217 return TESTBED_VERSION
1220 def supported_recovery_policies(self):
1221 return supported_recovery_policies