blob: 98b0116e47781b809c55843f9ebd0a306d100e36 [file] [log] [blame]
Matthew Treinishb86cda92013-07-29 11:22:23 -04001# Copyright 2013 IBM Corp.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
Miguel Lavalleb8fabc52013-08-23 11:19:57 -050015import netaddr
16
Andrea Frittolifc315902014-03-20 09:21:44 +000017from tempest import auth
Matthew Treinishb86cda92013-07-29 11:22:23 -040018from tempest import clients
Marc Kodererd2690fe2014-07-16 14:17:47 +020019from tempest.common import cred_provider
Masayuki Igawa259c1132013-10-31 17:48:44 +090020from tempest.common.utils import data_utils
Matthew Treinishb86cda92013-07-29 11:22:23 -040021from tempest import config
22from tempest import exceptions
23from tempest.openstack.common import log as logging
24
Sean Dague86bd8422013-12-20 09:56:44 -050025CONF = config.CONF
Matthew Treinishb86cda92013-07-29 11:22:23 -040026LOG = logging.getLogger(__name__)
27
28
Marc Kodererd2690fe2014-07-16 14:17:47 +020029class IsolatedCreds(cred_provider.CredentialProvider):
Matthew Treinishb86cda92013-07-29 11:22:23 -040030
31 def __init__(self, name, tempest_client=True, interface='json',
Matthew Treinish9f756a02014-01-15 10:26:07 -050032 password='pass', network_resources=None):
Marc Kodererd2690fe2014-07-16 14:17:47 +020033 super(IsolatedCreds, self).__init__(name, tempest_client, interface,
34 password, network_resources)
Matthew Treinish9f756a02014-01-15 10:26:07 -050035 self.network_resources = network_resources
Matthew Treinishb86cda92013-07-29 11:22:23 -040036 self.isolated_creds = {}
Miguel Lavalleb8fabc52013-08-23 11:19:57 -050037 self.isolated_net_resources = {}
38 self.ports = []
Matthew Treinishb86cda92013-07-29 11:22:23 -040039 self.tempest_client = tempest_client
40 self.interface = interface
41 self.password = password
Miguel Lavalleb8fabc52013-08-23 11:19:57 -050042 self.identity_admin_client, self.network_admin_client = (
43 self._get_admin_clients())
Matthew Treinishb86cda92013-07-29 11:22:23 -040044
Miguel Lavalleb8fabc52013-08-23 11:19:57 -050045 def _get_admin_clients(self):
Matthew Treinishb86cda92013-07-29 11:22:23 -040046 """
Miguel Lavalleb8fabc52013-08-23 11:19:57 -050047 Returns a tuple with instances of the following admin clients (in this
48 order):
49 identity
50 network
Matthew Treinishb86cda92013-07-29 11:22:23 -040051 """
52 if self.tempest_client:
53 os = clients.AdminManager(interface=self.interface)
Matthew Treinishb86cda92013-07-29 11:22:23 -040054 else:
Andrea Frittoli422fbdf2014-03-20 10:05:18 +000055 os = clients.OfficialClientManager(
56 auth.get_default_credentials('identity_admin')
57 )
58 return os.identity_client, os.network_client
Matthew Treinishb86cda92013-07-29 11:22:23 -040059
60 def _create_tenant(self, name, description):
61 if self.tempest_client:
David Kranze9d2f422014-07-02 13:57:41 -040062 _, tenant = self.identity_admin_client.create_tenant(
Matthew Treinishb86cda92013-07-29 11:22:23 -040063 name=name, description=description)
64 else:
Miguel Lavalleb8fabc52013-08-23 11:19:57 -050065 tenant = self.identity_admin_client.tenants.create(
66 name,
67 description=description)
Matthew Treinishb86cda92013-07-29 11:22:23 -040068 return tenant
69
70 def _get_tenant_by_name(self, name):
71 if self.tempest_client:
David Kranze9d2f422014-07-02 13:57:41 -040072 _, tenant = self.identity_admin_client.get_tenant_by_name(name)
Matthew Treinishb86cda92013-07-29 11:22:23 -040073 else:
Miguel Lavalleb8fabc52013-08-23 11:19:57 -050074 tenants = self.identity_admin_client.tenants.list()
Matthew Treinishb86cda92013-07-29 11:22:23 -040075 for ten in tenants:
76 if ten['name'] == name:
77 tenant = ten
DennyZhang1eb40462013-09-26 14:18:30 -050078 break
79 else:
80 raise exceptions.NotFound('No such tenant')
Matthew Treinishb86cda92013-07-29 11:22:23 -040081 return tenant
82
83 def _create_user(self, username, password, tenant, email):
84 if self.tempest_client:
David Kranze9d2f422014-07-02 13:57:41 -040085 _, user = self.identity_admin_client.create_user(username,
86 password,
87 tenant['id'],
88 email)
Matthew Treinishb86cda92013-07-29 11:22:23 -040089 else:
Miguel Lavalleb8fabc52013-08-23 11:19:57 -050090 user = self.identity_admin_client.users.create(username, password,
91 email,
92 tenant_id=tenant.id)
Matthew Treinishb86cda92013-07-29 11:22:23 -040093 return user
94
95 def _get_user(self, tenant, username):
96 if self.tempest_client:
David Kranze9d2f422014-07-02 13:57:41 -040097 _, user = self.identity_admin_client.get_user_by_username(
Miguel Lavalleb8fabc52013-08-23 11:19:57 -050098 tenant['id'],
99 username)
Matthew Treinishb86cda92013-07-29 11:22:23 -0400100 else:
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500101 user = self.identity_admin_client.users.get(username)
Matthew Treinishb86cda92013-07-29 11:22:23 -0400102 return user
103
104 def _list_roles(self):
105 if self.tempest_client:
David Kranze9d2f422014-07-02 13:57:41 -0400106 _, roles = self.identity_admin_client.list_roles()
Matthew Treinishb86cda92013-07-29 11:22:23 -0400107 else:
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500108 roles = self.identity_admin_client.roles.list()
Matthew Treinishb86cda92013-07-29 11:22:23 -0400109 return roles
110
Andrey Pavlovaf1fb702014-05-29 17:08:10 +0400111 def _assign_user_role(self, tenant, user, role_name):
112 role = None
113 try:
114 roles = self._list_roles()
115 if self.tempest_client:
116 role = next(r for r in roles if r['name'] == role_name)
117 else:
118 role = next(r for r in roles if r.name == role_name)
119 except StopIteration:
120 msg = 'No "%s" role found' % role_name
121 raise exceptions.NotFound(msg)
Matthew Treinishb86cda92013-07-29 11:22:23 -0400122 if self.tempest_client:
Andrey Pavlovaf1fb702014-05-29 17:08:10 +0400123 self.identity_admin_client.assign_user_role(tenant['id'],
124 user['id'], role['id'])
Matthew Treinishb86cda92013-07-29 11:22:23 -0400125 else:
Andrey Pavlovaf1fb702014-05-29 17:08:10 +0400126 self.identity_admin_client.roles.add_user_role(user.id, role.id,
127 tenant.id)
Matthew Treinishb86cda92013-07-29 11:22:23 -0400128
129 def _delete_user(self, user):
130 if self.tempest_client:
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500131 self.identity_admin_client.delete_user(user)
Matthew Treinishb86cda92013-07-29 11:22:23 -0400132 else:
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500133 self.identity_admin_client.users.delete(user)
Matthew Treinishb86cda92013-07-29 11:22:23 -0400134
135 def _delete_tenant(self, tenant):
136 if self.tempest_client:
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500137 self.identity_admin_client.delete_tenant(tenant)
Matthew Treinishb86cda92013-07-29 11:22:23 -0400138 else:
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500139 self.identity_admin_client.tenants.delete(tenant)
Matthew Treinishb86cda92013-07-29 11:22:23 -0400140
Sean Dague6969b902014-01-28 06:48:37 -0500141 def _create_creds(self, suffix="", admin=False):
142 """Create random credentials under the following schema.
143
144 If the name contains a '.' is the full class path of something, and
145 we don't really care. If it isn't, it's probably a meaningful name,
146 so use it.
147
148 For logging purposes, -user and -tenant are long and redundant,
149 don't use them. The user# will be sufficient to figure it out.
150 """
151 if '.' in self.name:
152 root = ""
153 else:
154 root = self.name
155
156 tenant_name = data_utils.rand_name(root) + suffix
Matthew Treinishb86cda92013-07-29 11:22:23 -0400157 tenant_desc = tenant_name + "-desc"
Matthew Treinishb86cda92013-07-29 11:22:23 -0400158 tenant = self._create_tenant(name=tenant_name,
159 description=tenant_desc)
Sean Dague6969b902014-01-28 06:48:37 -0500160
161 username = data_utils.rand_name(root) + suffix
162 email = data_utils.rand_name(root) + suffix + "@example.com"
Matthew Treinishb86cda92013-07-29 11:22:23 -0400163 user = self._create_user(username, self.password,
164 tenant, email)
Andrey Pavlovaf1fb702014-05-29 17:08:10 +0400165 # NOTE(andrey-mp): user needs this role to create containers in swift
166 swift_operator_role = CONF.object_storage.operator_role
167 self._assign_user_role(tenant, user, swift_operator_role)
Matthew Treinishb86cda92013-07-29 11:22:23 -0400168 if admin:
Andrey Pavlovaf1fb702014-05-29 17:08:10 +0400169 self._assign_user_role(tenant, user, CONF.identity.admin_role)
Andrea Frittoli9612e812014-03-13 10:57:26 +0000170 return self._get_credentials(user, tenant)
Matthew Treinishb86cda92013-07-29 11:22:23 -0400171
Andrea Frittolifc315902014-03-20 09:21:44 +0000172 def _get_credentials(self, user, tenant):
Matthew Treinishb86cda92013-07-29 11:22:23 -0400173 if self.tempest_client:
Andrea Frittolifc315902014-03-20 09:21:44 +0000174 user_get = user.get
175 tenant_get = tenant.get
Matthew Treinishb86cda92013-07-29 11:22:23 -0400176 else:
Andrea Frittolifc315902014-03-20 09:21:44 +0000177 user_get = user.__dict__.get
178 tenant_get = tenant.__dict__.get
179 return auth.get_credentials(
180 username=user_get('name'), user_id=user_get('id'),
181 tenant_name=tenant_get('name'), tenant_id=tenant_get('id'),
182 password=self.password)
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500183
184 def _create_network_resources(self, tenant_id):
185 network = None
186 subnet = None
187 router = None
Matthew Treinish9f756a02014-01-15 10:26:07 -0500188 # Make sure settings
189 if self.network_resources:
190 if self.network_resources['router']:
191 if (not self.network_resources['subnet'] or
192 not self.network_resources['network']):
193 raise exceptions.InvalidConfiguration(
194 'A router requires a subnet and network')
195 elif self.network_resources['subnet']:
196 if not self.network_resources['network']:
197 raise exceptions.InvalidConfiguration(
198 'A subnet requires a network')
199 elif self.network_resources['dhcp']:
200 raise exceptions.InvalidConfiguration('DHCP requires a subnet')
201
Masayuki Igawa259c1132013-10-31 17:48:44 +0900202 data_utils.rand_name_root = data_utils.rand_name(self.name)
Matthew Treinish9f756a02014-01-15 10:26:07 -0500203 if not self.network_resources or self.network_resources['network']:
204 network_name = data_utils.rand_name_root + "-network"
205 network = self._create_network(network_name, tenant_id)
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500206 try:
Matthew Treinish9f756a02014-01-15 10:26:07 -0500207 if not self.network_resources or self.network_resources['subnet']:
208 subnet_name = data_utils.rand_name_root + "-subnet"
209 subnet = self._create_subnet(subnet_name, tenant_id,
210 network['id'])
211 if not self.network_resources or self.network_resources['router']:
212 router_name = data_utils.rand_name_root + "-router"
213 router = self._create_router(router_name, tenant_id)
214 self._add_router_interface(router['id'], subnet['id'])
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500215 except Exception:
216 if router:
217 self._clear_isolated_router(router['id'], router['name'])
218 if subnet:
219 self._clear_isolated_subnet(subnet['id'], subnet['name'])
220 if network:
221 self._clear_isolated_network(network['id'], network['name'])
222 raise
223 return network, subnet, router
224
225 def _create_network(self, name, tenant_id):
226 if self.tempest_client:
227 resp, resp_body = self.network_admin_client.create_network(
Eugene Nikanorove9d255a2013-12-18 16:31:42 +0400228 name=name, tenant_id=tenant_id)
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500229 else:
230 body = {'network': {'tenant_id': tenant_id, 'name': name}}
231 resp_body = self.network_admin_client.create_network(body)
232 return resp_body['network']
233
234 def _create_subnet(self, subnet_name, tenant_id, network_id):
235 if not self.tempest_client:
236 body = {'subnet': {'name': subnet_name, 'tenant_id': tenant_id,
237 'network_id': network_id, 'ip_version': 4}}
Matthew Treinish9f756a02014-01-15 10:26:07 -0500238 if self.network_resources:
239 body['enable_dhcp'] = self.network_resources['dhcp']
Sean Dague86bd8422013-12-20 09:56:44 -0500240 base_cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr)
241 mask_bits = CONF.network.tenant_network_mask_bits
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500242 for subnet_cidr in base_cidr.subnet(mask_bits):
243 try:
244 if self.tempest_client:
Matthew Treinish9f756a02014-01-15 10:26:07 -0500245 if self.network_resources:
246 resp, resp_body = self.network_admin_client.\
247 create_subnet(
Eugene Nikanorove9d255a2013-12-18 16:31:42 +0400248 network_id=network_id, cidr=str(subnet_cidr),
Matthew Treinish9f756a02014-01-15 10:26:07 -0500249 name=subnet_name,
250 tenant_id=tenant_id,
Eugene Nikanorove9d255a2013-12-18 16:31:42 +0400251 enable_dhcp=self.network_resources['dhcp'],
252 ip_version=4)
Matthew Treinish9f756a02014-01-15 10:26:07 -0500253 else:
254 resp, resp_body = self.network_admin_client.\
Eugene Nikanorove9d255a2013-12-18 16:31:42 +0400255 create_subnet(network_id=network_id,
256 cidr=str(subnet_cidr),
Matthew Treinish9f756a02014-01-15 10:26:07 -0500257 name=subnet_name,
Eugene Nikanorove9d255a2013-12-18 16:31:42 +0400258 tenant_id=tenant_id,
259 ip_version=4)
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500260 else:
261 body['subnet']['cidr'] = str(subnet_cidr)
262 resp_body = self.network_admin_client.create_subnet(body)
263 break
264 except exceptions.BadRequest as e:
265 if 'overlaps with another subnet' not in str(e):
266 raise
267 else:
268 e = exceptions.BuildErrorException()
269 e.message = 'Available CIDR for subnet creation could not be found'
270 raise e
271 return resp_body['subnet']
272
273 def _create_router(self, router_name, tenant_id):
274 external_net_id = dict(
Sean Dague86bd8422013-12-20 09:56:44 -0500275 network_id=CONF.network.public_network_id)
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500276 if self.tempest_client:
277 resp, resp_body = self.network_admin_client.create_router(
278 router_name,
279 external_gateway_info=external_net_id,
280 tenant_id=tenant_id)
281 else:
282 body = {'router': {'name': router_name, 'tenant_id': tenant_id,
283 'external_gateway_info': external_net_id,
284 'admin_state_up': True}}
285 resp_body = self.network_admin_client.create_router(body)
286 return resp_body['router']
287
288 def _add_router_interface(self, router_id, subnet_id):
289 if self.tempest_client:
290 self.network_admin_client.add_router_interface_with_subnet_id(
291 router_id, subnet_id)
292 else:
293 body = {'subnet_id': subnet_id}
294 self.network_admin_client.add_interface_router(router_id, body)
295
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500296 def get_primary_network(self):
297 return self.isolated_net_resources.get('primary')[0]
298
299 def get_primary_subnet(self):
300 return self.isolated_net_resources.get('primary')[1]
301
302 def get_primary_router(self):
303 return self.isolated_net_resources.get('primary')[2]
304
305 def get_admin_network(self):
306 return self.isolated_net_resources.get('admin')[0]
307
308 def get_admin_subnet(self):
309 return self.isolated_net_resources.get('admin')[1]
310
311 def get_admin_router(self):
312 return self.isolated_net_resources.get('admin')[2]
313
314 def get_alt_network(self):
315 return self.isolated_net_resources.get('alt')[0]
316
317 def get_alt_subnet(self):
318 return self.isolated_net_resources.get('alt')[1]
319
320 def get_alt_router(self):
321 return self.isolated_net_resources.get('alt')[2]
322
Andrea Frittoli9612e812014-03-13 10:57:26 +0000323 def get_credentials(self, credential_type):
Andrea Frittolifc315902014-03-20 09:21:44 +0000324 if self.isolated_creds.get(credential_type):
325 credentials = self.isolated_creds[credential_type]
Matthew Treinishb86cda92013-07-29 11:22:23 -0400326 else:
Andrea Frittolifc315902014-03-20 09:21:44 +0000327 is_admin = (credential_type == 'admin')
Andrea Frittoli9612e812014-03-13 10:57:26 +0000328 credentials = self._create_creds(admin=is_admin)
Andrea Frittolifc315902014-03-20 09:21:44 +0000329 self.isolated_creds[credential_type] = credentials
330 # Maintained until tests are ported
Andrea Frittolifc315902014-03-20 09:21:44 +0000331 LOG.info("Acquired isolated creds:\n credentials: %s"
332 % credentials)
Sean Dague86bd8422013-12-20 09:56:44 -0500333 if CONF.service_available.neutron:
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500334 network, subnet, router = self._create_network_resources(
Andrea Frittolifc315902014-03-20 09:21:44 +0000335 credentials.tenant_id)
336 self.isolated_net_resources[credential_type] = (
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500337 network, subnet, router,)
338 LOG.info("Created isolated network resources for : \n"
Andrea Frittolifc315902014-03-20 09:21:44 +0000339 + " credentials: %s" % credentials)
Andrea Frittoli9612e812014-03-13 10:57:26 +0000340 return credentials
Matthew Treinishb86cda92013-07-29 11:22:23 -0400341
Andrea Frittoli9612e812014-03-13 10:57:26 +0000342 def get_primary_creds(self):
343 return self.get_credentials('primary')
Matthew Treinishb86cda92013-07-29 11:22:23 -0400344
Andrea Frittoli9612e812014-03-13 10:57:26 +0000345 def get_admin_creds(self):
346 return self.get_credentials('admin')
Andrea Frittolifc315902014-03-20 09:21:44 +0000347
Andrea Frittoli9612e812014-03-13 10:57:26 +0000348 def get_alt_creds(self):
349 return self.get_credentials('alt')
Matthew Treinishb86cda92013-07-29 11:22:23 -0400350
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500351 def _clear_isolated_router(self, router_id, router_name):
352 net_client = self.network_admin_client
353 try:
354 net_client.delete_router(router_id)
355 except exceptions.NotFound:
356 LOG.warn('router with name: %s not found for delete' %
357 router_name)
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500358
359 def _clear_isolated_subnet(self, subnet_id, subnet_name):
360 net_client = self.network_admin_client
361 try:
362 net_client.delete_subnet(subnet_id)
363 except exceptions.NotFound:
364 LOG.warn('subnet with name: %s not found for delete' %
365 subnet_name)
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500366
367 def _clear_isolated_network(self, network_id, network_name):
368 net_client = self.network_admin_client
369 try:
370 net_client.delete_network(network_id)
371 except exceptions.NotFound:
372 LOG.warn('network with name: %s not found for delete' %
373 network_name)
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500374
375 def _cleanup_ports(self, network_id):
376 # TODO(mlavalle) This method will be removed once patch
377 # https://review.openstack.org/#/c/46563/ merges in Neutron
378 if not self.ports:
379 if self.tempest_client:
380 resp, resp_body = self.network_admin_client.list_ports()
381 else:
382 resp_body = self.network_admin_client.list_ports()
383 self.ports = resp_body['ports']
384 ports_to_delete = [
armando-migliaccio96a86ae2013-11-21 17:26:16 -0800385 port
386 for port in self.ports
387 if (port['network_id'] == network_id and
shihanzhangc3d73c82014-02-18 10:27:02 +0800388 port['device_owner'] != 'network:router_interface' and
389 port['device_owner'] != 'network:dhcp')
armando-migliaccio96a86ae2013-11-21 17:26:16 -0800390 ]
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500391 for port in ports_to_delete:
392 try:
393 LOG.info('Cleaning up port id %s, name %s' %
394 (port['id'], port['name']))
395 self.network_admin_client.delete_port(port['id'])
396 except exceptions.NotFound:
397 LOG.warn('Port id: %s, name %s not found for clean-up' %
398 (port['id'], port['name']))
399
400 def _clear_isolated_net_resources(self):
401 net_client = self.network_admin_client
402 for cred in self.isolated_net_resources:
403 network, subnet, router = self.isolated_net_resources.get(cred)
Salvatore Orlandocf996c62014-01-30 09:15:18 -0800404 LOG.debug("Clearing network: %(network)s, "
405 "subnet: %(subnet)s, router: %(router)s",
406 {'network': network, 'subnet': subnet, 'router': router})
407 if (not self.network_resources or
408 self.network_resources.get('router')):
Matthew Treinish9f756a02014-01-15 10:26:07 -0500409 try:
410 if self.tempest_client:
411 net_client.remove_router_interface_with_subnet_id(
412 router['id'], subnet['id'])
413 else:
414 body = {'subnet_id': subnet['id']}
415 net_client.remove_interface_router(router['id'], body)
416 except exceptions.NotFound:
417 LOG.warn('router with name: %s not found for delete' %
418 router['name'])
Matthew Treinish9f756a02014-01-15 10:26:07 -0500419 self._clear_isolated_router(router['id'], router['name'])
Salvatore Orlandocf996c62014-01-30 09:15:18 -0800420 if (not self.network_resources or
421 self.network_resources.get('network')):
Matthew Treinish9f756a02014-01-15 10:26:07 -0500422 # TODO(mlavalle) This method call will be removed once patch
423 # https://review.openstack.org/#/c/46563/ merges in Neutron
424 self._cleanup_ports(network['id'])
Salvatore Orlandocf996c62014-01-30 09:15:18 -0800425 if (not self.network_resources or
426 self.network_resources.get('subnet')):
Matthew Treinish9f756a02014-01-15 10:26:07 -0500427 self._clear_isolated_subnet(subnet['id'], subnet['name'])
Salvatore Orlandocf996c62014-01-30 09:15:18 -0800428 if (not self.network_resources or
429 self.network_resources.get('network')):
Matthew Treinish9f756a02014-01-15 10:26:07 -0500430 self._clear_isolated_network(network['id'], network['name'])
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500431
Matthew Treinishb86cda92013-07-29 11:22:23 -0400432 def clear_isolated_creds(self):
433 if not self.isolated_creds:
434 return
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500435 self._clear_isolated_net_resources()
Andrea Frittolifc315902014-03-20 09:21:44 +0000436 for creds in self.isolated_creds.itervalues():
Matthew Treinishb86cda92013-07-29 11:22:23 -0400437 try:
Andrea Frittolifc315902014-03-20 09:21:44 +0000438 self._delete_user(creds.user_id)
Matthew Treinishb86cda92013-07-29 11:22:23 -0400439 except exceptions.NotFound:
Andrea Frittolifc315902014-03-20 09:21:44 +0000440 LOG.warn("user with name: %s not found for delete" %
441 creds.username)
Matthew Treinishb86cda92013-07-29 11:22:23 -0400442 try:
Andrea Frittolifc315902014-03-20 09:21:44 +0000443 self._delete_tenant(creds.tenant_id)
Matthew Treinishb86cda92013-07-29 11:22:23 -0400444 except exceptions.NotFound:
Andrea Frittolifc315902014-03-20 09:21:44 +0000445 LOG.warn("tenant with name: %s not found for delete" %
446 creds.tenant_name)