Beispiel #1
0
def _detect_software(ip, dev, http_family):
    detected = []
    if network.check_tcp_port(ip, 1521):
        detected.append('Oracle')
        Software.create(dev,
                        'oracle',
                        'Oracle',
                        family='Database',
                        priority=SAVE_PRIORITY)
    else:
        dev.software_set.filter(path='oracle').all().delete()
    if network.check_tcp_port(ip, 3306):
        detected.append('MySQL')
        Software.create(dev,
                        'mysql',
                        'MySQL',
                        family='Database',
                        priority=SAVE_PRIORITY)
    else:
        dev.software_set.filter(path='mysql').all().delete()
    if network.check_tcp_port(ip, 80) or network.check_tcp_port(ip, 443):
        detected.append('WWW')
        Software.create(dev,
                        'www',
                        'WWW',
                        label=http_family,
                        family='WWW',
                        priority=SAVE_PRIORITY)
    else:
        dev.software_set.filter(path='www').all().delete()
    return ', '.join(detected)
Beispiel #2
0
def ssh_linux(**kwargs):
    if 'nx-os' in kwargs.get('snmp_name', '').lower():
        return False, 'incompatible Nexus found.', kwargs
    kwargs['guessmodel'] = gvendor, gmodel = guessmodel.guessmodel(**kwargs)
    if gmodel not in {'Linux', 'ESX', 'XEN'}:
        return False, 'no match: %s %s' % (gvendor, gmodel), kwargs
    ip = str(kwargs['ip'])
    if not network.check_tcp_port(ip, 22):
        return False, 'closed.', kwargs
    ssh = None
    auths = [
        (settings.SSH_USER or 'root', settings.SSH_PASSWORD),
        (settings.XEN_USER, settings.XEN_PASSWORD),
    ]
    try:
        for user, password in auths:
            if user is None or password is None:
                continue
            try:
                ssh = network.connect_ssh(ip, user, password)
            except network.AuthError:
                pass
            else:
                break
        else:
            return False, 'Authorization failed', kwargs
        name = run_ssh_linux(ssh, ip)
    except (network.Error, paramiko.SSHException) as e:
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #3
0
def ssh_ibm_bladecenter(**kwargs):
    if 'nx-os' in kwargs.get('snmp_name', '').lower():
        return False, 'incompatible Nexus found.', kwargs
    ip = str(kwargs['ip'])
    if kwargs.get('http_family', '') not in ('IBM', 'Unspecified'):
        return False, 'no match.', kwargs
    if not kwargs.get('snmp_name', 'IBM').startswith('IBM'):
        return False, 'no match.', kwargs
    if not network.check_tcp_port(ip, 22):
        DiscoveryWarning(
            message="Port 22 closed on an IBM BladeServer.",
            plugin=__name__,
            ip=ip,
        ).save()
        return False, 'closed.', kwargs
    try:
        name = run_ssh_bladecenter(ip)
    except (network.Error, Error, paramiko.SSHException, socket.error) as e:
        DiscoveryWarning(
            message="This is an IBM BladeServer, but: " + str(e),
            plugin=__name__,
            ip=ip,
        ).save()
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #4
0
def ssh_linux(**kwargs):
    if "nx-os" in kwargs.get("snmp_name", "").lower():
        return False, "incompatible Nexus found.", kwargs
    kwargs["guessmodel"] = gvendor, gmodel = guessmodel.guessmodel(**kwargs)
    if gmodel not in {"Linux", "ESX", "XEN"}:
        return False, "no match: %s %s" % (gvendor, gmodel), kwargs
    ip = str(kwargs["ip"])
    if not network.check_tcp_port(ip, 22):
        return False, "closed.", kwargs
    ssh = None
    auths = [(settings.SSH_USER or "root", settings.SSH_PASSWORD), (settings.XEN_USER, settings.XEN_PASSWORD)]
    try:
        for user, password in auths:
            if user is None or password is None:
                continue
            try:
                ssh = network.connect_ssh(ip, user, password)
            except network.AuthError:
                pass
            else:
                break
        else:
            return False, "Authorization failed", kwargs
        name = run_ssh_linux(ssh, ip)
    except (network.Error, paramiko.SSHException) as e:
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #5
0
def ssh_onstor(**kwargs):
    if SSH_ONSTOR_USER is None or SSH_ONSTOR_PASSWORD is None:
        return False, 'no credentials.', kwargs
    if 'nx-os' in kwargs.get('snmp_name', '').lower():
        return False, 'incompatible Nexus found.', kwargs
    ip = str(kwargs['ip'])
    if kwargs.get('http_family') not in ('sscccc',):
        return False, 'no match.', kwargs
    if not network.check_tcp_port(ip, 22):
        DiscoveryWarning(
            message="Port 22 closed on an Onstor device.",
            plugin=__name__,
            ip=ip,
        ).save()
        return False, 'closed.', kwargs
    try:
        name = _run_ssh_onstor(ip)
    except (network.Error, Error, paramiko.SSHException) as e:
        DiscoveryWarning(
            message="This is an Onstor, but: " + str(e),
            plugin=__name__,
            ip=ip,
        ).save()
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #6
0
def ssh_xen(**kwargs):
    ip = str(kwargs['ip'])
    if XEN_USER is None:
        return False, 'no auth.', kwargs
    if 'nx-os' in kwargs.get('snmp_name', '').lower():
        return False, 'incompatible Nexus found.', kwargs
    if 'xen' not in kwargs.get('snmp_name', ''):
        return False, 'no match.', kwargs
    if not network.check_tcp_port(ip, 22):
        DiscoveryWarning(
            message="Port 22 closed on a XEN server.",
            plugin=__name__,
            ip=ip,
        ).save()
        return False, 'closed.', kwargs
    ipaddr = IPAddress.objects.get(address=ip)
    dev = ipaddr.device
    if dev is None:
        return False, 'no device.', kwargs
    try:
        name = run_ssh_xen(ipaddr, dev)
    except (network.Error, Error, paramiko.SSHException) as e:
        DiscoveryWarning(
            message="This is a XEN, but: " + str(e),
            plugin=__name__,
            ip=ip,
        ).save()
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #7
0
def ssh_linux(**kwargs):
    if 'nx-os' in kwargs.get('snmp_name', '').lower():
        return False, 'incompatible Nexus found.', kwargs
    kwargs['guessmodel'] = gvendor, gmodel = guessmodel.guessmodel(**kwargs)
    if gmodel not in {'Linux', 'ESX', 'XEN'}:
        return False, 'no match: %s %s' % (gvendor, gmodel), kwargs
    ip = str(kwargs['ip'])
    if not network.check_tcp_port(ip, 22):
        return False, 'closed.', kwargs
    ssh = None
    auths = [
        (settings.SSH_USER or 'root', settings.SSH_PASSWORD),
        (settings.XEN_USER, settings.XEN_PASSWORD),
    ]
    try:
        for user, password in auths:
            if user is None or password is None:
                continue
            try:
                ssh = network.connect_ssh(ip, user, password)
            except network.AuthError:
                pass
            else:
                break
        else:
            return False, 'Authorization failed', kwargs
        name = run_ssh_linux(ssh, ip)
    except (network.Error, paramiko.SSHException) as e:
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #8
0
def ssh_xen(**kwargs):
    ip = str(kwargs['ip'])
    if XEN_USER is None:
        return False, 'no auth.', kwargs
    if 'nx-os' in kwargs.get('snmp_name', '').lower():
        return False, 'incompatible Nexus found.', kwargs
    if 'xen' not in kwargs.get('snmp_name', ''):
        return False, 'no match.', kwargs
    if not network.check_tcp_port(ip, 22):
        DiscoveryWarning(
            message="Port 22 closed on a XEN server.",
            plugin=__name__,
            ip=ip,
        ).save()
        return False, 'closed.', kwargs
    ipaddr = IPAddress.objects.get(address=ip)
    dev = ipaddr.device
    if dev is None:
        return False, 'no device.', kwargs
    try:
        name = run_ssh_xen(ipaddr, dev)
    except (network.Error, Error, paramiko.SSHException) as e:
        DiscoveryWarning(
            message="This is a XEN, but: " + str(e),
            plugin=__name__,
            ip=ip,
        ).save()
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #9
0
def ssh_onstor(**kwargs):
    if SSH_ONSTOR_USER is None or SSH_ONSTOR_PASSWORD is None:
        return False, 'no credentials.', kwargs
    if 'nx-os' in kwargs.get('snmp_name', '').lower():
        return False, 'incompatible Nexus found.', kwargs
    ip = str(kwargs['ip'])
    if kwargs.get('http_family') not in ('sscccc', ):
        return False, 'no match.', kwargs
    if not network.check_tcp_port(ip, 22):
        DiscoveryWarning(
            message="Port 22 closed on an Onstor device.",
            plugin=__name__,
            ip=ip,
        ).save()
        return False, 'closed.', kwargs
    try:
        name = _run_ssh_onstor(ip)
    except (network.Error, Error, paramiko.SSHException) as e:
        DiscoveryWarning(
            message="This is an Onstor, but: " + str(e),
            plugin=__name__,
            ip=ip,
        ).save()
        return False, str(e), kwargs
    return True, name, kwargs
