Skip to content

Commit

Permalink
Registration & setup
Browse files Browse the repository at this point in the history
  • Loading branch information
damoore044 committed Oct 26, 2023
1 parent 7f03f7d commit ad9d4cd
Showing 1 changed file with 29 additions and 21 deletions.
50 changes: 29 additions & 21 deletions tests/foreman/ui/test_errata.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,20 +187,21 @@ def function_registered_contenthost(
organization=module_org,
environment=[module_lce],
).create()
content_view.publish()
latest_cvv_id = sorted(cvv.id for cvv in content_view.read().version)[-1]
latest_cv_version = [
version for version in content_view.read().version if version.id == latest_cvv_id
][-1]
latest_cv_version.promote(data={'environment_ids': module_lce.id})
content_view = content_view.read()

activation_key = module_target_sat.api.ActivationKey(
organization=module_org,
environment=module_lce,
content_view=content_view,
).create()

#result = custom_repo.sync()['humanized']
#assert len(result['errors']) == 0, f'Failed to sync custom repository: {str(result["errors"])}'

#out1 = rhel_contenthost.execute(r'subscription-manager refresh')
#out2 = rhel_contenthost.execute(f'subscription-manager repos --enable {custom_repo_id}')
#out3 = rhel_contenthost.execute(r'subscription-manager repos --enable \*')
#out4 = rhel_contenthost.execute(r'yum-config-manager --enable \*')

rhel_contenthost.create_custom_repos(custom_repo=repo_url)
custom_repo_id = module_target_sat.cli_factory.setup_org_for_a_custom_repo(
{
'url': repo_url,
Expand All @@ -210,29 +211,36 @@ def function_registered_contenthost(
'content-view-id': content_view.id,
}
)['repository-id']
rhel_contenthost.create_custom_repos(repo=repo_url)
rhel_contenthost.execute(r'subscription-manager repos --enable \*')
rhel_contenthost.execute(r'yum-config-manager --enable \*')
custom_repo = module_target_sat.api.Repository(id=custom_repo_id).read()
assert custom_repo
result = custom_repo.sync()['humanized']
assert len(result['errors']) == 0, f'Failed to sync custom repository: {str(result["errors"])}'
rhel_contenthost.execute(r'subscription-manager refresh')

result = rhel_contenthost.register(
activation_keys=activation_key.name,
lifecycle_environment=module_lce,
target=module_target_sat,
org=module_org,
loc=None,
)
assert result.status == 0, f'Failed to register host: {result.stderr}'
breakpoint()

assert result.status == 0, f'Failed to register host: {result.stdout}'
assert rhel_contenthost.subscribed

rhel_contenthost.create_custom_repos(custom_repo=repo_url)
rhel_contenthost.execute(r'subscription-manager refresh')
rhel_contenthost.execute(f'yum-config-manager --enable {custom_repo_id}')
result = rhel_contenthost.execute(f'subscription-manager repos --enable {custom_repo_id}')


breakpoint()

custom_repo = module_target_sat.api.Repository(id=custom_repo_id).read()
assert custom_repo

result = custom_repo.sync()['humanized']
assert len(result['errors']) == 0, f'Failed to sync custom repository: {str(result["errors"])}'

result = rhel_contenthost.execute(f'subscription-manager repos --enable {custom_repo.id}')
breakpoint()
assert (
result.status == 0
), f'Failed to enable custom repo with subscription-manager: {result.stderr}'
assert rhel_contenthost.subscribed, f'Failed to subscribe the registered host: {result.stderr}'
yield rhel_contenthost


Expand Down Expand Up @@ -265,7 +273,7 @@ def function_registered_contenthost(
def test_end_to_end(
session,
function_registered_contenthost,
module_entitlement_manifest_org,
module_org,
module_lce,
module_cv,
module_target_sat,
Expand Down

0 comments on commit ad9d4cd

Please sign in to comment.