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:]))
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:]))
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())
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
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())
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:])
def _env_kernel(): """Get the kernel version running in the remote host. """ return mico.run("uname -s")[0].lower()