Add a module_utils OpenStack Cloud constructor (#20974)

Start using this to construct shade OpenStack Cloud objects in a
consistent manner. This will let us centralize things like dealing with
password arguments and whatnot. It also allows us to introduce the
ability to pass a fully formed config dict directly to the module.

Migrate all OpenStack modules to use openstack_cloud_from_module.

Have it return the shade library since it's responsible for
importing shade and shade is needed for the exceptions.

Only pull specific OpenStack arguments for the constructor

Rather than passing **module.params to the shade constructor, pull out
only the values that make sense. This should prevent the issues with
module parameters stepping on shade parameters.

Replace module.params.pop with module.params.get

We don't need to pop these anymore since the shade constructor is now
using opt-in values.

Using real urls is ungood. Use example.com domains. Also, get rid of the
antiquated port numbers.
This commit is contained in:
Monty Taylor 2018-02-15 08:20:49 -06:00 committed by Ricardo Carrillo Cruz
commit 0f893027c4
47 changed files with 270 additions and 673 deletions

View file

@ -23,9 +23,13 @@ class ModuleDocFragment(object):
options:
cloud:
description:
- Named cloud to operate against. Provides default values for I(auth) and
I(auth_type). This parameter is not needed if I(auth) is provided or if
OpenStack OS_* environment variables are present.
- Named cloud or cloud config to operate against.
If I(cloud) is a string, it references a named cloud config as defined
in an OpenStack clouds.yaml file. Provides default values for I(auth)
and I(auth_type). This parameter is not needed if I(auth) is provided
or if OpenStack OS_* environment variables are present.
If I(cloud) is a dict, it contains a complete cloud configuration like
would be in a section of clouds.yaml.
required: false
auth:
description:
@ -87,18 +91,14 @@ options:
- A path to a client key to use as part of the SSL transaction.
required: false
default: None
endpoint_type:
interface:
description:
- Endpoint URL type to fetch from the service catalog.
choices: [public, internal, admin]
required: false
default: public
identity_api_version:
description:
- The identity API version
choices: [2.0, 3]
required: false
default: None
aliases: ['endpoint_type']
version_added: "2.3"
requirements:
- python >= 2.7
- shade