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, value):
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, "node", "devs")
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 testbed_instance.elements[guid] = element
177 def create_nodeiface(testbed_instance, guid):
178 parameters = testbed_instance._get_parameters(guid)
179 element = testbed_instance._make_node_iface(parameters)
180 testbed_instance.elements[guid] = element
182 def create_tuniface(testbed_instance, guid):
183 parameters = testbed_instance._get_parameters(guid)
184 element = testbed_instance._make_tun_iface(parameters)
186 # Set custom addresses, if there are any already
187 # Setting this early helps set up P2P links
188 if guid in testbed_instance._add_address and not (element.address or element.netmask or element.netprefix):
189 addresses = testbed_instance._add_address[guid]
190 for address in addresses:
191 (address, netprefix, broadcast) = address
192 element.add_address(address, netprefix, broadcast)
194 testbed_instance.elements[guid] = element
196 def create_tapiface(testbed_instance, guid):
197 parameters = testbed_instance._get_parameters(guid)
198 element = testbed_instance._make_tap_iface(parameters)
200 # Set custom addresses, if there are any already
201 # Setting this early helps set up P2P links
202 if guid in testbed_instance._add_address and not (element.address or element.netmask or element.netprefix):
203 addresses = testbed_instance._add_address[guid]
204 for address in addresses:
205 (address, netprefix, broadcast) = address
206 element.add_address(address, netprefix, broadcast)
208 testbed_instance.elements[guid] = element
210 def create_application(testbed_instance, guid):
211 parameters = testbed_instance._get_parameters(guid)
212 element = testbed_instance._make_application(parameters)
214 # Just inject configuration stuff
215 element.home_path = "nepi-app-%s" % (guid,)
217 testbed_instance.elements[guid] = element
219 def create_dependency(testbed_instance, guid):
220 parameters = testbed_instance._get_parameters(guid)
221 element = testbed_instance._make_dependency(parameters)
223 # Just inject configuration stuff
224 element.home_path = "nepi-dep-%s" % (guid,)
226 testbed_instance.elements[guid] = element
228 def create_nepi_dependency(testbed_instance, guid):
229 parameters = testbed_instance._get_parameters(guid)
230 element = testbed_instance._make_nepi_dependency(parameters)
232 # Just inject configuration stuff
233 element.home_path = "nepi-nepi-%s" % (guid,)
235 testbed_instance.elements[guid] = element
237 def create_ns3_dependency(testbed_instance, guid):
238 parameters = testbed_instance._get_parameters(guid)
239 element = testbed_instance._make_ns3_dependency(parameters)
241 # Just inject configuration stuff
242 element.home_path = "nepi-ns3-%s" % (guid,)
244 testbed_instance.elements[guid] = element
246 def create_internet(testbed_instance, guid):
247 parameters = testbed_instance._get_parameters(guid)
248 element = testbed_instance._make_internet(parameters)
249 testbed_instance.elements[guid] = element
251 def create_netpipe(testbed_instance, guid):
252 parameters = testbed_instance._get_parameters(guid)
253 element = testbed_instance._make_netpipe(parameters)
254 testbed_instance.elements[guid] = element
256 ### Start/Stop functions ###
258 def start_application(testbed_instance, guid):
259 parameters = testbed_instance._get_parameters(guid)
260 traces = testbed_instance._get_traces(guid)
261 app = testbed_instance.elements[guid]
263 app.stdout = "stdout" in traces
264 app.stderr = "stderr" in traces
265 app.buildlog = "buildlog" in traces
269 def stop_application(testbed_instance, guid):
270 app = testbed_instance.elements[guid]
273 ### Status functions ###
275 def status_application(testbed_instance, guid):
276 if guid not in testbed_instance.elements.keys():
277 return STATUS_NOT_STARTED
279 app = testbed_instance.elements[guid]
282 ### Configure functions ###
284 def configure_nodeiface(testbed_instance, guid):
285 element = testbed_instance._elements[guid]
287 # Cannot explicitly configure addresses
288 if guid in testbed_instance._add_address:
289 raise ValueError, "Cannot explicitly set address of public PlanetLab interface"
292 node_guid = testbed_instance.get_connected(guid, "node", "devs")[0]
293 dev_guids = testbed_instance.get_connected(node_guid, "node", "devs")
294 siblings = [ self._element[dev_guid]
295 for dev_guid in dev_guids
296 if dev_guid != guid ]
298 # Fetch address from PLC api
299 element.pick_iface(siblings)
301 # Do some validations
304 def preconfigure_tuniface(testbed_instance, guid):
305 element = testbed_instance._elements[guid]
307 # Set custom addresses if any, and if not set already
308 if guid in testbed_instance._add_address and not (element.address or element.netmask or element.netprefix):
309 addresses = testbed_instance._add_address[guid]
310 for address in addresses:
311 (address, netprefix, broadcast) = address
312 element.add_address(address, netprefix, broadcast)
314 # Link to external interface, if any
315 for iface in testbed_instance._elements.itervalues():
316 if isinstance(iface, testbed_instance._interfaces.NodeIface) and iface.node is element.node and iface.has_internet:
317 element.external_iface = iface
320 # Set standard TUN attributes
321 if (not element.tun_addr or not element.tun_port) and element.external_iface:
322 element.tun_addr = element.external_iface.address
323 element.tun_port = 15000 + int(guid)
326 traces = testbed_instance._get_traces(guid)
327 element.capture = 'packets' in traces
329 # Do some validations
333 if element.peer_proto:
334 if element.peer_iface and isinstance(element.peer_iface, testbed_instance._interfaces.TunIface):
336 listening = id(element) < id(element.peer_iface)
339 if not element.tun_addr or not element.tun_port:
341 elif not element.peer_addr or not element.peer_port:
344 # both have addresses...
345 # ...the one with the lesser address listens
346 listening = element.tun_addr < element.peer_addr
351 def postconfigure_tuniface(testbed_instance, guid):
352 element = testbed_instance._elements[guid]
357 def wait_tuniface(testbed_instance, guid):
358 element = testbed_instance._elements[guid]
361 element.async_launch_wait()
364 def configure_node(testbed_instance, guid):
365 node = testbed_instance._elements[guid]
367 # Just inject configuration stuff
368 node.home_path = "nepi-node-%s" % (guid,)
369 node.ident_path = testbed_instance.sliceSSHKey
370 node.slicename = testbed_instance.slicename
372 # Do some validations
375 # recently provisioned nodes may not be up yet
377 while not node.is_alive():
378 time.sleep(sleeptime)
379 sleeptime = min(30.0, sleeptime*1.5)
381 # this will be done in parallel in all nodes
382 # this call only spawns the process
383 node.install_dependencies()
385 def configure_node_routes(testbed_instance, guid):
386 node = testbed_instance._elements[guid]
387 routes = testbed_instance._add_route.get(guid)
391 for dev_guid in testbed_instance.get_connected(guid, "devs", "node")
392 for dev in ( testbed_instance._elements.get(dev_guid) ,)
393 if dev and isinstance(dev, testbed_instance._interfaces.TunIface) ]
395 node.configure_routes(routes, devs)
397 def configure_application(testbed_instance, guid):
398 app = testbed_instance._elements[guid]
400 # Do some validations
403 # Wait for dependencies
404 app.node.wait_dependencies()
409 def configure_dependency(testbed_instance, guid):
410 dep = testbed_instance._elements[guid]
412 # Do some validations
415 # Wait for dependencies
416 dep.node.wait_dependencies()
421 def configure_netpipe(testbed_instance, guid):
422 netpipe = testbed_instance._elements[guid]
424 # Do some validations
427 # Wait for dependencies
428 netpipe.node.wait_dependencies()
433 ### Factory information ###
435 connector_types = dict({
437 "help": "Connector from node to applications",
443 "help": "Connector from node to network interfaces",
449 "help": "Connector from node to application dependencies "
450 "(packages and applications that need to be installed)",
456 "help": "Connector from network interfaces to the internet",
462 "help": "Connector to a Node",
468 "help": "Connector to a NetPipe",
475 "help": "ip-ip tunneling over TCP link",
481 "help": "ip-ip tunneling over UDP datagrams",
487 "help": "TUN device file descriptor provider",
496 "from": (TESTBED_ID, NODE, "devs"),
497 "to": (TESTBED_ID, NODEIFACE, "node"),
498 "init_code": connect_node_iface_node,
502 "from": (TESTBED_ID, NODE, "devs"),
503 "to": (TESTBED_ID, TUNIFACE, "node"),
504 "init_code": connect_tun_iface_node,
508 "from": (TESTBED_ID, NODE, "devs"),
509 "to": (TESTBED_ID, TAPIFACE, "node"),
510 "init_code": connect_tun_iface_node,
514 "from": (TESTBED_ID, NODEIFACE, "inet"),
515 "to": (TESTBED_ID, INTERNET, "devs"),
516 "init_code": connect_node_iface_inet,
520 "from": (TESTBED_ID, NODE, "apps"),
521 "to": (TESTBED_ID, APPLICATION, "node"),
522 "init_code": connect_dep,
526 "from": (TESTBED_ID, NODE, "deps"),
527 "to": (TESTBED_ID, DEPENDENCY, "node"),
528 "init_code": connect_dep,
532 "from": (TESTBED_ID, NODE, "deps"),
533 "to": (TESTBED_ID, NEPIDEPENDENCY, "node"),
534 "init_code": connect_dep,
538 "from": (TESTBED_ID, NODE, "deps"),
539 "to": (TESTBED_ID, NS3DEPENDENCY, "node"),
540 "init_code": connect_dep,
544 "from": (TESTBED_ID, NODE, "pipes"),
545 "to": (TESTBED_ID, NETPIPE, "node"),
546 "init_code": connect_node_netpipe,
550 "from": (TESTBED_ID, TUNIFACE, "tcp"),
551 "to": (TESTBED_ID, TUNIFACE, "tcp"),
552 "init_code": functools.partial(connect_tun_iface_peer,"tcp"),
556 "from": (TESTBED_ID, TUNIFACE, "udp"),
557 "to": (TESTBED_ID, TUNIFACE, "udp"),
558 "init_code": functools.partial(connect_tun_iface_peer,"udp"),
562 "from": (TESTBED_ID, TAPIFACE, "tcp"),
563 "to": (TESTBED_ID, TAPIFACE, "tcp"),
564 "init_code": functools.partial(connect_tun_iface_peer,"tcp"),
568 "from": (TESTBED_ID, TAPIFACE, "udp"),
569 "to": (TESTBED_ID, TAPIFACE, "udp"),
570 "init_code": functools.partial(connect_tun_iface_peer,"udp"),
574 "from": (TESTBED_ID, TUNIFACE, "tcp"),
575 "to": (None, None, "tcp"),
576 "init_code": functools.partial(crossconnect_tun_iface_peer_init,"tcp"),
577 "compl_code": functools.partial(crossconnect_tun_iface_peer_compl,"tcp"),
581 "from": (TESTBED_ID, TUNIFACE, "udp"),
582 "to": (None, None, "udp"),
583 "init_code": functools.partial(crossconnect_tun_iface_peer_init,"udp"),
584 "compl_code": functools.partial(crossconnect_tun_iface_peer_compl,"udp"),
588 "from": (TESTBED_ID, TUNIFACE, "fd->"),
589 "to": (None, None, "->fd"),
590 "compl_code": functools.partial(crossconnect_tun_iface_peer_both,"fd"),
594 "from": (TESTBED_ID, TAPIFACE, "tcp"),
595 "to": (None, None, "tcp"),
596 "init_code": functools.partial(crossconnect_tun_iface_peer_init,"tcp"),
597 "compl_code": functools.partial(crossconnect_tun_iface_peer_compl,"tcp"),
601 "from": (TESTBED_ID, TAPIFACE, "udp"),
602 "to": (None, None, "udp"),
603 "init_code": functools.partial(crossconnect_tun_iface_peer_init,"udp"),
604 "compl_code": functools.partial(crossconnect_tun_iface_peer_compl,"udp"),
608 "from": (TESTBED_ID, TAPIFACE, "fd->"),
609 "to": (None, None, "->fd"),
610 "compl_code": functools.partial(crossconnect_tun_iface_peer_both,"fd"),
616 "forward_X11": dict({
617 "name": "forward_X11",
618 "help": "Forward x11 from main namespace to the node",
619 "type": Attribute.BOOL,
621 "flags": Attribute.DesignOnly,
622 "validation_function": validation.is_bool,
626 "help": "Constrain hostname during resource discovery. May use wildcards.",
627 "type": Attribute.STRING,
628 "flags": Attribute.DesignOnly,
629 "validation_function": validation.is_string,
631 "architecture": dict({
632 "name": "architecture",
633 "help": "Constrain architexture during resource discovery.",
634 "type": Attribute.ENUM,
635 "flags": Attribute.DesignOnly,
636 "allowed": ["x86_64",
638 "validation_function": validation.is_enum,
640 "operating_system": dict({
641 "name": "operatingSystem",
642 "help": "Constrain operating system during resource discovery.",
643 "type": Attribute.ENUM,
644 "flags": Attribute.DesignOnly,
650 "validation_function": validation.is_enum,
654 "help": "Constrain the PlanetLab site this node should reside on.",
655 "type": Attribute.ENUM,
656 "flags": Attribute.DesignOnly,
660 "validation_function": validation.is_enum,
664 "help": "Enable emulation on this node. Enables NetfilterRoutes, bridges, and a host of other functionality.",
665 "type": Attribute.BOOL,
667 "flags": Attribute.DesignOnly,
668 "validation_function": validation.is_bool,
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.DesignOnly,
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.DesignOnly,
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.DesignOnly,
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.DesignOnly,
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.DesignOnly,
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.DesignOnly,
750 "validation_function": validation.is_string
754 "help": "Transmission queue length (in packets)",
755 "type": Attribute.INTEGER,
756 "flags": Attribute.DesignOnly,
758 "validation_function": validation.is_integer
763 "help": "Command line string",
764 "type": Attribute.STRING,
765 "flags": Attribute.DesignOnly,
766 "validation_function": validation.is_string
770 "help": "Run with root privileges",
771 "type": Attribute.BOOL,
772 "flags": Attribute.DesignOnly,
774 "validation_function": validation.is_bool
778 "help": "Standard input",
779 "type": Attribute.STRING,
780 "flags": Attribute.DesignOnly,
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.DesignOnly,
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.DesignOnly,
796 "validation_function": validation.is_string
800 "help": "Space-separated list of regular files to be deployed in the working path prior to building. "
801 "Archives won't be expanded automatically.",
802 "type": Attribute.STRING,
803 "flags": Attribute.DesignOnly,
804 "validation_function": validation.is_string
808 "help": "Build commands to execute after deploying the sources. "
809 "Sources will be in the ${SOURCES} folder. "
810 "Example: tar xzf ${SOURCES}/my-app.tgz && cd my-app && ./configure && make && make clean.\n"
811 "Try to make the commands return with a nonzero exit code on error.\n"
812 "Also, do not install any programs here, use the 'install' attribute. This will "
813 "help keep the built files constrained to the build folder (which may "
814 "not be the home folder), and will result in faster deployment. Also, "
815 "make sure to clean up temporary files, to reduce bandwidth usage between "
816 "nodes when transferring built packages.",
817 "type": Attribute.STRING,
818 "flags": Attribute.DesignOnly,
819 "validation_function": validation.is_string
823 "help": "Commands to transfer built files to their final destinations. "
824 "Sources will be in the initial working folder, and a special "
825 "tag ${SOURCES} can be used to reference the experiment's "
826 "home folder (where the application commands will run).\n"
827 "ALL sources and targets needed for execution must be copied there, "
828 "if building has been enabled.\n"
829 "That is, 'slave' nodes will not automatically get any source files. "
830 "'slave' nodes don't get build dependencies either, so if you need "
831 "make and other tools to install, be sure to provide them as "
832 "actual dependencies instead.",
833 "type": Attribute.STRING,
834 "flags": Attribute.DesignOnly,
835 "validation_function": validation.is_string
838 "netpipe_mode": dict({
840 "help": "Link mode:\n"
841 " * SERVER: applies to incoming connections\n"
842 " * CLIENT: applies to outgoing connections\n"
843 " * SERVICE: applies to both",
844 "type": Attribute.ENUM,
845 "flags": Attribute.DesignOnly,
846 "allowed": ["SERVER",
849 "validation_function": validation.is_enum,
853 "help": "Port list or range. Eg: '22', '22,23,27', '20-2000'",
854 "type": Attribute.STRING,
855 "validation_function": is_portlist,
859 "help": "Address list or range. Eg: '127.0.0.1', '127.0.0.1,127.0.1.1', '127.0.0.1/8'",
860 "type": Attribute.STRING,
861 "validation_function": is_addrlist,
865 "help": "Inbound bandwidth limit (in Mbit/s)",
866 "type": Attribute.DOUBLE,
867 "validation_function": validation.is_double,
871 "help": "Outbound bandwidth limit (in Mbit/s)",
872 "type": Attribute.DOUBLE,
873 "validation_function": validation.is_double,
877 "help": "Inbound packet loss rate (0 = no loss, 1 = 100% loss)",
878 "type": Attribute.DOUBLE,
879 "validation_function": validation.is_double,
883 "help": "Outbound packet loss rate (0 = no loss, 1 = 100% loss)",
884 "type": Attribute.DOUBLE,
885 "validation_function": validation.is_double,
889 "help": "Inbound packet delay (in milliseconds)",
890 "type": Attribute.INTEGER,
892 "validation_function": validation.is_integer,
896 "help": "Outbound packet delay (in milliseconds)",
897 "type": Attribute.INTEGER,
899 "validation_function": validation.is_integer,
906 "help": "Standard output stream"
910 "help": "Application standard error",
914 "help": "Output of the build process",
917 "netpipe_stats": dict({
918 "name": "netpipeStats",
919 "help": "Information about rule match counters, packets dropped, etc.",
924 "help": "Detailled log of all packets going through the interface",
928 create_order = [ INTERNET, NODE, NODEIFACE, TAPIFACE, TUNIFACE, NETPIPE, NEPIDEPENDENCY, NS3DEPENDENCY, DEPENDENCY, APPLICATION ]
930 configure_order = [ INTERNET, NODE, NODEIFACE, TAPIFACE, TUNIFACE, NETPIPE, NEPIDEPENDENCY, NS3DEPENDENCY, DEPENDENCY, APPLICATION ]
932 # Start (and prestart) node after ifaces, because the node needs the ifaces in order to set up routes
933 start_order = [ INTERNET, NODEIFACE, TAPIFACE, TUNIFACE, NODE, NETPIPE, NEPIDEPENDENCY, NS3DEPENDENCY, DEPENDENCY, APPLICATION ]
935 factories_info = dict({
937 "allow_routes": True,
938 "help": "Virtualized Node (V-Server style)",
939 "category": "topology",
940 "create_function": create_node,
941 "preconfigure_function": configure_node,
942 "prestart_function": configure_node_routes,
955 # NEPI-in-NEPI attributes
956 ATTR_NEPI_TESTBED_ENVIRONMENT_SETUP,
958 "connector_types": ["devs", "apps", "pipes", "deps"]
961 "has_addresses": True,
962 "help": "External network interface - they cannot be brought up or down, and they MUST be connected to the internet.",
963 "category": "devices",
964 "create_function": create_nodeiface,
965 "preconfigure_function": configure_nodeiface,
966 "box_attributes": [ ],
967 "connector_types": ["node", "inet"]
970 "allow_addresses": True,
971 "help": "Virtual TUN network interface (layer 3)",
972 "category": "devices",
973 "create_function": create_tuniface,
974 "preconfigure_function": preconfigure_tuniface,
975 "configure_function": postconfigure_tuniface,
976 "prestart_function": wait_tuniface,
978 "up", "device_name", "mtu", "snat", "pointopoint",
980 "tun_proto", "tun_addr", "tun_port", "tun_key"
982 "traces": ["packets"],
983 "connector_types": ["node","udp","tcp","fd->"]
986 "allow_addresses": True,
987 "help": "Virtual TAP network interface (layer 2)",
988 "category": "devices",
989 "create_function": create_tapiface,
990 "preconfigure_function": preconfigure_tuniface,
991 "configure_function": postconfigure_tuniface,
992 "prestart_function": wait_tuniface,
994 "up", "device_name", "mtu", "snat", "pointopoint",
996 "tun_proto", "tun_addr", "tun_port", "tun_key"
998 "traces": ["packets"],
999 "connector_types": ["node","udp","tcp","fd->"]
1002 "help": "Generic executable command line application",
1003 "category": "applications",
1004 "create_function": create_application,
1005 "start_function": start_application,
1006 "status_function": status_application,
1007 "stop_function": stop_application,
1008 "configure_function": configure_application,
1009 "box_attributes": ["command", "sudo", "stdin",
1010 "depends", "build-depends", "build", "install",
1012 "connector_types": ["node"],
1013 "traces": ["stdout", "stderr", "buildlog"]
1016 "help": "Requirement for package or application to be installed on some node",
1017 "category": "applications",
1018 "create_function": create_dependency,
1019 "preconfigure_function": configure_dependency,
1020 "box_attributes": ["depends", "build-depends", "build", "install",
1022 "connector_types": ["node"],
1023 "traces": ["buildlog"]
1025 NEPIDEPENDENCY: dict({
1026 "help": "Requirement for NEPI inside NEPI - required to run testbed instances inside a node",
1027 "category": "applications",
1028 "create_function": create_nepi_dependency,
1029 "preconfigure_function": configure_dependency,
1030 "box_attributes": [ ],
1031 "connector_types": ["node"],
1032 "traces": ["buildlog"]
1034 NS3DEPENDENCY: dict({
1035 "help": "Requirement for NS3 inside NEPI - required to run NS3 testbed instances inside a node. It also needs NepiDependency.",
1036 "category": "applications",
1037 "create_function": create_ns3_dependency,
1038 "preconfigure_function": configure_dependency,
1039 "box_attributes": [ ],
1040 "connector_types": ["node"],
1041 "traces": ["buildlog"]
1044 "help": "Internet routing",
1045 "category": "topology",
1046 "create_function": create_internet,
1047 "connector_types": ["devs"],
1050 "help": "Link emulation",
1051 "category": "topology",
1052 "create_function": create_netpipe,
1053 "configure_function": configure_netpipe,
1054 "box_attributes": ["netpipe_mode",
1055 "addr_list", "port_list",
1056 "bw_in","plr_in","delay_in",
1057 "bw_out","plr_out","delay_out"],
1058 "connector_types": ["node"],
1059 "traces": ["netpipe_stats"]
1063 testbed_attributes = dict({
1066 "help": "The name of the PlanetLab slice to use",
1067 "type": Attribute.STRING,
1068 "flags": Attribute.DesignOnly | Attribute.HasNoDefaultValue,
1069 "validation_function": validation.is_string
1073 "help": "The name of the PlanetLab user to use for API calls - it must have at least a User role.",
1074 "type": Attribute.STRING,
1075 "flags": Attribute.DesignOnly | Attribute.HasNoDefaultValue,
1076 "validation_function": validation.is_string
1080 "help": "The PlanetLab user's password.",
1081 "type": Attribute.STRING,
1082 "flags": Attribute.DesignOnly | Attribute.HasNoDefaultValue,
1083 "validation_function": validation.is_string
1087 "help": "The PlanetLab PLC API host",
1088 "type": Attribute.STRING,
1089 "value": "www.planet-lab.eu",
1090 "flags": Attribute.DesignOnly,
1091 "validation_function": validation.is_string
1095 "help": "The PlanetLab PLC API url pattern - %(hostname)s is replaced by plcHost.",
1096 "type": Attribute.STRING,
1097 "value": "https://%(hostname)s:443/PLCAPI/",
1098 "flags": Attribute.DesignOnly,
1099 "validation_function": validation.is_string
1101 "slice_ssh_key": dict({
1102 "name": "sliceSSHKey",
1103 "help": "The controller-local path to the slice user's ssh private key. "
1104 "It is the user's responsability to deploy this file where the controller "
1105 "will run, it won't be done automatically because it's sensitive information. "
1106 "It is recommended that a NEPI-specific user be created for this purpose and "
1107 "this purpose alone.",
1108 "type": Attribute.STRING,
1109 "flags": Attribute.DesignOnly | Attribute.HasNoDefaultValue,
1110 "validation_function": validation.is_string
1114 class VersionedMetadataInfo(metadata.VersionedMetadataInfo):
1116 def connector_types(self):
1117 return connector_types
1120 def connections(self):
1124 def attributes(self):
1132 def create_order(self):
1136 def configure_order(self):
1137 return configure_order
1140 def prestart_order(self):
1144 def start_order(self):
1148 def factories_info(self):
1149 return factories_info
1152 def testbed_attributes(self):
1153 return testbed_attributes