feat: implement automated VMID discovery for LXC creation
This commit is contained in:
parent
1536974fcc
commit
b5814e9e61
4 changed files with 35 additions and 4 deletions
|
|
@ -156,7 +156,7 @@ def proxmox_list_lxcs(config, node):
|
|||
click.echo(mgr.list_lxcs())
|
||||
|
||||
@proxmox.command(name='create-lxc')
|
||||
@click.argument('vmid')
|
||||
@click.option('--vmid', help='VMID for the container (auto-discovered if omitted)')
|
||||
@click.argument('template')
|
||||
@click.argument('hostname')
|
||||
@click.argument('ip')
|
||||
|
|
@ -166,8 +166,18 @@ def proxmox_list_lxcs(config, node):
|
|||
@click.pass_obj
|
||||
def proxmox_create_lxc(config, vmid, template, hostname, ip, gateway, node, password):
|
||||
mgr = ProxmoxManager(config, node)
|
||||
mgr.create_lxc(vmid, template, hostname, ip, gateway, password=password)
|
||||
click.echo(f"LXC {vmid} ({hostname}) created on {mgr.node_name or 'default node'}")
|
||||
|
||||
target_vmid = vmid
|
||||
if not target_vmid:
|
||||
click.echo("Discovering next available VMID...")
|
||||
target_vmid = mgr.get_next_vmid()
|
||||
if not target_vmid:
|
||||
click.echo("Error: Could not automatically discover next VMID. Please provide one with --vmid", err=True)
|
||||
sys.exit(1)
|
||||
|
||||
click.echo(f"Using VMID: {target_vmid}")
|
||||
mgr.create_lxc(target_vmid, template, hostname, ip, gateway, password=password)
|
||||
click.echo(f"LXC {target_vmid} ({hostname}) created on {mgr.node_name or 'default node'}")
|
||||
|
||||
@cli.group()
|
||||
def samba():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue