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():
for host in app.config['PROXMOX_HOSTS']:
try: try:
proxmox = ProxmoxAPI( proxmox = ProxmoxAPI(
app.config['PROXMOX_HOST'], host,
user=app.config['PROXMOX_USER'], user=app.config['PROXMOX_USER'],
password=app.config['PROXMOX_PASS'], password=app.config['PROXMOX_PASS'],
verify_ssl=False) verify_ssl=False)
version = proxmox.version.get()
return proxmox
except: 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):