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

@@ -51,13 +51,13 @@ options:
description:
- The availability zone of the resource.
requirements:
- "shade"
- "openstacksdk"
'''
EXAMPLES = '''
- name: "Enable access to tiny flavor to your tenant."
os_project_access:
os_project_Access:
cloud: mycloud
state: present
target_project_id: f0f1f2f3f4f5f67f8f9e0e1
@@ -66,7 +66,7 @@ EXAMPLES = '''
- name: "Disable access to the given flavor to project"
os_project_access:
os_project_Access:
cloud: mycloud
state: absent
target_project_id: f0f1f2f3f4f5f67f8f9e0e1
@@ -93,15 +93,8 @@ flavor:
'''
try:
import shade
HAS_SHADE = True
except ImportError:
HAS_SHADE = False
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.openstack import openstack_full_argument_spec, openstack_module_kwargs
from ansible.module_utils.openstack import openstack_full_argument_spec, openstack_module_kwargs, openstack_cloud_from_module
def main():
@@ -123,8 +116,7 @@ def main():
],
**module_kwargs)
if not HAS_SHADE:
module.fail_json(msg='shade is required for this module')
sdk, cloud = openstack_cloud_from_module(module)
changed = False
state = module.params['state']
@@ -133,8 +125,6 @@ def main():
target_project_id = module.params['target_project_id']
try:
cloud = shade.operator_cloud(**module.params)
if resource_type == 'nova_flavor':
# returns Munch({'NAME_ATTR': 'name',
# 'tenant_id': u'37e55da59ec842649d84230f3a24eed5',
@@ -201,7 +191,7 @@ def main():
resource=resource,
id=resource_id)
except shade.OpenStackCloudException as e:
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e), **module.params)