Skip to content

Commit

Permalink
Merge branch 'devel' into release-notes
Browse files Browse the repository at this point in the history
  • Loading branch information
tvo318 authored Nov 15, 2023
2 parents e3999d3 + 0b8fedf commit 8070d2e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
17 changes: 16 additions & 1 deletion awx/main/credential_plugins/dsv.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from django.conf import settings
from django.utils.translation import gettext_lazy as _
from delinea.secrets.vault import PasswordGrantAuthorizer, SecretsVault
from base64 import b64decode

dsv_inputs = {
'fields': [
Expand Down Expand Up @@ -44,8 +45,16 @@
'help_text': _('The field to extract from the secret'),
'type': 'string',
},
{
'id': 'secret_decoding',
'label': _('Should the secret be base64 decoded?'),
'help_text': _('Specify whether the secret should be base64 decoded, typically used for storing files, such as SSH keys'),
'choices': ['No Decoding', 'Decode Base64'],
'type': 'string',
'default': 'No Decoding',
},
],
'required': ['tenant', 'client_id', 'client_secret', 'path', 'secret_field'],
'required': ['tenant', 'client_id', 'client_secret', 'path', 'secret_field', 'secret_decoding'],
}

if settings.DEBUG:
Expand All @@ -67,12 +76,18 @@ def dsv_backend(**kwargs):
client_secret = kwargs['client_secret']
secret_path = kwargs['path']
secret_field = kwargs['secret_field']
# providing a default value to remain backward compatible for secrets that have not specified this option
secret_decoding = kwargs.get('secret_decoding', 'No Decoding')

tenant_url = tenant_url_template.format(tenant_name, tenant_tld.strip("."))

authorizer = PasswordGrantAuthorizer(tenant_url, client_id, client_secret)
dsv_secret = SecretsVault(tenant_url, authorizer).get_secret(secret_path)

# files can be uploaded base64 decoded to DSV and thus decoding it only, when asked for
if secret_decoding == 'Decode Base64':
return b64decode(dsv_secret['data'][secret_field]).decode()

return dsv_secret['data'][secret_field]


Expand Down
26 changes: 24 additions & 2 deletions awx/main/utils/licensing.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ def _can_aggregate(sub, license):
license['support_level'] = attr.get('value')
elif attr.get('name') == 'usage':
license['usage'] = attr.get('value')
elif attr.get('name') == 'ph_product_name' and attr.get('value') == 'RHEL Developer':
license['license_type'] = 'developer'

if not license:
logger.error("No valid subscriptions found in manifest")
Expand Down Expand Up @@ -322,7 +324,9 @@ def is_appropriate_sub(self, sub):
def generate_license_options_from_entitlements(self, json):
from dateutil.parser import parse

ValidSub = collections.namedtuple('ValidSub', 'sku name support_level end_date trial quantity pool_id satellite subscription_id account_number usage')
ValidSub = collections.namedtuple(
'ValidSub', 'sku name support_level end_date trial developer_license quantity pool_id satellite subscription_id account_number usage'
)
valid_subs = []
for sub in json:
satellite = sub.get('satellite')
Expand Down Expand Up @@ -350,6 +354,7 @@ def generate_license_options_from_entitlements(self, json):

sku = sub['productId']
trial = sku.startswith('S') # i.e.,, SER/SVC
developer_license = False
support_level = ''
usage = ''
pool_id = sub['id']
Expand All @@ -364,9 +369,24 @@ def generate_license_options_from_entitlements(self, json):
support_level = attr.get('value')
elif attr.get('name') == 'usage':
usage = attr.get('value')
elif attr.get('name') == 'ph_product_name' and attr.get('value') == 'RHEL Developer':
developer_license = True

valid_subs.append(
ValidSub(sku, sub['productName'], support_level, end_date, trial, quantity, pool_id, satellite, subscription_id, account_number, usage)
ValidSub(
sku,
sub['productName'],
support_level,
end_date,
trial,
developer_license,
quantity,
pool_id,
satellite,
subscription_id,
account_number,
usage,
)
)

if valid_subs:
Expand All @@ -381,6 +401,8 @@ def generate_license_options_from_entitlements(self, json):
if sub.trial:
license._attrs['trial'] = True
license._attrs['license_type'] = 'trial'
if sub.developer_license:
license._attrs['license_type'] = 'developer'
license._attrs['instance_count'] = min(MAX_INSTANCES, license._attrs['instance_count'])
human_instances = license._attrs['instance_count']
if human_instances == MAX_INSTANCES:
Expand Down
2 changes: 2 additions & 0 deletions docs/docsite/rst/userguide/workflow_templates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,8 @@ Extra Variables
pair: workflow templates; survey extra variables
pair: surveys; extra variables

.. <- Comment to separate the index and the note to avoid rendering issues.
.. note::

``extra_vars`` passed to the job launch API are only honored if one of the following is true:
Expand Down

0 comments on commit 8070d2e

Please sign in to comment.