Ejemplo n.º 1
0
def _read_ip_address_from_arp_table(mac):
    rc, stdout, stderr = utils.cmd("arp -an")

    if rc != 0:
        raise exception.RuggedpodException()

    n_mac = format_mac_address_standard(mac)

    for line in stdout.split('\n'):
        search = re.search(
            '.* \(([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\) .* ([0-9a-f:]{17}) .*',
            line)
        if search and n_mac == search.group(2):
            return search.group(1)

    return None
Ejemplo n.º 2
0
def refresh():
    config = read_config(db.session())

    network = IPNetwork(config['dhcp_network'])
    config['dhcp_range_netmask'] = str(network.netmask)

    if config['dhcp_mode'] == 'proxy':
        config['dhcp_range_start'] = str(IPAddress(int(network.ip) + 1))

    with open("/etc/dnsmasq.conf", "w") as text_file:
        text_file.write(tpl.get_template('dnsmasq.conf').render(**config))

    rc, stdout, stderr = utils.cmd('service dnsmasq restart')

    if (rc != 0):
        raise exception.RuggedpodException()
Ejemplo n.º 3
0
 def detect(bus):
     rc, stdout, stderr = utils.cmd('i2cdetect -y %s' % bus)
     if rc != 0:
         raise exception.NoContent(reason='Cannot find any I2C bus')
     return stdout
Ejemplo n.º 4
0
 def list_bus():
     rc, stdout, stderr = utils.cmd(i2c['bus_lookup_command'])
     if rc != 0:
         raise exception.NoContent(reason='Cannot find any I2C bus')
     return stdout
Ejemplo n.º 5
0
def _network_discovery(net_cidr):
    nmap_cmd = "nmap --min-hostgroup 256 --min-parallelism 256 -sn %s" % net_cidr
    rc, stdout, stderr = utils.cmd(nmap_cmd)
    if rc != 0:
        raise exception.RuggedpodException()