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 tags, validation
10 from nepi.util.constants import ApplicationStatus as AS, \
11 FactoryCategories as FC, \
12 ATTR_NEPI_TESTBED_ENVIRONMENT_SETUP
19 NODEIFACE = "NodeInterface"
20 TUNIFACE = "TunInterface"
21 TAPIFACE = "TapInterface"
22 APPLICATION = "Application"
23 DEPENDENCY = "Dependency"
24 NEPIDEPENDENCY = "NepiDependency"
25 NS3DEPENDENCY = "NS3Dependency"
29 PL_TESTBED_ID = "planetlab"
32 ### Custom validation functions ###
33 def is_addrlist(attribute, value):
34 if not validation.is_string(attribute, value):
41 components = value.split(',')
43 for component in components:
45 addr, mask = component.split('/',1)
47 addr, mask = component, '32'
49 if mask is not None and not (mask and mask.isdigit()):
50 # No empty or nonnumeric masks
53 if not validation.is_ip4_address(attribute, addr):
54 # Address part must be ipv4
59 def is_portlist(attribute, value):
60 if not validation.is_string(attribute, value):
67 components = value.split(',')
69 for component in components:
71 pfrom, pto = component.split('-',1)
73 pfrom = pto = component
75 if not pfrom or not pto or not pfrom.isdigit() or not pto.isdigit():
76 # No empty or nonnumeric ports
82 ### Connection functions ####
84 def connect_node_iface_node(testbed_instance, node_guid, iface_guid):
85 node = testbed_instance._elements[node_guid]
86 iface = testbed_instance._elements[iface_guid]
89 def connect_node_iface_inet(testbed_instance, iface_guid, inet_guid):
90 iface = testbed_instance._elements[iface_guid]
91 iface.has_internet = True
93 def connect_tun_iface_node(testbed_instance, node_guid, iface_guid):
94 node = testbed_instance._elements[node_guid]
95 iface = testbed_instance._elements[iface_guid]
96 if not node.emulation:
97 raise RuntimeError, "Use of TUN interfaces requires emulation"
99 node.required_vsys.update(('fd_tuntap', 'vif_up'))
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]
158 if not node.emulation:
159 raise RuntimeError, "Use of NetPipes requires emulation"
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 = 15000 + int(guid)
335 traces = testbed_instance._get_traces(guid)
336 element.capture = 'packets' in traces
338 # Do some validations
342 if element.peer_proto:
343 if element.peer_iface and isinstance(element.peer_iface, testbed_instance._interfaces.TunIface):
345 listening = id(element) < id(element.peer_iface)
348 if not element.tun_addr or not element.tun_port:
350 elif not element.peer_addr or not element.peer_port:
353 # both have addresses...
354 # ...the one with the lesser address listens
355 listening = element.tun_addr < element.peer_addr
360 def postconfigure_tuniface(testbed_instance, guid):
361 element = testbed_instance._elements[guid]
366 def wait_tuniface(testbed_instance, guid):
367 element = testbed_instance._elements[guid]
370 element.async_launch_wait()
373 def configure_node(testbed_instance, guid):
374 node = testbed_instance._elements[guid]
376 # Just inject configuration stuff
377 node.home_path = "nepi-node-%s" % (guid,)
378 node.ident_path = testbed_instance.sliceSSHKey
379 node.slicename = testbed_instance.slicename
381 # Do some validations
384 # this will be done in parallel in all nodes
385 # this call only spawns the process
386 node.install_dependencies()
388 def configure_node_routes(testbed_instance, guid):
389 node = testbed_instance._elements[guid]
390 routes = testbed_instance._add_route.get(guid)
394 for dev_guid in testbed_instance.get_connected(guid, "devs", "node")
395 for dev in ( testbed_instance._elements.get(dev_guid) ,)
396 if dev and isinstance(dev, testbed_instance._interfaces.TunIface) ]
398 node.configure_routes(routes, devs)
400 def configure_application(testbed_instance, guid):
401 app = testbed_instance._elements[guid]
403 # Do some validations
406 # Wait for dependencies
407 app.node.wait_dependencies()
412 def configure_dependency(testbed_instance, guid):
413 dep = testbed_instance._elements[guid]
415 # Do some validations
418 # Wait for dependencies
419 dep.node.wait_dependencies()
424 def configure_netpipe(testbed_instance, guid):
425 netpipe = testbed_instance._elements[guid]
427 # Do some validations
430 # Wait for dependencies
431 netpipe.node.wait_dependencies()
436 ### Factory information ###
438 connector_types = dict({
440 "help": "Connector from node to applications",
446 "help": "Connector from node to network interfaces",
452 "help": "Connector from node to application dependencies "
453 "(packages and applications that need to be installed)",
459 "help": "Connector from network interfaces to the internet",
465 "help": "Connector to a Node",
471 "help": "Connector to a NetPipe",
478 "help": "ip-ip tunneling over TCP link",
484 "help": "ip-ip tunneling over UDP datagrams",
490 "help": "TUN device file descriptor provider",
499 "from": (TESTBED_ID, NODE, "devs"),
500 "to": (TESTBED_ID, NODEIFACE, "node"),
501 "init_code": connect_node_iface_node,
505 "from": (TESTBED_ID, NODE, "devs"),
506 "to": (TESTBED_ID, TUNIFACE, "node"),
507 "init_code": connect_tun_iface_node,
511 "from": (TESTBED_ID, NODE, "devs"),
512 "to": (TESTBED_ID, TAPIFACE, "node"),
513 "init_code": connect_tun_iface_node,
517 "from": (TESTBED_ID, NODEIFACE, "inet"),
518 "to": (TESTBED_ID, INTERNET, "devs"),
519 "init_code": connect_node_iface_inet,
523 "from": (TESTBED_ID, NODE, "apps"),
524 "to": (TESTBED_ID, APPLICATION, "node"),
525 "init_code": connect_dep,
529 "from": (TESTBED_ID, NODE, "deps"),
530 "to": (TESTBED_ID, DEPENDENCY, "node"),
531 "init_code": connect_dep,
535 "from": (TESTBED_ID, NODE, "deps"),
536 "to": (TESTBED_ID, NEPIDEPENDENCY, "node"),
537 "init_code": connect_dep,
541 "from": (TESTBED_ID, NODE, "deps"),
542 "to": (TESTBED_ID, NS3DEPENDENCY, "node"),
543 "init_code": connect_dep,
547 "from": (TESTBED_ID, NODE, "pipes"),
548 "to": (TESTBED_ID, NETPIPE, "node"),
549 "init_code": connect_node_netpipe,
553 "from": (TESTBED_ID, TUNIFACE, "tcp"),
554 "to": (TESTBED_ID, TUNIFACE, "tcp"),
555 "init_code": functools.partial(connect_tun_iface_peer,"tcp"),
559 "from": (TESTBED_ID, TUNIFACE, "udp"),
560 "to": (TESTBED_ID, TUNIFACE, "udp"),
561 "init_code": functools.partial(connect_tun_iface_peer,"udp"),
565 "from": (TESTBED_ID, TAPIFACE, "tcp"),
566 "to": (TESTBED_ID, TAPIFACE, "tcp"),
567 "init_code": functools.partial(connect_tun_iface_peer,"tcp"),
571 "from": (TESTBED_ID, TAPIFACE, "udp"),
572 "to": (TESTBED_ID, TAPIFACE, "udp"),
573 "init_code": functools.partial(connect_tun_iface_peer,"udp"),
577 "from": (TESTBED_ID, TUNIFACE, "tcp"),
578 "to": (None, None, "tcp"),
579 "init_code": functools.partial(crossconnect_tun_iface_peer_init,"tcp"),
580 "compl_code": functools.partial(crossconnect_tun_iface_peer_compl,"tcp"),
584 "from": (TESTBED_ID, TUNIFACE, "udp"),
585 "to": (None, None, "udp"),
586 "init_code": functools.partial(crossconnect_tun_iface_peer_init,"udp"),
587 "compl_code": functools.partial(crossconnect_tun_iface_peer_compl,"udp"),
591 "from": (TESTBED_ID, TUNIFACE, "fd->"),
592 "to": (None, None, "->fd"),
593 "compl_code": functools.partial(crossconnect_tun_iface_peer_both,"fd"),
597 "from": (TESTBED_ID, TAPIFACE, "tcp"),
598 "to": (None, None, "tcp"),
599 "init_code": functools.partial(crossconnect_tun_iface_peer_init,"tcp"),
600 "compl_code": functools.partial(crossconnect_tun_iface_peer_compl,"tcp"),
604 "from": (TESTBED_ID, TAPIFACE, "udp"),
605 "to": (None, None, "udp"),
606 "init_code": functools.partial(crossconnect_tun_iface_peer_init,"udp"),
607 "compl_code": functools.partial(crossconnect_tun_iface_peer_compl,"udp"),
611 "from": (TESTBED_ID, TAPIFACE, "fd->"),
612 "to": (None, None, "->fd"),
613 "compl_code": functools.partial(crossconnect_tun_iface_peer_both,"fd"),
619 "forward_X11": dict({
620 "name": "forward_X11",
621 "help": "Forward x11 from main namespace to the node",
622 "type": Attribute.BOOL,
624 "flags": Attribute.DesignOnly,
625 "validation_function": validation.is_bool,
629 "help": "Constrain hostname during resource discovery. May use wildcards.",
630 "type": Attribute.STRING,
631 "flags": Attribute.DesignOnly,
632 "validation_function": validation.is_string,
634 "architecture": dict({
635 "name": "architecture",
636 "help": "Constrain architexture during resource discovery.",
637 "type": Attribute.ENUM,
638 "flags": Attribute.DesignOnly,
639 "allowed": ["x86_64",
641 "validation_function": validation.is_enum,
643 "operating_system": dict({
644 "name": "operatingSystem",
645 "help": "Constrain operating system during resource discovery.",
646 "type": Attribute.ENUM,
647 "flags": Attribute.DesignOnly,
653 "validation_function": validation.is_enum,
657 "help": "Constrain the PlanetLab site this node should reside on.",
658 "type": Attribute.ENUM,
659 "flags": Attribute.DesignOnly,
663 "validation_function": validation.is_enum,
667 "help": "Enable emulation on this node. Enables NetfilterRoutes, bridges, and a host of other functionality.",
668 "type": Attribute.BOOL,
670 "flags": Attribute.DesignOnly,
671 "validation_function": validation.is_bool,
673 "min_reliability": dict({
674 "name": "minReliability",
675 "help": "Constrain reliability while picking PlanetLab nodes. Specifies a lower acceptable bound.",
676 "type": Attribute.DOUBLE,
678 "flags": Attribute.DesignOnly,
679 "validation_function": validation.is_double,
681 "max_reliability": dict({
682 "name": "maxReliability",
683 "help": "Constrain reliability while picking PlanetLab nodes. Specifies an upper acceptable bound.",
684 "type": Attribute.DOUBLE,
686 "flags": Attribute.DesignOnly,
687 "validation_function": validation.is_double,
689 "min_bandwidth": dict({
690 "name": "minBandwidth",
691 "help": "Constrain available bandwidth while picking PlanetLab nodes. Specifies a lower acceptable bound.",
692 "type": Attribute.DOUBLE,
694 "flags": Attribute.DesignOnly,
695 "validation_function": validation.is_double,
697 "max_bandwidth": dict({
698 "name": "maxBandwidth",
699 "help": "Constrain available bandwidth while picking PlanetLab nodes. Specifies an upper acceptable bound.",
700 "type": Attribute.DOUBLE,
702 "flags": Attribute.DesignOnly,
703 "validation_function": validation.is_double,
709 "type": Attribute.BOOL,
711 "validation_function": validation.is_bool
715 "help": "This is the primary interface for the attached node",
716 "type": Attribute.BOOL,
718 "validation_function": validation.is_bool
720 "device_name": dict({
722 "help": "Device name",
723 "type": Attribute.STRING,
724 "flags": Attribute.DesignOnly,
725 "validation_function": validation.is_string
729 "help": "Maximum transmition unit for device",
730 "type": Attribute.INTEGER,
732 "validation_function": validation.is_integer_range(0,1500)
736 "help": "Network mask for the device (eg: 24 for /24 network)",
737 "type": Attribute.INTEGER,
738 "validation_function": validation.is_integer_range(8,24)
742 "help": "Enable SNAT (source NAT to the internet) no this device",
743 "type": Attribute.BOOL,
745 "validation_function": validation.is_bool
747 "pointopoint": dict({
748 "name": "pointopoint",
749 "help": "If the interface is a P2P link, the remote endpoint's IP "
750 "should be set on this attribute.",
751 "type": Attribute.STRING,
752 "flags": Attribute.DesignOnly,
753 "validation_function": validation.is_string
757 "help": "Transmission queue length (in packets)",
758 "type": Attribute.INTEGER,
759 "flags": Attribute.DesignOnly,
761 "validation_function": validation.is_integer
766 "help": "Command line string",
767 "type": Attribute.STRING,
768 "flags": Attribute.DesignOnly,
769 "validation_function": validation.is_string
773 "help": "Run with root privileges",
774 "type": Attribute.BOOL,
775 "flags": Attribute.DesignOnly,
777 "validation_function": validation.is_bool
781 "help": "Standard input",
782 "type": Attribute.STRING,
783 "flags": Attribute.DesignOnly,
784 "validation_function": validation.is_string
789 "help": "Space-separated list of packages required to run the application",
790 "type": Attribute.STRING,
791 "flags": Attribute.DesignOnly,
792 "validation_function": validation.is_string
794 "build-depends": dict({
795 "name": "buildDepends",
796 "help": "Space-separated list of packages required to build the application",
797 "type": Attribute.STRING,
798 "flags": Attribute.DesignOnly,
799 "validation_function": validation.is_string
803 "help": "True if required packages can be found in the RpmFusion repository",
804 "type": Attribute.BOOL,
805 "flags": Attribute.DesignOnly,
807 "validation_function": validation.is_bool
811 "help": "Space-separated list of regular files to be deployed in the working path prior to building. "
812 "Archives won't be expanded automatically.",
813 "type": Attribute.STRING,
814 "flags": Attribute.DesignOnly,
815 "validation_function": validation.is_string
819 "help": "Build commands to execute after deploying the sources. "
820 "Sources will be in the ${SOURCES} folder. "
821 "Example: tar xzf ${SOURCES}/my-app.tgz && cd my-app && ./configure && make && make clean.\n"
822 "Try to make the commands return with a nonzero exit code on error.\n"
823 "Also, do not install any programs here, use the 'install' attribute. This will "
824 "help keep the built files constrained to the build folder (which may "
825 "not be the home folder), and will result in faster deployment. Also, "
826 "make sure to clean up temporary files, to reduce bandwidth usage between "
827 "nodes when transferring built packages.",
828 "type": Attribute.STRING,
829 "flags": Attribute.DesignOnly,
830 "validation_function": validation.is_string
834 "help": "Commands to transfer built files to their final destinations. "
835 "Sources will be in the initial working folder, and a special "
836 "tag ${SOURCES} can be used to reference the experiment's "
837 "home folder (where the application commands will run).\n"
838 "ALL sources and targets needed for execution must be copied there, "
839 "if building has been enabled.\n"
840 "That is, 'slave' nodes will not automatically get any source files. "
841 "'slave' nodes don't get build dependencies either, so if you need "
842 "make and other tools to install, be sure to provide them as "
843 "actual dependencies instead.",
844 "type": Attribute.STRING,
845 "flags": Attribute.DesignOnly,
846 "validation_function": validation.is_string
849 "netpipe_mode": dict({
851 "help": "Link mode:\n"
852 " * SERVER: applies to incoming connections\n"
853 " * CLIENT: applies to outgoing connections\n"
854 " * SERVICE: applies to both",
855 "type": Attribute.ENUM,
856 "flags": Attribute.DesignOnly,
857 "allowed": ["SERVER",
860 "validation_function": validation.is_enum,
864 "help": "Port list or range. Eg: '22', '22,23,27', '20-2000'",
865 "type": Attribute.STRING,
866 "validation_function": is_portlist,
870 "help": "Address list or range. Eg: '127.0.0.1', '127.0.0.1,127.0.1.1', '127.0.0.1/8'",
871 "type": Attribute.STRING,
872 "validation_function": is_addrlist,
876 "help": "Inbound bandwidth limit (in Mbit/s)",
877 "type": Attribute.DOUBLE,
878 "validation_function": validation.is_double,
882 "help": "Outbound bandwidth limit (in Mbit/s)",
883 "type": Attribute.DOUBLE,
884 "validation_function": validation.is_double,
888 "help": "Inbound packet loss rate (0 = no loss, 1 = 100% loss)",
889 "type": Attribute.DOUBLE,
890 "validation_function": validation.is_double,
894 "help": "Outbound packet loss rate (0 = no loss, 1 = 100% loss)",
895 "type": Attribute.DOUBLE,
896 "validation_function": validation.is_double,
900 "help": "Inbound packet delay (in milliseconds)",
901 "type": Attribute.INTEGER,
903 "validation_function": validation.is_integer,
907 "help": "Outbound packet delay (in milliseconds)",
908 "type": Attribute.INTEGER,
910 "validation_function": validation.is_integer,
917 "help": "Standard output stream"
921 "help": "Application standard error",
925 "help": "Output of the build process",
928 "netpipe_stats": dict({
929 "name": "netpipeStats",
930 "help": "Information about rule match counters, packets dropped, etc.",
935 "help": "Detailled log of all packets going through the interface",
939 create_order = [ INTERNET, NODE, NODEIFACE, TAPIFACE, TUNIFACE, NETPIPE, NEPIDEPENDENCY, NS3DEPENDENCY, DEPENDENCY, APPLICATION ]
941 configure_order = [ INTERNET, NODE, NODEIFACE, TAPIFACE, TUNIFACE, NETPIPE, NEPIDEPENDENCY, NS3DEPENDENCY, DEPENDENCY, APPLICATION ]
943 # Start (and prestart) node after ifaces, because the node needs the ifaces in order to set up routes
944 start_order = [ INTERNET, NODEIFACE, TAPIFACE, TUNIFACE, NODE, NETPIPE, NEPIDEPENDENCY, NS3DEPENDENCY, DEPENDENCY, APPLICATION ]
946 factories_info = dict({
948 "help": "Virtualized Node (V-Server style)",
949 "category": FC.CATEGORY_NODES,
950 "create_function": create_node,
951 "preconfigure_function": configure_node,
952 "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"],
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"],
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.DesignOnly | Attribute.HasNoDefaultValue,
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.DesignOnly | Attribute.HasNoDefaultValue,
1089 "validation_function": validation.is_string
1093 "help": "The PlanetLab user's password.",
1094 "type": Attribute.STRING,
1095 "flags": Attribute.DesignOnly | Attribute.HasNoDefaultValue,
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.DesignOnly,
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.DesignOnly,
1112 "validation_function": validation.is_string
1114 "slice_ssh_key": dict({
1115 "name": "sliceSSHKey",
1116 "help": "The controller-local path to the slice user's ssh private key. "
1117 "It is the user's responsability to deploy this file where the controller "
1118 "will run, it won't be done automatically because it's sensitive information. "
1119 "It is recommended that a NEPI-specific user be created for this purpose and "
1120 "this purpose alone.",
1121 "type": Attribute.STRING,
1122 "flags": Attribute.DesignOnly | Attribute.HasNoDefaultValue,
1123 "validation_function": validation.is_string
1127 class VersionedMetadataInfo(metadata.VersionedMetadataInfo):
1129 def connector_types(self):
1130 return connector_types
1133 def connections(self):
1137 def attributes(self):
1145 def create_order(self):
1149 def configure_order(self):
1150 return configure_order
1153 def prestart_order(self):
1157 def start_order(self):
1161 def factories_info(self):
1162 return factories_info
1165 def testbed_attributes(self):
1166 return testbed_attributes