kevydotvinu / openshift-network-playground

The OpenShift Network Playground is built for advanced OpenShift users who needs to quickly build and test different OpenShift network scenarios.
https://kevy.gitbook.io/onp
MIT License
3 stars 1 forks source link

Host ONP on KVM #91

Open kevydotvinu opened 1 year ago

kevydotvinu commented 1 year ago
$ cat macvtap.xml
<network>
  <name>macvtap-net</name>
  <forward mode="bridge">
    <interface dev="ens1f0"/>
  </forward>
</network>
$ cat vm.sh
VM_NAME=${1}
ISO=${2}
VCPU=20
MEMORY=81920
VM_DISK=${VM_NAME}.img,bus=scsi
# NETWORK=network=macvtap-net,model=virtio,mac=52:54:00:1e:4d:ae
NETWORK=network=macvtap-net,model=virtio
CDROM=${ISO}

virsh destroy ${VM_NAME}
virsh undefine ${VM_NAME}
sudo qemu-img create ${VM_NAME}.img 540G
virt-install --name $VM_NAME \
        --os-variant fedora-coreos-stable \
        --vcpus $VCPU \
        --memory $MEMORY \
        --disk $VM_DISK \
        --network $NETWORK \
        --pxe \
        --cdrom $CDROM \
        --boot hd,cdrom \
        --filesystem type=mount,mode=mapped,source=/mnt,target=/mnt \
        --graphics spice,listen=0.0.0.0 \
        --video virtio \
        --channel spicevmc \
        --console pty,target.type=virtio \
        --serial pty \
        --noautoconsole

function WAIT_FOR_REBOOT {
sp='/-\|'
sc=0

spin() {
   printf "\r[${sp:sc++:1}] $1"
   ((sc==${#sp})) && sc=0
}

endspin() {
   printf "\r%s\n" "$@"
}

until [[ $(sudo virsh -q list | grep -o ${VM_NAME} | wc -c) -eq 0 ]]
do spin "Waiting for the installation and restart ..."
sleep 0.5
done
endspin
}

function START_NODE {
        sudo virsh start ${VM_NAME} > /dev/null
        echo "[✔] Installation completed!"
}

WAIT_FOR_REBOOT
START_NODE