Skip to content

Commit f91908f

Browse files
committed
Linting
1 parent c8331b6 commit f91908f

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

proxstar/proxmox.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,33 @@
88

99
def connect_proxmox(host=None):
1010
if host:
11-
attempted_connection = attempt_proxmox_connection(host)
12-
if attempted_connection:
13-
return attempted_connection
14-
logging.error(f'unable to connect to {host}')
15-
raise
16-
17-
for host in app.config['PROXMOX_HOSTS']:
18-
attempted_connection = attempt_proxmox_connection(host)
19-
if attempted_connection:
20-
return attempted_connection
21-
logging.error('unable to connect to any of the given Proxmox servers')
22-
raise
11+
try:
12+
return attempt_proxmox_connection(host)
13+
except:
14+
logging.error(f'unable to connect to {host}')
15+
raise
16+
17+
for host_candidate in app.config['PROXMOX_HOSTS']:
18+
try:
19+
return attempt_proxmox_connection(host_candidate)
20+
except:
21+
if app.config['PROXMOX_HOSTS'].index(host_candidate) == (
22+
len(app.config['PROXMOX_HOSTS']) - 1
23+
):
24+
logging.error('unable to connect to any of the given Proxmox servers')
25+
raise
2326

2427

2528
def attempt_proxmox_connection(host):
26-
try:
27-
proxmox = ProxmoxAPI(
28-
host,
29-
user=app.config['PROXMOX_USER'],
30-
token_name=app.config['PROXMOX_TOKEN_NAME'],
31-
token_value=app.config['PROXMOX_TOKEN_VALUE'],
32-
verify_ssl=False,
33-
)
34-
proxmox.version.get()
35-
return proxmox
36-
except:
37-
return None
29+
proxmox = ProxmoxAPI(
30+
host,
31+
user=app.config['PROXMOX_USER'],
32+
token_name=app.config['PROXMOX_TOKEN_NAME'],
33+
token_value=app.config['PROXMOX_TOKEN_VALUE'],
34+
verify_ssl=False,
35+
)
36+
proxmox.version.get()
37+
return proxmox
3838

3939

4040
def get_node_least_mem(proxmox):

0 commit comments

Comments
 (0)