Handle out-of-tree openstack module_utils
ansible.module_utils.openstack will exist during ansible runtime due to ansible's runtime package renaming of module_utils. However with ansible-2.10 the openstack collection[1] is no longer in the ansible tree, so the unit tests will fail due to the missing package. This change works around this by handling import failure and adding a check in main() to fail if the openstack module_utils is not available. The unit tests deliberately don't test main() to avoid dealing with ansible internals. NOTE: Also explicitly enables the iscsi deployment interface as it has been deprecated and is no longer enabled by default. [1] https://opendev.org/openstack/ansible-collections-openstack Change-Id: I2d03696d673e74f0d4e6609532a8add1c0725f91
This commit is contained in:
parent
7aaa604749
commit
4de7115247
|
@ -147,6 +147,7 @@
|
|||
vars:
|
||||
devstack_localrc:
|
||||
IRONIC_DEFAULT_DEPLOY_INTERFACE: iscsi
|
||||
IRONIC_ENABLED_DEPLOY_INTERFACES: "iscsi,direct,fake"
|
||||
metalsmith_netboot: true
|
||||
metalsmith_precreate_port: true
|
||||
|
||||
|
|
|
@ -18,9 +18,14 @@ import io
|
|||
import logging
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.openstack import openstack_cloud_from_module
|
||||
from ansible.module_utils.openstack import openstack_full_argument_spec
|
||||
from ansible.module_utils.openstack import openstack_module_kwargs
|
||||
try:
|
||||
from ansible.module_utils.openstack import openstack_cloud_from_module
|
||||
from ansible.module_utils.openstack import openstack_full_argument_spec
|
||||
from ansible.module_utils.openstack import openstack_module_kwargs
|
||||
except ImportError:
|
||||
openstack_cloud_from_module = None
|
||||
openstack_full_argument_spec = None
|
||||
openstack_module_kwargs = None
|
||||
|
||||
import metalsmith
|
||||
from metalsmith import instance_config
|
||||
|
@ -364,6 +369,10 @@ def _configure_logging(log_level):
|
|||
|
||||
|
||||
def main():
|
||||
if not openstack_full_argument_spec:
|
||||
raise RuntimeError(
|
||||
'This module requires ansible-collections-openstack')
|
||||
|
||||
argument_spec = openstack_full_argument_spec(
|
||||
**yaml.safe_load(DOCUMENTATION)['options']
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue