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_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_PASS = environ.get('PROXSTAR_PROXMOX_PASS', '')
PROXMOX_ISO_STORAGE = environ.get('PROXSTAR_PROXMOX_ISO_STORAGE', 'nfs-iso')

View file

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