From 5a80b36dce54f2271118e9956578b87039937e40 Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Mon, 20 Dec 2021 00:06:24 +0000 Subject: [PATCH] Tuning of partition creation Also updating MAAS API key from new bootstrapped MAAS --- configs/asrock01.config | 6 ++++++ configs/asrock02.config | 5 +++++ configs/asrock03.config | 5 +++++ configs/rpi4-maas.config | 2 +- manage-hypervisor-nodes.sh | 37 +++++++++++++++++++++++++++++++++++-- user-data.yaml | 3 +++ 6 files changed, 55 insertions(+), 3 deletions(-) diff --git a/configs/asrock01.config b/configs/asrock01.config index e4cbf6a..b11df65 100644 --- a/configs/asrock01.config +++ b/configs/asrock01.config @@ -8,3 +8,9 @@ ip_suffix=241 external_ip=192.168.1.211 compute="as1-maas-node" + +# Disks that exist on the server +disk_name=() +disk_names+=(sda) +disk_names+=(nvme0n1) +disk_names+=(nvme1n1) diff --git a/configs/asrock02.config b/configs/asrock02.config index b5425bb..02c9258 100644 --- a/configs/asrock02.config +++ b/configs/asrock02.config @@ -8,3 +8,8 @@ ip_suffix=242 external_ip=192.168.1.212 compute="as2-maas-node" + +# Disks that exist on the server +disk_name=() +disk_names+=(sda) +disk_names+=(nvme0n1) diff --git a/configs/asrock03.config b/configs/asrock03.config index 95c6af4..87afdac 100644 --- a/configs/asrock03.config +++ b/configs/asrock03.config @@ -8,3 +8,8 @@ ip_suffix=243 external_ip=192.168.1.213 compute="as3-maas-node" + +# Disks that exist on the server +disk_name=() +disk_names+=(sda) +disk_names+=(nvme0n1) diff --git a/configs/rpi4-maas.config b/configs/rpi4-maas.config index 0a5e6b8..560dc99 100644 --- a/configs/rpi4-maas.config +++ b/configs/rpi4-maas.config @@ -16,7 +16,7 @@ maas_version="2.9" #no_proxy="localhost,127.0.0.1,$maas_system_ip" #squid_proxy="http://192.168.1.23:3128" maas_pkg_type="snap" -maas_api_key="QjzaY5ucvSSrydMKnz:aChrPQrVG4tfeAabrm:5ySUKY7c7EMhKhuKhpsXGzeaQLYpMAXx" +maas_api_key="cP5gj8RyemEhBLvyKG:AmRXEzR8MPAbRPWGBH:7T9LPemF3gAPe3qwr47rXAkLWZysjeRB" maas_subnet_start="10.0.1.1" maas_subnet_end="10.0.1.99" maas_dhcp_start_postfix="1" diff --git a/manage-hypervisor-nodes.sh b/manage-hypervisor-nodes.sh index de0386e..c306d58 100755 --- a/manage-hypervisor-nodes.sh +++ b/manage-hypervisor-nodes.sh @@ -64,11 +64,17 @@ maas_create_partitions() { system_id=$1 + disks=$(maas ${maas_profile} block-devices read ${system_id}) + size=20 actual_size=$(( $size * 1024 * 1024 * 1024 )) - storage_layout=$(maas ${maas_profile} machine set-storage-layout ${system_id} storage_layout=lvm vg_name=${hypervisor_name} lv_name=root lv_size=${actual_size}) + boot_disk=$(echo $disks | jq ".[] | select(.name == \"${disk_names[0]}\") | .id") + + set_boot_disk=$(maas ${maas_profile} block-device set-boot-disk ${system_id} ${boot_disk}) + + storage_layout=$(maas ${maas_profile} machine set-storage-layout ${system_id} storage_layout=lvm vg_name=${hypervisor_name} lv_name=root lv_size=${actual_size} root_disk=${boot_disk}) vg_device=$(echo $storage_layout | jq ".volume_groups[].id" ) remaining_space=$(maas ${maas_profile} volume-group read ${system_id} ${vg_device} | jq ".available_size" | sed s/\"//g) @@ -77,7 +83,34 @@ maas_create_partitions() libvirt_block_id=$(echo ${libvirt_lv} | jq .id) stg_fs=$(maas ${maas_profile} block-device format ${system_id} ${libvirt_block_id} fstype=ext4) - stg_mount=$(maas ${maas_profile} block-device mount ${system_id} ${libvirt_block_id} mount_point=${storage_path}) + + stg_mount=$(maas ${maas_profile} block-device mount ${system_id} ${libvirt_block_id} mount_point=${ceph_storage_path}) + + for ((disk=1;disk<${#disk_names[@]};disk++)); do + + disk_id=$(echo $disks | jq ".[] | select(.name == \"${disk_names[$disk]}\") | .id") + + create_partition=$(maas ${maas_profile} partitions create ${system_id} ${disk_id}) + + part_id=$(echo $create_partition | jq .id) + + if [[ $disk -eq 1 ]] ; then + vg_create=$(maas ${maas_profile} volume-groups create ${system_id} name=${hypervisor_name}-nvme block_device=${disk_id} partitions=${part_id}) + + vg_id=$(echo $vg_create | jq .id) + vg_size=$(echo $vg_create | jq .size) + else + + vg_update=$(maas ${maas_profile} volume-group update ${system_id} ${vg_id} add_partitions=${part_id}) + vg_size=$(echo $vg_update | jq .size) + fi + + done + + lv_create=$(maas admin volume-group create-logical-volume ${system_id} ${vg_id} name=images size=${vg_size}) + lv_id=$(echo $lv_create | jq .id) + lv_fs=$(maas ${maas_profile} block-device format ${system_id} ${lv_id} fstype=ext4) + lv_mount=$(maas ${maas_profile} block-device mount ${system_id} ${lv_id} mount_point=${storage_path}) } maas_add_pod() diff --git a/user-data.yaml b/user-data.yaml index 6125b55..0fe4b73 100644 --- a/user-data.yaml +++ b/user-data.yaml @@ -95,6 +95,9 @@ write_files: enp2s0: wakeonlan: true link-local: [] + enp3s0: + wakeonlan: true + link-local: [] permissions: '0644' owner: root:root