From 373ee0ff1cb5294fef84ab2b459c71bd3576048b Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Tue, 22 Dec 2020 12:50:53 +0000 Subject: [PATCH] More updates * Add hypervisor config file to standardise script * Add macs and bridges as an array --- asrock01.config | 23 ++++++++++++++++++++ hp01.config | 23 ++++++++++++++++++++ hypervisor.config | 1 + maas.config | 8 ++++--- manage-maas-nodes.sh | 52 +++++++++++--------------------------------- 5 files changed, 65 insertions(+), 42 deletions(-) create mode 100644 asrock01.config create mode 100644 hp01.config create mode 120000 hypervisor.config diff --git a/asrock01.config b/asrock01.config new file mode 100644 index 0000000..5fd87cf --- /dev/null +++ b/asrock01.config @@ -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") diff --git a/hp01.config b/hp01.config new file mode 100644 index 0000000..6875187 --- /dev/null +++ b/hp01.config @@ -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") diff --git a/hypervisor.config b/hypervisor.config new file mode 120000 index 0000000..fd62d6c --- /dev/null +++ b/hypervisor.config @@ -0,0 +1 @@ +asrock01.config \ No newline at end of file diff --git a/maas.config b/maas.config index 2fceabc..ce0b768 100644 --- a/maas.config +++ b/maas.config @@ -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="" \ No newline at end of file +snap_store_assertions="" diff --git a/manage-maas-nodes.sh b/manage-maas-nodes.sh index f21a863..3589a17 100755 --- a/manage-maas-nodes.sh +++ b/manage-maas-nodes.sh @@ -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 "$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 -