Utils

String utilities

deployer.utils.string_utils.esc1(string)

Escape single quotes, mainly for use in shell commands. Single quotes are usually preferred above double quotes, because they never do shell expension inside. e.g.

class HelloWorld(Node):
    def run(self):
        self.hosts.run("echo '%s'" % esc1("Here's some text"))
deployer.utils.string_utils.esc2(string)

Escape double quotes

deployer.utils.string_utils.indent(string, prefix=' ')

Indent every line of this string.

Other

deployer.utils.network.parse_ifconfig_output(output, only_active_interfaces=True)

Parse the output of an ifconfig command.

Returns:A list of IfConfig objects.

Example usage:

ifconfig = parse_ifconfig_output(host.run('ifconfig'))
interface = ifconfig.get_interface('eth0')
print interface.ip
class deployer.utils.network.IfConfig

Container for the network settings, found by ifconfig. This contains a list of NetworkInterface.

get_address(ip)

Return the NetworkInterface object, given an IP addres (e.g. “127.0.0.1”) or raise AttributeError.

get_interface(name)

Return the NetworkInterface object, given an interface name (e.g. “eth0”) or raise AttributeError.

interfaces

List of all NetworkInterface objects.

class deployer.utils.network.NetworkInterface(name='eth0')

Information about a single network interface.

ip

IP address of the network interface. e.g. “127.0.0.1”

name

Name of the network interface. e.g. “eth0”.