Skip to content

Commit

Permalink
chore(black): Patch black warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
lperdereau committed Dec 9, 2024
1 parent 8c078f5 commit de2e170
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/pvecontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import re
import sys
from pvecontrol import main # pylint: disable=import-self
from pvecontrol import main # pylint: disable=import-self

if __name__ == "__main__":
sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0])
Expand Down
2 changes: 2 additions & 0 deletions src/pvecontrol/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ def _column_type(value):

def add_table_related_arguments(parser, columns, default_sort):
filter_type_generator = _make_filter_type_generator(columns)

def filter_type(x):
return next(filter_type_generator)(x)

parser.add_argument(
"--sort-by",
action="store",
Expand Down
10 changes: 7 additions & 3 deletions src/pvecontrol/actions/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def action_nodelist(proxmox, args):
print_tableoutput(proxmox.nodes, columns=args.columns, sortby=args.sort_by, filters=args.filter)


#pylint: disable=too-many-branches,too-many-statements
# pylint: disable=too-many-branches,too-many-statements
def action_nodeevacuate(proxmox, args):
"""Evacuate a node by migrating all it's VM out"""
# check node exists
Expand Down Expand Up @@ -56,7 +56,9 @@ def action_nodeevacuate(proxmox, args):
for target in targets:
logging.debug(
"Test target: %s, allocatedmem: %i, allocatedcpu: %i",
target.node, target.allocatedmem, target.allocatedcpu
target.node,
target.allocatedmem,
target.allocatedcpu,
)
if (vm.maxmem + target.allocatedmem) > (target.maxmem - proxmox.config["node"]["memoryminimum"]):
logging.debug("Discard target: %s, will overcommit ram", target.node)
Expand All @@ -75,7 +77,9 @@ def action_nodeevacuate(proxmox, args):
target.allocatedcpu += vm.cpus
logging.debug(
"Selected target %s: new allocatedmem %i, new allocatedcpu %i",
target.node, target.allocatedmem, target.allocatedcpu
target.node,
target.allocatedmem,
target.allocatedcpu,
)
break
else:
Expand Down
6 changes: 2 additions & 4 deletions src/pvecontrol/actions/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ def action_vmmigrate(proxmox, args):
# FIXME

# Check que la migration est possible
check = proxmox.api.nodes(node.node).qemu(
vmid).migrate.get(node=node.node, target=target.node)
check = proxmox.api.nodes(node.node).qemu(vmid).migrate.get(node=node.node, target=target.node)
logging.debug("Migration check: %s", check)
options = {}
options["node"] = node.node
Expand All @@ -65,5 +64,4 @@ def action_vmmigrate(proxmox, args):
def action_vmlist(proxmox, args):
"""List VMs in the Proxmox Cluster"""
vms = proxmox.vms()
print_tableoutput(vms, columns=args.columns,
sortby=args.sort_by, filters=args.filter)
print_tableoutput(vms, columns=args.columns, sortby=args.sort_by, filters=args.filter)
2 changes: 1 addition & 1 deletion src/pvecontrol/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def refresh(self):
self._initstatus()

def __str__(self):
output = f"Proxmox VE Cluster {self.name}\n"
output = f"Proxmox VE Cluster {self.name}\n"
output += f" Status: {self.status}\n"
output += " Resources: {self.resources}\n"
output += " Nodes:\n"
Expand Down
1 change: 1 addition & 0 deletions src/pvecontrol/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

config = confuse.LazyConfig("pvecontrol", __name__)


def set_config(cluster_name):
validconfig = config.get(configtemplate)
logging.debug("configuration is %s", validconfig)
Expand Down
3 changes: 1 addition & 2 deletions src/pvecontrol/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ def _init_vms(self):
self.vms = []
if self.status == NodeStatus.ONLINE:
self.vms = [
PVEVm(self.api, self.node, vm["vmid"], vm["status"], vm)
for vm in self.api.nodes(self.node).qemu.get()
PVEVm(self.api, self.node, vm["vmid"], vm["status"], vm) for vm in self.api.nodes(self.node).qemu.get()
]

def _init_allocatedmem(self):
Expand Down

0 comments on commit de2e170

Please sign in to comment.