fixed stuffs

This commit is contained in:
Pünkösd Marcell 2021-11-11 02:32:26 +01:00
parent f4bdf8809e
commit fbee178ad2

View File

@ -59,7 +59,7 @@ libvirt = """<domain type="kvm">
<currentMemory unit="MiB">{ram}</currentMemory>
<vcpu placement="static">2</vcpu>
<os>
<type arch="x86_64" machine="pc-q35-6.1">hvm</type>
<type arch="x86_64" machine="pc-q35-6.0">hvm</type>
<boot dev="hd"/>
</os>
<features>
@ -88,9 +88,11 @@ libvirt = """<domain type="kvm">
<target dev="sda" bus="sata"/>
<readonly/>
</disk>
<disk type="file" device="disk">
<driver name="qemu" type="qcow2"/>
<source file="{hostdrive}"/>
<disk type="block" device="disk">
<driver name="qemu" type="raw" cache="none" io="native"/>
<backingStore/>
<source dev="{hostdrive}"/>
<alias name="virtio-disk0"/>
<target dev="vda" bus="virtio"/>
</disk>
<controller type="usb" index="0" model="qemu-xhci" ports="15">
@ -195,8 +197,8 @@ libvirt = """<domain type="kvm">
def run_iso(hostname:str, ipaddr:str):
isoout = "/var/lib/libvirt/images/cloudiso"
gateway = '192.168.' + ipaddr.split('.')[3] + '.1' # Ezen Kristóf jót nevetett
isoout = "/home/marcsello/ultrabirbcluster/vm_generator_luna/iso"
os.makedirs(isoout, exist_ok=True)
cloudinit_fhandle, cloudinit_fname = tempfile.mkstemp(suffix='.yaml')
with open(cloudinit_fhandle, "wt") as f:
@ -204,6 +206,8 @@ def run_iso(hostname:str, ipaddr:str):
cloudinit.format(hostname=hostname)
)
if ipaddr:
gateway = '192.168.' + ipaddr.split('.')[2] + '.1' # Ezen Kristóf jót nevetett
netplan_fhandle, netplan_fname = tempfile.mkstemp(suffix='.yaml')
with open(netplan_fhandle, "wt") as f:
f.write(
@ -212,12 +216,12 @@ def run_iso(hostname:str, ipaddr:str):
gateway=gateway,
)
)
os.makedirs(isoout, exist_ok=True)
os.system(f'cloud-localds -v {isoout}/cloudinit-{hostname}.iso --network-config={netplan_fname} {cloudinit_fname}')
os.unlink(cloudinit_fname)
os.unlink(netplan_fname)
else:
os.system(f'cloud-localds -v {isoout}/cloudinit-{hostname}.iso {cloudinit_fname}')
os.unlink(cloudinit_fname)
def run_img(hostname:str, img_src:str):