More updates

* Move stuff from common to default, as it didn't make sense
* use virsh_user instead, that was its more customisable
* Revert the change to manage-maas-nodes.sh now use extra function to
  call maas_auto_assign_networks instead
* More comments to the code
This commit is contained in:
Arif Ali 2020-12-27 10:06:21 +00:00
parent 5fa6255160
commit 35d195c334
Signed by: arif
GPG Key ID: 369608FBA1353A70
8 changed files with 49 additions and 22 deletions

View File

@ -2,8 +2,6 @@ hypervisor_name=asrock01
hypervisor_ip=10.0.1.253
hypervisor_mac="a8:a1:59:44:70:ac"
qemu_connection="qemu+ssh://virsh@${hypervisor_ip}/system"
external_ip=192.168.1.211
compute="as1-maas-node"

View File

@ -2,8 +2,6 @@ hypervisor_name=asrock02
hypervisor_ip=10.0.1.251
hypervisor_mac="a8:a1:59:44:76:79"
qemu_connection="qemu+ssh://virsh@${hypervisor_ip}/system"
external_ip=192.168.1.212
compute="as2-maas-node"

View File

@ -2,8 +2,6 @@ hypervisor_name=asrock03
hypervisor_ip=10.0.1.250
hypervisor_mac=""
qemu_connection="qemu+ssh://virsh@${hypervisor_ip}/system"
external_ip=192.168.1.213
compute="as3-maas-node"

View File

@ -1,21 +1,43 @@
storage_path="/storage/images/maas"
external_vlan=1
qemu_password="SgUoBByKjG9Lj78SwfWAHXD8DvgE67Cu"
virsh_user="virsh"
storage_path="/var/lib/libvirt/maas-images"
compute="maas-node"
control_count=0
control_count=1
control_cpus=3
control_ram=8192
node_count=20
node_count=11
node_start=1
node_cpus=4
node_cpus=2
node_ram=4096
disks=()
disks+=(50)
disks+=(100)
disks+=(100)
disks+=(20)
disks+=(20)
network_type=network
network_type=bridge
networks=()
networks+=("maas")
networks+=("maas")
vlans=()
vlans+=(300)
vlans+=(301)
vlans+=(302)
vlans+=(303)
vlans+=(304)
vlans+=(305)
vlans+=(1)
bridges=()
bridges+=("br0")
bridges+=("br1")
bridges+=("br2")
bridges+=("br3")
bridges+=("br4")
bridges+=("br5")
bridges+=("br6")

View File

@ -2,7 +2,8 @@ hypervisor_name=hp01
hypervisor_ip=10.0.1.252
hypervisor_mac="e0:07:1b:ff:27:48"
qemu_connection="qemu+ssh://virt@10.0.1.252/system"
virsh_user="virt"
qemu_password="5b5Bnev4kh3QeDGQ4KK8bVtX"
storage_path="/var/lib/vz/maas"

View File

@ -102,7 +102,7 @@ maas_add_node()
if [[ $machine_type == "vm" ]] ; then
power_type="virsh"
power_params="power_parameters_power_id=${node_name}"
power_params+=" power_parameters_power_address=${qemu_connection}"
power_params+=" power_parameters_power_address=qemu+ssh://${virsh_user}@${hypervisor_ip}/system"
power_params+=" power_parameters_power_pass=${qemu_password}"
else
power_type="manual"
@ -134,7 +134,6 @@ read_config()
configs=""
configs+=" configs/default.config"
configs+=" configs/maas.config"
configs+=" configs/hypervisor.common.config"
configs+=" configs/hypervisor.config"
for config in $configs ; do
@ -146,4 +145,4 @@ read_config()
source "$config"
fi
done
}
}

View File

@ -6,7 +6,8 @@
# Time between building VMs
build_fanout=60
# Attempts to auto assign all the networks for a host
# Adds all the subnets, vlans and therefore bridges to the hypervisor, all
# based on the configuration from hypervisor.config and/or default.config
maas_assign_networks()
{
system_id=$1
@ -24,6 +25,8 @@ maas_assign_networks()
maas_subnet_id=$(echo $subnet_line | jq .subnet_id | sed s/\"//g)
ip_addr=""
if [[ $i -eq 0 ]] ; then
# Set the first interface to be static as per the configuration so that it
# consistent over re-provisioning of the system
vlan_int_id=${phys_int_id}
mode="STATIC"
ip_addr="ip_address=$hypervisor_ip"
@ -31,9 +34,11 @@ maas_assign_networks()
vlan_int=$(maas ${maas_profile} interfaces create-vlan ${system_id} vlan=${maas_vlan_id} parent=$phys_int_id)
vlan_int_id=$(echo $vlan_int | jq .id | sed s/\"//g)
if [[ $vlan -eq $external_vlan ]] ; then
# Set the external IP to be static as per the configuration
mode="STATIC"
ip_addr="ip_address=$external_ip"
else
# Set everything else to be auto assigned
mode="AUTO"
fi
fi

View File

@ -13,8 +13,13 @@ stg_bus="scsi"
# Time between building VMs
build_fanout=60
# Attempts to auto assign all the networks for a host
maas_assign_networks()
{
maas_auto_assign_networks $1
}
# Attempts to auto assign all the networks for a host
maas_auto_assign_networks()
{
system_id=$1
@ -81,6 +86,7 @@ wipe_disks() {
ensure_machine_in_state ${system_id} "Ready"
# Stop the machine if it is running
# It's probably stopped anyway as per the release above
virsh --connect qemu:///system shutdown "$virt_node"
# Remove the disks