Skip to content

Commit

Permalink
Merge pull request #33 from gyptazy/fix/27-container-migration
Browse files Browse the repository at this point in the history
fix: Rebalance CT function including reboot
  • Loading branch information
gyptazy authored Jul 28, 2024
2 parents 5c6cf04 + 4efa9df commit 4671b41
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions proxlb
Original file line number Diff line number Diff line change
Expand Up @@ -697,9 +697,18 @@ def __run_vm_rebalancing(api_object, vm_statistics_rebalanced, app_args):

if len(vm_statistics_rebalanced) > 0 and not app_args.dry_run:
for vm, value in vm_statistics_rebalanced.items():

try:
logging.info(f'{info_prefix} Rebalancing vm {vm} from node {value["node_parent"]} to node {value["node_rebalance"]}.')
api_object.nodes(value['node_parent']).qemu(value['vmid']).migrate().post(target=value['node_rebalance'],online=1)
# Migrate type VM (live migration).
if value['type'] == 'vm':
logging.info(f'{info_prefix} Rebalancing VM {vm} from node {value["node_parent"]} to node {value["node_rebalance"]}.')
api_object.nodes(value['node_parent']).qemu(value['vmid']).migrate().post(target=value['node_rebalance'],online=1)

# Migrate type CT (requires restart of container).
if value['type'] == 'ct':
logging.info(f'{info_prefix} Rebalancing CT {vm} from node {value["node_parent"]} to node {value["node_rebalance"]}.')
api_object.nodes(value['node_parent']).lxc(value['vmid']).migrate().post(target=value['node_rebalance'],restart=1)

except proxmoxer.core.ResourceException as error_resource:
logging.critical(f'{error_prefix} {error_resource}')
else:
Expand Down

0 comments on commit 4671b41

Please sign in to comment.