More updates

* Add hypervisor config file to standardise script
* Add macs and bridges as an array
This commit is contained in:
2020-12-22 12:50:53 +00:00
parent 3c35b5de22
commit 373ee0ff1c
5 changed files with 65 additions and 42 deletions

23
asrock01.config Normal file
View File

@@ -0,0 +1,23 @@
qemu_connection="qemu+ssh://virsh@10.0.1.253/system"
qemu_password="seBGtkWFKZuFUFgig8NYU5uh"
storage_path="/var/lib/libvirt/maas-images"
compute="as1-maas-node"
control_count=1
control_cpus=3
control_ram=8192
node_count=11
node_start=1
node_cpus=2
node_ram=4096
num_networks=5
bridges=()
bridges+=("br-enp1s0")
bridges+=("br-enp1s0.301")
bridges+=("br-enp1s0.302")
bridges+=("br-enp1s0.303")
bridges+=("br-enp1s0.304")

23
hp01.config Normal file
View File

@@ -0,0 +1,23 @@
qemu_connection="qemu+ssh://virt@10.0.1.252/system"
qemu_password="5b5Bnev4kh3QeDGQ4KK8bVtX"
storage_path="/var/lib/vz/maas"
compute="hp1-maas-node"
control_count=1
control_cpus=3
control_ram=8192
node_count=7
node_start=1
node_cpus=2
node_ram=4096
num_networks=5
bridges=()
bridges+=("br0")
bridges+=("br1")
bridges+=("br2")
bridges+=("br3")
bridges+=("br4")

1
hypervisor.config Symbolic link
View File

@@ -0,0 +1 @@
asrock01.config

View File

@@ -1,9 +1,9 @@
juju_version="latest/stable"
launchpad_user="setuid"
maas_bridge_ip="192.168.100.1"
maas_bridge_ip="192.168.1.22"
maas_boot_source="http://"$maas_bridge_ip":8765/maas/images/ephemeral-v3/daily/"
maas_endpoint="http://$maas_bridge_ip:5240/MAAS"
maas_ip_range="192.168.100"
maas_ip_range="10.0.1"
maas_local_proxy="http://$maas_bridge_ip:8000"
maas_pass="openstack"
maas_profile="admin"
@@ -11,9 +11,11 @@ maas_system_ip="192.168.1.10"
maas_upstream_dns="1.1.1.1 4.4.4.4 8.8.8.8"
maas_user="maas"
maas_version="2.4"
maas_url="$maas_endpoint/api/2.0/"
maas_api_key="z9cT7jE3BhmxcXkWWN:ew5WW9QdDMg8TXVnjt:NtKgJdfgA5FVw2YT9CnaKU87wJ5fTxKa"
no_proxy="localhost,127.0.0.1,$maas_system_ip"
squid_proxy="http://192.168.100.10:3128"
virsh_user="ubuntu"
package_repository="http://$maas_bridge_ip:8765/mirror/ubuntu"
snap_store_proxy="$squid_proxy"
snap_store_assertions=""
snap_store_assertions=""

View File

@@ -2,39 +2,16 @@
# set -x
# This is the connection to this host, where the VM is being stored
qemu_connection="qemu+ssh://virsh@10.0.1.253/system"
qemu_password="seBGtkWFKZuFUFgig8NYU5uh"
. hypervisor.config
. maas.config
# This is the connection to the MAAS server
maas_url="http://192.168.1.22:5240/MAAS/api/2.0/"
maas_api_key="z9cT7jE3BhmxcXkWWN:ew5WW9QdDMg8TXVnjt:NtKgJdfgA5FVw2YT9CnaKU87wJ5fTxKa"
# Storage area and type
storage_path="/var/lib/libvirt/maas-images"
# Storage type
storage_format="raw"
# Host prefix
compute="as1-maas-node"
# Number of control nodes, and theeir specifications
control_count=1
control_cpus=3
control_ram=8192
# Total number of VMs, and their specifications
node_count=11
node_start=1
node_cpus=2
node_ram=4096
# Models for nic and storage
nic_model="virtio"
stg_bus="scsi"
# The default network to use
network="maas"
# Sizes of disks for each of the VMs
d1=50
d2=20
@@ -149,7 +126,7 @@ wipe_disks() {
rm -rf "$storage_path/$maas_node/$maas_node-d2.img" &
rm -rf "$storage_path/$maas_node/$maas_node-d3.img" &
done
create_storge
create_storage
wait
}
@@ -166,11 +143,13 @@ build_vms() {
node_type="control"
fi
bus=$stg_bus
macaddr1=$(printf '52:54:00:63:%02x:%02x\n' "$((RANDOM%256))" "$((RANDOM%256))")
macaddr2=$(printf '52:54:00:63:%02x:%02x\n' "$((RANDOM%256))" "$((RANDOM%256))")
macaddr3=$(printf '52:54:00:63:%02x:%02x\n' "$((RANDOM%256))" "$((RANDOM%256))")
macaddr4=$(printf '52:54:00:63:%02x:%02x\n' "$((RANDOM%256))" "$((RANDOM%256))")
macaddr5=$(printf '52:54:00:63:%02x:%02x\n' "$((RANDOM%256))" "$((RANDOM%256))")
macaddr=()
network_spec=""
for ((mac=0;mac<num_networks;mac++)); do
macaddr+=($(printf '52:54:00:63:%02x:%02x\n' "$((RANDOM%256))" "$((RANDOM%256))"))
network_spec+=" --network=bridge="${bridges[$mac]}",mac="${macaddr[$mac]}",model=$nic_model"
done
virt-install -v --noautoconsole \
--print-xml \
@@ -188,15 +167,11 @@ build_vms() {
--disk path="$storage_path/$virt_node/$virt_node-d1.img,format=$storage_format,size=$d1,bus=$bus,io=native,cache=directsync" \
--disk path="$storage_path/$virt_node/$virt_node-d2.img,format=$storage_format,size=$d2,bus=$bus,io=native,cache=directsync" \
--disk path="$storage_path/$virt_node/$virt_node-d3.img,format=$storage_format,size=$d3,bus=$bus,io=native,cache=directsync" \
--network=bridge="br-enp1s0",mac="$macaddr1",model=$nic_model \
--network=bridge="br-enp1s0.301",mac="$macaddr2",model=$nic_model \
--network=bridge="br-enp1s0.302",mac="$macaddr3",model=$nic_model \
--network=bridge="br-enp1s0.303",mac="$macaddr4",model=$nic_model \
--network=bridge="br-enp1s0.304",mac="$macaddr5",model=$nic_model > "$virt_node.xml" &&
$network_spec > "$virt_node.xml" &
virsh define "$virt_node.xml"
virsh start "$virt_node" &
maas_add_node ${virt_node} ${macaddr1} ${node_type} &
maas_add_node ${virt_node} ${macaddr[0]} ${node_type} &
# Wait some time before building the next, this helps with a lot of DHCP requests
# and ensures that all VMs are commissioned and deployed.
@@ -248,4 +223,3 @@ while getopts ":cwd" opt; do
;;
esac
done