def ssh_ibm_bladecenter(**kwargs):
    if 'nx-os' in kwargs.get('snmp_name', '').lower():
        return False, 'incompatible Nexus found.', kwargs
    ip = str(kwargs['ip'])
    if kwargs.get('http_family', '') not in ('IBM', 'Unspecified'):
        return False, 'no match.', kwargs
    if not kwargs.get('snmp_name', 'IBM').startswith('IBM'):
        return False, 'no match.', kwargs
    if not network.check_tcp_port(ip, 22):
        DiscoveryWarning(
            message="Port 22 closed on an IBM BladeServer.",
            plugin=__name__,
            ip=ip,
        ).save()
        return False, 'closed.', kwargs
    try:
        name = run_ssh_bladecenter(ip)
    except (network.Error, Error, paramiko.SSHException, socket.error) as e:
        DiscoveryWarning(
            message="This is an IBM BladeServer, but: " + str(e),
            plugin=__name__,
            ip=ip,
        ).save()
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #11
0
def _connect_ssh(ip):
    if not network.check_tcp_port(ip, 22):
        raise ConnectionError('Port 22 closed.')
    return network.connect_ssh(
        ip,
        SSH_USER,
        SSH_PASSWORD,
        client=CiscoSSHClient,
    )
Beispiel #12
0
def _connect_ssh(ip, username, password):
    if not network.check_tcp_port(ip, 22):
        raise ConnectionError('Port 22 closed.')
    return network.connect_ssh(
        ip,
        username,
        password,
        client=CiscoSSHClient,
    )
