retire shade in favor of openstacksdk for openstack modules (#40532)

* Establish connection through openstacksdk
* Switch from shade to openstacksdk
* fix typo in link to openstacksdk
* remove nova_client usage
* further remove of min_version from openstack modules
This commit is contained in:
Artem Goncharov
2018-05-26 03:40:39 +02:00
committed by Monty Taylor
parent e16490c9c0
commit 89ce826a9f
51 changed files with 266 additions and 321 deletions

View File

@@ -60,7 +60,7 @@ options:
version_added: "2.4"
requirements:
- "python >= 2.6"
- "shade"
- "openstacksdk"
'''
EXAMPLES = '''
@@ -117,14 +117,14 @@ def _present_volume(module, cloud):
module.exit_json(changed=True, id=volume['id'], volume=volume)
def _absent_volume(module, cloud, shade):
def _absent_volume(module, cloud, sdk):
changed = False
if cloud.volume_exists(module.params['display_name']):
try:
changed = cloud.delete_volume(name_or_id=module.params['display_name'],
wait=module.params['wait'],
timeout=module.params['timeout'])
except shade.OpenStackCloudTimeout:
except sdk.exceptions.OpenStackCloudTimeout:
module.exit_json(changed=changed)
module.exit_json(changed=changed)
@@ -149,23 +149,18 @@ def main():
)
module = AnsibleModule(argument_spec=argument_spec, **module_kwargs)
if (module.params['scheduler_hints'] and
StrictVersion(shade.__version__) < StrictVersion('1.22')):
module.fail_json(msg="To utilize scheduler_hints, the installed version of"
"the shade library MUST be >= 1.22")
state = module.params['state']
if state == 'present' and not module.params['size']:
module.fail_json(msg="Size is required when state is 'present'")
shade, cloud = openstack_cloud_from_module(module)
sdk, cloud = openstack_cloud_from_module(module)
try:
if state == 'present':
_present_volume(module, cloud)
if state == 'absent':
_absent_volume(module, cloud, shade)
except shade.OpenStackCloudException as e:
_absent_volume(module, cloud, sdk)
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e))