From bb8f9673782163027d36bce5baa2a4115a4b2ab1 Mon Sep 17 00:00:00 2001 From: Alex Iribarren Date: Wed, 6 Apr 2022 16:10:48 +0200 Subject: [PATCH 1/2] Get entitlements from multiple machines, one per arch --- reposync/rhncheck.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/reposync/rhncheck.py b/reposync/rhncheck.py index c46b886..738b0f5 100755 --- a/reposync/rhncheck.py +++ b/reposync/rhncheck.py @@ -24,8 +24,12 @@ if email_to is None or login is None or password is None: print('Cannot determine email_to, login or password variables. Exiting') sys.exit(1) -# taken from access.redhat.com for the 'linuxsoft-mirror' host -linuxsoft_uuid="b4ec8c2d-3eae-4ae0-b8fa-ec6d8a08ce9f" +# taken from access.redhat.com +linuxsoft_uuids=[ + "b4ec8c2d-3eae-4ae0-b8fa-ec6d8a08ce9f", # linuxsoft-mirror + "91793aa3-6820-41c1-a0d3-f906aa8ef5eb", # linuxsoft-mirror-aarch64 + "d1a88fcb-df73-4107-a32b-f41bd9f0c5ce", # linuxsoft-mirror-ppc64le +] email_from='linux.support@cern.ch' tmpdir = tempfile.mkdtemp(dir = '/tmp') @@ -49,7 +53,7 @@ def call_https_rhsm(url): pass return False -def get_entitlements(directory): +def get_entitlements(directory, linuxsoft_uuid): try: key = call_https_rhsm(f"https://subscription.rhsm.redhat.com/subscription/consumers/{linuxsoft_uuid}")['idCert']['key'] certificates = call_https_rhsm('https://subscription.rhsm.redhat.com/subscription/consumers/' + linuxsoft_uuid + "/certificates") @@ -67,7 +71,10 @@ def get_entitlements(directory): for existingcert in glob.glob('/certs/*pem'): if 'rhn_entitlements.pem' not in existingcert and 'redhat-uep.pem' not in existingcert: existingcerts.add(os.path.basename(existingcert)) -get_entitlements(tmpdir) + +for uuid in linuxsoft_uuids: + get_entitlements(tmpdir, uuid) + for cert in glob.glob(f"{tmpdir}/*pem"): latestcerts.add(os.path.basename(cert)) -- GitLab From faa6ca822d2c18f70fe54867cce94d41928a78cd Mon Sep 17 00:00:00 2001 From: Alex Iribarren Date: Wed, 6 Apr 2022 16:12:23 +0200 Subject: [PATCH 2/2] Fix undefined stuff --- reposync/rhncheck.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/reposync/rhncheck.py b/reposync/rhncheck.py index 738b0f5..8e2e39a 100755 --- a/reposync/rhncheck.py +++ b/reposync/rhncheck.py @@ -9,6 +9,7 @@ import os import tempfile import smtplib import shutil +from time import sleep from email.mime.base import MIMEBase from email.mime.multipart import MIMEMultipart @@ -46,7 +47,7 @@ def call_https_rhsm(url): result = requests.get(url, headers=headers, verify=False) if result.status_code == requests.codes.ok: return json.loads(result.content) - print('Failed ({}) to get {}'.format(request.status_code, url)) + print('Failed ({}) to get {}'.format(result.status_code, url)) retries+=1 sleep(retries**3) except: -- GitLab