Add pod for the hypervisor and other fixes

* Add pod creation, so that when we remove the hypervisor
  then all the VMs also get removed automatically
* virtinst is only used when creating/installing VMs, so
  only install on hypervisor nodes
* Only grab the top vlan if we have 2, this typically
  means that we have an ipv4 and ipv6 IP. Could probably
  do this better, but keep it simple for the time being
This commit is contained in:
Arif Ali 2020-12-28 10:17:02 +00:00
parent 121ff6b456
commit b7c47ef0ee
Signed by: arif
GPG Key ID: 369608FBA1353A70
4 changed files with 31 additions and 8 deletions

View File

@ -1 +1 @@
asrock01.config
asrock02.config

View File

@ -10,7 +10,7 @@ maas_profile="admin"
maas_system_ip="192.168.1.10"
maas_upstream_dns="1.1.1.1 4.4.4.4 8.8.8.8"
maas_user="admin"
maas_version="2.8"
maas_version="2.9"
maas_api_key="z9cT7jE3BhmxcXkWWN:ew5WW9QdDMg8TXVnjt:NtKgJdfgA5FVw2YT9CnaKU87wJ5fTxKa"
no_proxy="localhost,127.0.0.1,$maas_system_ip"
squid_proxy="http://192.168.100.10:3128"

View File

@ -7,7 +7,11 @@ state_timeout=1200
install_deps()
{
# Install some of the dependent packages
sudo apt -y update && sudo apt -y install jq bc virtinst
deps="jq bc"
if [[ "$0" == "*manage-maas-*" ]] ; then
deps+=" virtinst"
fi
sudo apt -y update && sudo apt -y install ${deps}
# We install the snap, as maas-cli is not in distributions, this ensures
# that the package we invoke would be consistent

View File

@ -20,7 +20,7 @@ maas_assign_networks()
i=0
for vlan in ${vlans[*]}
do
subnet_line=$(maas admin subnets read | jq ".[] | {subnet_id:.id, vlan:.vlan.vid, vlan_id:.vlan.id}" --compact-output | grep "vlan\":$vlan,")
subnet_line=$(maas admin subnets read | jq ".[] | {subnet_id:.id, vlan:.vlan.vid, vlan_id:.vlan.id}" --compact-output | grep "vlan\":$vlan," | head -n 1)
maas_vlan_id=$(echo $subnet_line | jq .vlan_id | sed s/\"//g)
maas_subnet_id=$(echo $subnet_line | jq .subnet_id | sed s/\"//g)
ip_addr=""
@ -69,6 +69,13 @@ maas_create_partitions()
stg_mount=$(maas ${maas_profile} block-device mount ${system_id} ${libvirt_block_id} mount_point=${storage_path})
}
maas_add_pod()
{
pod_create=$(maas ${maas_profile} pods create power_address="qemu+ssh://${virsh_user}@${hypervisor_ip}/system" power_user="${virsh_user}" power_pass="${qemu_password}" type="virsh")
pod_id=$(echo $pod_create | jq ".id" | sed s/\"//g)
pod_name=$(maas ${maas_profile} pod update ${pod_id} name=${hypervisor_name})
}
# Calls the functions that destroys and cleans up all the VMs
wipe_node() {
install_deps
@ -86,6 +93,14 @@ install_node() {
install_deps
maas_login
deploy_node
maas_add_pod
}
add_pod()
{
install_deps
maas_login
maas_add_pod
}
# Fixes all the networks on all the VMs
@ -128,18 +143,19 @@ deploy_node() {
show_help() {
echo "
-c Creates Hypervisor
-w Removes Hypervisor
-d Deploy Hypervisor
-a Create and Deploy
-c Creates Hypervisor
-d Deploy Hypervisor
-k Add Hypervisor as Pod
-n Assign Networks
-p Update Partitioning
-w Removes Hypervisor
"
}
read_config
while getopts ":cwdanp" opt; do
while getopts ":cwdaknp" opt; do
case $opt in
c)
create_node
@ -154,6 +170,9 @@ while getopts ":cwdanp" opt; do
create_node
install_node
;;
k)
add_pod
;;
n)
network_auto
;;