Beispiel #13
0
def _connect_ssh(ip_address, user, password):
    if not network.check_tcp_port(ip_address, 22):
        raise ConnectionError('Port 22 closed on a HP MSA Storage.')
    return network.connect_ssh(
        ip_address,
        user,
        password,
        client=HPSSHClient,
    )
Beispiel #14
0
def _detect_software(ip, dev, http_family):
    detected = []
    if network.check_tcp_port(ip, 1521):
        detected.append('Oracle')
        Software.create(dev, 'oracle', 'Oracle', family='Database').save()
    else:
        dev.software_set.filter(path='oracle').all().delete()
    if network.check_tcp_port(ip, 3306):
        detected.append('MySQL')
        Software.create(dev, 'mysql', 'MySQL', family='Database').save()
    else:
        dev.software_set.filter(path='mysql').all().delete()
    if network.check_tcp_port(ip, 80) or network.check_tcp_port(ip, 443):
        detected.append('WWW')
        Software.create(dev, 'www', 'WWW', label=http_family, family='WWW').save()
    else:
        dev.software_set.filter(path='www').all().delete()
    return ', '.join(detected)
Beispiel #15
0
def _connect_ssh(ip_address, user, password):
    if not network.check_tcp_port(ip_address, 22):
        raise ConnectionError('Port 22 closed on a HP MSA Storage.')
    return network.connect_ssh(
        ip_address,
        user,
        password,
        client=HPSSHClient,
    )
Beispiel #16
0
def ssh_ganeti(**kwargs):
    if 'nx-os' in kwargs.get('snmp_name', '').lower():
        return False, 'incompatible Nexus found.', kwargs
    ip = str(kwargs['ip'])
    if not network.check_tcp_port(ip, 22):
        return False, 'port 22 closed.', kwargs
    try:
        name = run_ssh_ganeti(ip)
    except (network.Error, Error, paramiko.SSHException) as e:
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #17
0
def ssh_ganeti(**kwargs):
    if 'nx-os' in kwargs.get('snmp_name', '').lower():
        return False, 'incompatible Nexus found.', kwargs
    ip = str(kwargs['ip'])
    if not network.check_tcp_port(ip, 22):
        return False, 'port 22 closed.', kwargs
    try:
        name = run_ssh_ganeti(ip)
    except (network.Error, Error, paramiko.SSHException) as e:
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #18
0
def ssh_cisco_asa(**kwargs):
    ip = str(kwargs['ip'])
    kwargs['guessmodel'] = gvendor, gmodel = guessmodel.guessmodel(**kwargs)
    if gvendor != 'Cisco' or gmodel not in ('',):
        return False, 'no match: %s %s' % (gvendor, gmodel), kwargs
    if not network.check_tcp_port(ip, 22):
        return False, 'closed.', kwargs
    try:
        name = run_ssh_asa(ip)
    except (network.Error, Error) as e:
        return False, str(e), kwargs
    except paramiko.SSHException as e:
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #19
0
def ssh_cisco_asa(**kwargs):
    ip = str(kwargs["ip"])
    kwargs["guessmodel"] = gvendor, gmodel = guessmodel.guessmodel(**kwargs)
    if gvendor != "Cisco" or gmodel not in ("",):
        return False, "no match: %s %s" % (gvendor, gmodel), kwargs
    if not network.check_tcp_port(ip, 22):
        return False, "closed.", kwargs
    try:
        name = run_ssh_asa(ip)
    except (network.Error, Error) as e:
        return False, str(e), kwargs
    except paramiko.SSHException as e:
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #20
0
def ssh_proxmox(**kwargs):
    ip = str(kwargs['ip'])
    if kwargs.get('http_family') not in ('Proxmox',):
        return False, 'no match.', kwargs
    if not network.check_tcp_port(ip, 22):
        return False, 'closed.', kwargs
    try:
        name = run_ssh_proxmox(ip)
    except (network.Error, Error) as e:
        return False, str(e), kwargs
    except paramiko.SSHException as e:
        return False, str(e), kwargs
    except Error as e:
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #21
0
def scan_address(ip_address, **kwargs):
    if 'nx-os' in kwargs.get('snmp_name', '').lower():
        raise NoMatchError("Incompatible Nexus found.")
    if 'StorageWorks' not in kwargs.get('snmp_name'):
        raise NoMatchError("No match")
    if not network.check_tcp_port(ip_address, 22):
        raise ConnectionError("Port 22 closed.")
    device = _run_ssh_p2000(ip_address)
    ret = {
        'status': 'success',
        'device': device,
    }
    tpl = get_base_result_template('ssh_hp_p2000')
    tpl.update(ret)
    return json.loads(json.dumps(tpl))  # to ensure its picklable
