topology_docker.utils

topology_docker utilities module.

Functions

topology_docker.utils.ensure_dir(path)

Ensure that a path exists.

Parameters:path (str) – Directory path to create.
topology_docker.utils.tmp_iface()

Return a valid temporal interface name.

Return type:str
Returns:A random valid network interface name.
topology_docker.utils.cmd_prefix()

Determine if the current user can run privileged commands and thus determines the command prefix to use.

Return type:str
Returns:The prefix to use for privileged commands.
topology_docker.utils.privileged_cmd(commands_tpl, **kwargs)

Run a privileged command.

This function will replace the tokens in the template with the provided keyword arguments, then it will split the lines of the template, strip them and execute them using the prefix for privileged commands, checking that the command returns 0.

Parameters:
  • commands_tpl (str) – Single line or multiline template for commands.
  • kwargs (dict) – Replacement tokens.
topology_docker.utils.get_iface_name(enode, netname)

Get interface name inside a container

This function will figure out the interface name inside the container for a given docker network.

Parameters:
  • enode – The platform (“engine”) node to get the iface name from.
  • netname (str) – The name of the docker network to which the interface we’re looking for is connected.