Added stuff

This commit is contained in:
2021-11-11 23:56:09 +01:00
parent f67835393f
commit a306d9e56c
73 changed files with 4021 additions and 16 deletions

View File

@ -206,22 +206,33 @@ def run_iso(hostname:str, ipaddr:str):
cloudinit.format(hostname=hostname)
)
netplan_fname = None
netplan_generated = False
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(
netplan.format(
addr=ipaddr,
gateway=gateway,
if not ipaddr.startswith('@'):
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(
netplan.format(
addr=ipaddr,
gateway=gateway,
)
)
)
os.system(f'cloud-localds -v {isoout}/cloudinit-{hostname}.iso --network-config={netplan_fname} {cloudinit_fname}')
os.unlink(netplan_fname)
else:
os.system(f'cloud-localds -v {isoout}/cloudinit-{hostname}.iso {cloudinit_fname}')
netplan_generated = True
else:
fname = ipaddr[1:]
netplan_fname = fname
if netplan_fname:
os.system(f'cloud-localds -v {isoout}/cloudinit-{hostname}.iso --network-config={netplan_fname} {cloudinit_fname}')
else:
os.system(f'cloud-localds -v {isoout}/cloudinit-{hostname}.iso {cloudinit_fname}')
os.unlink(cloudinit_fname)
if netplan_generated:
os.unlink(netplan_fname)
def run_img(hostname:str, img_src:str):
@ -239,11 +250,21 @@ def run_xml(outdir:str, hostname:str, ram:int, net:str):
os.makedirs(xmlout, exist_ok=True)
interfacecfg = ""
interfaces=list(net.split(','))
for n in net.split(','):
for i, n in enumerate(interfaces):
multi = ""
if i == 0 and len(interfaces) > 1:
multi = 'multifunction="on"'
# Defining address like this fixes the interface to be enp1s0
# And consequitive interfaces will be enp1s0f{n}
interfacecfg += f""" <interface type="network">
<source network="{n}"/>
<model type="virtio"/>
<address type="pci" domain="0x0000" bus="0x01" slot="0x00" function="0x{i}" {multi} />
</interface>"""
@ -262,7 +283,7 @@ def run_xml(outdir:str, hostname:str, ram:int, net:str):
def run_ssh(outdir:str, hostname:str, ipaddr:str):
if not ipaddr:
return
sshout_file = os.path.join(outdir, 'ssh_config')
with open(sshout_file, 'at') as f:
f.write("\n".join([

View File

@ -0,0 +1,32 @@
network:
version: 2
ethernets:
# cloud
enp1s0f0:
dhcp4: false
dhcp6: false
gateway4: 192.168.110.1
addresses:
- "192.168.110.10/24"
# edge-1
enp1s0f1:
dhcp4: false
dhcp6: false
addresses:
- "192.168.111.10/24"
# edge-2
enp1s0f2:
dhcp4: false
dhcp6: false
addresses:
- "192.168.112.10/24"
# site
enp1s0f3:
dhcp4: false
dhcp6: false
addresses:
- "192.168.113.10/24"