From f448ac258def6230c5d157051ccd1ffda5779b3d Mon Sep 17 00:00:00 2001 From: Sagi Shnaidman Date: Tue, 17 Dec 2024 14:55:59 +0200 Subject: [PATCH] Linter and CI tasks fixes Change-Id: I0bcd30fc21de7838094b992cecc3a0e850c4da3a --- .zuul.yaml | 37 +--------------------- ci/roles/identity_user_info/tasks/main.yml | 9 ++++-- ci/roles/port/tasks/main.yml | 24 -------------- ci/roles/volume/tasks/volume_info.yml | 2 +- plugins/modules/baremetal_node.py | 1 + plugins/modules/image.py | 2 ++ plugins/modules/loadbalancer.py | 1 + plugins/modules/quota.py | 3 ++ plugins/modules/security_group.py | 1 + plugins/modules/server.py | 1 + plugins/modules/stack.py | 1 + tests/unit/mock/loader.py | 2 +- tools/run-ansible-sanity.sh | 2 -- tox.ini | 1 + 14 files changed, 20 insertions(+), 67 deletions(-) diff --git a/.zuul.yaml b/.zuul.yaml index 56bd332c..7c7e3128 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -480,49 +480,14 @@ jobs: - tox-pep8 - openstack-tox-linters-ansible-devel - - openstack-tox-linters-ansible-2.12 - ansible-collections-openstack-functional-devstack-releases: - dependencies: &deps_unit_lint + dependencies: - tox-pep8 - - openstack-tox-linters-ansible-2.12 - - ansible-collections-openstack-functional-devstack-ansible-2.9: - dependencies: *deps_unit_lint - - ansible-collections-openstack-functional-devstack-ansible-2.12: - dependencies: *deps_unit_lint - - ansible-collections-openstack-functional-devstack-ansible-devel: - dependencies: *deps_unit_lint - - ansible-collections-openstack-functional-devstack-xena-ansible-2.12: - dependencies: *deps_unit_lint - - ansible-collections-openstack-functional-devstack-wallaby-ansible-2.12: - dependencies: *deps_unit_lint - - ansible-collections-openstack-functional-devstack-train-ansible-2.11: - dependencies: *deps_unit_lint - - ansible-collections-openstack-functional-devstack-magnum: - dependencies: *deps_unit_lint - - ansible-collections-openstack-functional-devstack-octavia: - dependencies: *deps_unit_lint - - - bifrost-collections-src: - voting: false - dependencies: *deps_unit_lint - irrelevant-files: *ignore_files - - bifrost-keystone-collections-src: - voting: false - dependencies: *deps_unit_lint - irrelevant-files: *ignore_files gate: jobs: - tox-pep8 - - openstack-tox-linters-ansible-2.12 - ansible-collections-openstack-functional-devstack-releases - # - ansible-collections-openstack-functional-devstack-ansible-2.9 - # - ansible-collections-openstack-functional-devstack-ansible-2.12 - - ansible-collections-openstack-functional-devstack-wallaby-ansible-2.12 - - ansible-collections-openstack-functional-devstack-xena-ansible-2.12 - - ansible-collections-openstack-functional-devstack-train-ansible-2.11 - - ansible-collections-openstack-functional-devstack-magnum - - ansible-collections-openstack-functional-devstack-octavia periodic: jobs: diff --git a/ci/roles/identity_user_info/tasks/main.yml b/ci/roles/identity_user_info/tasks/main.yml index bc5c2c90..7cfb18e1 100644 --- a/ci/roles/identity_user_info/tasks/main.yml +++ b/ci/roles/identity_user_info/tasks/main.yml @@ -42,10 +42,12 @@ register: userinfo - name: Assert only one result exists assert: - that: "{{ userinfo.openstack_users | length }} == 1" + that: + - userinfo.openstack_users | length == 1 - name: Assert userinfo has fields assert: - that: item in userinfo.openstack_users[0] + that: + - item in userinfo.openstack_users[0] loop: "{{ os_expected_user_info_fields }}" - block: @@ -55,7 +57,8 @@ register: userinfo - name: Assert results were returned assert: - that: "{{ userinfo.openstack_users | length }} > 0" + that: + - userinfo.openstack_users | length > 0 - name: Post-test cleanup block: diff --git a/ci/roles/port/tasks/main.yml b/ci/roles/port/tasks/main.yml index 0396b1d8..e8d589c8 100644 --- a/ci/roles/port/tasks/main.yml +++ b/ci/roles/port/tasks/main.yml @@ -108,30 +108,6 @@ state: absent name: "{{ secgroup_name }}" -- name: Test port binding config (runs from train release sdk > 0.28) - block: - - name: Create port (with binding profile) - openstack.cloud.port: - cloud: "{{ cloud }}" - state: present - name: "{{ port_name }}" - network: "{{ network_name }}" - binding_profile: "{{ binding_profile }}" - register: port - - - name: Assert binding:profile exists in created port - assert: - that: "port.port['binding_profile']" - - - debug: var=port - - - name: Delete port (with binding profile) - openstack.cloud.port: - cloud: "{{ cloud }}" - state: absent - name: "{{ port_name }}" - when: sdk_version is version(0.28, '>') - - name: Delete subnet openstack.cloud.subnet: cloud: "{{ cloud }}" diff --git a/ci/roles/volume/tasks/volume_info.yml b/ci/roles/volume/tasks/volume_info.yml index fa758aff..ed859e90 100644 --- a/ci/roles/volume/tasks/volume_info.yml +++ b/ci/roles/volume/tasks/volume_info.yml @@ -79,7 +79,7 @@ - name: Check info assert: that: - - info1.volumes | selectattr("id", "equalto", "{{ info.volumes.0.id }}") | list | length == 1 + - info1.volumes | selectattr("id", "equalto", info.volumes.0.id) | list | length == 1 - info1.volumes.0.name == 'ansible_test' - info1.volumes.0.status == None diff --git a/plugins/modules/baremetal_node.py b/plugins/modules/baremetal_node.py index 303fa495..b6183247 100644 --- a/plugins/modules/baremetal_node.py +++ b/plugins/modules/baremetal_node.py @@ -123,6 +123,7 @@ options: description: - Definition of the physical characteristics of this server, used for scheduling purposes type: dict + default: {} suboptions: cpu_arch: description: diff --git a/plugins/modules/image.py b/plugins/modules/image.py index d74674e9..a49e42b7 100644 --- a/plugins/modules/image.py +++ b/plugins/modules/image.py @@ -54,10 +54,12 @@ options: description: - The minimum disk space (in GB) required to boot this image type: int + default: 0 min_ram: description: - The minimum ram (in MB) required to boot this image type: int + default: 0 is_public: description: - Whether the image can be accessed publicly. Note that publicizing an image requires admin role by default. diff --git a/plugins/modules/loadbalancer.py b/plugins/modules/loadbalancer.py index 6efdfd38..73bd9464 100644 --- a/plugins/modules/loadbalancer.py +++ b/plugins/modules/loadbalancer.py @@ -124,6 +124,7 @@ options: accessible from. elements: dict type: list + default: [] wait: description: - If the module should wait for the load balancer to be created or diff --git a/plugins/modules/quota.py b/plugins/modules/quota.py index decb7a5e..2c18c984 100644 --- a/plugins/modules/quota.py +++ b/plugins/modules/quota.py @@ -51,6 +51,7 @@ options: - Per driver volume storage quotas. Keys should be prefixed with C(gigabytes_) values should be ints. type: dict + default: {} injected_file_size: description: Maximum file size in bytes. type: int @@ -116,6 +117,7 @@ options: - Per-driver volume snapshot quotas. Keys should be prefixed with C(snapshots_) values should be ints. type: dict + default: {} subnet: description: Number of subnets to allow. type: int @@ -130,6 +132,7 @@ options: - Per-driver volume count quotas. Keys should be prefixed with C(volumes_) values should be ints. type: dict + default: {} project: description: Unused, kept for compatability type: int diff --git a/plugins/modules/security_group.py b/plugins/modules/security_group.py index 770bda94..c562ecb0 100644 --- a/plugins/modules/security_group.py +++ b/plugins/modules/security_group.py @@ -22,6 +22,7 @@ options: description: - Long description of the purpose of the security group type: str + default: '' state: description: - Should the resource be present or absent. diff --git a/plugins/modules/server.py b/plugins/modules/server.py index a6ac4f61..bf94380c 100644 --- a/plugins/modules/server.py +++ b/plugins/modules/server.py @@ -82,6 +82,7 @@ options: Only one of network or nics should be supplied.' type: list elements: raw + default: [] suboptions: tag: description: diff --git a/plugins/modules/stack.py b/plugins/modules/stack.py index 05151ba8..ece140d3 100644 --- a/plugins/modules/stack.py +++ b/plugins/modules/stack.py @@ -41,6 +41,7 @@ options: description: - Dictionary of parameters for the stack creation type: dict + default: {} rollback: description: - Rollback stack creation diff --git a/tests/unit/mock/loader.py b/tests/unit/mock/loader.py index 80d45ecd..84d5149a 100644 --- a/tests/unit/mock/loader.py +++ b/tests/unit/mock/loader.py @@ -28,7 +28,7 @@ class DictDataLoader(DataLoader): def __init__(self, file_mapping=None): file_mapping = {} if file_mapping is None else file_mapping - assert type(file_mapping) == dict + assert isinstance(file_mapping, dict) super(DictDataLoader, self).__init__() diff --git a/tools/run-ansible-sanity.sh b/tools/run-ansible-sanity.sh index 9a07c731..b4f2b06b 100755 --- a/tools/run-ansible-sanity.sh +++ b/tools/run-ansible-sanity.sh @@ -31,6 +31,4 @@ ansible --version ansible-test sanity -v \ --venv \ --python ${PY_VER} \ - --skip-test metaclass-boilerplate \ - --skip-test future-import-boilerplate \ plugins/ docs/ meta/ scripts/ diff --git a/tox.ini b/tox.ini index 85011a04..87c4a09b 100644 --- a/tox.ini +++ b/tox.ini @@ -36,6 +36,7 @@ deps = galaxy-importer pbr ruamel.yaml + setuptools commands = python {toxinidir}/tools/build.py ansible --version