blob: 02c50e44c5482ca9150321050eda9f8592dc70be [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
Kevin Bentonc10a9cf2014-08-19 17:10:03 -070016from neutronclient.common import exceptions as n_exc
Miguel Lavalleb8fabc52013-08-23 11:19:57 -050017
Andrea Frittolifc315902014-03-20 09:21:44 +000018from tempest import auth
Matthew Treinishb86cda92013-07-29 11:22:23 -040019from tempest import clients
Marc Kodererd2690fe2014-07-16 14:17:47 +020020from tempest.common import cred_provider
Masayuki Igawa259c1132013-10-31 17:48:44 +090021from tempest.common.utils import data_utils
Matthew Treinishb86cda92013-07-29 11:22:23 -040022from tempest import config
23from tempest import exceptions
24from tempest.openstack.common import log as logging
25
Sean Dague86bd8422013-12-20 09:56:44 -050026CONF = config.CONF
Matthew Treinishb86cda92013-07-29 11:22:23 -040027LOG = logging.getLogger(__name__)
28
29
Marc Kodererd2690fe2014-07-16 14:17:47 +020030class IsolatedCreds(cred_provider.CredentialProvider):
Matthew Treinishb86cda92013-07-29 11:22:23 -040031
32 def __init__(self, name, tempest_client=True, interface='json',
Matthew Treinish9f756a02014-01-15 10:26:07 -050033 password='pass', network_resources=None):
Marc Kodererd2690fe2014-07-16 14:17:47 +020034 super(IsolatedCreds, self).__init__(name, tempest_client, interface,
35 password, network_resources)
Matthew Treinish9f756a02014-01-15 10:26:07 -050036 self.network_resources = network_resources
Matthew Treinishb86cda92013-07-29 11:22:23 -040037 self.isolated_creds = {}
Miguel Lavalleb8fabc52013-08-23 11:19:57 -050038 self.isolated_net_resources = {}
39 self.ports = []
Matthew Treinishb86cda92013-07-29 11:22:23 -040040 self.tempest_client = tempest_client
41 self.interface = interface
42 self.password = password
Miguel Lavalleb8fabc52013-08-23 11:19:57 -050043 self.identity_admin_client, self.network_admin_client = (
44 self._get_admin_clients())
Matthew Treinishb86cda92013-07-29 11:22:23 -040045
Miguel Lavalleb8fabc52013-08-23 11:19:57 -050046 def _get_admin_clients(self):
Matthew Treinishb86cda92013-07-29 11:22:23 -040047 """
Miguel Lavalleb8fabc52013-08-23 11:19:57 -050048 Returns a tuple with instances of the following admin clients (in this
49 order):
50 identity
51 network
Matthew Treinishb86cda92013-07-29 11:22:23 -040052 """
53 if self.tempest_client:
54 os = clients.AdminManager(interface=self.interface)
Matthew Treinishb86cda92013-07-29 11:22:23 -040055 else:
Andrea Frittoli422fbdf2014-03-20 10:05:18 +000056 os = clients.OfficialClientManager(
57 auth.get_default_credentials('identity_admin')
58 )
59 return os.identity_client, os.network_client
Matthew Treinishb86cda92013-07-29 11:22:23 -040060
61 def _create_tenant(self, name, description):
62 if self.tempest_client:
David Kranze9d2f422014-07-02 13:57:41 -040063 _, tenant = self.identity_admin_client.create_tenant(
Matthew Treinishb86cda92013-07-29 11:22:23 -040064 name=name, description=description)
65 else:
Miguel Lavalleb8fabc52013-08-23 11:19:57 -050066 tenant = self.identity_admin_client.tenants.create(
67 name,
68 description=description)
Matthew Treinishb86cda92013-07-29 11:22:23 -040069 return tenant
70
71 def _get_tenant_by_name(self, name):
72 if self.tempest_client:
David Kranze9d2f422014-07-02 13:57:41 -040073 _, tenant = self.identity_admin_client.get_tenant_by_name(name)
Matthew Treinishb86cda92013-07-29 11:22:23 -040074 else:
Miguel Lavalleb8fabc52013-08-23 11:19:57 -050075 tenants = self.identity_admin_client.tenants.list()
Matthew Treinishb86cda92013-07-29 11:22:23 -040076 for ten in tenants:
77 if ten['name'] == name:
78 tenant = ten
DennyZhang1eb40462013-09-26 14:18:30 -050079 break
80 else:
81 raise exceptions.NotFound('No such tenant')
Matthew Treinishb86cda92013-07-29 11:22:23 -040082 return tenant
83
84 def _create_user(self, username, password, tenant, email):
85 if self.tempest_client:
David Kranze9d2f422014-07-02 13:57:41 -040086 _, user = self.identity_admin_client.create_user(username,
87 password,
88 tenant['id'],
89 email)
Matthew Treinishb86cda92013-07-29 11:22:23 -040090 else:
Miguel Lavalleb8fabc52013-08-23 11:19:57 -050091 user = self.identity_admin_client.users.create(username, password,
92 email,
93 tenant_id=tenant.id)
Matthew Treinishb86cda92013-07-29 11:22:23 -040094 return user
95
96 def _get_user(self, tenant, username):
97 if self.tempest_client:
David Kranze9d2f422014-07-02 13:57:41 -040098 _, user = self.identity_admin_client.get_user_by_username(
Miguel Lavalleb8fabc52013-08-23 11:19:57 -050099 tenant['id'],
100 username)
Matthew Treinishb86cda92013-07-29 11:22:23 -0400101 else:
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500102 user = self.identity_admin_client.users.get(username)
Matthew Treinishb86cda92013-07-29 11:22:23 -0400103 return user
104
105 def _list_roles(self):
106 if self.tempest_client:
David Kranze9d2f422014-07-02 13:57:41 -0400107 _, roles = self.identity_admin_client.list_roles()
Matthew Treinishb86cda92013-07-29 11:22:23 -0400108 else:
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500109 roles = self.identity_admin_client.roles.list()
Matthew Treinishb86cda92013-07-29 11:22:23 -0400110 return roles
111
Andrey Pavlovaf1fb702014-05-29 17:08:10 +0400112 def _assign_user_role(self, tenant, user, role_name):
113 role = None
114 try:
115 roles = self._list_roles()
116 if self.tempest_client:
117 role = next(r for r in roles if r['name'] == role_name)
118 else:
119 role = next(r for r in roles if r.name == role_name)
120 except StopIteration:
121 msg = 'No "%s" role found' % role_name
122 raise exceptions.NotFound(msg)
Matthew Treinishb86cda92013-07-29 11:22:23 -0400123 if self.tempest_client:
Andrey Pavlovaf1fb702014-05-29 17:08:10 +0400124 self.identity_admin_client.assign_user_role(tenant['id'],
125 user['id'], role['id'])
Matthew Treinishb86cda92013-07-29 11:22:23 -0400126 else:
Andrey Pavlovaf1fb702014-05-29 17:08:10 +0400127 self.identity_admin_client.roles.add_user_role(user.id, role.id,
128 tenant.id)
Matthew Treinishb86cda92013-07-29 11:22:23 -0400129
130 def _delete_user(self, user):
131 if self.tempest_client:
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500132 self.identity_admin_client.delete_user(user)
Matthew Treinishb86cda92013-07-29 11:22:23 -0400133 else:
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500134 self.identity_admin_client.users.delete(user)
Matthew Treinishb86cda92013-07-29 11:22:23 -0400135
136 def _delete_tenant(self, tenant):
Ala Rezmerita846eb7c2014-03-10 09:06:03 +0100137 if CONF.service_available.neutron:
138 self._cleanup_default_secgroup(tenant)
Matthew Treinishb86cda92013-07-29 11:22:23 -0400139 if self.tempest_client:
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500140 self.identity_admin_client.delete_tenant(tenant)
Matthew Treinishb86cda92013-07-29 11:22:23 -0400141 else:
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500142 self.identity_admin_client.tenants.delete(tenant)
Matthew Treinishb86cda92013-07-29 11:22:23 -0400143
Sean Dague6969b902014-01-28 06:48:37 -0500144 def _create_creds(self, suffix="", admin=False):
145 """Create random credentials under the following schema.
146
147 If the name contains a '.' is the full class path of something, and
148 we don't really care. If it isn't, it's probably a meaningful name,
149 so use it.
150
151 For logging purposes, -user and -tenant are long and redundant,
152 don't use them. The user# will be sufficient to figure it out.
153 """
154 if '.' in self.name:
155 root = ""
156 else:
157 root = self.name
158
159 tenant_name = data_utils.rand_name(root) + suffix
Matthew Treinishb86cda92013-07-29 11:22:23 -0400160 tenant_desc = tenant_name + "-desc"
Matthew Treinishb86cda92013-07-29 11:22:23 -0400161 tenant = self._create_tenant(name=tenant_name,
162 description=tenant_desc)
Sean Dague6969b902014-01-28 06:48:37 -0500163
164 username = data_utils.rand_name(root) + suffix
165 email = data_utils.rand_name(root) + suffix + "@example.com"
Matthew Treinishb86cda92013-07-29 11:22:23 -0400166 user = self._create_user(username, self.password,
167 tenant, email)
Sergey Shnaidman37099612014-07-10 09:43:41 +0400168 if CONF.service_available.swift:
169 # NOTE(andrey-mp): user needs this role to create containers
170 # in swift
171 swift_operator_role = CONF.object_storage.operator_role
172 self._assign_user_role(tenant, user, swift_operator_role)
Matthew Treinishb86cda92013-07-29 11:22:23 -0400173 if admin:
Andrey Pavlovaf1fb702014-05-29 17:08:10 +0400174 self._assign_user_role(tenant, user, CONF.identity.admin_role)
Andrea Frittoli9612e812014-03-13 10:57:26 +0000175 return self._get_credentials(user, tenant)
Matthew Treinishb86cda92013-07-29 11:22:23 -0400176
Andrea Frittolifc315902014-03-20 09:21:44 +0000177 def _get_credentials(self, user, tenant):
Matthew Treinishb86cda92013-07-29 11:22:23 -0400178 if self.tempest_client:
Andrea Frittolifc315902014-03-20 09:21:44 +0000179 user_get = user.get
180 tenant_get = tenant.get
Matthew Treinishb86cda92013-07-29 11:22:23 -0400181 else:
Andrea Frittolifc315902014-03-20 09:21:44 +0000182 user_get = user.__dict__.get
183 tenant_get = tenant.__dict__.get
184 return auth.get_credentials(
185 username=user_get('name'), user_id=user_get('id'),
186 tenant_name=tenant_get('name'), tenant_id=tenant_get('id'),
187 password=self.password)
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500188
189 def _create_network_resources(self, tenant_id):
190 network = None
191 subnet = None
192 router = None
Matthew Treinish9f756a02014-01-15 10:26:07 -0500193 # Make sure settings
194 if self.network_resources:
195 if self.network_resources['router']:
196 if (not self.network_resources['subnet'] or
197 not self.network_resources['network']):
198 raise exceptions.InvalidConfiguration(
199 'A router requires a subnet and network')
200 elif self.network_resources['subnet']:
201 if not self.network_resources['network']:
202 raise exceptions.InvalidConfiguration(
203 'A subnet requires a network')
204 elif self.network_resources['dhcp']:
205 raise exceptions.InvalidConfiguration('DHCP requires a subnet')
206
Masayuki Igawa259c1132013-10-31 17:48:44 +0900207 data_utils.rand_name_root = data_utils.rand_name(self.name)
Matthew Treinish9f756a02014-01-15 10:26:07 -0500208 if not self.network_resources or self.network_resources['network']:
209 network_name = data_utils.rand_name_root + "-network"
210 network = self._create_network(network_name, tenant_id)
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500211 try:
Matthew Treinish9f756a02014-01-15 10:26:07 -0500212 if not self.network_resources or self.network_resources['subnet']:
213 subnet_name = data_utils.rand_name_root + "-subnet"
214 subnet = self._create_subnet(subnet_name, tenant_id,
215 network['id'])
216 if not self.network_resources or self.network_resources['router']:
217 router_name = data_utils.rand_name_root + "-router"
218 router = self._create_router(router_name, tenant_id)
219 self._add_router_interface(router['id'], subnet['id'])
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500220 except Exception:
221 if router:
222 self._clear_isolated_router(router['id'], router['name'])
223 if subnet:
224 self._clear_isolated_subnet(subnet['id'], subnet['name'])
225 if network:
226 self._clear_isolated_network(network['id'], network['name'])
227 raise
228 return network, subnet, router
229
230 def _create_network(self, name, tenant_id):
231 if self.tempest_client:
232 resp, resp_body = self.network_admin_client.create_network(
Eugene Nikanorove9d255a2013-12-18 16:31:42 +0400233 name=name, tenant_id=tenant_id)
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500234 else:
235 body = {'network': {'tenant_id': tenant_id, 'name': name}}
236 resp_body = self.network_admin_client.create_network(body)
237 return resp_body['network']
238
239 def _create_subnet(self, subnet_name, tenant_id, network_id):
240 if not self.tempest_client:
241 body = {'subnet': {'name': subnet_name, 'tenant_id': tenant_id,
242 'network_id': network_id, 'ip_version': 4}}
Matthew Treinish9f756a02014-01-15 10:26:07 -0500243 if self.network_resources:
244 body['enable_dhcp'] = self.network_resources['dhcp']
Sean Dague86bd8422013-12-20 09:56:44 -0500245 base_cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr)
246 mask_bits = CONF.network.tenant_network_mask_bits
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500247 for subnet_cidr in base_cidr.subnet(mask_bits):
248 try:
249 if self.tempest_client:
Matthew Treinish9f756a02014-01-15 10:26:07 -0500250 if self.network_resources:
251 resp, resp_body = self.network_admin_client.\
252 create_subnet(
Eugene Nikanorove9d255a2013-12-18 16:31:42 +0400253 network_id=network_id, cidr=str(subnet_cidr),
Matthew Treinish9f756a02014-01-15 10:26:07 -0500254 name=subnet_name,
255 tenant_id=tenant_id,
Eugene Nikanorove9d255a2013-12-18 16:31:42 +0400256 enable_dhcp=self.network_resources['dhcp'],
257 ip_version=4)
Matthew Treinish9f756a02014-01-15 10:26:07 -0500258 else:
259 resp, resp_body = self.network_admin_client.\
Eugene Nikanorove9d255a2013-12-18 16:31:42 +0400260 create_subnet(network_id=network_id,
261 cidr=str(subnet_cidr),
Matthew Treinish9f756a02014-01-15 10:26:07 -0500262 name=subnet_name,
Eugene Nikanorove9d255a2013-12-18 16:31:42 +0400263 tenant_id=tenant_id,
264 ip_version=4)
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500265 else:
266 body['subnet']['cidr'] = str(subnet_cidr)
267 resp_body = self.network_admin_client.create_subnet(body)
268 break
Kevin Bentonc10a9cf2014-08-19 17:10:03 -0700269 except (n_exc.BadRequest, exceptions.BadRequest) as e:
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500270 if 'overlaps with another subnet' not in str(e):
271 raise
272 else:
273 e = exceptions.BuildErrorException()
274 e.message = 'Available CIDR for subnet creation could not be found'
275 raise e
276 return resp_body['subnet']
277
278 def _create_router(self, router_name, tenant_id):
279 external_net_id = dict(
Sean Dague86bd8422013-12-20 09:56:44 -0500280 network_id=CONF.network.public_network_id)
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500281 if self.tempest_client:
282 resp, resp_body = self.network_admin_client.create_router(
283 router_name,
284 external_gateway_info=external_net_id,
285 tenant_id=tenant_id)
286 else:
287 body = {'router': {'name': router_name, 'tenant_id': tenant_id,
288 'external_gateway_info': external_net_id,
289 'admin_state_up': True}}
290 resp_body = self.network_admin_client.create_router(body)
291 return resp_body['router']
292
293 def _add_router_interface(self, router_id, subnet_id):
294 if self.tempest_client:
295 self.network_admin_client.add_router_interface_with_subnet_id(
296 router_id, subnet_id)
297 else:
298 body = {'subnet_id': subnet_id}
299 self.network_admin_client.add_interface_router(router_id, body)
300
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500301 def get_primary_network(self):
302 return self.isolated_net_resources.get('primary')[0]
303
304 def get_primary_subnet(self):
305 return self.isolated_net_resources.get('primary')[1]
306
307 def get_primary_router(self):
308 return self.isolated_net_resources.get('primary')[2]
309
310 def get_admin_network(self):
311 return self.isolated_net_resources.get('admin')[0]
312
313 def get_admin_subnet(self):
314 return self.isolated_net_resources.get('admin')[1]
315
316 def get_admin_router(self):
317 return self.isolated_net_resources.get('admin')[2]
318
319 def get_alt_network(self):
320 return self.isolated_net_resources.get('alt')[0]
321
322 def get_alt_subnet(self):
323 return self.isolated_net_resources.get('alt')[1]
324
325 def get_alt_router(self):
326 return self.isolated_net_resources.get('alt')[2]
327
Andrea Frittoli9612e812014-03-13 10:57:26 +0000328 def get_credentials(self, credential_type):
Andrea Frittolifc315902014-03-20 09:21:44 +0000329 if self.isolated_creds.get(credential_type):
330 credentials = self.isolated_creds[credential_type]
Matthew Treinishb86cda92013-07-29 11:22:23 -0400331 else:
Andrea Frittolifc315902014-03-20 09:21:44 +0000332 is_admin = (credential_type == 'admin')
Andrea Frittoli9612e812014-03-13 10:57:26 +0000333 credentials = self._create_creds(admin=is_admin)
Andrea Frittolifc315902014-03-20 09:21:44 +0000334 self.isolated_creds[credential_type] = credentials
335 # Maintained until tests are ported
Andrea Frittolifc315902014-03-20 09:21:44 +0000336 LOG.info("Acquired isolated creds:\n credentials: %s"
337 % credentials)
Adam Gandelman85395e72014-07-29 18:34:33 -0700338 if (CONF.service_available.neutron and
339 not CONF.baremetal.driver_enabled):
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500340 network, subnet, router = self._create_network_resources(
Andrea Frittolifc315902014-03-20 09:21:44 +0000341 credentials.tenant_id)
342 self.isolated_net_resources[credential_type] = (
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500343 network, subnet, router,)
344 LOG.info("Created isolated network resources for : \n"
Andrea Frittolifc315902014-03-20 09:21:44 +0000345 + " credentials: %s" % credentials)
Andrea Frittoli9612e812014-03-13 10:57:26 +0000346 return credentials
Matthew Treinishb86cda92013-07-29 11:22:23 -0400347
Andrea Frittoli9612e812014-03-13 10:57:26 +0000348 def get_primary_creds(self):
349 return self.get_credentials('primary')
Matthew Treinishb86cda92013-07-29 11:22:23 -0400350
Andrea Frittoli9612e812014-03-13 10:57:26 +0000351 def get_admin_creds(self):
352 return self.get_credentials('admin')
Andrea Frittolifc315902014-03-20 09:21:44 +0000353
Andrea Frittoli9612e812014-03-13 10:57:26 +0000354 def get_alt_creds(self):
355 return self.get_credentials('alt')
Matthew Treinishb86cda92013-07-29 11:22:23 -0400356
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500357 def _clear_isolated_router(self, router_id, router_name):
358 net_client = self.network_admin_client
359 try:
360 net_client.delete_router(router_id)
361 except exceptions.NotFound:
362 LOG.warn('router with name: %s not found for delete' %
363 router_name)
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500364
365 def _clear_isolated_subnet(self, subnet_id, subnet_name):
366 net_client = self.network_admin_client
367 try:
368 net_client.delete_subnet(subnet_id)
369 except exceptions.NotFound:
370 LOG.warn('subnet with name: %s not found for delete' %
371 subnet_name)
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500372
373 def _clear_isolated_network(self, network_id, network_name):
374 net_client = self.network_admin_client
375 try:
376 net_client.delete_network(network_id)
377 except exceptions.NotFound:
378 LOG.warn('network with name: %s not found for delete' %
379 network_name)
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500380
Ala Rezmerita846eb7c2014-03-10 09:06:03 +0100381 def _cleanup_default_secgroup(self, tenant):
382 net_client = self.network_admin_client
383 if self.tempest_client:
384 resp, resp_body = net_client.list_security_groups(tenant_id=tenant,
385 name="default")
386 else:
387 resp_body = net_client.list_security_groups(tenant_id=tenant,
388 name="default")
389 secgroups_to_delete = resp_body['security_groups']
390 for secgroup in secgroups_to_delete:
391 try:
392 net_client.delete_security_group(secgroup['id'])
393 except exceptions.NotFound:
394 LOG.warn('Security group %s, id %s not found for clean-up' %
395 (secgroup['name'], secgroup['id']))
396
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500397 def _clear_isolated_net_resources(self):
398 net_client = self.network_admin_client
399 for cred in self.isolated_net_resources:
400 network, subnet, router = self.isolated_net_resources.get(cred)
Salvatore Orlandocf996c62014-01-30 09:15:18 -0800401 LOG.debug("Clearing network: %(network)s, "
402 "subnet: %(subnet)s, router: %(router)s",
403 {'network': network, 'subnet': subnet, 'router': router})
404 if (not self.network_resources or
405 self.network_resources.get('router')):
Matthew Treinish9f756a02014-01-15 10:26:07 -0500406 try:
407 if self.tempest_client:
408 net_client.remove_router_interface_with_subnet_id(
409 router['id'], subnet['id'])
410 else:
411 body = {'subnet_id': subnet['id']}
412 net_client.remove_interface_router(router['id'], body)
413 except exceptions.NotFound:
414 LOG.warn('router with name: %s not found for delete' %
415 router['name'])
Matthew Treinish9f756a02014-01-15 10:26:07 -0500416 self._clear_isolated_router(router['id'], router['name'])
Salvatore Orlandocf996c62014-01-30 09:15:18 -0800417 if (not self.network_resources or
Salvatore Orlandocf996c62014-01-30 09:15:18 -0800418 self.network_resources.get('subnet')):
Matthew Treinish9f756a02014-01-15 10:26:07 -0500419 self._clear_isolated_subnet(subnet['id'], subnet['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 self._clear_isolated_network(network['id'], network['name'])
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500423
Matthew Treinishb86cda92013-07-29 11:22:23 -0400424 def clear_isolated_creds(self):
425 if not self.isolated_creds:
426 return
Miguel Lavalleb8fabc52013-08-23 11:19:57 -0500427 self._clear_isolated_net_resources()
Andrea Frittolifc315902014-03-20 09:21:44 +0000428 for creds in self.isolated_creds.itervalues():
Matthew Treinishb86cda92013-07-29 11:22:23 -0400429 try:
Andrea Frittolifc315902014-03-20 09:21:44 +0000430 self._delete_user(creds.user_id)
Matthew Treinishb86cda92013-07-29 11:22:23 -0400431 except exceptions.NotFound:
Andrea Frittolifc315902014-03-20 09:21:44 +0000432 LOG.warn("user with name: %s not found for delete" %
433 creds.username)
Matthew Treinishb86cda92013-07-29 11:22:23 -0400434 try:
Andrea Frittolifc315902014-03-20 09:21:44 +0000435 self._delete_tenant(creds.tenant_id)
Matthew Treinishb86cda92013-07-29 11:22:23 -0400436 except exceptions.NotFound:
Andrea Frittolifc315902014-03-20 09:21:44 +0000437 LOG.warn("tenant with name: %s not found for delete" %
438 creds.tenant_name)