2 # -*- coding: utf-8 -*-
6 from constants import TESTBED_ID
7 from nepi.core import metadata
8 from nepi.core.attributes import Attribute
9 from nepi.util import validation
10 from nepi.util.constants import STATUS_NOT_STARTED, STATUS_RUNNING, \
11 STATUS_FINISHED, ATTR_NEPI_TESTBED_ENVIRONMENT_SETUP
18 NODEIFACE = "NodeInterface"
19 TUNIFACE = "TunInterface"
20 TAPIFACE = "TapInterface"
21 APPLICATION = "Application"
22 DEPENDENCY = "Dependency"
23 NEPIDEPENDENCY = "NepiDependency"
24 NS3DEPENDENCY = "NS3Dependency"
28 PL_TESTBED_ID = "planetlab"
31 ### Custom validation functions ###
32 def is_addrlist(attribute, value):
33 if not validation.is_string(attribute, value):
40 components = value.split(',')
42 for component in components:
44 addr, mask = component.split('/',1)
46 addr, mask = component, '32'
48 if mask is not None and not (mask and mask.isdigit()):
49 # No empty or nonnumeric masks
52 if not validation.is_ip4_address(attribute, addr):
53 # Address part must be ipv4
58 def is_portlist(attribute, value):
59 if not validation.is_string(attribute, value):
66 components = value.split(',')
68 for component in components:
70 pfrom, pto = component.split('-',1)
72 pfrom = pto = component
74 if not pfrom or not pto or not pfrom.isdigit() or not pto.isdigit():
75 # No empty or nonnumeric ports
81 ### Connection functions ####
83 def connect_node_iface_node(testbed_instance, node_guid, iface_guid):
84 node = testbed_instance._elements[node_guid]
85 iface = testbed_instance._elements[iface_guid]
88 def connect_node_iface_inet(testbed_instance, iface_guid, inet_guid):
89 iface = testbed_instance._elements[iface_guid]
90 iface.has_internet = True
92 def connect_tun_iface_node(testbed_instance, node_guid, iface_guid):
93 node = testbed_instance._elements[node_guid]
94 iface = testbed_instance._elements[iface_guid]
95 if not node.emulation:
96 raise RuntimeError, "Use of TUN interfaces requires emulation"
98 node.required_vsys.update(('fd_tuntap', 'vif_up'))
99 node.required_packages.update(('python', 'python-crypto', 'python-setuptools', 'gcc'))
101 def connect_tun_iface_peer(proto, testbed_instance, iface_guid, peer_iface_guid):
102 iface = testbed_instance._elements[iface_guid]
103 peer_iface = testbed_instance._elements[peer_iface_guid]
104 iface.peer_iface = peer_iface
106 iface.tun_proto = proto
107 iface.tun_key = peer_iface.tun_key
109 def crossconnect_tun_iface_peer_init(proto, testbed_instance, iface_guid, peer_iface_data):
110 iface = testbed_instance._elements[iface_guid]
111 iface.peer_iface = None
112 iface.peer_addr = peer_iface_data.get("tun_addr")
113 iface.peer_proto = peer_iface_data.get("tun_proto") or proto
114 iface.peer_port = peer_iface_data.get("tun_port")
115 iface.tun_key = min(iface.tun_key, peer_iface_data.get("tun_key"))
116 iface.tun_proto = proto
118 preconfigure_tuniface(testbed_instance, iface_guid)
120 def crossconnect_tun_iface_peer_compl(proto, testbed_instance, iface_guid, peer_iface_data):
121 # refresh (refreshable) attributes for second-phase
122 iface = testbed_instance._elements[iface_guid]
123 iface.peer_addr = peer_iface_data.get("tun_addr")
124 iface.peer_proto = peer_iface_data.get("tun_proto") or proto
125 iface.peer_port = peer_iface_data.get("tun_port")
127 postconfigure_tuniface(testbed_instance, iface_guid)
129 def crossconnect_tun_iface_peer_both(proto, testbed_instance, iface_guid, peer_iface_data):
130 crossconnect_tun_iface_peer_init(proto, testbed_instance, iface_guid, peer_iface_data)
131 crossconnect_tun_iface_peer_compl(proto, testbed_instance, iface_guid, peer_iface_data)
133 def connect_dep(testbed_instance, node_guid, app_guid):
134 node = testbed_instance._elements[node_guid]
135 app = testbed_instance._elements[app_guid]
139 node.required_packages.update(set(
140 app.depends.split() ))
143 if app.home_path and app.home_path not in node.pythonpath:
144 node.pythonpath.append(app.home_path)
147 for envkey, envval in app.env.iteritems():
148 envval = app._replace_paths(envval)
149 node.env[envkey].append(envval)
151 def connect_node_netpipe(testbed_instance, node_guid, netpipe_guid):
152 node = testbed_instance._elements[node_guid]
153 netpipe = testbed_instance._elements[netpipe_guid]
154 if not node.emulation:
155 raise RuntimeError, "Use of NetPipes requires emulation"
159 ### Creation functions ###
161 def create_node(testbed_instance, guid):
162 parameters = testbed_instance._get_parameters(guid)
164 # create element with basic attributes
165 element = testbed_instance._make_node(parameters)
167 # add constraint on number of (real) interfaces
168 # by counting connected devices
169 dev_guids = testbed_instance.get_connected(guid, "devs", "node")
170 num_open_ifaces = sum( # count True values
171 NODEIFACE == testbed_instance._get_factory_id(guid)
172 for guid in dev_guids )
173 element.min_num_external_ifaces = num_open_ifaces
175 # require vroute vsys if we have routes to set up
176 routes = testbed_instance._add_route.get(guid)
178 element.required_vsys.add("vroute")
180 testbed_instance.elements[guid] = element
182 def create_nodeiface(testbed_instance, guid):
183 parameters = testbed_instance._get_parameters(guid)
184 element = testbed_instance._make_node_iface(parameters)
185 testbed_instance.elements[guid] = element
187 def create_tuniface(testbed_instance, guid):
188 parameters = testbed_instance._get_parameters(guid)
189 element = testbed_instance._make_tun_iface(parameters)
191 # Set custom addresses, if there are any already
192 # Setting this early helps set up P2P links
193 if guid in testbed_instance._add_address and not (element.address or element.netmask or element.netprefix):
194 addresses = testbed_instance._add_address[guid]
195 for address in addresses:
196 (address, netprefix, broadcast) = address
197 element.add_address(address, netprefix, broadcast)
199 testbed_instance.elements[guid] = element
201 def create_tapiface(testbed_instance, guid):
202 parameters = testbed_instance._get_parameters(guid)
203 element = testbed_instance._make_tap_iface(parameters)
205 # Set custom addresses, if there are any already
206 # Setting this early helps set up P2P links
207 if guid in testbed_instance._add_address and not (element.address or element.netmask or element.netprefix):
208 addresses = testbed_instance._add_address[guid]
209 for address in addresses:
210 (address, netprefix, broadcast) = address
211 element.add_address(address, netprefix, broadcast)
213 testbed_instance.elements[guid] = element
215 def create_application(testbed_instance, guid):
216 parameters = testbed_instance._get_parameters(guid)
217 element = testbed_instance._make_application(parameters)
219 # Just inject configuration stuff
220 element.home_path = "nepi-app-%s" % (guid,)
222 testbed_instance.elements[guid] = element
224 def create_dependency(testbed_instance, guid):
225 parameters = testbed_instance._get_parameters(guid)
226 element = testbed_instance._make_dependency(parameters)
228 # Just inject configuration stuff
229 element.home_path = "nepi-dep-%s" % (guid,)
231 testbed_instance.elements[guid] = element
233 def create_nepi_dependency(testbed_instance, guid):
234 parameters = testbed_instance._get_parameters(guid)
235 element = testbed_instance._make_nepi_dependency(parameters)
237 # Just inject configuration stuff
238 element.home_path = "nepi-nepi-%s" % (guid,)
240 testbed_instance.elements[guid] = element
242 def create_ns3_dependency(testbed_instance, guid):
243 parameters = testbed_instance._get_parameters(guid)
244 element = testbed_instance._make_ns3_dependency(parameters)
246 # Just inject configuration stuff
247 element.home_path = "nepi-ns3-%s" % (guid,)
249 testbed_instance.elements[guid] = element
251 def create_internet(testbed_instance, guid):
252 parameters = testbed_instance._get_parameters(guid)
253 element = testbed_instance._make_internet(parameters)
254 testbed_instance.elements[guid] = element
256 def create_netpipe(testbed_instance, guid):
257 parameters = testbed_instance._get_parameters(guid)
258 element = testbed_instance._make_netpipe(parameters)
259 testbed_instance.elements[guid] = element
261 ### Start/Stop functions ###
263 def start_application(testbed_instance, guid):
264 parameters = testbed_instance._get_parameters(guid)
265 traces = testbed_instance._get_traces(guid)
266 app = testbed_instance.elements[guid]
268 app.stdout = "stdout" in traces
269 app.stderr = "stderr" in traces
270 app.buildlog = "buildlog" in traces
274 def stop_application(testbed_instance, guid):
275 app = testbed_instance.elements[guid]
278 ### Status functions ###
280 def status_application(testbed_instance, guid):
281 if guid not in testbed_instance.elements.keys():
282 return STATUS_NOT_STARTED
284 app = testbed_instance.elements[guid]
287 ### Configure functions ###
289 def configure_nodeiface(testbed_instance, guid):
290 element = testbed_instance._elements[guid]
292 # Cannot explicitly configure addresses
293 if guid in testbed_instance._add_address:
294 raise ValueError, "Cannot explicitly set address of public PlanetLab interface"
297 node_guid = testbed_instance.get_connected(guid, "node", "devs")[0]
298 dev_guids = testbed_instance.get_connected(node_guid, "node", "devs")
299 siblings = [ self._element[dev_guid]
300 for dev_guid in dev_guids
301 if dev_guid != guid ]
303 # Fetch address from PLC api
304 element.pick_iface(siblings)
306 # Do some validations
309 def preconfigure_tuniface(testbed_instance, guid):
310 element = testbed_instance._elements[guid]
312 # Set custom addresses if any, and if not set already
313 if guid in testbed_instance._add_address and not (element.address or element.netmask or element.netprefix):
314 addresses = testbed_instance._add_address[guid]
315 for address in addresses:
316 (address, netprefix, broadcast) = address
317 element.add_address(address, netprefix, broadcast)
319 # Link to external interface, if any
320 for iface in testbed_instance._elements.itervalues():
321 if isinstance(iface, testbed_instance._interfaces.NodeIface) and iface.node is element.node and iface.has_internet:
322 element.external_iface = iface
325 # Set standard TUN attributes
326 if (not element.tun_addr or not element.tun_port) and element.external_iface:
327 element.tun_addr = element.external_iface.address
328 element.tun_port = 15000 + int(guid)
331 traces = testbed_instance._get_traces(guid)
332 element.capture = 'packets' in traces
334 # Do some validations
338 if element.peer_proto:
339 if element.peer_iface and isinstance(element.peer_iface, testbed_instance._interfaces.TunIface):
341 listening = id(element) < id(element.peer_iface)
344 if not element.tun_addr or not element.tun_port:
346 elif not element.peer_addr or not element.peer_port:
349 # both have addresses...
350 # ...the one with the lesser address listens
351 listening = element.tun_addr < element.peer_addr
356 def postconfigure_tuniface(testbed_instance, guid):
357 element = testbed_instance._elements[guid]
362 def wait_tuniface(testbed_instance, guid):
363 element = testbed_instance._elements[guid]
366 element.async_launch_wait()
369 def configure_node(testbed_instance, guid):
370 node = testbed_instance._elements[guid]
372 # Just inject configuration stuff
373 node.home_path = "nepi-node-%s" % (guid,)
374 node.ident_path = testbed_instance.sliceSSHKey
375 node.slicename = testbed_instance.slicename
377 # Do some validations
380 # this will be done in parallel in all nodes
381 # this call only spawns the process
382 node.install_dependencies()
384 def configure_node_routes(testbed_instance, guid):
385 node = testbed_instance._elements[guid]
386 routes = testbed_instance._add_route.get(guid)
390 for dev_guid in testbed_instance.get_connected(guid, "devs", "node")
391 for dev in ( testbed_instance._elements.get(dev_guid) ,)
392 if dev and isinstance(dev, testbed_instance._interfaces.TunIface) ]
394 node.configure_routes(routes, devs)
396 def configure_application(testbed_instance, guid):
397 app = testbed_instance._elements[guid]
399 # Do some validations
402 # Wait for dependencies
403 app.node.wait_dependencies()
408 def configure_dependency(testbed_instance, guid):
409 dep = testbed_instance._elements[guid]
411 # Do some validations
414 # Wait for dependencies
415 dep.node.wait_dependencies()
420 def configure_netpipe(testbed_instance, guid):
421 netpipe = testbed_instance._elements[guid]
423 # Do some validations
426 # Wait for dependencies
427 netpipe.node.wait_dependencies()
432 ### Factory information ###
434 connector_types = dict({
436 "help": "Connector from node to applications",
442 "help": "Connector from node to network interfaces",
448 "help": "Connector from node to application dependencies "
449 "(packages and applications that need to be installed)",
455 "help": "Connector from network interfaces to the internet",
461 "help": "Connector to a Node",
467 "help": "Connector to a NetPipe",
474 "help": "ip-ip tunneling over TCP link",
480 "help": "ip-ip tunneling over UDP datagrams",
486 "help": "TUN device file descriptor provider",
495 "from": (TESTBED_ID, NODE, "devs"),
496 "to": (TESTBED_ID, NODEIFACE, "node"),
497 "init_code": connect_node_iface_node,
501 "from": (TESTBED_ID, NODE, "devs"),
502 "to": (TESTBED_ID, TUNIFACE, "node"),
503 "init_code": connect_tun_iface_node,
507 "from": (TESTBED_ID, NODE, "devs"),
508 "to": (TESTBED_ID, TAPIFACE, "node"),
509 "init_code": connect_tun_iface_node,
513 "from": (TESTBED_ID, NODEIFACE, "inet"),
514 "to": (TESTBED_ID, INTERNET, "devs"),
515 "init_code": connect_node_iface_inet,
519 "from": (TESTBED_ID, NODE, "apps"),
520 "to": (TESTBED_ID, APPLICATION, "node"),
521 "init_code": connect_dep,
525 "from": (TESTBED_ID, NODE, "deps"),
526 "to": (TESTBED_ID, DEPENDENCY, "node"),
527 "init_code": connect_dep,
531 "from": (TESTBED_ID, NODE, "deps"),
532 "to": (TESTBED_ID, NEPIDEPENDENCY, "node"),
533 "init_code": connect_dep,
537 "from": (TESTBED_ID, NODE, "deps"),
538 "to": (TESTBED_ID, NS3DEPENDENCY, "node"),
539 "init_code": connect_dep,
543 "from": (TESTBED_ID, NODE, "pipes"),
544 "to": (TESTBED_ID, NETPIPE, "node"),
545 "init_code": connect_node_netpipe,
549 "from": (TESTBED_ID, TUNIFACE, "tcp"),
550 "to": (TESTBED_ID, TUNIFACE, "tcp"),
551 "init_code": functools.partial(connect_tun_iface_peer,"tcp"),
555 "from": (TESTBED_ID, TUNIFACE, "udp"),
556 "to": (TESTBED_ID, TUNIFACE, "udp"),
557 "init_code": functools.partial(connect_tun_iface_peer,"udp"),
561 "from": (TESTBED_ID, TAPIFACE, "tcp"),
562 "to": (TESTBED_ID, TAPIFACE, "tcp"),
563 "init_code": functools.partial(connect_tun_iface_peer,"tcp"),
567 "from": (TESTBED_ID, TAPIFACE, "udp"),
568 "to": (TESTBED_ID, TAPIFACE, "udp"),
569 "init_code": functools.partial(connect_tun_iface_peer,"udp"),
573 "from": (TESTBED_ID, TUNIFACE, "tcp"),
574 "to": (None, None, "tcp"),
575 "init_code": functools.partial(crossconnect_tun_iface_peer_init,"tcp"),
576 "compl_code": functools.partial(crossconnect_tun_iface_peer_compl,"tcp"),
580 "from": (TESTBED_ID, TUNIFACE, "udp"),
581 "to": (None, None, "udp"),
582 "init_code": functools.partial(crossconnect_tun_iface_peer_init,"udp"),
583 "compl_code": functools.partial(crossconnect_tun_iface_peer_compl,"udp"),
587 "from": (TESTBED_ID, TUNIFACE, "fd->"),
588 "to": (None, None, "->fd"),
589 "compl_code": functools.partial(crossconnect_tun_iface_peer_both,"fd"),
593 "from": (TESTBED_ID, TAPIFACE, "tcp"),
594 "to": (None, None, "tcp"),
595 "init_code": functools.partial(crossconnect_tun_iface_peer_init,"tcp"),
596 "compl_code": functools.partial(crossconnect_tun_iface_peer_compl,"tcp"),
600 "from": (TESTBED_ID, TAPIFACE, "udp"),
601 "to": (None, None, "udp"),
602 "init_code": functools.partial(crossconnect_tun_iface_peer_init,"udp"),
603 "compl_code": functools.partial(crossconnect_tun_iface_peer_compl,"udp"),
607 "from": (TESTBED_ID, TAPIFACE, "fd->"),
608 "to": (None, None, "->fd"),
609 "compl_code": functools.partial(crossconnect_tun_iface_peer_both,"fd"),
615 "forward_X11": dict({
616 "name": "forward_X11",
617 "help": "Forward x11 from main namespace to the node",
618 "type": Attribute.BOOL,
620 "flags": Attribute.DesignOnly,
621 "validation_function": validation.is_bool,
625 "help": "Constrain hostname during resource discovery. May use wildcards.",
626 "type": Attribute.STRING,
627 "flags": Attribute.DesignOnly,
628 "validation_function": validation.is_string,
630 "architecture": dict({
631 "name": "architecture",
632 "help": "Constrain architexture during resource discovery.",
633 "type": Attribute.ENUM,
634 "flags": Attribute.DesignOnly,
635 "allowed": ["x86_64",
637 "validation_function": validation.is_enum,
639 "operating_system": dict({
640 "name": "operatingSystem",
641 "help": "Constrain operating system during resource discovery.",
642 "type": Attribute.ENUM,
643 "flags": Attribute.DesignOnly,
649 "validation_function": validation.is_enum,
653 "help": "Constrain the PlanetLab site this node should reside on.",
654 "type": Attribute.ENUM,
655 "flags": Attribute.DesignOnly,
659 "validation_function": validation.is_enum,
663 "help": "Enable emulation on this node. Enables NetfilterRoutes, bridges, and a host of other functionality.",
664 "type": Attribute.BOOL,
666 "flags": Attribute.DesignOnly,
667 "validation_function": validation.is_bool,
669 "min_reliability": dict({
670 "name": "minReliability",
671 "help": "Constrain reliability while picking PlanetLab nodes. Specifies a lower acceptable bound.",
672 "type": Attribute.DOUBLE,
674 "flags": Attribute.DesignOnly,
675 "validation_function": validation.is_double,
677 "max_reliability": dict({
678 "name": "maxReliability",
679 "help": "Constrain reliability while picking PlanetLab nodes. Specifies an upper acceptable bound.",
680 "type": Attribute.DOUBLE,
682 "flags": Attribute.DesignOnly,
683 "validation_function": validation.is_double,
685 "min_bandwidth": dict({
686 "name": "minBandwidth",
687 "help": "Constrain available bandwidth while picking PlanetLab nodes. Specifies a lower acceptable bound.",
688 "type": Attribute.DOUBLE,
690 "flags": Attribute.DesignOnly,
691 "validation_function": validation.is_double,
693 "max_bandwidth": dict({
694 "name": "maxBandwidth",
695 "help": "Constrain available bandwidth while picking PlanetLab nodes. Specifies an upper acceptable bound.",
696 "type": Attribute.DOUBLE,
698 "flags": Attribute.DesignOnly,
699 "validation_function": validation.is_double,
705 "type": Attribute.BOOL,
707 "validation_function": validation.is_bool
711 "help": "This is the primary interface for the attached node",
712 "type": Attribute.BOOL,
714 "validation_function": validation.is_bool
716 "device_name": dict({
718 "help": "Device name",
719 "type": Attribute.STRING,
720 "flags": Attribute.DesignOnly,
721 "validation_function": validation.is_string
725 "help": "Maximum transmition unit for device",
726 "type": Attribute.INTEGER,
728 "validation_function": validation.is_integer_range(0,1500)
732 "help": "Network mask for the device (eg: 24 for /24 network)",
733 "type": Attribute.INTEGER,
734 "validation_function": validation.is_integer_range(8,24)
738 "help": "Enable SNAT (source NAT to the internet) no this device",
739 "type": Attribute.BOOL,
741 "validation_function": validation.is_bool
743 "pointopoint": dict({
744 "name": "pointopoint",
745 "help": "If the interface is a P2P link, the remote endpoint's IP "
746 "should be set on this attribute.",
747 "type": Attribute.STRING,
748 "flags": Attribute.DesignOnly,
749 "validation_function": validation.is_string
753 "help": "Transmission queue length (in packets)",
754 "type": Attribute.INTEGER,
755 "flags": Attribute.DesignOnly,
757 "validation_function": validation.is_integer
762 "help": "Command line string",
763 "type": Attribute.STRING,
764 "flags": Attribute.DesignOnly,
765 "validation_function": validation.is_string
769 "help": "Run with root privileges",
770 "type": Attribute.BOOL,
771 "flags": Attribute.DesignOnly,
773 "validation_function": validation.is_bool
777 "help": "Standard input",
778 "type": Attribute.STRING,
779 "flags": Attribute.DesignOnly,
780 "validation_function": validation.is_string
785 "help": "Space-separated list of packages required to run the application",
786 "type": Attribute.STRING,
787 "flags": Attribute.DesignOnly,
788 "validation_function": validation.is_string
790 "build-depends": dict({
791 "name": "buildDepends",
792 "help": "Space-separated list of packages required to build the application",
793 "type": Attribute.STRING,
794 "flags": Attribute.DesignOnly,
795 "validation_function": validation.is_string
799 "help": "Space-separated list of regular files to be deployed in the working path prior to building. "
800 "Archives won't be expanded automatically.",
801 "type": Attribute.STRING,
802 "flags": Attribute.DesignOnly,
803 "validation_function": validation.is_string
807 "help": "Build commands to execute after deploying the sources. "
808 "Sources will be in the ${SOURCES} folder. "
809 "Example: tar xzf ${SOURCES}/my-app.tgz && cd my-app && ./configure && make && make clean.\n"
810 "Try to make the commands return with a nonzero exit code on error.\n"
811 "Also, do not install any programs here, use the 'install' attribute. This will "
812 "help keep the built files constrained to the build folder (which may "
813 "not be the home folder), and will result in faster deployment. Also, "
814 "make sure to clean up temporary files, to reduce bandwidth usage between "
815 "nodes when transferring built packages.",
816 "type": Attribute.STRING,
817 "flags": Attribute.DesignOnly,
818 "validation_function": validation.is_string
822 "help": "Commands to transfer built files to their final destinations. "
823 "Sources will be in the initial working folder, and a special "
824 "tag ${SOURCES} can be used to reference the experiment's "
825 "home folder (where the application commands will run).\n"
826 "ALL sources and targets needed for execution must be copied there, "
827 "if building has been enabled.\n"
828 "That is, 'slave' nodes will not automatically get any source files. "
829 "'slave' nodes don't get build dependencies either, so if you need "
830 "make and other tools to install, be sure to provide them as "
831 "actual dependencies instead.",
832 "type": Attribute.STRING,
833 "flags": Attribute.DesignOnly,
834 "validation_function": validation.is_string
837 "netpipe_mode": dict({
839 "help": "Link mode:\n"
840 " * SERVER: applies to incoming connections\n"
841 " * CLIENT: applies to outgoing connections\n"
842 " * SERVICE: applies to both",
843 "type": Attribute.ENUM,
844 "flags": Attribute.DesignOnly,
845 "allowed": ["SERVER",
848 "validation_function": validation.is_enum,
852 "help": "Port list or range. Eg: '22', '22,23,27', '20-2000'",
853 "type": Attribute.STRING,
854 "validation_function": is_portlist,
858 "help": "Address list or range. Eg: '127.0.0.1', '127.0.0.1,127.0.1.1', '127.0.0.1/8'",
859 "type": Attribute.STRING,
860 "validation_function": is_addrlist,
864 "help": "Inbound bandwidth limit (in Mbit/s)",
865 "type": Attribute.DOUBLE,
866 "validation_function": validation.is_double,
870 "help": "Outbound bandwidth limit (in Mbit/s)",
871 "type": Attribute.DOUBLE,
872 "validation_function": validation.is_double,
876 "help": "Inbound packet loss rate (0 = no loss, 1 = 100% loss)",
877 "type": Attribute.DOUBLE,
878 "validation_function": validation.is_double,
882 "help": "Outbound packet loss rate (0 = no loss, 1 = 100% loss)",
883 "type": Attribute.DOUBLE,
884 "validation_function": validation.is_double,
888 "help": "Inbound packet delay (in milliseconds)",
889 "type": Attribute.INTEGER,
891 "validation_function": validation.is_integer,
895 "help": "Outbound packet delay (in milliseconds)",
896 "type": Attribute.INTEGER,
898 "validation_function": validation.is_integer,
905 "help": "Standard output stream"
909 "help": "Application standard error",
913 "help": "Output of the build process",
916 "netpipe_stats": dict({
917 "name": "netpipeStats",
918 "help": "Information about rule match counters, packets dropped, etc.",
923 "help": "Detailled log of all packets going through the interface",
927 create_order = [ INTERNET, NODE, NODEIFACE, TAPIFACE, TUNIFACE, NETPIPE, NEPIDEPENDENCY, NS3DEPENDENCY, DEPENDENCY, APPLICATION ]
929 configure_order = [ INTERNET, NODE, NODEIFACE, TAPIFACE, TUNIFACE, NETPIPE, NEPIDEPENDENCY, NS3DEPENDENCY, DEPENDENCY, APPLICATION ]
931 # Start (and prestart) node after ifaces, because the node needs the ifaces in order to set up routes
932 start_order = [ INTERNET, NODEIFACE, TAPIFACE, TUNIFACE, NODE, NETPIPE, NEPIDEPENDENCY, NS3DEPENDENCY, DEPENDENCY, APPLICATION ]
934 factories_info = dict({
936 "allow_routes": True,
937 "help": "Virtualized Node (V-Server style)",
938 "category": "topology",
939 "create_function": create_node,
940 "preconfigure_function": configure_node,
941 "prestart_function": configure_node_routes,
954 # NEPI-in-NEPI attributes
955 ATTR_NEPI_TESTBED_ENVIRONMENT_SETUP,
957 "connector_types": ["devs", "apps", "pipes", "deps"]
960 "has_addresses": True,
961 "help": "External network interface - they cannot be brought up or down, and they MUST be connected to the internet.",
962 "category": "devices",
963 "create_function": create_nodeiface,
964 "preconfigure_function": configure_nodeiface,
965 "box_attributes": [ ],
966 "connector_types": ["node", "inet"]
969 "allow_addresses": True,
970 "help": "Virtual TUN network interface (layer 3)",
971 "category": "devices",
972 "create_function": create_tuniface,
973 "preconfigure_function": preconfigure_tuniface,
974 "configure_function": postconfigure_tuniface,
975 "prestart_function": wait_tuniface,
977 "up", "device_name", "mtu", "snat", "pointopoint",
979 "tun_proto", "tun_addr", "tun_port", "tun_key"
981 "traces": ["packets"],
982 "connector_types": ["node","udp","tcp","fd->"]
985 "allow_addresses": True,
986 "help": "Virtual TAP network interface (layer 2)",
987 "category": "devices",
988 "create_function": create_tapiface,
989 "preconfigure_function": preconfigure_tuniface,
990 "configure_function": postconfigure_tuniface,
991 "prestart_function": wait_tuniface,
993 "up", "device_name", "mtu", "snat", "pointopoint",
995 "tun_proto", "tun_addr", "tun_port", "tun_key"
997 "traces": ["packets"],
998 "connector_types": ["node","udp","tcp","fd->"]
1001 "help": "Generic executable command line application",
1002 "category": "applications",
1003 "create_function": create_application,
1004 "start_function": start_application,
1005 "status_function": status_application,
1006 "stop_function": stop_application,
1007 "configure_function": configure_application,
1008 "box_attributes": ["command", "sudo", "stdin",
1009 "depends", "build-depends", "build", "install",
1011 "connector_types": ["node"],
1012 "traces": ["stdout", "stderr", "buildlog"]
1015 "help": "Requirement for package or application to be installed on some node",
1016 "category": "applications",
1017 "create_function": create_dependency,
1018 "preconfigure_function": configure_dependency,
1019 "box_attributes": ["depends", "build-depends", "build", "install",
1021 "connector_types": ["node"],
1022 "traces": ["buildlog"]
1024 NEPIDEPENDENCY: dict({
1025 "help": "Requirement for NEPI inside NEPI - required to run testbed instances inside a node",
1026 "category": "applications",
1027 "create_function": create_nepi_dependency,
1028 "preconfigure_function": configure_dependency,
1029 "box_attributes": [ ],
1030 "connector_types": ["node"],
1031 "traces": ["buildlog"]
1033 NS3DEPENDENCY: dict({
1034 "help": "Requirement for NS3 inside NEPI - required to run NS3 testbed instances inside a node. It also needs NepiDependency.",
1035 "category": "applications",
1036 "create_function": create_ns3_dependency,
1037 "preconfigure_function": configure_dependency,
1038 "box_attributes": [ ],
1039 "connector_types": ["node"],
1040 "traces": ["buildlog"]
1043 "help": "Internet routing",
1044 "category": "topology",
1045 "create_function": create_internet,
1046 "connector_types": ["devs"],
1049 "help": "Link emulation",
1050 "category": "topology",
1051 "create_function": create_netpipe,
1052 "configure_function": configure_netpipe,
1053 "box_attributes": ["netpipe_mode",
1054 "addr_list", "port_list",
1055 "bw_in","plr_in","delay_in",
1056 "bw_out","plr_out","delay_out"],
1057 "connector_types": ["node"],
1058 "traces": ["netpipe_stats"]
1062 testbed_attributes = dict({
1065 "help": "The name of the PlanetLab slice to use",
1066 "type": Attribute.STRING,
1067 "flags": Attribute.DesignOnly | Attribute.HasNoDefaultValue,
1068 "validation_function": validation.is_string
1072 "help": "The name of the PlanetLab user to use for API calls - it must have at least a User role.",
1073 "type": Attribute.STRING,
1074 "flags": Attribute.DesignOnly | Attribute.HasNoDefaultValue,
1075 "validation_function": validation.is_string
1079 "help": "The PlanetLab user's password.",
1080 "type": Attribute.STRING,
1081 "flags": Attribute.DesignOnly | Attribute.HasNoDefaultValue,
1082 "validation_function": validation.is_string
1086 "help": "The PlanetLab PLC API host",
1087 "type": Attribute.STRING,
1088 "value": "www.planet-lab.eu",
1089 "flags": Attribute.DesignOnly,
1090 "validation_function": validation.is_string
1094 "help": "The PlanetLab PLC API url pattern - %(hostname)s is replaced by plcHost.",
1095 "type": Attribute.STRING,
1096 "value": "https://%(hostname)s:443/PLCAPI/",
1097 "flags": Attribute.DesignOnly,
1098 "validation_function": validation.is_string
1100 "slice_ssh_key": dict({
1101 "name": "sliceSSHKey",
1102 "help": "The controller-local path to the slice user's ssh private key. "
1103 "It is the user's responsability to deploy this file where the controller "
1104 "will run, it won't be done automatically because it's sensitive information. "
1105 "It is recommended that a NEPI-specific user be created for this purpose and "
1106 "this purpose alone.",
1107 "type": Attribute.STRING,
1108 "flags": Attribute.DesignOnly | Attribute.HasNoDefaultValue,
1109 "validation_function": validation.is_string
1113 class VersionedMetadataInfo(metadata.VersionedMetadataInfo):
1115 def connector_types(self):
1116 return connector_types
1119 def connections(self):
1123 def attributes(self):
1131 def create_order(self):
1135 def configure_order(self):
1136 return configure_order
1139 def prestart_order(self):
1143 def start_order(self):
1147 def factories_info(self):
1148 return factories_info
1151 def testbed_attributes(self):
1152 return testbed_attributes