示例#1
0
def run(*args):
    """Execute command over a number of hosts which match with specified Tag
    name provided as argument. Example::

        mico ec2 run 'apaches-*' service apache reload
    """
    env.host_label = { x.ip_address:x.name for x in ec2_list(args[0]) if x.ip_address is not None }
    env.roledefs['mico'] = [ x for x in env.host_label ]

    env.roles.append('mico')

    if len(env.roledefs['mico']) > 0:
        mico.run(" ".join(args[1:]))
示例#2
0
def run(*args):
    """Execute command over a number of hosts which match with specified Tag
    name provided as argument. Example::

        mico ec2 run 'apaches-*' service apache reload
    """
    env.host_label = {
        x.ip_address: x.name
        for x in ec2_list(args[0]) if x.ip_address is not None
    }
    env.roledefs['mico'] = [x for x in env.host_label]

    env.roles.append('mico')

    if len(env.roledefs['mico']) > 0:
        mico.run(" ".join(args[1:]))
示例#3
0
文件: network.py 项目: ajdiaz/mico
def network_address(iface=""):
    """Return a list of IP addresses associated with an specific interface
    or, if not provided, the full list of the system."""
    with settings(hide('running', 'stdout')):
        res = mico.run("/sbin/ifconfig %s | grep 'inet addr'" % iface)[0]
        return map(lambda x: x.split()[1].split(':')[1],
                    res.splitlines())
示例#4
0
文件: network.py 项目: ajdiaz/mico
def network_netmask(iface=""):
    """Return a list of IP netmask associated with an specific interface
    or, if not provided, the full list of the system."""
    with settings(hide('running', 'stdout')):
        res = mico.run("/sbin/ifconfig %s | grep 'inet addr'" % iface)[0]
        ret = []
        for _res in res.splitlines():
            field = _res.split()[2]
            if field.startswith("Mask"):
                ret.append(field.split(':')[1])
            else:
                field = res.split()[3]
                ret.append(field.split(':')[1])
        return ret
示例#5
0
def network_netmask(iface=""):
    """Return a list of IP netmask associated with an specific interface
    or, if not provided, the full list of the system."""
    with settings(hide('running', 'stdout')):
        res = mico.run("/sbin/ifconfig %s | grep 'inet addr'" % iface)[0]
        ret = []
        for _res in res.splitlines():
            field = _res.split()[2]
            if field.startswith("Mask"):
                ret.append(field.split(':')[1])
            else:
                field = res.split()[3]
                ret.append(field.split(':')[1])
        return ret
示例#6
0
文件: network.py 项目: ajdiaz/mico
def network_nameservers():
    """Return a list with the nameservers present in the remote system."""
    with settings(hide('running', 'stdout')):
        res = mico.run("grep ^nameserver /etc/resolv.conf")[0]
        return map(lambda x: x.split()[1], res.splitlines())
示例#7
0
文件: network.py 项目: ajdiaz/mico
def network_interfaces():
    """Return a list of available network interfaces in the remote host."""
    with settings(hide('running', 'stdout')):
        res = mico.run("/sbin/ifconfig -s")[0]
        return map(lambda line: line.split(' ')[0], res.splitlines()[1:])
示例#8
0
def _env_kernel():
    """Get the kernel version running in the remote host.
    """
    return mico.run("uname -s")[0].lower()
示例#9
0
文件: environ.py 项目: ajdiaz/mico
def _env_kernel():
    """Get the kernel version running in the remote host.
    """
    return mico.run("uname -s")[0].lower()
示例#10
0
def network_nameservers():
    """Return a list with the nameservers present in the remote system."""
    with settings(hide('running', 'stdout')):
        res = mico.run("grep ^nameserver /etc/resolv.conf")[0]
        return map(lambda x: x.split()[1], res.splitlines())
示例#11
0
def network_address(iface=""):
    """Return a list of IP addresses associated with an specific interface
    or, if not provided, the full list of the system."""
    with settings(hide('running', 'stdout')):
        res = mico.run("/sbin/ifconfig %s | grep 'inet addr'" % iface)[0]
        return map(lambda x: x.split()[1].split(':')[1], res.splitlines())
示例#12
0
def network_interfaces():
    """Return a list of available network interfaces in the remote host."""
    with settings(hide('running', 'stdout')):
        res = mico.run("/sbin/ifconfig -s")[0]
        return map(lambda line: line.split(' ')[0], res.splitlines()[1:])