Skip to content

Commit

Permalink
fix scrap merge
Browse files Browse the repository at this point in the history
  • Loading branch information
dguenault committed Sep 12, 2023
1 parent 4557ada commit cc95c5d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
7 changes: 2 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@

all: clean venv setup tests
all: clean venv setup

setup:
venv/bin/python3 setup.py install

tests:
./venv/bin/python tests.py

venv:
python3 -m venv venv
./venv/bin/pip install --upgrade pip wheel

clean:
rm -Rf build dist *.egg-info __pycache__ venv

.PHONY: all setup tests venv clean
.PHONY: all setup venv clean
6 changes: 4 additions & 2 deletions proxcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,8 @@ def vms_set(
cipassword: Annotated[str, typer.Option()] = None,
citype: Annotated[str, typer.Option()] = None,
ciuser: Annotated[str, typer.Option()] = None,
boot: Annotated[str, typer.Option] = None
boot: Annotated[str, typer.Option] = None,
sshkey: Annotated[str, typer.Option] = None
):
p.set_vms(
vmid=vmid,
Expand All @@ -375,7 +376,8 @@ def vms_set(
cipassword=cipassword,
ciuser=ciuser,
citype=citype,
boot=boot
boot=boot,
sshkey=sshkey
)

@vms.command("migrate")
Expand Down
26 changes: 16 additions & 10 deletions proxmoxlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import sys
import requests
from requests_toolbelt import MultipartEncoder
import urllib

class proxmox():
def __init__(self) -> None:
Expand Down Expand Up @@ -608,31 +609,36 @@ def vms_resize_disk(self, size, vmid=None, vmname=None,disk=None):
self.proxmox_instance.nodes(node).qemu(vmid).resize.put(**{"disk": disk, "size": size})


def set_vms(self, vmid, vmname, cores, sockets, cpulimit, memory, ipconfig=None, cipassword=None, citype=None, ciuser=None, boot=None):
def set_vms(self, vmid, vmname, cores, sockets, cpulimit, memory, ipconfig=None, cipassword=None, citype=None, ciuser=None, boot=None, sshkey=None):
vm = self.get_vm_by_id_or_name(vmid, vmname)
if not vm:
raise("Error: no vm match the requested vmid or name")
node = vm["node"]
vmid = vm["vmid"] if not vmid else vmid

data = {}

if cores:
self.proxmox_instance.nodes(node).qemu(vmid).config.put(**{"cores": cores})
data["cores"] = cores
if sockets:
self.proxmox_instance.nodes(node).qemu(vmid).config.put(**{"sockets": sockets})
data["sockets"] = sockets
if cpulimit:
self.proxmox_instance.nodes(node).qemu(vmid).config.put(**{"cpulimit": cpulimit})
data["cpulimit"] = cpulimit
if memory:
self.proxmox_instance.nodes(node).qemu(vmid).config.put(**{"memory": memory})
data["memory"] = memory
if cipassword:
self.proxmox_instance.nodes(node).qemu(vmid).config.put(**{"cipassword": cipassword})
data["cipassword"] = cipassword
if citype:
self.proxmox_instance.nodes(node).qemu(vmid).config.put(**{"citype": citype})
data["citype"] = citype
if ciuser:
self.proxmox_instance.nodes(node).qemu(vmid).config.put(**{"ciuser": ciuser})
data["ciuser"] = ciuser
if ipconfig:
self.proxmox_instance.nodes(node).qemu(vmid).config.put(**{"ipconfig0": ipconfig})
data["ipconfig0"] = ipconfig
if boot:
self.proxmox_instance.nodes(node).qemu(vmid).config.put(**{"boot": boot})
data["boot"] = boot
if sshkey:
data["sshkeys"] = urllib.parse.quote(sshkey.strip(),safe='')
self.proxmox_instance.nodes(node).qemu(vmid).config.put(**data)


def get_vm_public_ip(self,node, vmid, type="ipv4") :
Expand Down

0 comments on commit cc95c5d

Please sign in to comment.