Beispiel #22
0
def _detect_software(ip_address, http_family):
    software = []
    if network.check_tcp_port(ip_address, 1521):
        software.append({
            'path': 'oracle',
            'model_name': 'Oracle',
        })
    if network.check_tcp_port(ip_address, 3306):
        software.append({
            'path': 'mysql',
            'model_name': 'MySQL',
        })
    if any((
        network.check_tcp_port(ip_address, 80),
        network.check_tcp_port(ip_address, 443),
    )):
        soft = {
            'path': 'www',
            'model_name': 'WWW',
        }
        if http_family:
            soft['label'] = http_family
        software.append(soft)
    return software
Beispiel #23
0
def scan_address(ip_address, **kwargs):
    if 'nx-os' in kwargs.get('snmp_name', '').lower():
        raise NoMatchError("Incompatible Nexus found.")
    if 'StorageWorks' not in kwargs.get('snmp_name'):
        raise NoMatchError("No match")
    if not network.check_tcp_port(ip_address, 22):
        raise ConnectionError("Port 22 closed.")
    device = _run_ssh_p2000(ip_address)
    ret = {
        'status': 'success',
        'device': device,
    }
    tpl = get_base_result_template('ssh_hp_p2000')
    tpl.update(ret)
    return json.loads(json.dumps(tpl))  # to ensure its picklable
Beispiel #24
0
def _detect_software(ip_address, http_family):
    software = []
    if network.check_tcp_port(ip_address, 1521):
        software.append({
            'path': 'oracle',
            'model_name': 'Oracle',
        })
    if network.check_tcp_port(ip_address, 3306):
        software.append({
            'path': 'mysql',
            'model_name': 'MySQL',
        })
    if any((
            network.check_tcp_port(ip_address, 80),
            network.check_tcp_port(ip_address, 443),
    )):
        soft = {
            'path': 'www',
            'model_name': 'WWW',
        }
        if http_family:
            soft['label'] = http_family
        software.append(soft)
    return software
Beispiel #25
0
def ssh_proxmox(**kwargs):
    ip = str(kwargs["ip"])
    if kwargs.get("http_family") not in ("Proxmox",):
        return False, "no match.", kwargs
    if not network.check_tcp_port(ip, 22):
        return False, "closed.", kwargs
    try:
        name = run_ssh_proxmox(ip)
    except (network.Error, Error) as e:
        return False, str(e), kwargs
    except paramiko.SSHException as e:
        return False, str(e), kwargs
    except Error as e:
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #26
0
def ssh_ssg(**kwargs):
    ip = str(kwargs['ip'])
    if kwargs.get('http_family') not in ('SSG', 'Unspecified'):
        return False, 'no match.', kwargs
    if not network.check_tcp_port(ip, 22):
        return False, 'closed.', kwargs
    try:
        name = run_ssh_ssg(ip)
    except network.Error as e:
        return False, str(e), kwargs
    except Error as e:
        return False, str(e), kwargs
    except paramiko.SSHException as e:
        return False, str(e), kwargs
    return True, name, kwargs
