Exemple #1
0
def connect_ldap():
    try:
        ldap = CSHLDAP(app.config['LDAP_BIND_DN'], app.config['LDAP_BIND_PW'])
    except Exception as e:
        logging.error('unable to connect to LDAP: %s', e)
        raise
    return ldap
def connect_proxmox():
    for host in app.config['PROXMOX_HOSTS']:
        try:
            proxmox = ProxmoxAPI(
                host,
                user=app.config['PROXMOX_USER'],
                password=app.config['PROXMOX_PASS'],
                verify_ssl=False,
            )
            proxmox.version.get()
            return proxmox
        except:
            if app.config['PROXMOX_HOSTS'].index(host) == (len(app.config['PROXMOX_HOSTS']) - 1):
                logging.error('unable to connect to any of the given Proxmox servers')
                raise
def connect_proxmox_ssh():
    for host in app.config['PROXMOX_HOSTS']:
        try:
            proxmox = ProxmoxAPI(
                host,
                user=app.config['PROXMOX_SSH_USER'],
                private_key_file='proxmox_ssh_key',
                password=app.config['PROXMOX_SSH_KEY_PASS'],
                backend='ssh_paramiko',
            )
            proxmox.version.get()
            return proxmox
        except:
            if app.config['PROXMOX_HOSTS'].index(host) == (len(app.config['PROXMOX_HOSTS']) - 1):
                logging.error('unable to connect to any of the given Proxmox servers')
                raise