allow for multiple proxmox hosts in case one fails

This commit is contained in:
Jordan Rodgers 2018-02-06 22:27:08 -05:00
parent 423e5ad119
commit ecd7809749
2 changed files with 12 additions and 9 deletions

View file

@ -24,7 +24,7 @@ OIDC_CLIENT_CONFIG = {
} }
# Proxmox # Proxmox
PROXMOX_HOST = environ.get('PROXSTAR_PROXMOX_HOST', '') PROXMOX_HOSTS = [host.strip() for host in environ.get('PROXSTAR_PROXMOX_HOSTS', '').split(',')]
PROXMOX_USER = environ.get('PROXSTAR_PROXMOX_USER', '') PROXMOX_USER = environ.get('PROXSTAR_PROXMOX_USER', '')
PROXMOX_PASS = environ.get('PROXSTAR_PROXMOX_PASS', '') PROXMOX_PASS = environ.get('PROXSTAR_PROXMOX_PASS', '')
PROXMOX_ISO_STORAGE = environ.get('PROXSTAR_PROXMOX_ISO_STORAGE', 'nfs-iso') PROXMOX_ISO_STORAGE = environ.get('PROXSTAR_PROXMOX_ISO_STORAGE', 'nfs-iso')

View file

@ -5,16 +5,19 @@ from proxstar.ldapdb import *
def connect_proxmox(): def connect_proxmox():
try: for host in app.config['PROXMOX_HOSTS']:
proxmox = ProxmoxAPI( try:
app.config['PROXMOX_HOST'], proxmox = ProxmoxAPI(
user=app.config['PROXMOX_USER'], host,
password=app.config['PROXMOX_PASS'], user=app.config['PROXMOX_USER'],
verify_ssl=False) password=app.config['PROXMOX_PASS'],
except: verify_ssl=False)
version = proxmox.version.get()
return proxmox
except:
pass
print("Unable to connect to Proxmox!") print("Unable to connect to Proxmox!")
raise raise
return proxmox
def create_user(proxmox, user): def create_user(proxmox, user):