diff --git a/inventory/host_vars/vmhost-p08-copr01.rdu-cc.fedoraproject.org b/inventory/host_vars/vmhost-p08-copr01.rdu-cc.fedoraproject.org index c5b780d387..0e0321ce5a 100644 --- a/inventory/host_vars/vmhost-p08-copr01.rdu-cc.fedoraproject.org +++ b/inventory/host_vars/vmhost-p08-copr01.rdu-cc.fedoraproject.org @@ -22,6 +22,9 @@ mac4: "40:f2:e9:5d:50:f8" mac5: "40:f2:e9:5d:50:f9" mac6: "40:f2:e9:5d:50:fa" mac7: "40:f2:e9:5d:50:fb" +libvirt_pool: copr_hv_ppc64le_01 +libvirt_pool_order_id: 4 +libvirt_arch: ppc64le nftables: false network_connections: - autoconnect: yes diff --git a/inventory/host_vars/vmhost-p08-copr02.rdu-cc.fedoraproject.org b/inventory/host_vars/vmhost-p08-copr02.rdu-cc.fedoraproject.org index 7a3bd1d115..c5299a9295 100644 --- a/inventory/host_vars/vmhost-p08-copr02.rdu-cc.fedoraproject.org +++ b/inventory/host_vars/vmhost-p08-copr02.rdu-cc.fedoraproject.org @@ -22,6 +22,9 @@ mac4: "40:f2:e9:5d:53:5c" mac5: "40:f2:e9:5d:53:5d" mac6: "40:f2:e9:5d:53:5e" mac7: "40:f2:e9:5d:53:5f" +libvirt_pool: copr_hv_ppc64le_02 +libvirt_pool_order_id: 5 +libvirt_arch: ppc64le nftables: false network_connections: - autoconnect: yes diff --git a/inventory/host_vars/vmhost-p09-copr01.rdu-cc.fedoraproject.org b/inventory/host_vars/vmhost-p09-copr01.rdu-cc.fedoraproject.org index 032607d0d4..9b0f0ecbee 100644 --- a/inventory/host_vars/vmhost-p09-copr01.rdu-cc.fedoraproject.org +++ b/inventory/host_vars/vmhost-p09-copr01.rdu-cc.fedoraproject.org @@ -20,6 +20,9 @@ mac2: "b8:ce:f6:c6:00:c6" mac3: "b8:ce:f6:c6:00:c7" mac4: "b8:ce:f6:c6:00:d0" mac5: "b8:ce:f6:c6:00:d1" +libvirt_pool: copr_p09_01 +libvirt_pool_order_id: 6 +libvirt_arch: ppc64le network_connections: - autoconnect: yes ip: diff --git a/inventory/host_vars/vmhost-p09-copr02.rdu3.fedoraproject.org b/inventory/host_vars/vmhost-p09-copr02.rdu3.fedoraproject.org index 8af95619d1..7995cb7d0d 100644 --- a/inventory/host_vars/vmhost-p09-copr02.rdu3.fedoraproject.org +++ b/inventory/host_vars/vmhost-p09-copr02.rdu3.fedoraproject.org @@ -22,6 +22,9 @@ mac7: ac:1f:6b:a5:4e:f5 mac8: ac:1f:6b:a5:4e:f6 mac9: ac:1f:6b:a5:4e:f7 libvirt_host: "[{{ br0_ipv6_ip }}]" +libvirt_pool: vmhost_p09_02 +libvirt_pool_order_id: 7 +libvirt_arch: ppc64le network_connections: # Bridge profile - name: br0 diff --git a/inventory/host_vars/vmhost-p09-copr03.rdu3.fedoraproject.org b/inventory/host_vars/vmhost-p09-copr03.rdu3.fedoraproject.org index 004e10555d..b0c99b35c7 100644 --- a/inventory/host_vars/vmhost-p09-copr03.rdu3.fedoraproject.org +++ b/inventory/host_vars/vmhost-p09-copr03.rdu3.fedoraproject.org @@ -22,6 +22,9 @@ mac7: ac:1f:6b:8a:9a:31 mac8: ac:1f:6b:8a:9a:32 mac9: ac:1f:6b:8a:9a:33 libvirt_host: "[{{ br0_ipv6_ip }}]" +libvirt_pool: vmhost_p09_03 +libvirt_pool_order_id: 8 +libvirt_arch: ppc64le network_connections: # Bridge profile - name: br0 diff --git a/inventory/host_vars/vmhost-p09-copr04.rdu3.fedoraproject.org b/inventory/host_vars/vmhost-p09-copr04.rdu3.fedoraproject.org index b5833866a0..4f1bcfd8d7 100644 --- a/inventory/host_vars/vmhost-p09-copr04.rdu3.fedoraproject.org +++ b/inventory/host_vars/vmhost-p09-copr04.rdu3.fedoraproject.org @@ -22,6 +22,9 @@ mac7: ac:1f:6b:a4:e3:b1 mac8: ac:1f:6b:a4:e3:b2 mac9: ac:1f:6b:a4:e3:b3 libvirt_host: "[{{ br0_ipv6_ip }}]" +libvirt_pool: vmhost_p09_04 +libvirt_pool_order_id: 9 +libvirt_arch: ppc64le network_connections: # Bridge profile - name: br0 diff --git a/inventory/host_vars/vmhost-x86-copr01.rdu-cc.fedoraproject.org b/inventory/host_vars/vmhost-x86-copr01.rdu-cc.fedoraproject.org index ec1dcfe942..54c5919a48 100644 --- a/inventory/host_vars/vmhost-x86-copr01.rdu-cc.fedoraproject.org +++ b/inventory/host_vars/vmhost-x86-copr01.rdu-cc.fedoraproject.org @@ -19,6 +19,9 @@ mac4: "b4:96:91:63:3b:e8" mac5: "b4:96:91:63:3b:e9" mac6: "b4:96:91:63:3b:ea" mac7: "b4:96:91:63:3b:eb" +libvirt_pool: copr_hv_x86_64_01 +libvirt_pool_order_id: 0 +libvirt_arch: x86_64 nftables: false network_connections: - autoconnect: yes diff --git a/inventory/host_vars/vmhost-x86-copr02.rdu-cc.fedoraproject.org b/inventory/host_vars/vmhost-x86-copr02.rdu-cc.fedoraproject.org index 5dcb966c1c..75d381b332 100644 --- a/inventory/host_vars/vmhost-x86-copr02.rdu-cc.fedoraproject.org +++ b/inventory/host_vars/vmhost-x86-copr02.rdu-cc.fedoraproject.org @@ -17,6 +17,9 @@ mac2: "b4:96:91:63:3b:9c" mac3: "b4:96:91:63:3b:9d" mac4: "b4:96:91:63:3b:9e" mac5: "b4:96:91:63:3b:9f" +libvirt_pool: copr_hv_x86_64_02 +libvirt_pool_order_id: 1 +libvirt_arch: x86_64 nftables: false network_connections: - autoconnect: yes diff --git a/inventory/host_vars/vmhost-x86-copr03.rdu-cc.fedoraproject.org b/inventory/host_vars/vmhost-x86-copr03.rdu-cc.fedoraproject.org index 64b1583f3f..8bcc25ed7e 100644 --- a/inventory/host_vars/vmhost-x86-copr03.rdu-cc.fedoraproject.org +++ b/inventory/host_vars/vmhost-x86-copr03.rdu-cc.fedoraproject.org @@ -19,6 +19,9 @@ mac4: "b4:96:91:63:3b:50" mac5: "b4:96:91:63:3b:51" mac6: "b4:96:91:63:3b:52" mac7: "b4:96:91:63:3b:53" +libvirt_pool: copr_hv_x86_64_03 +libvirt_pool_order_id: 2 +libvirt_arch: x86_64 nftables: false network_connections: - autoconnect: yes diff --git a/inventory/host_vars/vmhost-x86-copr04.rdu-cc.fedoraproject.org b/inventory/host_vars/vmhost-x86-copr04.rdu-cc.fedoraproject.org index 2e45d4c18b..0629abd650 100644 --- a/inventory/host_vars/vmhost-x86-copr04.rdu-cc.fedoraproject.org +++ b/inventory/host_vars/vmhost-x86-copr04.rdu-cc.fedoraproject.org @@ -19,6 +19,9 @@ mac4: "b4:96:91:63:3a:a0" mac5: "b4:96:91:63:3a:a1" mac6: "b4:96:91:63:3a:a2" mac7: "b4:96:91:63:3a:a3" +libvirt_pool: copr_hv_x86_64_04 +libvirt_pool_order_id: 3 +libvirt_arch: x86_64 nftables: false network_connections: - autoconnect: yes diff --git a/roles/copr/backend/files/provision/helpers.py b/roles/copr/backend/files/provision/helpers.py index 35fd7d3945..ee174d7bd0 100644 --- a/roles/copr/backend/files/provision/helpers.py +++ b/roles/copr/backend/files/provision/helpers.py @@ -1,53 +1,15 @@ def get_hv_identification_from_pool_id(pool_id): """ Get unique ID of the hypervisor """ - if pool_id.startswith("copr_hv_x86_64_01"): + +{% for host in groups["copr_hypervisor"] %} +{% set hostinfo = groups["copr_hypervisor"] %} + if pool_id.startswith("{{ hostinfo['libvirt_pool']"): return ( - 0, - "qemu+ssh://copr@vmhost-x86-copr01" - ".rdu-cc.fedoraproject.org/system", - "x86_64", - ) - if pool_id.startswith("copr_hv_x86_64_02"): - return ( - 1, - "qemu+ssh://copr@vmhost-x86-copr02" - ".rdu-cc.fedoraproject.org/system", - "x86_64", - ) - if pool_id.startswith("copr_hv_x86_64_03"): - return ( - 2, - "qemu+ssh://copr@vmhost-x86-copr03" - ".rdu-cc.fedoraproject.org/system", - "x86_64", - ) - if pool_id.startswith("copr_hv_x86_64_04"): - return ( - 3, - "qemu+ssh://copr@vmhost-x86-copr04" - ".rdu-cc.fedoraproject.org/system", - "x86_64", - ) - if pool_id.startswith("copr_hv_ppc64le_01"): - return ( - 4, - "qemu+ssh://copr@vmhost-p08-copr01" - ".rdu-cc.fedoraproject.org/system", - "ppc64le", - ) - if pool_id.startswith("copr_hv_ppc64le_02"): - return ( - 5, - "qemu+ssh://copr@vmhost-p08-copr02" - ".rdu-cc.fedoraproject.org/system", - "ppc64le", + {{ hostinfo["libvirt_pool_order_id"] }}, + "qemu+ssh://copr@{{ hostinfo['libvirt_host'] }}/system", + "{{ hostinfo['libvirt_arch'] }}", ) - if pool_id.startswith("copr_p09_01"): - return ( - 6, - "qemu+ssh://copr@vmhost-p09-copr01" - ".rdu-cc.fedoraproject.org/system", - "ppc64le", - ) +{% endfor %} + raise Exception("can't convert pool_id to hv ID") diff --git a/roles/copr/backend/files/provision/libvirt-delete b/roles/copr/backend/files/provision/libvirt-delete index f3b937d1c0..d77dbe626d 100755 --- a/roles/copr/backend/files/provision/libvirt-delete +++ b/roles/copr/backend/files/provision/libvirt-delete @@ -9,9 +9,12 @@ Delete the given Resalloc-related LibVirt domain (and the related resources) import argparse import logging import time +import os import libvirt +from helpers import get_hv_identification_from_pool_id + def repeat(call, args): """ Repeat the given function call, with args """ attempts = 3 @@ -29,7 +32,6 @@ def repeat(call, args): def _get_parser(): parser = argparse.ArgumentParser() - parser.add_argument("--connection", required=True) parser.add_argument("domainname") return parser @@ -51,7 +53,9 @@ def _delete_volume(pool, volume_name): def _main(): logging.basicConfig(level=logging.INFO) args = _get_parser().parse_args() - conn = repeat(libvirt.open, (args.connection,)) + pool_id = args.pool or os.getenv("RESALLOC_POOL_ID") + connection = get_hv_identification_from_pool_id(pool_id)[1] + conn = repeat(libvirt.open, (connection,)) try: domain = repeat(conn.lookupByName, (args.domainname,)) repeat(_delete_domain, (domain,)) diff --git a/roles/copr/backend/templates/resalloc/vm-delete.j2 b/roles/copr/backend/templates/resalloc/vm-delete.j2 index a5d042dc49..fd45192861 100755 --- a/roles/copr/backend/templates/resalloc/vm-delete.j2 +++ b/roles/copr/backend/templates/resalloc/vm-delete.j2 @@ -23,7 +23,7 @@ if timeout 30 ssh root@"$IP" "echo machine works"; then done fi -case "$RESALLOC_POOL_ID" in +case $RESALLOC_POOL_ID in *aws*) # Delegate the rest of the task to an AWS specific script. exec /usr/bin/resalloc-aws-delete --aws-profile default @@ -38,40 +38,18 @@ copr_osuosl_*) *s390x*) exit 0 ;; + *copr_hv_x86_64_*) - pool_id=${RESALLOC_POOL_ID//copr_hv_x86_64_/} - pool_id=${pool_id//_dev/} - pool_id=${pool_id//_prod/} - pool_id=${pool_id//_stg/} - conn=qemu+ssh://copr@vmhost-x86-copr${pool_id}.rdu-cc.fedoraproject.org/system ;; - -*aarch64_01*) - conn=qemu+ssh://copr@virthost-aarch64-os01.fedorainfracloud.org/system +*copr_hv_ppc64le_*) ;; - -*aarch64_02*) - conn=qemu+ssh://copr@virthost-aarch64-os02.fedorainfracloud.org/system - ;; - -*copr_hv_ppc64le_*): - pool_id=${RESALLOC_POOL_ID//copr_hv_ppc64le_/} - pool_id=${pool_id//_dev/} - pool_id=${pool_id//_prod/} - pool_id=${pool_id//_stg/} - conn=qemu+ssh://copr@vmhost-p08-copr${pool_id}.rdu-cc.fedoraproject.org/system - ;; - copr_p09_01*) - pool_id=${RESALLOC_POOL_ID//copr_p09_/} - pool_id=${pool_id//_dev/} - pool_id=${pool_id//_prod/} - pool_id=${pool_id//_stg/} - conn=qemu+ssh://copr@vmhost-p09-copr${pool_id}.rdu-cc.fedoraproject.org/system + ;; +vmhost*) ;; *) die "unknown RESALLOC_POOL_ID=$RESALLOC_POOL_ID" ;; esac # The rest of this script is LibVirt only! -{{ provision_directory }}/libvirt-delete --connection "$conn" "$RESALLOC_NAME" +"{{ provision_directory }}/libvirt-delete" "$RESALLOC_NAME"