Gentoo Archives: gentoo-commits

From: Magnus Granberg <zorry@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/tinderbox-cluster:master commit in: gosbs/conf/, gosbs/
Date: Thu, 03 Sep 2020 00:43:03
Message-Id: 1599093624.f715a6953ed1e5f62a406029b62ca8d1000197fb.zorry@gentoo
1 commit: f715a6953ed1e5f62a406029b62ca8d1000197fb
2 Author: Magnus Granberg <zorry <AT> gentoo <DOT> org>
3 AuthorDate: Thu Sep 3 00:40:24 2020 +0000
4 Commit: Magnus Granberg <zorry <AT> gentoo <DOT> org>
5 CommitDate: Thu Sep 3 00:40:24 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/tinderbox-cluster.git/commit/?id=f715a695
7
8 Add Openstack connect and MinIO connect
9
10 Signed-off-by: Magnus Granberg <zorry <AT> gentoo.org>
11
12 gosbs/conf/__init__.py | 3 ++-
13 gosbs/conf/minio.py | 42 ++++++++++++++++++++++++++++++++++++++++++
14 gosbs/context.py | 27 +++++++++++++++++++++++++++
15 3 files changed, 71 insertions(+), 1 deletion(-)
16
17 diff --git a/gosbs/conf/__init__.py b/gosbs/conf/__init__.py
18 index d79e8a5..0589ca1 100644
19 --- a/gosbs/conf/__init__.py
20 +++ b/gosbs/conf/__init__.py
21 @@ -41,6 +41,7 @@ from gosbs.conf import database
22 #from nova.conf import key_manager
23 from gosbs.conf import keystone
24 #from nova.conf import libvirt
25 +from gosbs.conf import minio
26 #from nova.conf import mks
27 from gosbs.conf import netconf
28 #from nova.conf import neutron
29 @@ -88,7 +89,7 @@ database.register_opts(CONF)
30 #glance.register_opts(CONF)
31 #guestfs.register_opts(CONF)
32 #hyperv.register_opts(CONF)
33 -#mks.register_opts(CONF)
34 +minio.register_opts(CONF)
35 #imagecache.register_opts(CONF)
36 #ironic.register_opts(CONF)
37 #key_manager.register_opts(CONF)
38
39 diff --git a/gosbs/conf/minio.py b/gosbs/conf/minio.py
40 new file mode 100644
41 index 0000000..82524c0
42 --- /dev/null
43 +++ b/gosbs/conf/minio.py
44 @@ -0,0 +1,42 @@
45 +#
46 +# Licensed under the Apache License, Version 2.0 (the "License"); you may
47 +# not use this file except in compliance with the License. You may obtain
48 +# a copy of the License at
49 +#
50 +# http://www.apache.org/licenses/LICENSE-2.0
51 +#
52 +# Unless required by applicable law or agreed to in writing, software
53 +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
54 +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
55 +# License for the specific language governing permissions and limitations
56 +# under the License.
57 +
58 +from oslo_config import cfg
59 +
60 +
61 +minio_group = cfg.OptGroup(
62 + name='minio',
63 + title='MinIO Options',
64 + help='Configuration options for the MinIO service')
65 +
66 +minio_opts = [
67 + cfg.StrOpt('url',
68 + default='',
69 + help=''),
70 + cfg.StrOpt('username',
71 + default='',
72 + help=''),
73 + cfg.StrOpt('password',
74 + secret=True,
75 + default='True',
76 + help=''),
77 +]
78 +
79 +
80 +def register_opts(conf):
81 + conf.register_group(minio_group)
82 + conf.register_opts(minio_opts, group=minio_group)
83 +
84 +
85 +def list_opts():
86 + return {minio_group: minio_opts}
87
88 diff --git a/gosbs/context.py b/gosbs/context.py
89 index 11ef81a..bffda32 100644
90 --- a/gosbs/context.py
91 +++ b/gosbs/context.py
92 @@ -20,6 +20,7 @@
93 from contextlib import contextmanager
94 import copy
95 import warnings
96 +from minio import Minio
97
98 import eventlet.queue
99 import eventlet.timeout
100 @@ -29,6 +30,7 @@ from oslo_context import context
101 from oslo_db.sqlalchemy import enginefacade
102 from oslo_log import log as logging
103 from oslo_utils import timeutils
104 +from openstack import connection
105 import six
106
107 from gosbs import exception
108 @@ -36,6 +38,9 @@ from gosbs.i18n import _
109 from gosbs import objects
110 from gosbs import policy
111 from gosbs import utils
112 +import gosbs.conf
113 +
114 +CONF = gosbs.conf.CONF
115
116 LOG = logging.getLogger(__name__)
117 # TODO(melwitt): This cache should be cleared whenever WSGIService receives a
118 @@ -558,3 +563,25 @@ def scatter_gather_all_cells(context, fn, *args, **kwargs):
119 load_cells()
120 return scatter_gather_cells(context, CELLS, CELL_TIMEOUT,
121 fn, *args, **kwargs)
122 +
123 +def get_openstack_connect():
124 + openstack_conn = connection.Connection(
125 + region_name = CONF.keystone.region_name,
126 + auth=dict(
127 + auth_url = CONF.keystone.auth_url,
128 + username = CONF.keystone.username,
129 + password = CONF.keystone.password,
130 + project_id = CONF.keystone.project_id,
131 + user_domain_id = CONF.keystone.user_domain_name),
132 + gosbs_api_version = CONF.keystone.auth_version,
133 + identity_interface= CONF.keystone.identity_interface)
134 + return openstack_conn
135 +
136 +def get_minio_connect():
137 + minioclient = Minio(
138 + CONF.minio.url,
139 + access_key = CONF.minio.username,
140 + secret_key = CONF.minio.password,
141 + secure = True
142 + )
143 + return minioclient