Merge "Improve logging in fixed_networks"
diff --git a/tempest/common/fixed_network.py b/tempest/common/fixed_network.py
index 67fbab1..b2d7c0b 100644
--- a/tempest/common/fixed_network.py
+++ b/tempest/common/fixed_network.py
@@ -13,6 +13,7 @@
import copy
from oslo_log import log as logging
+from tempest_lib.common.utils import misc as misc_utils
from tempest_lib import exceptions as lib_exc
from tempest.common import isolated_creds
@@ -35,6 +36,7 @@
is the network to be used, and it's not visible to the tenant
:return a dict with 'id' and 'name' of the network
"""
+ caller = misc_utils.find_test_caller()
fixed_network_name = CONF.compute.fixed_network_name
network = None
# NOTE(andreaf) get_primary_network will always be available once
@@ -46,6 +48,12 @@
network = creds_provider.get_primary_creds().network
else:
if fixed_network_name:
+ msg = ('No valid network provided or created, defaulting to '
+ 'fixed_network_name')
+ if caller:
+ LOG.debug('(%s) %s' % (caller, msg))
+ else:
+ LOG.debug(msg)
try:
resp = compute_networks_client.list_networks(
name=fixed_network_name)
@@ -59,19 +67,33 @@
network = networks[0]
else:
msg = "Configured fixed_network_name not found"
+ if caller:
+ msg = '(%s) %s' % (caller, msg)
raise exceptions.InvalidConfiguration(msg)
# To be consistent with network isolation, add name is only
# label is available
- network['name'] = network.get('name', network.get('label'))
+ name = network.get('name', network.get('label'))
+ if name:
+ network['name'] = name
+ else:
+ raise lib_exc.NotFound()
except lib_exc.NotFound:
# In case of nova network, if the fixed_network_name is not
# owned by the tenant, and the network client is not an admin
# one, list_networks will not find it
- LOG.info('Unable to find network %s. '
- 'Starting instance without specifying a network.' %
- fixed_network_name)
+ msg = ('Unable to find network %s. '
+ 'Starting instance without specifying a network.' %
+ fixed_network_name)
+ if caller:
+ LOG.info('(%s) %s' % (caller, msg))
+ else:
+ LOG.info(msg)
network = {'name': fixed_network_name}
- LOG.info('Found network %s available for tenant' % network)
+ msg = ('Found network %s available for tenant' % network)
+ if caller:
+ LOG.info('(%s) %s' % (caller, msg))
+ else:
+ LOG.info(msg)
return network
@@ -87,5 +109,9 @@
return params
if network:
- params.update({"networks": [{'uuid': network['id']}]})
+ if 'id' in network.keys():
+ params.update({"networks": [{'uuid': network['id']}]})
+ else:
+ LOG.warn('The provided network dict: %s was invalid and did not '
+ ' contain an id' % network)
return params