marvis.node.lxd
LXD containers in the simulation.
Functions
Log the container's output. |
Classes
A LXDNode represents a LXD container. |
- marvis.node.lxd.log_to_file(container, log_path, stdout=False, stderr=False)[source]
Log the container’s output.
This opens a stream to the docker container’s log output and writes it into a file.
- Parameters
log_path (str) – The file path to the log file.
stdout (bool) – Whether stdout should be logged.
stderr (bool) – Whether stderr should be logged.
- class marvis.node.lxd.LXDNode(name, image=None, image_server='https://images.linuxcontainers.org', custom_configuration=None)[source]
Bases:
marvis.node.base.Node
A LXDNode represents a LXD container.
- Parameters
name (str) – The name of the node (and container).
image (str) – The name of the image to use (=the alias).
image_server (str) – The server to pull the image off if not found locally.
custom_configuration (dict) – Additional configuration key-value-pairs to pass to LXD.
- image
The image’s name being used.
- container
The container instance.
- custom_configuration
Custom configuration values.
- command_executor
The executor for running commands in the container. This is useful for a scripted
Workflow
.
- image_server
The server to fetch the image from. Before fetching from the server, local images will be checked.
- wants_ip_stack()[source]
Indicates whether a IP stack shall be installed onto the node.
Installing is handled by the Channel.
- Returns
True
indicates that a ns-3 IP stack shall be installed when preparing this node.- Return type
bool
- start_container(log_directory, hosts=None)[source]
Start the LXC container.
All docker containers are labeled with “ns-3” as the creator.
- Parameters
log_directory (str) – The path to the directory to put log files in.
hosts (dict) – A dictionary with hostnames as keys and IP addresses (a list) as value.
- setup_host_interfaces()[source]
Setup the interfaces (bridge, tap, VETH pair) on the host and connect them to the container.
- add_interface(interface, name=None, prefix='eth')
Add an interface to the node.
- Warning: Do not call this function manually.
The functionality is handled by the network and channels.
- Parameters
interface (
Interface
) – The interface to add.name (str) – The name of the interface.
prefix (str) – If no name is supplied, the function works out a name by appending a number to the prefix.
- execute_command(command, user=None)
Execute a command within the node.
- Parameters
command (str or list of str) – The command to execute.
user (str) – If a user (name) is specified, the command is executed as this user. Warning: Not all nodes support this feature.
- go_offline()
Disconnect the node from all channels.
- go_online()
Connect the node back to all channels.
- set_position(x, y, z=0)
Set the position of the node and updates the mobitlity model.
- Parameters
x (float) – The x-position.
y (float) – The y-position.
z (float) – The z-position.
- channels
The cannels the node is connected to.
- name
The name of the node.
- ns3_node
The ns-3 internal node.
- position
The position of the node (used by wifi models and visualization)
- color
The color of the node used in the visualization.
- interfaces
The interfaces (~network cards) of this node.
Inheritance Diagramm