From 96629a900db576cf54a442d1c5cd8d2f2c532b77 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Mon, 12 Jul 2021 14:13:59 +0200 Subject: [PATCH] copr-hv: fix VMs IPv6 allocation The bug was that we tried to allocate addresses like "*cafe:c1001" (one additional number). This is now fixed, and since we are allowed to use c1, c2, c3, .. let's give each hypervisor a fixed block of 64 addresses, and don't be afraid to overflow there with new hypervisors. --- .../backend/templates/provision/libvirt-new | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/roles/copr/backend/templates/provision/libvirt-new b/roles/copr/backend/templates/provision/libvirt-new index 447635f5d3..682e6b5fb5 100755 --- a/roles/copr/backend/templates/provision/libvirt-new +++ b/roles/copr/backend/templates/provision/libvirt-new @@ -381,22 +381,25 @@ def get_fedora_ipv6_address(pool_id, id_in_pool, dev=False): Statically assign IPv6 + Gateway based on id_in_pool. """ gateway = "2620:52:3:1:ffff:ffff:ffff:fffe" - base = "2620:52:3:1:dead:beef:cafe:c1" + base = "2620:52:3:1:dead:beef:cafe:c" + + # The initial 256 addresses (:c0XX) is reserved for hypervisor machines + # itself. + start = 0x100 + + # each hypervisor has block of 64 IPs + block = 64 - offset = 0 - # 01 => 0, 02 => 1, ... hv_id, _, _ = get_hv_identification_from_pool_id(pool_id) - # we have block of 256 ipv6 addresses for builder, and 4 hypervisors - block = int(256 / 4) + # give 48 IPs to each hv (32 prod, some dev), currently 4*48=192 ips offset = hv_id * block if not dev: - # give the dev only 8 addresses + # give the first 8 addresses to Copr dev instance offset += 8 - addr_number = offset + int(id_in_pool) - addr_number = hex(addr_number).replace("0x", "") - + addr_number = start + offset + int(id_in_pool) + addr_number = "{0:#05x}".format(addr_number).replace("0x", "") return base + addr_number, gateway