From de2e170c660aa4e7204f11b666491c1a62bc5c1a Mon Sep 17 00:00:00 2001 From: Louis PERDEREAU Date: Mon, 9 Dec 2024 14:03:17 +0100 Subject: [PATCH] chore(black): Patch black warnings --- src/pvecontrol.py | 2 +- src/pvecontrol/__init__.py | 2 ++ src/pvecontrol/actions/node.py | 10 +++++++--- src/pvecontrol/actions/vm.py | 6 ++---- src/pvecontrol/cluster.py | 2 +- src/pvecontrol/config.py | 1 + src/pvecontrol/node.py | 3 +-- 7 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/pvecontrol.py b/src/pvecontrol.py index 5532c0e..0b864cc 100644 --- a/src/pvecontrol.py +++ b/src/pvecontrol.py @@ -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]) diff --git a/src/pvecontrol/__init__.py b/src/pvecontrol/__init__.py index a0f9b71..ca4a63c 100644 --- a/src/pvecontrol/__init__.py +++ b/src/pvecontrol/__init__.py @@ -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", diff --git a/src/pvecontrol/actions/node.py b/src/pvecontrol/actions/node.py index da98a66..f361125 100644 --- a/src/pvecontrol/actions/node.py +++ b/src/pvecontrol/actions/node.py @@ -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 @@ -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) @@ -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: diff --git a/src/pvecontrol/actions/vm.py b/src/pvecontrol/actions/vm.py index 38b5b70..85afd14 100644 --- a/src/pvecontrol/actions/vm.py +++ b/src/pvecontrol/actions/vm.py @@ -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 @@ -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) diff --git a/src/pvecontrol/cluster.py b/src/pvecontrol/cluster.py index ce25c38..e335310 100644 --- a/src/pvecontrol/cluster.py +++ b/src/pvecontrol/cluster.py @@ -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" diff --git a/src/pvecontrol/config.py b/src/pvecontrol/config.py index f7ec5dd..5f0c654 100644 --- a/src/pvecontrol/config.py +++ b/src/pvecontrol/config.py @@ -25,6 +25,7 @@ config = confuse.LazyConfig("pvecontrol", __name__) + def set_config(cluster_name): validconfig = config.get(configtemplate) logging.debug("configuration is %s", validconfig) diff --git a/src/pvecontrol/node.py b/src/pvecontrol/node.py index c0f97df..69962da 100644 --- a/src/pvecontrol/node.py +++ b/src/pvecontrol/node.py @@ -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):