Add ability to configure extra_specs to be off

We fetch flavor extra_specs for each flavor for consistency with old
behavior. However, it's costly and often just simply not needed.

Query clouds.yaml for extra client settings and if "get_flavor_extra_specs" is
set to false, set the default for list_flavors to false.

Change-Id: Iaea1c41e8e0ae504cb080d7d37407de12be96fd1
This commit is contained in:
Monty Taylor 2017-04-02 15:53:06 -05:00
parent cf54ef6b92
commit aa58173f0d
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594
2 changed files with 17 additions and 1 deletions

View File

@ -0,0 +1,4 @@
---
features:
- Adds ability to add a config setting to clouds.yaml to
disable fetching extra_specs from flavors.

View File

@ -149,6 +149,12 @@ class OpenStackCloud(_normalize.Normalizer):
self.secgroup_source = cloud_config.config['secgroup_source']
self.force_ipv4 = cloud_config.force_ipv4
self.strict_mode = strict
# TODO(mordred) When os-client-config adds a "get_client_settings()"
# method to CloudConfig - remove this.
self._extra_config = cloud_config._openstack_config.get_extra_config(
'shade', {
'get_flavor_extra_specs': True,
})
if manager is not None:
self.manager = manager
@ -1757,12 +1763,18 @@ class OpenStackCloud(_normalize.Normalizer):
return ret
@_utils.cache_on_arguments()
def list_flavors(self, get_extra=True):
def list_flavors(self, get_extra=None):
"""List all available flavors.
:param get_extra: Whether or not to fetch extra specs for each flavor.
Defaults to True. Default behavior value can be
overridden in clouds.yaml by setting
shade.get_extra_specs to False.
:returns: A list of flavor ``munch.Munch``.
"""
if get_extra is None:
get_extra = self._extra_config['get_flavor_extra_specs']
with _utils.shade_exceptions("Error fetching flavor list"):
flavors = self._normalize_flavors(
self._compute_client.get(