commit: f715a6953ed1e5f62a406029b62ca8d1000197fb Author: Magnus Granberg <zorry <AT> gentoo <DOT> org> AuthorDate: Thu Sep 3 00:40:24 2020 +0000 Commit: Magnus Granberg <zorry <AT> gentoo <DOT> org> CommitDate: Thu Sep 3 00:40:24 2020 +0000 URL: https://gitweb.gentoo.org/proj/tinderbox-cluster.git/commit/?id=f715a695
Add Openstack connect and MinIO connect Signed-off-by: Magnus Granberg <zorry <AT> gentoo.org> gosbs/conf/__init__.py | 3 ++- gosbs/conf/minio.py | 42 ++++++++++++++++++++++++++++++++++++++++++ gosbs/context.py | 27 +++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) diff --git a/gosbs/conf/__init__.py b/gosbs/conf/__init__.py index d79e8a5..0589ca1 100644 --- a/gosbs/conf/__init__.py +++ b/gosbs/conf/__init__.py @@ -41,6 +41,7 @@ from gosbs.conf import database #from nova.conf import key_manager from gosbs.conf import keystone #from nova.conf import libvirt +from gosbs.conf import minio #from nova.conf import mks from gosbs.conf import netconf #from nova.conf import neutron @@ -88,7 +89,7 @@ database.register_opts(CONF) #glance.register_opts(CONF) #guestfs.register_opts(CONF) #hyperv.register_opts(CONF) -#mks.register_opts(CONF) +minio.register_opts(CONF) #imagecache.register_opts(CONF) #ironic.register_opts(CONF) #key_manager.register_opts(CONF) diff --git a/gosbs/conf/minio.py b/gosbs/conf/minio.py new file mode 100644 index 0000000..82524c0 --- /dev/null +++ b/gosbs/conf/minio.py @@ -0,0 +1,42 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from oslo_config import cfg + + +minio_group = cfg.OptGroup( + name='minio', + title='MinIO Options', + help='Configuration options for the MinIO service') + +minio_opts = [ + cfg.StrOpt('url', + default='', + help=''), + cfg.StrOpt('username', + default='', + help=''), + cfg.StrOpt('password', + secret=True, + default='True', + help=''), +] + + +def register_opts(conf): + conf.register_group(minio_group) + conf.register_opts(minio_opts, group=minio_group) + + +def list_opts(): + return {minio_group: minio_opts} diff --git a/gosbs/context.py b/gosbs/context.py index 11ef81a..bffda32 100644 --- a/gosbs/context.py +++ b/gosbs/context.py @@ -20,6 +20,7 @@ from contextlib import contextmanager import copy import warnings +from minio import Minio import eventlet.queue import eventlet.timeout @@ -29,6 +30,7 @@ from oslo_context import context from oslo_db.sqlalchemy import enginefacade from oslo_log import log as logging from oslo_utils import timeutils +from openstack import connection import six from gosbs import exception @@ -36,6 +38,9 @@ from gosbs.i18n import _ from gosbs import objects from gosbs import policy from gosbs import utils +import gosbs.conf + +CONF = gosbs.conf.CONF LOG = logging.getLogger(__name__) # TODO(melwitt): This cache should be cleared whenever WSGIService receives a @@ -558,3 +563,25 @@ def scatter_gather_all_cells(context, fn, *args, **kwargs): load_cells() return scatter_gather_cells(context, CELLS, CELL_TIMEOUT, fn, *args, **kwargs) + +def get_openstack_connect(): + openstack_conn = connection.Connection( + region_name = CONF.keystone.region_name, + auth=dict( + auth_url = CONF.keystone.auth_url, + username = CONF.keystone.username, + password = CONF.keystone.password, + project_id = CONF.keystone.project_id, + user_domain_id = CONF.keystone.user_domain_name), + gosbs_api_version = CONF.keystone.auth_version, + identity_interface= CONF.keystone.identity_interface) + return openstack_conn + +def get_minio_connect(): + minioclient = Minio( + CONF.minio.url, + access_key = CONF.minio.username, + secret_key = CONF.minio.password, + secure = True + ) + return minioclient