def ssh_cisco_asa(**kwargs):
    ip = str(kwargs['ip'])
    if 'nx-os' in kwargs.get('snmp_name', '').lower():
        return False, 'incompatible Nexus found.', kwargs
    kwargs['guessmodel'] = gvendor, gmodel = guessmodel.guessmodel(**kwargs)
    if gvendor != 'Cisco' or gmodel not in ('',):
        return False, 'no match: %s %s' % (gvendor, gmodel), kwargs
    if not network.check_tcp_port(ip, 22):
        return False, 'closed.', kwargs
    try:
        name = run_ssh_asa(ip)
    except (network.Error, Error) as e:
        return False, str(e), kwargs
    except paramiko.SSHException as e:
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #28
0
def ssh_cisco_asa(**kwargs):
    ip = str(kwargs['ip'])
    if 'nx-os' in kwargs.get('snmp_name', '').lower():
        return False, 'incompatible Nexus found.', kwargs
    kwargs['guessmodel'] = gvendor, gmodel = guessmodel.guessmodel(**kwargs)
    if gvendor != 'Cisco' or gmodel not in ('', ):
        return False, 'no match: %s %s' % (gvendor, gmodel), kwargs
    if not network.check_tcp_port(ip, 22):
        return False, 'closed.', kwargs
    try:
        name = run_ssh_asa(ip)
    except (network.Error, Error) as e:
        return False, str(e), kwargs
    except paramiko.SSHException as e:
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #29
0
def ssh_hp_p2000(**kwargs):
    if SSH_P2000_USER is None or SSH_P2000_PASSWORD is None:
        return False, 'no credentials.', kwargs
    ip = str(kwargs['ip'])
    if 'StorageWorks' not in kwargs.get('snmp_name'):
        return False, 'no match.', kwargs
    if not network.check_tcp_port(ip, 22):
        return False, 'closed.', kwargs
    try:
        name = _run_ssh_p2000(ip)
    except (network.Error, storageworks.Error) as e:
        return False, str(e), kwargs
    except storageworks.Error as e:
        return False, str(e), kwargs
    except paramiko.SSHException as e:
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #30
0
def scan_address(ip_address, **kwargs):
    if 'nx-os' in (kwargs.get('snmp_name', '') or '').lower():
        raise NoMatchError('Incompatible Nexus found.')
    if kwargs.get('http_family', '') not in ('IBM', 'Unspecified'):
        raise NoMatchError('It is not IBM.')
    if not (kwargs.get('snmp_name', 'IBM') or 'IBM').startswith('IBM'):
        raise NoMatchError('It is not IBM.')
    if not network.check_tcp_port(ip_address, 22):
        raise ConnectionError('Port 22 closed on an IBM BladeServer.')
    messages = []
    result = get_base_result_template('ssh_ibm_bladecenter', messages)
    device = _blade_scan(ip_address)
    if not device:
        raise DeviceError("Malformed bladecenter device: %s" % ip_address)
    result['device'] = device
    result['status'] = 'success'
    return result
Beispiel #31
0
def ssh_hp_msa(**kwargs):
    if SSH_MSA_USER is None or SSH_MSA_PASSWORD is None:
        return False, 'no credentials.', kwargs
    ip = str(kwargs['ip'])
    if kwargs.get('http_family') not in ('WindRiver-WebServer',):
        return False, 'no match.', kwargs
    if not network.check_tcp_port(ip, 22):
        return False, 'closed.', kwargs
    try:
        name = _run_ssh_msa(ip)
    except (network.Error, storageworks.Error) as e:
        return False, str(e), kwargs
    except storageworks.Error as e:
        return False, str(e), kwargs
    except paramiko.SSHException as e:
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #32
0
def scan_address(ip_address, **kwargs):
    if 'nx-os' in (kwargs.get('snmp_name', '') or '').lower():
        raise NoMatchError('Incompatible Nexus found.')
    if kwargs.get('http_family', '') not in ('IBM', 'Unspecified'):
        raise NoMatchError('It is not IBM.')
    if not (kwargs.get('snmp_name', 'IBM') or 'IBM').startswith('IBM'):
        raise NoMatchError('It is not IBM.')
    if not network.check_tcp_port(ip_address, 22):
        raise ConnectionError('Port 22 closed on an IBM BladeServer.')
    messages = []
    result = get_base_result_template('ssh_ibm_bladecenter', messages)
    device = _blade_scan(ip_address)
    if not device:
        raise DeviceError("Malformed bladecenter device: %s" % ip_address)
    result['device'] = device
    result['status'] = 'success'
    return result
