Skip to content

Commit

Permalink
use correct rhnactivationkey everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
karmab committed Apr 17, 2024
1 parent fbf766c commit f64eb66
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion kvirt/baseconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def __init__(self, client=None, containerclient=None, debug=False, quiet=False,
self.rhnserver = options.get('rhnserver')
self.rhnuser = options.get('rhnuser')
self.rhnpassword = options.get('rhnpassword')
self.rhnak = options.get('rhnactivationkey')
self.rhnactivationkey = options.get('rhnactivationkey')
self.rhnorg = options.get('rhnorg')
self.rhnpool = options.get('rhnpool')
self.tags = options.get('tags')
Expand Down
8 changes: 2 additions & 6 deletions kvirt/cluster/microshift/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@
def valid_rhn_credentials(config, overrides):
rhnuser = config.rhnuser or overrides.get('rhnuser')
rhnpassword = config.rhnpassword or overrides.get('rhnpassword')
if rhnuser is not None and rhnpassword is not None:
return True
rhnak = config.rhnak or overrides.get('rhnactivationkey')
rhnactivationkey = config.rhnactivationkey or overrides.get('rhnactivationkey')
rhnorg = config.rhnorg or overrides.get('rhnorg')
if rhnak is not None and rhnorg is not None:
return True
return False
return (rhnuser is not None and rhnpassword is not None) or (rhnactivationkey is not None and rhnorg is not None)


def create(config, plandir, cluster, overrides, dnsconfig=None):
Expand Down
2 changes: 1 addition & 1 deletion kvirt/cluster/microshift/kcli_plan_default.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
info: |
Deploy kubernetes using microshift on $nodes vms
Image defaults to rhel8, which requires valid credentials (rhnuser/rhnpassword or rhnak/rhnorg)
Image defaults to rhel8, which requires valid credentials (rhnuser/rhnpassword or rhnorg/rhnactivationkey)
The nodes can also be registered to an ACM instance by stting register_acm to true and providing kubeconfig_acm
nodes: 1
cluster: mymicroshift
Expand Down
12 changes: 6 additions & 6 deletions kvirt/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ def create_vm(self, name, profile=None, overrides={}, customprofile={}, k=None,
default_rhnserver = father.get('rhnserver', self.rhnserver)
default_rhnuser = father.get('rhnuser', self.rhnuser)
default_rhnpassword = father.get('rhnpassword', self.rhnpassword)
default_rhnak = father.get('rhnactivationkey', self.rhnak)
default_rhnactivationkey = father.get('rhnactivationkey', self.rhnactivationkey)
default_rhnorg = father.get('rhnorg', self.rhnorg)
default_rhnpool = father.get('rhnpool', self.rhnpool)
default_tags = father.get('tags', self.tags)
Expand Down Expand Up @@ -666,7 +666,7 @@ def create_vm(self, name, profile=None, overrides={}, customprofile={}, k=None,
rhnserver = profile.get('rhnserver', default_rhnserver)
rhnuser = profile.get('rhnuser', default_rhnuser)
rhnpassword = profile.get('rhnpassword', default_rhnpassword)
rhnak = profile.get('rhnactivationkey', default_rhnak)
rhnactivationkey = profile.get('rhnactivationkey', default_rhnactivationkey)
rhnorg = profile.get('rhnorg', default_rhnorg)
rhnpool = profile.get('rhnpool', default_rhnpool)
flavor = profile.get('flavor', default_flavor)
Expand Down Expand Up @@ -705,8 +705,8 @@ def create_vm(self, name, profile=None, overrides={}, customprofile={}, k=None,
if rhnuser is not None and rhnpassword is not None:
overrides['rhnuser'] = rhnuser
overrides['rhnpassword'] = rhnpassword
elif rhnak is not None and rhnorg is not None:
overrides['rhnactivationkey'] = rhnak
elif rhnactivationkey is not None and rhnorg is not None:
overrides['rhnactivationkey'] = rhnactivationkey
overrides['rhnorg'] = rhnorg
else:
msg = "Rhn registration required but missing credentials. "
Expand Down Expand Up @@ -763,9 +763,9 @@ def create_vm(self, name, profile=None, overrides={}, customprofile={}, k=None,
if rhnserver != "https://subscription.rhsm.redhat.com" and not valid_ip(rhnserver):
fqdn = os.path.basename(rhnserver)
rhncommands.append(f'rpm -Uvh http://{fqdn}/pub/katello-ca-consumer-latest.noarch.rpm')
if rhnak is not None and rhnorg is not None:
if rhnactivationkey is not None and rhnorg is not None:
rhncommands.append('subscription-manager register --serverurl=%s --force --activationkey=%s --org=%s'
% (rhnserver, rhnak, rhnorg))
% (rhnserver, rhnactivationkey, rhnorg))
if image.startswith('rhel-8') or image == 'rhel8':
rhncommands.append('subscription-manager repos --enable=rhel-8-for-x86_64-baseos-rpms')
elif image.startswith('rhel-server-7') or image == 'rhel7':
Expand Down
3 changes: 2 additions & 1 deletion kvirt/providers/ovirt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ def create(self, name, virttype=None, profile='', flavor=None, plan='kvirt',
if cloudinit and not custom_properties and initialization is None:
custom_script = ''
if storemetadata and overrides:
storeoverrides = {k: overrides[k] for k in overrides if k not in ['password', 'rhnpassword', 'rhnak']}
storeoverrides = {k: overrides[k] for k in overrides if k not in ['password', 'rhnpassword',
'rhnactivationkey']}
storedata = {'path': '/root/.metadata',
'content': yaml.dump(storeoverrides, default_flow_style=False, indent=2)}
if files:
Expand Down

0 comments on commit f64eb66

Please sign in to comment.