mirror of
https://opendev.org/openstack/ansible-collections-openstack.git
synced 2026-04-10 02:40:58 +00:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
030df96dc0 | ||
|
|
0cff7eb3a2 | ||
|
|
29e3f3dac8 | ||
|
|
d18ea87091 | ||
|
|
529c1e8dcc | ||
|
|
99b7af529c | ||
|
|
2ed3ffe1d0 | ||
|
|
ae5dbf0fc0 | ||
|
|
4074db1bd0 | ||
|
|
3248ba9960 | ||
|
|
2d5ca42629 |
56
.zuul.yaml
56
.zuul.yaml
@@ -164,17 +164,17 @@
|
|||||||
tox_install_siblings: false
|
tox_install_siblings: false
|
||||||
|
|
||||||
- job:
|
- job:
|
||||||
name: ansible-collections-openstack-functional-devstack-ansible-2.12
|
name: ansible-collections-openstack-functional-devstack-ansible-2.18
|
||||||
parent: ansible-collections-openstack-functional-devstack-base
|
parent: ansible-collections-openstack-functional-devstack-base
|
||||||
branches: master
|
branches: master
|
||||||
description: |
|
description: |
|
||||||
Run openstack collections functional tests against a master devstack
|
Run openstack collections functional tests against a master devstack
|
||||||
using master of openstacksdk and stable 2.12 branch of ansible
|
using master of openstacksdk and stable 2.16 branch of ansible
|
||||||
required-projects:
|
required-projects:
|
||||||
- name: github.com/ansible/ansible
|
- name: github.com/ansible/ansible
|
||||||
override-checkout: stable-2.12
|
override-checkout: stable-2.18
|
||||||
vars:
|
vars:
|
||||||
tox_envlist: ansible_2_12
|
tox_envlist: ansible_2_18
|
||||||
|
|
||||||
- job:
|
- job:
|
||||||
name: ansible-collections-openstack-functional-devstack-ansible-devel
|
name: ansible-collections-openstack-functional-devstack-ansible-devel
|
||||||
@@ -218,19 +218,17 @@
|
|||||||
bindep_profile: test py310
|
bindep_profile: test py310
|
||||||
|
|
||||||
- job:
|
- job:
|
||||||
name: openstack-tox-linters-ansible-2.12
|
name: openstack-tox-linters-ansible-2.18
|
||||||
parent: openstack-tox-linters-ansible
|
parent: openstack-tox-linters-ansible
|
||||||
nodeset: ubuntu-focal
|
|
||||||
description: |
|
description: |
|
||||||
Run openstack collections linter tests using the 2.12 branch of ansible
|
Run openstack collections linter tests using the 2.18 branch of ansible
|
||||||
required-projects:
|
required-projects:
|
||||||
- name: github.com/ansible/ansible
|
- name: github.com/ansible/ansible
|
||||||
override-checkout: stable-2.12
|
override-checkout: stable-2.18
|
||||||
vars:
|
vars:
|
||||||
ensure_tox_version: '<4'
|
tox_envlist: linters_2_18
|
||||||
tox_envlist: linters_2_12
|
python_version: "3.12"
|
||||||
python_version: 3.8
|
bindep_profile: test py312
|
||||||
bindep_profile: test py38
|
|
||||||
|
|
||||||
# Cross-checks with other projects
|
# Cross-checks with other projects
|
||||||
- job:
|
- job:
|
||||||
@@ -258,7 +256,7 @@
|
|||||||
|
|
||||||
- job:
|
- job:
|
||||||
name: ansible-collections-openstack-release
|
name: ansible-collections-openstack-release
|
||||||
parent: base
|
parent: openstack-tox-linters-ansible
|
||||||
run: ci/publish/publish_collection.yml
|
run: ci/publish/publish_collection.yml
|
||||||
secrets:
|
secrets:
|
||||||
- ansible_galaxy_info
|
- ansible_galaxy_info
|
||||||
@@ -268,26 +266,26 @@
|
|||||||
data:
|
data:
|
||||||
url: https://galaxy.ansible.com
|
url: https://galaxy.ansible.com
|
||||||
token: !encrypted/pkcs1-oaep
|
token: !encrypted/pkcs1-oaep
|
||||||
- lZFzfoCbuwqV1k6qRfl/VS7E+knUW7+zpg7BptrenK4n0g7UY0HtdVkYq0pV0Tj/LbhzG
|
- QJ3c5LfmM4YmqwwLKv4wK5lroWDLGeMyPkmHXhvf0ry3vGjKZvZxVpbIhFXJHXevHov/r
|
||||||
jHD0mehcV1iS6B7ORKg4criJkdDfEx09BD8z8yv0EleiIMmhlrCoMcY593OZMBtVbGi0D
|
nvlqwmG8D5msynQKZDFg2ZwSMIQWRKfSbsSLe7A6NWI2wC+QtZSPiRiBcBcHY1QbNNW21
|
||||||
CwQtNO98QIsfZogChfLfvRNiBmUV98mEb/p6p3EtGx8J7qcAsqfWxc/CzB8GCleLAHHHT
|
84cssYa1oHOA0WXpomBz1qXuPV48aKLjMnWysgFhNSx3Oog+ZOSCczyyVVuXP1lIWIO26
|
||||||
FuikMM03ZnV0ew7E+TPkHbzzPhBZOqS5HYF0HtgttHwIXdfIWp/XdTuEEk7uRRgYZ2Iao
|
AtRTrEcr37K3JY9usE2PCbZKFOq/+IDPz9fbS7PtBOv7iXOHOf3AfBiJiaJe3q/ecoaaq
|
||||||
ifWRzoKaOQmhM++e1ydCqw9D4y9dZEFNMQLwSqcrvtb8cNwT1kl7SCFqYNE2lbutj4ne6
|
ejk2WTKWfvq/3rY4pU1976kUcxgcd+jj9ReFyw8edCsc1ecL0qmZFbdHmC03jEcVo4p8I
|
||||||
PTBQRsKegMB4Y3ena14fNF6tCynvJLPhF/cjPH2Jhs+B19XQhWkL3TgiOY02W24YHwRcP
|
WJQ0D5wk4/u2Fu9texNuBvb62Yu3Y028Zhm5rz8Zl/ISsdaA3losn5S7C7iAH/yKlGQEI
|
||||||
+LdkM8inAvyVi3DEbEqdjBPO9OFJcBOKPlCdkGvuwdNCuEpEwctWs0gV3voflG2CDKzmJ
|
N/1X4M0tVPaMtsIhZyyz+JMbeNyVR9ZarqbtpzRtVhjxL7KOiAQbEzAmZcBbCJ2Z5iI+P
|
||||||
wu9JJOAWnq/0l1WpuDqWreKeQ/BUGZC2Gb4xRAqofulgvhs4WuYoEccjH4EJFIZ90S1EP
|
bTp03f9Y/tZNtkohARvx1TKhv8CvsmyGkMm+r5Y8aWz3SNy8LL6bSwtGun/ifbnadHmw/
|
||||||
R/ZLadqZaEhmjwGM5sMWbBbjT23XsRgg0Tzt9m8DENYMuYDqkMdRbt2jYZa+32p4hyxVe
|
TD5/UUXHHjBGkeAu9HTtwUZ5Qdkfg92PnPgruAAuOkF1Y4RyRS9qvwhtqyHO8TwU0INRY
|
||||||
Y6H/pqYq5b9uOzumnShaK4WlmkQyXcNPkoSlMC1h4OGvqX/WUixpI38jyMA5Tc=
|
5MHEzeOQWemoQb/qdENp+J/Q9oMEbpFYv9TkrWkxVoKop6Str8e3FF5sxmN/SE=
|
||||||
|
|
||||||
- project:
|
- project:
|
||||||
check:
|
check:
|
||||||
jobs:
|
jobs:
|
||||||
- tox-pep8
|
- tox-pep8
|
||||||
- openstack-tox-linters-ansible-devel
|
- openstack-tox-linters-ansible-devel
|
||||||
- openstack-tox-linters-ansible-2.12
|
- openstack-tox-linters-ansible-2.18
|
||||||
- ansible-collections-openstack-functional-devstack
|
- ansible-collections-openstack-functional-devstack
|
||||||
- ansible-collections-openstack-functional-devstack-releases
|
- ansible-collections-openstack-functional-devstack-releases
|
||||||
- ansible-collections-openstack-functional-devstack-ansible-2.12
|
- ansible-collections-openstack-functional-devstack-ansible-2.18
|
||||||
- ansible-collections-openstack-functional-devstack-ansible-devel
|
- ansible-collections-openstack-functional-devstack-ansible-devel
|
||||||
- ansible-collections-openstack-functional-devstack-magnum
|
- ansible-collections-openstack-functional-devstack-magnum
|
||||||
- ansible-collections-openstack-functional-devstack-octavia
|
- ansible-collections-openstack-functional-devstack-octavia
|
||||||
@@ -302,20 +300,18 @@
|
|||||||
gate:
|
gate:
|
||||||
jobs:
|
jobs:
|
||||||
- tox-pep8
|
- tox-pep8
|
||||||
- openstack-tox-linters-ansible-2.12
|
- openstack-tox-linters-ansible-2.18
|
||||||
# - ansible-collections-openstack-functional-devstack
|
|
||||||
- ansible-collections-openstack-functional-devstack-releases
|
- ansible-collections-openstack-functional-devstack-releases
|
||||||
# - ansible-collections-openstack-functional-devstack-ansible-2.12
|
|
||||||
- ansible-collections-openstack-functional-devstack-magnum
|
- ansible-collections-openstack-functional-devstack-magnum
|
||||||
- ansible-collections-openstack-functional-devstack-octavia
|
- ansible-collections-openstack-functional-devstack-octavia
|
||||||
|
|
||||||
periodic:
|
periodic:
|
||||||
jobs:
|
jobs:
|
||||||
- openstack-tox-linters-ansible-devel
|
- openstack-tox-linters-ansible-devel
|
||||||
- openstack-tox-linters-ansible-2.12
|
- openstack-tox-linters-ansible-2.18
|
||||||
- ansible-collections-openstack-functional-devstack
|
- ansible-collections-openstack-functional-devstack
|
||||||
- ansible-collections-openstack-functional-devstack-releases
|
- ansible-collections-openstack-functional-devstack-releases
|
||||||
- ansible-collections-openstack-functional-devstack-ansible-2.12
|
- ansible-collections-openstack-functional-devstack-ansible-2.18
|
||||||
- ansible-collections-openstack-functional-devstack-ansible-devel
|
- ansible-collections-openstack-functional-devstack-ansible-devel
|
||||||
- bifrost-collections-src
|
- bifrost-collections-src
|
||||||
- bifrost-keystone-collections-src
|
- bifrost-keystone-collections-src
|
||||||
|
|||||||
@@ -5,6 +5,37 @@ Ansible OpenStack Collection Release Notes
|
|||||||
.. contents:: Topics
|
.. contents:: Topics
|
||||||
|
|
||||||
|
|
||||||
|
v2.3.2
|
||||||
|
======
|
||||||
|
|
||||||
|
Release Summary
|
||||||
|
---------------
|
||||||
|
|
||||||
|
Bugfixes and minor changes
|
||||||
|
|
||||||
|
Minor Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- Drop compat implementations for tests
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
--------
|
||||||
|
|
||||||
|
- Fix openstack.cloud.port module failure in check mode
|
||||||
|
|
||||||
|
v2.3.1
|
||||||
|
======
|
||||||
|
|
||||||
|
Release Summary
|
||||||
|
---------------
|
||||||
|
|
||||||
|
Client TLS certificate support
|
||||||
|
|
||||||
|
Minor Changes
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- Add ability to pass client tls certificate
|
||||||
|
|
||||||
v2.3.0
|
v2.3.0
|
||||||
======
|
======
|
||||||
|
|
||||||
|
|||||||
@@ -572,3 +572,17 @@ releases:
|
|||||||
name: volume_service_info
|
name: volume_service_info
|
||||||
namespace: ''
|
namespace: ''
|
||||||
release_date: '2024-11-28'
|
release_date: '2024-11-28'
|
||||||
|
2.3.1:
|
||||||
|
changes:
|
||||||
|
minor_changes:
|
||||||
|
- Add ability to pass client tls certificate
|
||||||
|
release_summary: Client TLS certificate support
|
||||||
|
release_date: '2024-12-18'
|
||||||
|
2.3.2:
|
||||||
|
changes:
|
||||||
|
bugfixes:
|
||||||
|
- Fix openstack.cloud.port module failure in check mode
|
||||||
|
minor_changes:
|
||||||
|
- Drop compat implementations for tests
|
||||||
|
release_summary: Bugfixes and minor changes
|
||||||
|
release_date: '2024-12-20'
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
---
|
|
||||||
|
|
||||||
bugfixes:
|
|
||||||
- |
|
|
||||||
coe_cluster_template - now labels are converted to strings by module that
|
|
||||||
fixes module idempotence in case label values defined by users are
|
|
||||||
integers or booleans.
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
---
|
|
||||||
|
|
||||||
minor_changes:
|
|
||||||
- |
|
|
||||||
openstack.cloud.image - Added new `inactive` option for the image `state`
|
|
||||||
It will deactivate the image. Setting state `present` can re-activate it
|
|
||||||
again for deactivated previously images.
|
|
||||||
@@ -3,7 +3,8 @@
|
|||||||
vars:
|
vars:
|
||||||
collection_path: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}"
|
collection_path: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}"
|
||||||
build_collection_path: /tmp/collection_built/
|
build_collection_path: /tmp/collection_built/
|
||||||
ansible_galaxy_path: "~/.local/bin/ansible-galaxy"
|
ansible_virtualenv_path: /tmp/ansible_venv
|
||||||
|
ansible_galaxy_path: "{{ ansible_virtualenv_path }}/bin/ansible-galaxy"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
|
|
||||||
@@ -11,9 +12,15 @@
|
|||||||
include_role:
|
include_role:
|
||||||
name: ensure-pip
|
name: ensure-pip
|
||||||
|
|
||||||
- name: Install ansible
|
- name: Install Ansible in virtualenv
|
||||||
pip:
|
pip:
|
||||||
name: ansible-core<2.12
|
name: ansible-core<2.19
|
||||||
|
virtualenv: "{{ ansible_virtualenv_path }}"
|
||||||
|
virtualenv_command: "{{ ensure_pip_virtualenv_command }}"
|
||||||
|
|
||||||
|
- name: Detect ansible version
|
||||||
|
command: "{{ ansible_virtualenv_path }}/bin/ansible --version"
|
||||||
|
register: ansible_version
|
||||||
|
|
||||||
- name: Discover tag version
|
- name: Discover tag version
|
||||||
set_fact:
|
set_fact:
|
||||||
|
|||||||
@@ -460,20 +460,14 @@
|
|||||||
register: server
|
register: server
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- name: Assert shelve offload server
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- ((server is success)
|
|
||||||
or (server is not success
|
|
||||||
and "Cannot 'shelveOffload' instance" in server.msg
|
|
||||||
and ("while it is in vm_state shelved_offloaded" in server.msg
|
|
||||||
or "while it is in task_state shelving_offloading" in server.msg )))
|
|
||||||
|
|
||||||
- name: Get info about server
|
- name: Get info about server
|
||||||
openstack.cloud.server_info:
|
openstack.cloud.server_info:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
server: ansible_server
|
server: ansible_server
|
||||||
register: servers
|
register: servers
|
||||||
|
until: servers.servers.0.task_state == none
|
||||||
|
retries: 30
|
||||||
|
delay: 10
|
||||||
|
|
||||||
- name: Ensure status for server is SHELVED_OFFLOADED
|
- name: Ensure status for server is SHELVED_OFFLOADED
|
||||||
# no change if server has been offloaded automatically after first shelve command
|
# no change if server has been offloaded automatically after first shelve command
|
||||||
|
|||||||
@@ -32,4 +32,4 @@ build_ignore:
|
|||||||
- .vscode
|
- .vscode
|
||||||
- ansible_collections_openstack.egg-info
|
- ansible_collections_openstack.egg-info
|
||||||
- changelogs
|
- changelogs
|
||||||
version: 2.3.0
|
version: 2.3.2
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ def openstack_cloud_from_module(module, min_version=None, max_version=None):
|
|||||||
" excluded.")
|
" excluded.")
|
||||||
for param in (
|
for param in (
|
||||||
'auth', 'region_name', 'validate_certs',
|
'auth', 'region_name', 'validate_certs',
|
||||||
'ca_cert', 'client_key', 'api_timeout', 'auth_type'):
|
'ca_cert', 'client_cert', 'client_key', 'api_timeout', 'auth_type'):
|
||||||
if module.params[param] is not None:
|
if module.params[param] is not None:
|
||||||
module.fail_json(msg=fail_message.format(param=param))
|
module.fail_json(msg=fail_message.format(param=param))
|
||||||
# For 'interface' parameter, fail if we receive a non-default value
|
# For 'interface' parameter, fail if we receive a non-default value
|
||||||
@@ -199,6 +199,7 @@ def openstack_cloud_from_module(module, min_version=None, max_version=None):
|
|||||||
verify=module.params['validate_certs'],
|
verify=module.params['validate_certs'],
|
||||||
cacert=module.params['ca_cert'],
|
cacert=module.params['ca_cert'],
|
||||||
key=module.params['client_key'],
|
key=module.params['client_key'],
|
||||||
|
cert=module.params['client_cert'],
|
||||||
api_timeout=module.params['api_timeout'],
|
api_timeout=module.params['api_timeout'],
|
||||||
interface=module.params['interface'],
|
interface=module.params['interface'],
|
||||||
)
|
)
|
||||||
@@ -358,7 +359,7 @@ class OpenStackModule:
|
|||||||
" excluded.")
|
" excluded.")
|
||||||
for param in (
|
for param in (
|
||||||
'auth', 'region_name', 'validate_certs',
|
'auth', 'region_name', 'validate_certs',
|
||||||
'ca_cert', 'client_key', 'api_timeout', 'auth_type'):
|
'ca_cert', 'client_cert', 'client_key', 'api_timeout', 'auth_type'):
|
||||||
if self.params[param] is not None:
|
if self.params[param] is not None:
|
||||||
self.fail_json(msg=fail_message.format(param=param))
|
self.fail_json(msg=fail_message.format(param=param))
|
||||||
# For 'interface' parameter, fail if we receive a non-default value
|
# For 'interface' parameter, fail if we receive a non-default value
|
||||||
|
|||||||
@@ -511,7 +511,7 @@ class PortModule(OpenStackModule):
|
|||||||
**(dict(network_id=network.id) if network else dict()))
|
**(dict(network_id=network.id) if network else dict()))
|
||||||
|
|
||||||
if self.ansible.check_mode:
|
if self.ansible.check_mode:
|
||||||
self.exit_json(changed=self._will_change(network, port, state))
|
self.exit_json(changed=self._will_change(port, state))
|
||||||
|
|
||||||
if state == 'present' and not port:
|
if state == 'present' and not port:
|
||||||
# create port
|
# create port
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -4,6 +4,6 @@
|
|||||||
import setuptools
|
import setuptools
|
||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
setup_requires=['pbr'],
|
setup_requires=['pbr', 'setuptools'],
|
||||||
pbr=True,
|
pbr=True,
|
||||||
py_modules=[])
|
py_modules=[])
|
||||||
|
|||||||
12
tests/requirements-ansible-2.16.txt
Normal file
12
tests/requirements-ansible-2.16.txt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
ansible-core>=2.16.0,<2.17.0
|
||||||
|
flake8
|
||||||
|
galaxy-importer
|
||||||
|
openstacksdk
|
||||||
|
pycodestyle
|
||||||
|
pylint
|
||||||
|
rstcheck
|
||||||
|
ruamel.yaml
|
||||||
|
tox
|
||||||
|
voluptuous
|
||||||
|
yamllint
|
||||||
|
setuptools
|
||||||
12
tests/requirements-ansible-2.18.txt
Normal file
12
tests/requirements-ansible-2.18.txt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
ansible-core>=2.18.0,<2.19.0
|
||||||
|
flake8
|
||||||
|
galaxy-importer
|
||||||
|
openstacksdk
|
||||||
|
pycodestyle
|
||||||
|
pylint
|
||||||
|
rstcheck
|
||||||
|
ruamel.yaml
|
||||||
|
tox
|
||||||
|
voluptuous
|
||||||
|
yamllint
|
||||||
|
setuptools
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com>
|
|
||||||
#
|
|
||||||
# This file is part of Ansible
|
|
||||||
#
|
|
||||||
# Ansible is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# Ansible is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
# Make coding more python3-ish
|
|
||||||
|
|
||||||
#
|
|
||||||
# Compat for python2.7
|
|
||||||
#
|
|
||||||
|
|
||||||
# One unittest needs to import builtins via __import__() so we need to have
|
|
||||||
# the string that represents it
|
|
||||||
try:
|
|
||||||
import __builtin__ # noqa
|
|
||||||
except ImportError:
|
|
||||||
BUILTINS = 'builtins'
|
|
||||||
else:
|
|
||||||
BUILTINS = '__builtin__'
|
|
||||||
@@ -1,120 +0,0 @@
|
|||||||
# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com>
|
|
||||||
#
|
|
||||||
# This file is part of Ansible
|
|
||||||
#
|
|
||||||
# Ansible is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# Ansible is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
# Make coding more python3-ish
|
|
||||||
|
|
||||||
'''
|
|
||||||
Compat module for Python3.x's unittest.mock module
|
|
||||||
'''
|
|
||||||
import sys
|
|
||||||
|
|
||||||
# Python 2.7
|
|
||||||
|
|
||||||
# Note: Could use the pypi mock library on python3.x as well as python2.x. It
|
|
||||||
# is the same as the python3 stdlib mock library
|
|
||||||
|
|
||||||
try:
|
|
||||||
# Allow wildcard import because we really do want to import all of mock's
|
|
||||||
# symbols into this compat shim
|
|
||||||
# pylint: disable=wildcard-import,unused-wildcard-import
|
|
||||||
from unittest.mock import * # noqa
|
|
||||||
except ImportError:
|
|
||||||
# Python 2
|
|
||||||
# pylint: disable=wildcard-import,unused-wildcard-import
|
|
||||||
try:
|
|
||||||
from mock import * # noqa
|
|
||||||
except ImportError:
|
|
||||||
print('You need the mock library installed on python2.x to run tests')
|
|
||||||
|
|
||||||
|
|
||||||
# Prior to 3.4.4, mock_open cannot handle binary read_data
|
|
||||||
if sys.version_info >= (3,) and sys.version_info < (3, 4, 4):
|
|
||||||
file_spec = None
|
|
||||||
|
|
||||||
def _iterate_read_data(read_data):
|
|
||||||
# Helper for mock_open:
|
|
||||||
# Retrieve lines from read_data via a generator so that separate calls to
|
|
||||||
# readline, read, and readlines are properly interleaved
|
|
||||||
sep = b'\n' if isinstance(read_data, bytes) else '\n'
|
|
||||||
data_as_list = [li + sep for li in read_data.split(sep)]
|
|
||||||
|
|
||||||
if data_as_list[-1] == sep:
|
|
||||||
# If the last line ended in a newline, the list comprehension will have an
|
|
||||||
# extra entry that's just a newline. Remove this.
|
|
||||||
data_as_list = data_as_list[:-1]
|
|
||||||
else:
|
|
||||||
# If there wasn't an extra newline by itself, then the file being
|
|
||||||
# emulated doesn't have a newline to end the last line remove the
|
|
||||||
# newline that our naive format() added
|
|
||||||
data_as_list[-1] = data_as_list[-1][:-1]
|
|
||||||
|
|
||||||
for line in data_as_list:
|
|
||||||
yield line
|
|
||||||
|
|
||||||
def mock_open(mock=None, read_data=''):
|
|
||||||
"""
|
|
||||||
A helper function to create a mock to replace the use of `open`. It works
|
|
||||||
for `open` called directly or used as a context manager.
|
|
||||||
|
|
||||||
The `mock` argument is the mock object to configure. If `None` (the
|
|
||||||
default) then a `MagicMock` will be created for you, with the API limited
|
|
||||||
to methods or attributes available on standard file handles.
|
|
||||||
|
|
||||||
`read_data` is a string for the `read` methoddline`, and `readlines` of the
|
|
||||||
file handle to return. This is an empty string by default.
|
|
||||||
"""
|
|
||||||
def _readlines_side_effect(*args, **kwargs):
|
|
||||||
if handle.readlines.return_value is not None:
|
|
||||||
return handle.readlines.return_value
|
|
||||||
return list(_data)
|
|
||||||
|
|
||||||
def _read_side_effect(*args, **kwargs):
|
|
||||||
if handle.read.return_value is not None:
|
|
||||||
return handle.read.return_value
|
|
||||||
return type(read_data)().join(_data)
|
|
||||||
|
|
||||||
def _readline_side_effect():
|
|
||||||
if handle.readline.return_value is not None:
|
|
||||||
while True:
|
|
||||||
yield handle.readline.return_value
|
|
||||||
for line in _data:
|
|
||||||
yield line
|
|
||||||
|
|
||||||
global file_spec
|
|
||||||
if file_spec is None:
|
|
||||||
import _io # noqa
|
|
||||||
file_spec = list(set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO))))
|
|
||||||
|
|
||||||
if mock is None:
|
|
||||||
mock = MagicMock(name='open', spec=open) # noqa
|
|
||||||
|
|
||||||
handle = MagicMock(spec=file_spec) # noqa
|
|
||||||
handle.__enter__.return_value = handle
|
|
||||||
|
|
||||||
_data = _iterate_read_data(read_data)
|
|
||||||
|
|
||||||
handle.write.return_value = None
|
|
||||||
handle.read.return_value = None
|
|
||||||
handle.readline.return_value = None
|
|
||||||
handle.readlines.return_value = None
|
|
||||||
|
|
||||||
handle.read.side_effect = _read_side_effect
|
|
||||||
handle.readline.side_effect = _readline_side_effect()
|
|
||||||
handle.readlines.side_effect = _readlines_side_effect
|
|
||||||
|
|
||||||
mock.return_value = handle
|
|
||||||
return mock
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com>
|
|
||||||
#
|
|
||||||
# This file is part of Ansible
|
|
||||||
#
|
|
||||||
# Ansible is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# Ansible is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
# Make coding more python3-ish
|
|
||||||
|
|
||||||
'''
|
|
||||||
Compat module for Python2.7's unittest module
|
|
||||||
'''
|
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
# Allow wildcard import because we really do want to import all of
|
|
||||||
# unittests's symbols into this compat shim
|
|
||||||
# pylint: disable=wildcard-import,unused-wildcard-import
|
|
||||||
if sys.version_info < (2, 7):
|
|
||||||
try:
|
|
||||||
# Need unittest2 on python2.6
|
|
||||||
from unittest2 import * # noqa
|
|
||||||
except ImportError:
|
|
||||||
print('You need unittest2 installed on python2.6.x to run tests')
|
|
||||||
else:
|
|
||||||
from unittest import * # noqa
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
from ansible_collections.openstack.cloud.tests.unit.compat.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
from ansible.utils.path import unfrackpath
|
from ansible.utils.path import unfrackpath
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,10 +20,10 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
|
import unittest
|
||||||
|
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from io import BytesIO, StringIO
|
from io import BytesIO, StringIO
|
||||||
from ansible_collections.openstack.cloud.tests.unit.compat import unittest
|
|
||||||
from ansible.module_utils.six import PY3
|
from ansible.module_utils.six import PY3
|
||||||
from ansible.module_utils._text import to_bytes
|
from ansible.module_utils._text import to_bytes
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import collections
|
import collections
|
||||||
import inspect
|
import inspect
|
||||||
import mock
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from unittest import mock
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from ansible.module_utils.six import string_types
|
from ansible.module_utils.six import string_types
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import json
|
import json
|
||||||
|
import unittest
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
from ansible_collections.openstack.cloud.tests.unit.compat import unittest
|
|
||||||
from ansible_collections.openstack.cloud.tests.unit.compat.mock import patch
|
|
||||||
from ansible.module_utils import basic
|
from ansible.module_utils import basic
|
||||||
from ansible.module_utils._text import to_bytes
|
from ansible.module_utils._text import to_bytes
|
||||||
|
|
||||||
|
|||||||
9
tox.ini
9
tox.ini
@@ -36,13 +36,14 @@ deps =
|
|||||||
galaxy-importer
|
galaxy-importer
|
||||||
pbr
|
pbr
|
||||||
ruamel.yaml
|
ruamel.yaml
|
||||||
|
setuptools
|
||||||
commands =
|
commands =
|
||||||
python {toxinidir}/tools/build.py
|
python {toxinidir}/tools/build.py
|
||||||
ansible --version
|
ansible --version
|
||||||
ansible-galaxy collection build --force {toxinidir} --output-path {toxinidir}/build_artifact
|
ansible-galaxy collection build --force {toxinidir} --output-path {toxinidir}/build_artifact
|
||||||
bash {toxinidir}/tools/check-import.sh {toxinidir}
|
bash {toxinidir}/tools/check-import.sh {toxinidir}
|
||||||
|
|
||||||
[testenv:linters_{2_9,2_11,2_12,latest}]
|
[testenv:linters_{2_9,2_11,2_12,2_16,2_18,latest}]
|
||||||
allowlist_externals = bash
|
allowlist_externals = bash
|
||||||
commands =
|
commands =
|
||||||
{[testenv:build]commands}
|
{[testenv:build]commands}
|
||||||
@@ -56,6 +57,8 @@ deps =
|
|||||||
linters_2_9: -r{toxinidir}/tests/requirements-ansible-2.9.txt
|
linters_2_9: -r{toxinidir}/tests/requirements-ansible-2.9.txt
|
||||||
linters_2_11: -r{toxinidir}/tests/requirements-ansible-2.11.txt
|
linters_2_11: -r{toxinidir}/tests/requirements-ansible-2.11.txt
|
||||||
linters_2_12: -r{toxinidir}/tests/requirements-ansible-2.12.txt
|
linters_2_12: -r{toxinidir}/tests/requirements-ansible-2.12.txt
|
||||||
|
linters_2_16: -r{toxinidir}/tests/requirements-ansible-2.16.txt
|
||||||
|
linters_2_16: -r{toxinidir}/tests/requirements-ansible-2.18.txt
|
||||||
passenv = *
|
passenv = *
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
@@ -69,7 +72,7 @@ ignore = W503,H4,E501,E402,H301
|
|||||||
show-source = True
|
show-source = True
|
||||||
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,ansible_collections
|
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,ansible_collections
|
||||||
|
|
||||||
[testenv:ansible_{2_9,2_11,2_12,latest}]
|
[testenv:ansible_{2_9,2_11,2_12,2_16,2_18,latest}]
|
||||||
allowlist_externals = bash
|
allowlist_externals = bash
|
||||||
commands =
|
commands =
|
||||||
bash {toxinidir}/ci/run-ansible-tests-collection.sh -e {envdir} {posargs}
|
bash {toxinidir}/ci/run-ansible-tests-collection.sh -e {envdir} {posargs}
|
||||||
@@ -79,6 +82,8 @@ deps =
|
|||||||
ansible_2_9: -r{toxinidir}/tests/requirements-ansible-2.9.txt
|
ansible_2_9: -r{toxinidir}/tests/requirements-ansible-2.9.txt
|
||||||
ansible_2_11: -r{toxinidir}/tests/requirements-ansible-2.11.txt
|
ansible_2_11: -r{toxinidir}/tests/requirements-ansible-2.11.txt
|
||||||
ansible_2_12: -r{toxinidir}/tests/requirements-ansible-2.12.txt
|
ansible_2_12: -r{toxinidir}/tests/requirements-ansible-2.12.txt
|
||||||
|
ansible_2_16: -r{toxinidir}/tests/requirements-ansible-2.16.txt
|
||||||
|
ansible_2_18: -r{toxinidir}/tests/requirements-ansible-2.18.txt
|
||||||
# Need to pass some env vars for the Ansible playbooks
|
# Need to pass some env vars for the Ansible playbooks
|
||||||
passenv =
|
passenv =
|
||||||
HOME
|
HOME
|
||||||
|
|||||||
Reference in New Issue
Block a user