Beispiel #33
0
def ssh_onstor(**kwargs):
    if SSH_ONSTOR_USER is None or SSH_ONSTOR_PASSWORD is None:
        return False, 'no credentials.', kwargs
    ip = str(kwargs['ip'])
    if kwargs.get('http_family') not in ('sscccc',):
        return False, 'no match.', kwargs
    if not network.check_tcp_port(ip, 22):
        return False, 'closed.', kwargs
    try:
        name = _run_ssh_onstor(ip)
    except (network.Error, Error) as e:
        return False, str(e), kwargs
    except paramiko.SSHException as e:
        return False, str(e), kwargs
    except Error as e:
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #34
0
def ssh_proxmox(**kwargs):
    if 'nx-os' in kwargs.get('snmp_name', '').lower():
        return False, 'incompatible Nexus found.', kwargs
    ip = str(kwargs['ip'])
    if kwargs.get('http_family') not in ('Proxmox',):
        return False, 'no match.', kwargs
    if not network.check_tcp_port(ip, 22):
        return False, 'closed.', kwargs
    try:
        name = run_ssh_proxmox(ip)
    except (network.Error, Error) as e:
        return False, str(e), kwargs
    except paramiko.SSHException as e:
        return False, str(e), kwargs
    except Error as e:
        return False, str(e), kwargs
    return True, name, kwargs
