Skip to content

Commit

Permalink
Merge "Update download/import feature in RHEL Agent: - Remove downloa…
Browse files Browse the repository at this point in the history
…d_only feature from RHEL agent - Move dci-import out of job loop so it executes once per run of agent - Create new download_and_import_topics function to encapsulate functionality Change-Id: Ic676e6b9e9e4cc09684e9565d99757347a146dc9"
  • Loading branch information
Zuul CI authored and Gerrit Code Review committed Jun 26, 2020
2 parents be3d14a + e2d2aeb commit c636e24
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 31 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ The possible values are:
| local_repo | True | String | Path to store DCI artefacts (Local RHEL mirror that will be exposed to SUT by `httpd`). Default is `/var/www/html`. |
| dci_rhel_agent_cert | True | True/False | Enable or disable the certification tests suite. |
| dci_rhel_agent_cki | True | True/False | Enable or disable the cki tests suite. |
| download_only | False | True/False | If enable, dci-rhel-agnt will exit after downloading RHEL builds (no job will be executed). |
| systems | False | List of string | List of all systems that will be deployed using RHEL from DCI. |
| beaker_xml | False | String | Path to a custom XML file to use with Beaker job. |
| variants | False | List of string | List of RHEL 8.x variant to enable (AppStream, BaseOS, CRB, HighAvailability, NFV, RT, ResilientStorage, SAP, SAPHANA and unified). |
Expand All @@ -142,7 +141,6 @@ topics:
- topic: RHEL-8.1
dci_rhel_agent_cert: false
dci_rhel_agent_cki: false
download_only: false
variants:
- AppStream
- BaseOS
Expand All @@ -156,7 +154,6 @@ topics:
- topic: RHEL-7.8
dci_rhel_agent_cert: false
dci_rhel_agent_cki: false
download_only: false
variants:
- Server
archs:
Expand Down
3 changes: 2 additions & 1 deletion dci-rhel-agent/dci-import.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@
when: hostvars.localhost.skip_download == False

- name: Import the latest build
shell: beaker-import -v --ignore-missing-tree-compose "http://{{ local_repo_ip }}/{{ topic }}/compose/"
shell: beaker-import -v --ignore-missing-tree-compose "http://{{ local_repo_ip }}/{{ item.topic }}/compose/"
become: true
with_items: "{{ topics }}"

- name: Delete the temporary file
file:
Expand Down
43 changes: 17 additions & 26 deletions dci-rhel-agent/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
- Server
dci_rhel_agent_cert: false
dci_rhel_agent_cki: false
download_only: false
systems:
- labvm-1.novalocal
- labvm-2.novalocal
Expand All @@ -27,7 +26,6 @@
- AppStream
dci_rhel-agent_cert: false
dci_rhel-agent_cki: false
download_only: false
systems:
- SUT3
- SUT4
Expand All @@ -46,10 +44,8 @@ def sigterm_handler(signal, frame):
print('Handle podman stop here !')
sys.exit(0)


signal.signal(signal.SIGTERM, sigterm_handler)


def load_settings():
with open('/etc/dci-rhel-agent/settings.yml', 'r') as settings:
try:
Expand All @@ -58,6 +54,18 @@ def load_settings():
print(exc)
sys.exit(1)

def download_and_import_topics(extravars):
r = ansible_runner.run(
private_data_dir="/usr/share/dci-rhel-agent/",
inventory="/etc/dci-rhel-agent/inventory",
verbosity=1,
playbook="dci-import.yml",
extravars=extravars,
quiet=False
)
if r.rc != 0:
print ("Distro(s) download/import in Beaker has failed. {}: {}".format(r.status, r.rc))
sys.exit(1)

def provision_and_test(extravars):
# # Path is static in the container
Expand All @@ -70,26 +78,8 @@ def provision_and_test(extravars):
print ("Error ! No topic found in settings.")
sys.exit(1)

# This function is kept for backward compatibility.
if 'download_only' in extravars.keys():
if extravars['download_only'] == True:
print ('The dci-rhel-agent is configured in download-only mode.')
sys.exit(0)

r = ansible_runner.run(
private_data_dir="/usr/share/dci-rhel-agent/",
inventory="/etc/dci-rhel-agent/inventory",
verbosity=1,
playbook="dci-import.yml",
extravars=extravars,
quiet=False
)
if r.rc != 0:
print ("Distro(s) import in Beaker has failed. {}: {}".format(r.status, r.rc))
sys.exit(1)

if 'systems' not in extravars.keys():
print ('No hosts found in settings. You should configure download-only mode or add systems[].')
print ('No hosts found in settings. Please add systems to provision to your settings file.')
sys.exit(1)
fqdns = extravars['systems']

Expand Down Expand Up @@ -128,6 +118,8 @@ def main():
sets = load_settings()
# Check if the settings contain multiple topics and process accordingly
if 'topics' in sets:
#Download and import all topics in settings file
download_and_import_topics(sets)
# Break up settings file into individual jobs by topic
jobs = sets['topics']
# Loop over each job and provision system(s)
Expand All @@ -137,9 +129,8 @@ def main():
current_job['local_repo_ip'] = sets['local_repo_ip']
provision_and_test(current_job)
else:
# Legacy settings file format (single topic/job)
# preserved for compatibility
provision_and_test(sets)
print ('Incompatible settings file. Topics not found. Please update settings file format.')
sys.exit(1)
sys.exit(number_of_failed_jobs)


Expand Down
1 change: 0 additions & 1 deletion settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ topics:
- topic: RHEL-8.1
dci_rhel_agent_cki: false
dci_rhel_agent_cert: false
download_only: false
variants:
- AppStream
- BaseOS
Expand Down

0 comments on commit c636e24

Please sign in to comment.