Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for specifying a custom CA bundle #2

Open
wants to merge 1 commit into
base: stackhpc/2023.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion blazar/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@
help='A domain name the os_admin_username belongs to.'),
cfg.StrOpt('os_admin_project_domain_name',
default='Default',
help='A domain name the os_admin_project_name belongs to')
help='A domain name the os_admin_project_name belongs to'),
cfg.StrOpt('cafile',
help='Path of the custom CA certificates bundle.'),
]

api_opts = [
Expand Down
20 changes: 18 additions & 2 deletions blazar/utils/openstack/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,15 @@ def client_kwargs(**_kwargs):
auth_kwargs.update(project_name=project_name)

auth = v3.Password(**auth_kwargs)
sess = session.Session(auth=auth)

sess_kwargs = dict(
auth=auth
)

if CONF.cafile:
sess_kwargs.update(verify=CONF.cafile)

sess = session.Session(**sess_kwargs)

kwargs.setdefault('session', sess)
kwargs.setdefault('region_name', region_name)
Expand Down Expand Up @@ -117,7 +125,15 @@ def client_user_kwargs(**_kwargs):
data = admin_ks_client.tokens.get_token_data(ctx.auth_token)
access_info = create_access_info(body=data, auth_token=ctx.auth_token)
auth = access.AccessInfoPlugin(access_info, auth_url=auth_url)
sess = session.Session(auth=auth)

sess_kwargs = dict(
auth=auth
)

if CONF.cafile:
sess_kwargs.update(verify=CONF.cafile)

sess = session.Session(**sess_kwargs)

kwargs.setdefault('session', sess)
kwargs.setdefault('region_name', region_name)
Expand Down
7 changes: 6 additions & 1 deletion blazar/utils/openstack/neutron.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ def __init__(self, **kwargs):
project_name=project_name,
user_domain_name=user_domain_name,
project_domain_name=project_domain_name)
sess = session.Session(auth=auth)
sess_kwargs = dict(
auth=auth
)
if CONF.cafile:
sess_kwargs.update(verify=CONF.cafile)
sess = session.Session(**sess_kwargs)
kwargs.setdefault('session', sess)
kwargs.setdefault('region_name', region_name)
kwargs.setdefault('endpoint_type', CONF.neutron.endpoint_type + 'URL')
Expand Down
10 changes: 9 additions & 1 deletion blazar/utils/openstack/nova.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,18 @@ def __init__(self, **kwargs):
if "v2.0" not in auth_url:
kwargs.setdefault('project_domain_name', project_domain_name)
kwargs.setdefault('user_domain_name', user_domain_name)

if CONF.cafile:
kwargs.setdefault('cacert', CONF.cafile)
else:
auth = token_endpoint.Token(endpoint_override,
auth_token)
sess = session.Session(auth=auth)
sess_kwargs = dict(
auth=auth
)
if CONF.cafile:
sess_kwargs.update(verify=CONF.cafile)
sess = session.Session(**sess_kwargs)
kwargs.setdefault('session', sess)

kwargs.setdefault('endpoint_type', CONF.nova.endpoint_type + 'URL')
Expand Down
7 changes: 6 additions & 1 deletion blazar/utils/openstack/placement.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ def _create_client(self, **kwargs):
project_name=project_name,
user_domain_name=user_domain_name,
project_domain_name=project_domain_name)
sess = session.Session(auth=auth)
sess_kwargs = dict(
auth=auth
)
if CONF.cafile:
sess_kwargs.update(verify=CONF.cafile)
sess = session.Session(**sess_kwargs)
# Set accept header on every request to ensure we notify placement
# service of our response body media type preferences.
headers = {'accept': 'application/json'}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
fixes:
- |
The Blazar service now supports using a custom CA certificate bundle with
the ``[DEFAULT]/cafile`` option. This allows for deployment on OpenStack
clouds that are using HTTPS endpoints with certificates signed by a custom
CA. `LP#2045281 <https://launchpad.net/bugs/2045281>`__