def ssh_ibm_bladecenter(**kwargs):
    if "nx-os" in kwargs.get("snmp_name", "").lower():
        return False, "incompatible Nexus found.", kwargs
    ip = str(kwargs["ip"])
    if kwargs.get("http_family", "") not in ("IBM", "Unspecified"):
        return False, "no match.", kwargs
    if not kwargs.get("snmp_name", "IBM").startswith("IBM"):
        return False, "no match.", kwargs
    if not network.check_tcp_port(ip, 22):
        DiscoveryWarning(message="Port 22 closed on an IBM BladeServer.", plugin=__name__, ip=ip).save()
        return False, "closed.", kwargs
    try:
        name = run_ssh_bladecenter(ip)
    except (network.Error, Error, paramiko.SSHException, socket.error) as e:
        DiscoveryWarning(message="This is an IBM BladeServer, but: " + str(e), plugin=__name__, ip=ip).save()
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #36
0
def ssh_proxmox(**kwargs):
    if "nx-os" in kwargs.get("snmp_name", "").lower():
        return False, "incompatible Nexus found.", kwargs
    ip = str(kwargs["ip"])
    if kwargs.get("http_family") not in ("Proxmox",):
        return False, "no match.", kwargs
    if not network.check_tcp_port(ip, 22):
        return False, "closed.", kwargs
    try:
        name = run_ssh_proxmox(ip)
    except (network.Error, Error) as e:
        return False, str(e), kwargs
    except paramiko.SSHException as e:
        return False, str(e), kwargs
    except Error as e:
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #37
0
def ssh_ssg(**kwargs):
    ip = str(kwargs['ip'])
    if kwargs.get('http_family') not in ('SSG', 'Unspecified'):
        return False, 'no match.', kwargs
    if 'nx-os' in kwargs.get('snmp_name', '').lower():
        return False, 'incompatible Nexus found.', kwargs
    if not network.check_tcp_port(ip, 22):
        return False, 'closed.', kwargs
    try:
        name = run_ssh_ssg(ip)
    except network.Error as e:
        return False, str(e), kwargs
    except Error as e:
        return False, str(e), kwargs
    except paramiko.SSHException as e:
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #38
0
def ssh_ibm_bladecenter(**kwargs):
    ip = str(kwargs['ip'])
    if kwargs.get('http_family', '') not in ('IBM', 'Unspecified'):
        return False, 'no match.', kwargs
    if not kwargs.get('snmp_name', 'IBM').startswith('IBM'):
        return False, 'no match.', kwargs
    if not network.check_tcp_port(ip, 22):
        return False, 'closed.', kwargs
    try:
        name = run_ssh_bladecenter(ip)
    except network.Error as e:
        return False, str(e), kwargs
    except Error as e:
        return False, str(e), kwargs
    except paramiko.SSHException as e:
        return False, str(e), kwargs
    except socket.error as e:
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #39
0
def ssh_hp_p2000(**kwargs):
    if SSH_P2000_USER is None or SSH_P2000_PASSWORD is None:
        return False, 'no credentials.', kwargs
    if 'nx-os' in kwargs.get('snmp_name', '').lower():
        return False, 'incompatible Nexus found.', kwargs
    ip = str(kwargs['ip'])
    if 'StorageWorks' not in kwargs.get('snmp_name'):
        return False, 'no match.', kwargs
    if not network.check_tcp_port(ip, 22):
        return False, 'closed.', kwargs
    try:
        name = _run_ssh_p2000(ip)
    except (network.Error, storageworks.Error) as e:
        return False, str(e), kwargs
    except storageworks.Error as e:
        return False, str(e), kwargs
    except paramiko.SSHException as e:
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #40
0
def ssh_3par(**kwargs):
    if SSH_3PAR_USER is None or SSH_3PAR_PASSWORD is None:
        return False, 'no credentials.', kwargs
    ip = str(kwargs['ip'])
    if kwargs.get('http_family') not in ('Unspecified',):
        return False, 'no match.', kwargs
    if not kwargs.get('snmp_name').startswith('3PAR'):
        return False, 'no match.', kwargs
    if not network.check_tcp_port(ip, 22):
        return False, 'closed.', kwargs
    try:
        name = _run_ssh_3par(ip)
    except (network.Error, Error) as e:
        return False, str(e), kwargs
    except Error as e:
        return False, str(e), kwargs
    except paramiko.SSHException as e:
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #41
0
def ssh_catalyst(**kwargs):
    if SSH_USER is None or SSH_PASSWORD is None:
        return False, 'no credentials.', kwargs
    ip = str(kwargs['ip'])
    if 'nx-os' in kwargs.get('snmp_name', '').lower():
        return False, 'incompatible Nexus found.', kwargs
    if kwargs.get('http_family') not in ('Unspecified', 'Cisco'):
        return False, 'no match.', kwargs
    if not network.check_tcp_port(ip, 22):
        return False, 'closed.', kwargs
    try:
        name = _run_ssh_catalyst(ip)
    except (network.Error, Error) as e:
        return False, str(e), kwargs
    except paramiko.SSHException as e:
        return False, str(e), kwargs
    except Error as e:
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #42
0
def ssh_ibm_bladecenter(**kwargs):
    ip = str(kwargs["ip"])
    if kwargs.get("http_family", "") not in ("IBM", "Unspecified"):
        return False, "no match.", kwargs
    if not kwargs.get("snmp_name", "IBM").startswith("IBM"):
        return False, "no match.", kwargs
    if not network.check_tcp_port(ip, 22):
        return False, "closed.", kwargs
    try:
        name = run_ssh_bladecenter(ip)
    except network.Error as e:
        return False, str(e), kwargs
    except Error as e:
        return False, str(e), kwargs
    except paramiko.SSHException as e:
        return False, str(e), kwargs
    except socket.error as e:
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #43
0
def ssh_catalyst(**kwargs):
    if SSH_USER is None or SSH_PASSWORD is None:
        return False, 'no credentials.', kwargs
    ip = str(kwargs['ip'])
    if 'nx-os' in kwargs.get('snmp_name', '').lower():
        return False, 'incompatible Nexus found.', kwargs
    if kwargs.get('http_family') not in ('Unspecified', 'Cisco'):
        return False, 'no match.', kwargs
    if not network.check_tcp_port(ip, 22):
        return False, 'closed.', kwargs
    try:
        name = _run_ssh_catalyst(ip)
    except (network.Error, Error) as e:
        return False, str(e), kwargs
    except paramiko.SSHException as e:
        return False, str(e), kwargs
    except Error as e:
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #44
0
def ssh_catalyst(**kwargs):
    if SSH_USER is None or SSH_PASSWORD is None:
        return False, "no credentials.", kwargs
    ip = str(kwargs["ip"])
    if "nx-os" in kwargs.get("snmp_name", "").lower():
        return False, "incompatible Nexus found.", kwargs
    if kwargs.get("http_family") not in ("Unspecified", "Cisco"):
        return False, "no match.", kwargs
    if not network.check_tcp_port(ip, 22):
        return False, "closed.", kwargs
    try:
        name = _run_ssh_catalyst(ip)
    except (network.Error, Error) as e:
        return False, str(e), kwargs
    except paramiko.SSHException as e:
        return False, str(e), kwargs
    except Error as e:
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #45
0
def ssh_hp_msa(**kwargs):
    if SSH_MSA_USER is None or SSH_MSA_PASSWORD is None:
        return False, 'no credentials.', kwargs
    if 'nx-os' in kwargs.get('snmp_name', '').lower():
        return False, 'incompatible Nexus found.', kwargs
    ip = str(kwargs['ip'])
    if kwargs.get('http_family') not in ('WindRiver-WebServer',):
        return False, 'no match.', kwargs
    if not network.check_tcp_port(ip, 22):
        return False, 'closed.', kwargs
    try:
        name = _run_ssh_msa(ip)
    except (network.Error, storageworks.Error) as e:
        return False, str(e), kwargs
    except storageworks.Error as e:
        return False, str(e), kwargs
    except paramiko.SSHException as e:
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #46
0
def ssh_aix(**kwargs):
    ip = str(kwargs["ip"])
    if AIX_USER is None:
        return False, "no auth.", kwargs
    kwargs["guessmodel"] = gvendor, gmodel = guessmodel.guessmodel(**kwargs)
    if gvendor != "IBM":
        return False, "no match: %s %s" % (gvendor, gmodel), kwargs
    snmp_name = kwargs.get("snmp_name", "")
    if snmp_name and not snmp_name.startswith("IBM PowerPC"):
        return False, "no match.", kwargs
    if not network.check_tcp_port(ip, 22):
        return False, "closed.", kwargs
    try:
        name = run_ssh_aix(ip)
    except (network.Error, Error) as e:
        return False, str(e), kwargs
    except paramiko.SSHException as e:
        return False, str(e), kwargs
    except Error as e:
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #47
0
def ssh_xen(**kwargs):
    ip = str(kwargs['ip'])
    if XEN_USER is None:
        return False, 'no auth.', kwargs
    if 'xen' not in kwargs.get('snmp_name', ''):
        return False, 'no match.', kwargs
    if not network.check_tcp_port(ip, 22):
        return False, 'closed.', kwargs
    ipaddr = IPAddress.objects.get(address=ip)
    dev = ipaddr.device
    if dev is None:
        return False, 'no device.', kwargs
    try:
        name = run_ssh_xen(ipaddr, dev)
    except (network.Error, Error) as e:
        return False, str(e), kwargs
    except paramiko.SSHException as e:
        return False, str(e), kwargs
    except Error as e:
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #48
0
def ssh_xen(**kwargs):
    ip = str(kwargs['ip'])
    if XEN_USER is None:
        return False, 'no auth.', kwargs
    if 'nx-os' in kwargs.get('snmp_name', '').lower():
        return False, 'incompatible Nexus found.', kwargs
    if 'xen' not in kwargs.get('snmp_name', ''):
        return False, 'no match.', kwargs
    if not network.check_tcp_port(ip, 22):
        return False, 'closed.', kwargs
    ipaddr = IPAddress.objects.get(address=ip)
    dev = ipaddr.device
    if dev is None:
        return False, 'no device.', kwargs
    try:
        name = run_ssh_xen(ipaddr, dev)
    except (network.Error, Error) as e:
        return False, str(e), kwargs
    except paramiko.SSHException as e:
        return False, str(e), kwargs
    except Error as e:
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #49
0
def ssh_proxmox(**kwargs):
    if 'nx-os' in kwargs.get('snmp_name', '').lower():
        return False, 'incompatible Nexus found.', kwargs
    ip = str(kwargs['ip'])
    if kwargs.get('http_family') not in ('Proxmox', ):
        return False, 'no match.', kwargs
    if not network.check_tcp_port(ip, 22):
        DiscoveryWarning(
            message="Port 22 closed on a Proxmox server.",
            plugin=__name__,
            ip=ip,
        ).save()
        return False, 'closed.', kwargs
    try:
        name = run_ssh_proxmox(ip)
    except (network.Error, Error, paramiko.SSHException) as e:
        DiscoveryWarning(
            message="This is a Proxmox, but: " + str(e),
            plugin=__name__,
            ip=ip,
        ).save()
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #50
0
def ssh_aix(**kwargs):
    if 'nx-os' in kwargs.get('snmp_name', '').lower():
        return False, 'incompatible Nexus found.', kwargs
    ip = str(kwargs['ip'])
    if AIX_USER is None:
        return False, 'no auth.', kwargs
    kwargs['guessmodel'] = gvendor, gmodel = guessmodel.guessmodel(**kwargs)
    if gvendor != 'IBM':
        return False, 'no match: %s %s' % (gvendor, gmodel), kwargs
    snmp_name = kwargs.get('snmp_name', '')
    if snmp_name and not snmp_name.startswith('IBM PowerPC'):
        return False, 'no match.', kwargs
    if not network.check_tcp_port(ip, 22):
        return False, 'closed.', kwargs
    try:
        name = run_ssh_aix(ip)
    except (network.Error, Error) as e:
        return False, str(e), kwargs
    except paramiko.SSHException as e:
        return False, str(e), kwargs
    except Error as e:
        return False, str(e), kwargs
    return True, name, kwargs
Beispiel #51
0
def _connect_ssh(ip_address, user, password):
    if not network.check_tcp_port(ip_address, 22):
        raise ConnectionError('Port 22 closed on a Proxmox server.')
    return network.connect_ssh(ip_address, user, password)
Beispiel #52
0
def _connect_ssh(ip_address, user, password):
    if not check_tcp_port(ip_address, 22):
        raise ConnectionError('Port 22 closed on a XEN server.')
    return connect_ssh(ip_address, user, password)
Beispiel #53
0
def _connect_ssh(ip_address, user, password):
    if not check_tcp_port(ip_address, 22):
        raise ConnectionError('Port 22 closed.')
    return connect_ssh(ip_address, user, password, client=SSGSSHClient)