1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix os_quota to not break when volumev2 service is not available.

os_quota checks the current quotas for compute, network and volume
services and fails when no volume service is found in the catalog.

Since openstack test deployments without volume services are common
os_quota shouldn't fail if such service is missing.

Fixes #23085

Signed-off-by: Alberto Murillo Silva <alberto.murillo.silva@intel.com>
This commit is contained in:
Alberto Murillo Silva 2017-05-03 14:43:27 -05:00 committed by Brian Coca
parent 136a6eec9e
commit d31a09ceb7

View file

@ -290,6 +290,7 @@ import sys
try: try:
import shade import shade
from keystoneauth1 import exceptions
HAS_SHADE = True HAS_SHADE = True
except ImportError: except ImportError:
HAS_SHADE = False HAS_SHADE = False
@ -307,11 +308,19 @@ def _get_compute_quotas(cloud, project):
return cloud.get_compute_quotas(project) return cloud.get_compute_quotas(project)
def _get_quotas(cloud, project): def _get_quotas(module, cloud, project):
quota = {} quota = {}
try:
quota['volume'] = _get_volume_quotas(cloud, project) quota['volume'] = _get_volume_quotas(cloud, project)
except exceptions.EndpointNotFound:
module.warn("No public endpoint for volumev2 service was found. Ignoring volume quotas.")
try:
quota['network'] = _get_network_quotas(cloud, project) quota['network'] = _get_network_quotas(cloud, project)
except exceptions.EndpointNotFound:
module.warn("No public endpoint for network service was found. Ignoring network quotas.")
quota['compute'] = _get_compute_quotas(cloud, project) quota['compute'] = _get_compute_quotas(cloud, project)
for quota_type in quota.keys(): for quota_type in quota.keys():
@ -432,7 +441,7 @@ def main():
module.params[k] = int(v) module.params[k] = int(v)
#Get current quota values #Get current quota values
project_quota_output = _get_quotas(cloud, cloud_params['name']) project_quota_output = _get_quotas(module, cloud, cloud_params['name'])
changes_required = False changes_required = False
if module.params['state'] == "absent": if module.params['state'] == "absent":
@ -461,7 +470,7 @@ def main():
else: else:
module.fail_json(msg=str(e), extra_data=e.extra_data) module.fail_json(msg=str(e), extra_data=e.extra_data)
project_quota_output = _get_quotas(cloud, cloud_params['name']) project_quota_output = _get_quotas(module, cloud, cloud_params['name'])
changes_required = True changes_required = True
@ -480,7 +489,7 @@ def main():
quota_call(cloud_params['name'], **quota_change_request[quota_type]) quota_call(cloud_params['name'], **quota_change_request[quota_type])
#Get quota state post changes for validation #Get quota state post changes for validation
project_quota_update = _get_quotas(cloud, cloud_params['name']) project_quota_update = _get_quotas(module, cloud, cloud_params['name'])
if project_quota_output == project_quota_update: if project_quota_output == project_quota_update:
module.fail_json(msg='Could not apply quota update') module.fail_json(msg='Could not apply quota update')