21
24
class TempestAdminAdapter(adapters.OpenStackRelationAdapter):
26
"""Inspect relations and provide properties that can be used when
27
rendering templates"""
23
29
interface_type = "identity-admin"
25
31
def __init__(self, relation):
32
"""Initialise a keystone client and collect user defined config"""
27
34
super(TempestAdminAdapter, self).__init__(relation)
28
35
self.init_keystone_client()
29
36
self.uconfig = hookenv.config()
39
def keystone_info(self):
40
"""Collection keystone information from keystone relation"""
41
return self.relation.credentials()
31
43
def init_keystone_client(self):
44
"""Initialise keystone client"""
34
47
self.keystone_auth_url = '{}://{}:{}/v2.0'.format(
36
self.creds['service_hostname'],
37
self.creds['service_port']
49
self.keystone_info['service_hostname'],
50
self.keystone_info['service_port']
40
'username': self.creds['service_username'],
41
'password': self.creds['service_password'],
53
'username': self.keystone_info['service_username'],
54
'password': self.keystone_info['service_password'],
42
55
'auth_url': self.keystone_auth_url,
43
'tenant_name': self.creds['service_tenant_name'],
44
'region_name': self.creds['service_region'],
56
'tenant_name': self.keystone_info['service_tenant_name'],
57
'region_name': self.keystone_info['service_region'],
47
60
self.kc = keystoneclient.client.Client(**auth)
64
81
def image_info(self):
82
"""Return image ids for the user-defined image names
84
@returns {'image_id' id1, 'image_alt_id': id2}
65
86
self.init_keystone_client()
66
87
glance_endpoint = self.kc.service_catalog.url_for(
67
88
service_type='image',
83
104
def network_info(self):
105
"""Return public network and router ids for user-defined router and
108
@returns {'image_id' id1, 'image_alt_id': id2}
84
110
self.init_keystone_client()
85
111
neutron_ep = self.kc.service_catalog.url_for(
86
112
service_type='network',
112
138
def compute_info(self):
139
"""Return flavor ids for user-defined flavors
141
@returns {'flavor_id' id1, 'flavor_alt_id': id2}
113
143
self.init_keystone_client()
114
144
nova_ep = self.kc.service_catalog.url_for(
115
145
service_type='compute',
122
152
url.netloc.split(':')[0])
124
154
nova_client = novaclient.client.Client(
125
self.creds['service_username'],
126
self.creds['service_password'],
127
self.creds['service_tenant_name'],
155
self.keystone_info['service_username'],
156
self.keystone_info['service_password'],
157
self.keystone_info['service_tenant_name'],
128
158
self.keystone_auth_url,
130
160
for flavor in nova_client.flavors.list():
136
166
hookenv.log("Nova is not ready, deferring nova query")
137
167
return compute_info
141
return self.relation.credentials()
145
bob = self.get_keystone_client() or 'bugger'
148
170
def get_present_services(self):
171
"""Query keystone catalogue for a list for registered services
173
@returns [svc1, svc2, ...]: List of registered services
149
175
self.init_keystone_client()
150
176
services = [svc.name for svc in self.kc.services.list() if svc.enabled]
151
# if DashboardRelation().get('dashboard_url'):
152
# services.append('horizon')
156
180
def service_info(self):
181
"""Assemble a list of services tempest should tests
183
Compare the list of keystone registered services with the services the
184
user has requested be tested. If in 'auto' mode test all services
185
registered in keystone.
187
@returns [svc1, svc2, ...]: List of services to test
157
189
service_info = {}
158
190
tempest_candidates = ['ceilometer', 'cinder', 'glance', 'heat',
159
191
'horizon', 'ironic', 'neutron', 'nova',
182
214
class TempestAdapters(adapters.OpenStackRelationAdapters):
184
Adapters class for the Designate charm.
216
Adapters class for the Tempest charm.
186
218
relation_adapters = {
187
219
'identity_admin': TempestAdminAdapter,
196
228
class TempestConfigurationAdapter(adapters.ConfigurationAdapter):
230
Manipulate user supplied config as needed
198
232
def __init__(self):
199
233
super(TempestConfigurationAdapter, self).__init__()
202
236
class TempestCharm(charm.OpenStackCharm):
238
"""Directories and files used for running tempest"""
204
239
TEMPEST_ROOT = '/var/lib/tempest/'
205
240
TEMPEST_LOGDIR = TEMPEST_ROOT + '/logs'
206
241
TEMPEST_CONF = TEMPEST_ROOT + '/tempest.conf'
242
"""pip.conf for proxy settings etc"""
207
243
PIP_CONF = '/root/.pip/pip.conf'
245
"""List of packages charm should install
246
XXX The install hook is currently installing most packages ahead of
247
this because modules like keystoneclient are needed at load time
210
250
'git', 'testrepository', 'subunit', 'python-nose', 'python-lxml',
211
251
'python-boto', 'python-junitxml', 'python-subunit',
217
257
'python3-keystoneclient', 'python3-neutronclient',
218
258
'python3-novaclient', 'python3-swiftclient',
219
259
'python3-ceilometerclient', 'openvswitch-common', 'libffi-dev',
220
'libssl-dev', 'python-dev', 'python-cffi', 'tox'
260
'libssl-dev', 'python-dev', 'python-cffi'
263
"""Use the Tempest specific adapters"""
223
264
adapters_class = TempestAdapters
265
"""Tempest has no running services so no services need restarting on
225
269
TEMPEST_CONF: [],