pre-commit: Migrate from black to ruff format

This is mostly a case of adding trailing commas and rewrapping things to
fit on one line.

Change-Id: Iaabb38970e8077c3cfd19041c39e3d40d2d93ffa
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2024-08-29 11:29:24 +01:00
parent f83b657fc3
commit 187e88a559
69 changed files with 161 additions and 431 deletions

View File

@ -28,11 +28,7 @@ repos:
hooks:
- id: ruff
args: ['--fix']
- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
args: ['-S', '-l', '79']
- id: ruff-format
- repo: https://opendev.org/openstack/hacking
rev: 7.0.0
hooks:

View File

@ -61,5 +61,5 @@ def assert_no_deprecated_exceptions(logical_line, filename):
'OpenStackCloudURINotFound',
'OpenStackCloudResourceNotFound',
):
if re.search(fr'\b{exception}\b', logical_line):
if re.search(rf'\b{exception}\b', logical_line):
yield (0, 'O310: Use of deprecated Exception class')

View File

@ -73,7 +73,7 @@ class Deployable(resource.Resource):
json=request.body,
headers=request.headers,
microversion=microversion,
**kwargs
**kwargs,
)
self.microversion = microversion
self._translate_response(response, has_body=has_body)

View File

@ -14,7 +14,6 @@ from openstack.cloud import openstackcloud
class AcceleratorCloudMixin(openstackcloud._OpenStackCloudMixin):
def list_deployables(self, filters=None):
"""List all available deployables.

View File

@ -42,7 +42,6 @@ def _normalize_port_list(nics):
class BaremetalCloudMixin(openstackcloud._OpenStackCloudMixin):
def list_nics(self):
"""Return a list of all bare metal ports."""
return list(self.baremetal.ports(details=True))
@ -187,7 +186,7 @@ class BaremetalCloudMixin(openstackcloud._OpenStackCloudMixin):
timeout=3600,
lock_timeout=600,
provision_state='available',
**kwargs
**kwargs,
):
"""Register Baremetal with Ironic
@ -208,10 +207,7 @@ class BaremetalCloudMixin(openstackcloud._OpenStackCloudMixin):
Example::
[
{'address': 'aa:bb:cc:dd:ee:01'},
{'address': 'aa:bb:cc:dd:ee:02'}
]
[{'address': 'aa:bb:cc:dd:ee:01'}, {'address': 'aa:bb:cc:dd:ee:02'}]
Alternatively, you can provide an array of MAC addresses.
:param wait: Boolean value, defaulting to false, to wait for the node
@ -352,21 +348,16 @@ class BaremetalCloudMixin(openstackcloud._OpenStackCloudMixin):
Example patch construction::
patch=[]
patch.append({
'op': 'remove',
'path': '/instance_info'
})
patch.append({
'op': 'replace',
'path': '/name',
'value': 'newname'
})
patch.append({
patch = []
patch.append({'op': 'remove', 'path': '/instance_info'})
patch.append({'op': 'replace', 'path': '/name', 'value': 'newname'})
patch.append(
{
'op': 'add',
'path': '/driver_info/username',
'value': 'administrator'
})
'value': 'administrator',
}
)
:returns: Current state of the node.
:rtype: :class:`~openstack.baremetal.v1.node.Node`.

View File

@ -19,7 +19,6 @@ from openstack import warnings as os_warnings
class BlockStorageCloudMixin(openstackcloud._OpenStackCloudMixin):
# TODO(stephenfin): Remove 'cache' in a future major version
def list_volumes(self, cache=True):
"""List all available volumes.
@ -59,12 +58,7 @@ class BlockStorageCloudMixin(openstackcloud._OpenStackCloudMixin):
further filtering. Elements of this dictionary may, themselves, be
dictionaries. Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
@ -94,12 +88,7 @@ class BlockStorageCloudMixin(openstackcloud._OpenStackCloudMixin):
further filtering. Elements of this dictionary may, themselves, be
dictionaries. Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
@ -467,12 +456,7 @@ class BlockStorageCloudMixin(openstackcloud._OpenStackCloudMixin):
further filtering. Elements of this dictionary may, themselves, be
dictionaries. Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
@ -542,12 +526,7 @@ class BlockStorageCloudMixin(openstackcloud._OpenStackCloudMixin):
further filtering. Elements of this dictionary may, themselves, be
dictionaries. Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
@ -570,7 +549,7 @@ class BlockStorageCloudMixin(openstackcloud._OpenStackCloudMixin):
{
'name': 'my-volume-snapshot',
'volume_id': 'e126044c-7b4c-43be-a32a-c9cbbc9ddb56',
'all_tenants': 1
'all_tenants': 1,
}
:returns: A list of volume ``Snapshot`` objects.
@ -590,7 +569,7 @@ class BlockStorageCloudMixin(openstackcloud._OpenStackCloudMixin):
'name': 'my-volume-backup',
'status': 'available',
'volume_id': 'e126044c-7b4c-43be-a32a-c9cbbc9ddb56',
'all_tenants': 1
'all_tenants': 1,
}
:returns: A list of volume ``Backup`` objects.
@ -671,12 +650,7 @@ class BlockStorageCloudMixin(openstackcloud._OpenStackCloudMixin):
further filtering. Elements of this dictionary may, themselves, be
dictionaries. Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
@ -698,12 +672,7 @@ class BlockStorageCloudMixin(openstackcloud._OpenStackCloudMixin):
further filtering. Elements of this dictionary may, themselves, be
dictionaries. Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
@ -725,12 +694,7 @@ class BlockStorageCloudMixin(openstackcloud._OpenStackCloudMixin):
further filtering. Elements of this dictionary may, themselves, be
dictionaries. Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
@ -758,12 +722,7 @@ class BlockStorageCloudMixin(openstackcloud._OpenStackCloudMixin):
further filtering. Elements of this dictionary may, themselves, be
dictionaries. Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR

View File

@ -16,7 +16,6 @@ from openstack import exceptions
class CoeCloudMixin(openstackcloud._OpenStackCloudMixin):
def list_coe_clusters(self):
"""List COE (Container Orchestration Engine) cluster.
@ -51,12 +50,7 @@ class CoeCloudMixin(openstackcloud._OpenStackCloudMixin):
A dictionary of meta data to use for further filtering. Elements
of this dictionary may, themselves, be dictionaries. Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
A string containing a jmespath expression for further filtering.
@ -207,12 +201,7 @@ class CoeCloudMixin(openstackcloud._OpenStackCloudMixin):
A dictionary of meta data to use for further filtering. Elements
of this dictionary may, themselves, be dictionaries. Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
A string containing a jmespath expression for further filtering.

View File

@ -69,7 +69,6 @@ def _pop_or_get(resource, key, default, strict):
class ComputeCloudMixin(_network_common.NetworkCommonCloudMixin):
@property
def _compute_region(self):
# This is only used in exception messages. Can we get rid of it?
@ -398,12 +397,7 @@ class ComputeCloudMixin(_network_common.NetworkCommonCloudMixin):
Elements of this dictionary may, themselves, be dictionaries.
Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
A string containing a jmespath expression for further filtering.
@ -421,12 +415,7 @@ class ComputeCloudMixin(_network_common.NetworkCommonCloudMixin):
Elements of this dictionary may, themselves, be dictionaries.
Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
A string containing a jmespath expression for further filtering.
@ -505,12 +494,7 @@ class ComputeCloudMixin(_network_common.NetworkCommonCloudMixin):
A dictionary of meta data to use for further filtering. Elements
of this dictionary may, themselves, be dictionaries. Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
A string containing a jmespath expression for further filtering.
@ -1640,9 +1624,7 @@ class ComputeCloudMixin(_network_common.NetworkCommonCloudMixin):
{
'availability_zone': 'nova',
'metadata': {
'cpu_allocation_ratio': '1.0'
}
'metadata': {'cpu_allocation_ratio': '1.0'},
}
:returns: An aggregate dict or None if no matching aggregate is

View File

@ -17,7 +17,6 @@ from openstack import resource
class DnsCloudMixin(openstackcloud._OpenStackCloudMixin):
def list_zones(self, filters=None):
"""List all available zones.

View File

@ -20,7 +20,6 @@ from openstack import warnings as os_warnings
class IdentityCloudMixin(openstackcloud._OpenStackCloudMixin):
def _get_project_id_param_dict(self, name_or_id):
if name_or_id:
project = self.get_project(name_or_id)
@ -73,12 +72,7 @@ class IdentityCloudMixin(openstackcloud._OpenStackCloudMixin):
Elements of this dictionary may, themselves, be dictionaries.
Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
@ -114,12 +108,7 @@ class IdentityCloudMixin(openstackcloud._OpenStackCloudMixin):
Elements of this dictionary may, themselves, be dictionaries.
Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
@ -141,12 +130,7 @@ class IdentityCloudMixin(openstackcloud._OpenStackCloudMixin):
further filtering. Elements of this dictionary may, themselves, be
dictionaries. Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
@ -264,12 +248,7 @@ class IdentityCloudMixin(openstackcloud._OpenStackCloudMixin):
Elements of this dictionary may, themselves, be dictionaries.
Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
@ -304,12 +283,7 @@ class IdentityCloudMixin(openstackcloud._OpenStackCloudMixin):
further filtering. Elements of this dictionary may, themselves, be
dictionaries. Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
@ -506,12 +480,7 @@ class IdentityCloudMixin(openstackcloud._OpenStackCloudMixin):
Elements of this dictionary may, themselves, be dictionaries.
Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
@ -675,12 +644,7 @@ class IdentityCloudMixin(openstackcloud._OpenStackCloudMixin):
Elements of this dictionary may, themselves, be dictionaries.
Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
@ -837,12 +801,7 @@ class IdentityCloudMixin(openstackcloud._OpenStackCloudMixin):
Elements of this dictionary may, themselves, be dictionaries.
Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
@ -875,12 +834,7 @@ class IdentityCloudMixin(openstackcloud._OpenStackCloudMixin):
further filtering. Elements of this dictionary may, themselves, be
dictionaries. Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
@ -919,12 +873,7 @@ class IdentityCloudMixin(openstackcloud._OpenStackCloudMixin):
Elements of this dictionary may, themselves, be dictionaries.
Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
@ -1055,12 +1004,7 @@ class IdentityCloudMixin(openstackcloud._OpenStackCloudMixin):
Elements of this dictionary may, themselves, be dictionaries.
Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR

View File

@ -17,7 +17,6 @@ from openstack import utils
class ImageCloudMixin(openstackcloud._OpenStackCloudMixin):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@ -65,12 +64,7 @@ class ImageCloudMixin(openstackcloud._OpenStackCloudMixin):
Elements of this dictionary may, themselves, be dictionaries.
Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
A string containing a jmespath expression for further filtering.

View File

@ -17,7 +17,6 @@ from openstack import exceptions
class NetworkCloudMixin(_network_common.NetworkCommonCloudMixin):
def _neutron_extensions(self):
extensions = set()
for extension in self.network.extensions():
@ -180,12 +179,7 @@ class NetworkCloudMixin(_network_common.NetworkCommonCloudMixin):
Elements of this dictionary may, themselves, be dictionaries.
Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
A string containing a jmespath expression for further filtering.
@ -254,12 +248,7 @@ class NetworkCloudMixin(_network_common.NetworkCommonCloudMixin):
Elements of this dictionary may, themselves, be dictionaries.
Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
A string containing a jmespath expression for further filtering.
@ -304,12 +293,7 @@ class NetworkCloudMixin(_network_common.NetworkCommonCloudMixin):
Elements of this dictionary may, themselves, be dictionaries.
Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
A string containing a jmespath expression for further filtering.
@ -340,12 +324,7 @@ class NetworkCloudMixin(_network_common.NetworkCommonCloudMixin):
Elements of this dictionary may, themselves, be dictionaries.
Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
A string containing a jmespath expression for further filtering.
@ -368,12 +347,7 @@ class NetworkCloudMixin(_network_common.NetworkCommonCloudMixin):
Elements of this dictionary may, themselves, be dictionaries.
Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
:returns: A network ``Subnet`` object if found, else None.
"""
@ -400,12 +374,7 @@ class NetworkCloudMixin(_network_common.NetworkCommonCloudMixin):
Elements of this dictionary may, themselves, be dictionaries.
Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
A string containing a jmespath expression for further filtering.
@ -459,7 +428,7 @@ class NetworkCloudMixin(_network_common.NetworkCommonCloudMixin):
:param bool external: Whether this network is externally accessible.
:param dict provider: A dict of network provider options. Example::
{ 'network_type': 'vlan', 'segmentation_id': 'vlan1' }
{'network_type': 'vlan', 'segmentation_id': 'vlan1'}
:param string project_id: Specify the project ID this network
will be created on (admin-only).
@ -566,7 +535,7 @@ class NetworkCloudMixin(_network_common.NetworkCommonCloudMixin):
:param bool external: Whether this network is externally accessible.
:param dict provider: A dict of network provider options. Example::
{ 'network_type': 'vlan', 'segmentation_id': 'vlan1' }
{'network_type': 'vlan', 'segmentation_id': 'vlan1'}
:param int mtu_size: New maximum transmission unit value to address
fragmentation. Minimum value is 68 for IPv4, and 1280 for IPv6.
@ -753,12 +722,7 @@ class NetworkCloudMixin(_network_common.NetworkCommonCloudMixin):
Elements of this dictionary may, themselves, be dictionaries.
Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
A string containing a jmespath expression for further filtering.
@ -794,12 +758,7 @@ class NetworkCloudMixin(_network_common.NetworkCommonCloudMixin):
Elements of this dictionary may, themselves, be dictionaries.
Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
A string containing a jmespath expression for further filtering.
@ -822,12 +781,7 @@ class NetworkCloudMixin(_network_common.NetworkCommonCloudMixin):
Elements of this dictionary may, themselves, be dictionaries.
Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
A string containing a jmespath expression for further filtering.
@ -865,12 +819,7 @@ class NetworkCloudMixin(_network_common.NetworkCommonCloudMixin):
Elements of this dictionary may, themselves, be dictionaries.
Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
A string containing a jmespath expression for further filtering.
@ -957,12 +906,7 @@ class NetworkCloudMixin(_network_common.NetworkCommonCloudMixin):
Elements of this dictionary may, themselves, be dictionaries.
Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
A string containing a jmespath expression for further filtering.
@ -998,12 +942,7 @@ class NetworkCloudMixin(_network_common.NetworkCommonCloudMixin):
Elements of this dictionary may, themselves, be dictionaries.
Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
A string containing a jmespath expression for further filtering.
@ -1026,12 +965,7 @@ class NetworkCloudMixin(_network_common.NetworkCommonCloudMixin):
Elements of this dictionary may, themselves, be dictionaries.
Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
A string containing a jmespath expression for further filtering.
@ -1061,12 +995,7 @@ class NetworkCloudMixin(_network_common.NetworkCommonCloudMixin):
Elements of this dictionary may, themselves, be dictionaries.
Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
A string containing a jmespath expression for further filtering.
@ -2176,7 +2105,7 @@ class NetworkCloudMixin(_network_common.NetworkCommonCloudMixin):
[
{
"subnet_id": "8ca37218-28ff-41cb-9b10-039601ea7e6b",
"ip_address": "192.168.10.2"
"ip_address": "192.168.10.2",
}
]
@ -2237,7 +2166,7 @@ class NetworkCloudMixin(_network_common.NetworkCommonCloudMixin):
[
{
"subnet_id": "8ca37218-28ff-41cb-9b10-039601ea7e6b",
"ip_address": "192.168.10.2"
"ip_address": "192.168.10.2",
}
]
@ -2247,12 +2176,7 @@ class NetworkCloudMixin(_network_common.NetworkCommonCloudMixin):
Example::
[
{
"destination": "179.24.1.0/24",
"nexthop": "172.24.3.99"
}
]
[{"destination": "179.24.1.0/24", "nexthop": "172.24.3.99"}]
:returns: The updated network ``Router`` object.
:raises: :class:`~openstack.exceptions.SDKException` on operation
@ -2346,12 +2270,7 @@ class NetworkCloudMixin(_network_common.NetworkCommonCloudMixin):
:param allocation_pools: A list of dictionaries of the start and end
addresses for the allocation pools. For example::
[
{
"start": "192.168.199.2",
"end": "192.168.199.254"
}
]
[{"start": "192.168.199.2", "end": "192.168.199.254"}]
:param string gateway_ip: The gateway IP address. When you specify both
allocation_pools and gateway_ip, you must ensure that the gateway
@ -2362,20 +2281,14 @@ class NetworkCloudMixin(_network_common.NetworkCommonCloudMixin):
:param dns_nameservers: A list of DNS name servers for the subnet. For
example::
[ "8.8.8.7", "8.8.8.8" ]
["8.8.8.7", "8.8.8.8"]
:param host_routes: A list of host route dictionaries for the subnet.
For example::
[
{
"destination": "0.0.0.0/0",
"nexthop": "123.456.78.9"
},
{
"destination": "192.168.0.0/24",
"nexthop": "192.168.0.1"
}
{"destination": "0.0.0.0/0", "nexthop": "123.456.78.9"},
{"destination": "192.168.0.0/24", "nexthop": "192.168.0.1"},
]
:param string ipv6_ra_mode: IPv6 Router Advertisement mode. Valid
@ -2536,30 +2449,19 @@ class NetworkCloudMixin(_network_common.NetworkCommonCloudMixin):
:param allocation_pools: A list of dictionaries of the start and end
addresses for the allocation pools. For example::
[
{
"start": "192.168.199.2",
"end": "192.168.199.254"
}
]
[{"start": "192.168.199.2", "end": "192.168.199.254"}]
:param dns_nameservers: A list of DNS name servers for the subnet. For
example::
[ "8.8.8.7", "8.8.8.8" ]
["8.8.8.7", "8.8.8.8"]
:param host_routes: A list of host route dictionaries for the subnet.
For example::
[
{
"destination": "0.0.0.0/0",
"nexthop": "123.456.78.9"
},
{
"destination": "192.168.0.0/24",
"nexthop": "192.168.0.1"
}
{"destination": "0.0.0.0/0", "nexthop": "123.456.78.9"},
{"destination": "192.168.0.0/24", "nexthop": "192.168.0.1"},
]
:returns: The updated network ``Subnet`` object.
@ -2636,8 +2538,9 @@ class NetworkCloudMixin(_network_common.NetworkCommonCloudMixin):
[
{
"ip_address": "10.29.29.13",
"subnet_id": "a78484c4-c380-4b47-85aa-21c51a2d8cbd"
}, ...
"subnet_id": "a78484c4-c380-4b47-85aa-21c51a2d8cbd",
},
...,
]
:param subnet_id: If you specify only a subnet ID, OpenStack Networking
@ -2651,22 +2554,12 @@ class NetworkCloudMixin(_network_common.NetworkCommonCloudMixin):
:param allowed_address_pairs: Allowed address pairs list (Optional)
For example::
[
{
"ip_address": "23.23.23.1",
"mac_address": "fa:16:3e:c4:cd:3f"
}, ...
]
[{"ip_address": "23.23.23.1", "mac_address": "fa:16:3e:c4:cd:3f"}, ...]
:param extra_dhcp_opts: Extra DHCP options. (Optional).
For example::
[
{
"opt_name": "opt name1",
"opt_value": "value1"
}, ...
]
[{"opt_name": "opt name1", "opt_value": "value1"}, ...]
:param device_owner: The ID of the entity that uses this port.
For example, a DHCP agent. (Optional)
@ -2731,30 +2624,21 @@ class NetworkCloudMixin(_network_common.NetworkCommonCloudMixin):
[
{
"ip_address": "10.29.29.13",
"subnet_id": "a78484c4-c380-4b47-85aa-21c51a2d8cbd"
}, ...
"subnet_id": "a78484c4-c380-4b47-85aa-21c51a2d8cbd",
},
...,
]
:param security_groups: List of security group UUIDs. (Optional)
:param allowed_address_pairs: Allowed address pairs list (Optional)
For example::
[
{
"ip_address": "23.23.23.1",
"mac_address": "fa:16:3e:c4:cd:3f"
}, ...
]
[{"ip_address": "23.23.23.1", "mac_address": "fa:16:3e:c4:cd:3f"}, ...]
:param extra_dhcp_opts: Extra DHCP options. (Optional).
For example::
[
{
"opt_name": "opt name1",
"opt_value": "value1"
}, ...
]
[{"opt_name": "opt name1", "opt_value": "value1"}, ...]
:param device_owner: The ID of the entity that uses this port.
For example, a DHCP agent. (Optional)

View File

@ -458,12 +458,7 @@ class NetworkCommonCloudMixin(openstackcloud._OpenStackCloudMixin):
A dictionary of meta data to use for further filtering. Elements
of this dictionary may, themselves, be dictionaries. Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
A string containing a jmespath expression for further filtering.
@ -1177,8 +1172,7 @@ class NetworkCommonCloudMixin(openstackcloud._OpenStackCloudMixin):
self.network.update_ip(floating_ip_id, port_id=None)
except exceptions.SDKException:
raise exceptions.SDKException(
"Error detaching IP {ip} from "
"server {server_id}".format(
"Error detaching IP {ip} from server {server_id}".format(
ip=floating_ip_id, server_id=server_id
)
)
@ -1647,8 +1641,9 @@ class NetworkCommonCloudMixin(openstackcloud._OpenStackCloudMixin):
"floating_ip_address": "198.51.100.10",
"network": "this-is-a-net-or-pool-id",
"attached": True,
"status": "ACTIVE"
}, ...
"status": "ACTIVE",
},
...,
]
"""
@ -1769,12 +1764,7 @@ class NetworkCommonCloudMixin(openstackcloud._OpenStackCloudMixin):
A dictionary of meta data to use for further filtering. Elements
of this dictionary may, themselves, be dictionaries. Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR
A string containing a jmespath expression for further filtering.

View File

@ -26,7 +26,6 @@ OBJECT_CONTAINER_ACLS = {
class ObjectStoreCloudMixin(openstackcloud._OpenStackCloudMixin):
# TODO(stephenfin): Remove 'full_listing' as it's a noop
def list_containers(self, full_listing=True, prefix=None):
"""List containers.

View File

@ -17,7 +17,6 @@ from openstack.orchestration.util import event_utils
class OrchestrationCloudMixin(openstackcloud._OpenStackCloudMixin):
def get_template_contents(
self,
template_file=None,
@ -44,7 +43,7 @@ class OrchestrationCloudMixin(openstackcloud._OpenStackCloudMixin):
wait=False,
timeout=3600,
environment_files=None,
**parameters
**parameters,
):
"""Create a stack.
@ -101,7 +100,7 @@ class OrchestrationCloudMixin(openstackcloud._OpenStackCloudMixin):
wait=False,
timeout=3600,
environment_files=None,
**parameters
**parameters,
):
"""Update a stack.

View File

@ -14,7 +14,6 @@ from openstack.cloud import openstackcloud
class SharedFileSystemCloudMixin(openstackcloud._OpenStackCloudMixin):
def list_share_availability_zones(self):
"""List all availability zones for the Shared File Systems service.

View File

@ -47,12 +47,7 @@ def _filter_list(data, name_or_id, filters):
:param filters: A dictionary of meta data to use for further filtering.
Elements of this dictionary may, themselves, be dictionaries. Example::
{
'last_name': 'Smith',
'other': {
'gender': 'Female'
}
}
{'last_name': 'Smith', 'other': {'gender': 'Female'}}
OR

View File

@ -33,7 +33,7 @@ class OpenStackCloudCreateException(OpenStackCloudException):
resource=resource, resource_id=resource_id
),
extra_data=extra_data,
**kwargs
**kwargs,
)
self.resource_id = resource_id

View File

@ -302,6 +302,7 @@ class _OpenStackCloudMixin(_services_mixin.ServicesMixin):
.. code-block:: python
from oslo_context import context
cloud = openstack.connect(cloud='example')
# Work normally
servers = cloud.list_servers()
@ -314,6 +315,7 @@ class _OpenStackCloudMixin(_services_mixin.ServicesMixin):
.. code-block:: python
from oslo_context import context
c = openstack.connect(cloud='example')
# Work normally
servers = c.list_servers()

View File

@ -55,14 +55,14 @@ class QuotaSet(resource.Resource):
requires_id=False,
base_path=None,
error_message=None,
**params
**params,
):
return super().fetch(
session,
requires_id=False,
base_path=base_path,
error_message=error_message,
**params
**params,
)
def _translate_response(self, response, has_body=None, error_message=None):

View File

@ -124,7 +124,7 @@ class Limits(resource.Resource):
error_message=None,
base_path=None,
skip_cache=False,
**params
**params,
):
"""Get the Limits resource.
@ -142,5 +142,5 @@ class Limits(resource.Resource):
error_message=error_message,
base_path=base_path,
skip_cache=skip_cache,
**params
**params,
)

View File

@ -39,7 +39,7 @@ class ServerIP(resource.Resource):
server_id=None,
network_label=None,
base_path=None,
**params
**params,
):
if base_path is None:
base_path = cls.base_path

View File

@ -24,7 +24,7 @@ def get_cloud_region(
app_version=None,
load_yaml_config=True,
load_envvars=True,
**kwargs
**kwargs,
):
config = OpenStackConfig(
load_yaml_config=load_yaml_config,

View File

@ -218,8 +218,9 @@ def from_conf(conf, session=None, service_types=None, **kwargs):
)
)
_logger.warning(
"Disabling service '{service_type}': "
"{reason}".format(service_type=st, reason=reason)
"Disabling service '{service_type}': {reason}".format(
service_type=st, reason=reason
)
)
_disable_service(config_dict, st, reason=reason)
continue

View File

@ -87,7 +87,7 @@ settings from files or the environment.
'username': 'amazing-user',
'password': 'super-secret-password',
'project_id': '33aa1afc-03fe-43b8-8201-4e0d3b4b8ab5',
'user_domain_id': '054abd68-9ad9-418b-96d3-3437bb376703'
'user_domain_id': '054abd68-9ad9-418b-96d3-3437bb376703',
},
compute_api_version='2',
identity_interface='internal',

View File

@ -35,7 +35,7 @@ class Project(resource.Resource, tag.TagMixin):
'name',
'parent_id',
is_enabled='enabled',
**tag.TagMixin._tag_query_parameters
**tag.TagMixin._tag_query_parameters,
)
# Properties

View File

@ -349,9 +349,9 @@ class Image(resource.Resource, tag.TagMixin, _download.DownloadMixin):
if remote_region and remote_image_id:
if remote_service_interface:
data['method'][
'glance_service_interface'
] = remote_service_interface
data['method']['glance_service_interface'] = (
remote_service_interface
)
data['method']['glance_region'] = remote_region
data['method']['glance_image_id'] = remote_image_id

View File

@ -1188,7 +1188,7 @@ class Proxy(proxy.Proxy):
return self._update(
_availability_zone_profile.AvailabilityZoneProfile,
availability_zone_profile,
**attrs
**attrs,
)
def create_availability_zone(self, **attrs):

View File

@ -42,7 +42,7 @@ class HealthMonitor(resource.Resource, tag.TagMixin):
'type',
'url_path',
is_admin_state_up='admin_state_up',
**tag.TagMixin._tag_query_parameters
**tag.TagMixin._tag_query_parameters,
)
#: Properties

View File

@ -38,7 +38,7 @@ class L7Policy(resource.Resource, tag.TagMixin):
'redirect_prefix',
'project_id',
is_admin_state_up='admin_state_up',
**tag.TagMixin._tag_query_parameters
**tag.TagMixin._tag_query_parameters,
)
#: Properties

View File

@ -38,7 +38,7 @@ class L7Rule(resource.Resource, tag.TagMixin):
'operating_status',
is_admin_state_up='admin_state_up',
l7_policy_id='l7policy_id',
**tag.TagMixin._tag_query_parameters
**tag.TagMixin._tag_query_parameters,
)
#: Properties

View File

@ -53,7 +53,7 @@ class Listener(resource.Resource, tag.TagMixin):
is_hsts_include_subdomains='hsts_include_subdomains',
is_hsts_preload='hsts_preload',
is_admin_state_up='admin_state_up',
**tag.TagMixin._tag_query_parameters
**tag.TagMixin._tag_query_parameters,
)
# Properties

View File

@ -40,7 +40,7 @@ class LoadBalancer(resource.Resource, tag.TagMixin):
'operating_status',
'availability_zone',
is_admin_state_up='admin_state_up',
**tag.TagMixin._tag_query_parameters
**tag.TagMixin._tag_query_parameters,
)
# Properties

View File

@ -40,7 +40,7 @@ class Member(resource.Resource, tag.TagMixin):
'monitor_port',
'backup',
is_admin_state_up='admin_state_up',
**tag.TagMixin._tag_query_parameters
**tag.TagMixin._tag_query_parameters,
)
# Properties

View File

@ -45,7 +45,7 @@ class Pool(resource.Resource, tag.TagMixin):
'ca_tls_container_ref',
'crl_container_ref',
is_admin_state_up='admin_state_up',
**tag.TagMixin._tag_query_parameters
**tag.TagMixin._tag_query_parameters,
)
#: Properties

View File

@ -26,7 +26,7 @@ class NetworkResource(resource.Resource):
base_path=None,
params=None,
if_revision=None,
**kwargs
**kwargs,
):
req = super()._prepare_request(
requires_id=requires_id,

View File

@ -43,7 +43,7 @@ class FloatingIP(_base.NetworkResource, tag.TagMixin):
'sort_key',
'sort_dir',
tenant_id='project_id',
**tag.TagMixin._tag_query_parameters
**tag.TagMixin._tag_query_parameters,
)
# Properties

View File

@ -43,7 +43,7 @@ class Network(_base.NetworkResource, tag.TagMixin):
provider_network_type='provider:network_type',
provider_physical_network='provider:physical_network',
provider_segmentation_id='provider:segmentation_id',
**tag.TagMixin._tag_query_parameters
**tag.TagMixin._tag_query_parameters,
)
# Properties

View File

@ -53,7 +53,7 @@ class Port(_base.NetworkResource, tag.TagMixin):
is_admin_state_up='admin_state_up',
is_port_security_enabled='port_security_enabled',
security_group_ids='security_groups',
**tag.TagMixin._tag_query_parameters
**tag.TagMixin._tag_query_parameters,
)
# Properties

View File

@ -36,7 +36,7 @@ class QoSPolicy(resource.Resource, tag.TagMixin):
'sort_key',
'sort_dir',
is_shared='shared',
**tag.TagMixin._tag_query_parameters
**tag.TagMixin._tag_query_parameters,
)
# Properties

View File

@ -40,7 +40,7 @@ class Router(_base.NetworkResource, tag.TagMixin):
is_admin_state_up='admin_state_up',
is_distributed='distributed',
is_ha='ha',
**tag.TagMixin._tag_query_parameters
**tag.TagMixin._tag_query_parameters,
)
# Properties

View File

@ -37,7 +37,7 @@ class SecurityGroup(_base.NetworkResource, tag.TagMixin):
'revision_number',
'sort_dir',
'sort_key',
**tag.TagMixin._tag_query_parameters
**tag.TagMixin._tag_query_parameters,
)
# Properties

View File

@ -43,7 +43,7 @@ class SecurityGroupRule(_base.NetworkResource, tag.TagMixin):
'sort_dir',
'sort_key',
ether_type='ethertype',
**tag.TagMixin._tag_query_parameters
**tag.TagMixin._tag_query_parameters,
)
# Properties

View File

@ -44,7 +44,7 @@ class Subnet(_base.NetworkResource, tag.TagMixin):
is_dhcp_enabled='enable_dhcp',
subnet_pool_id='subnetpool_id',
use_default_subnet_pool='use_default_subnetpool',
**tag.TagMixin._tag_query_parameters
**tag.TagMixin._tag_query_parameters,
)
# Properties

View File

@ -37,7 +37,7 @@ class SubnetPool(resource.Resource, tag.TagMixin):
'sort_key',
'sort_dir',
is_shared='shared',
**tag.TagMixin._tag_query_parameters
**tag.TagMixin._tag_query_parameters,
)
# Properties

View File

@ -37,7 +37,7 @@ class Trunk(resource.Resource, tag.TagMixin):
'sub_ports',
'project_id',
is_admin_state_up='admin_state_up',
**tag.TagMixin._tag_query_parameters
**tag.TagMixin._tag_query_parameters,
)
# Properties

View File

@ -635,12 +635,12 @@ class Proxy(proxy.Proxy):
stack_id=obj.id,
resource_name=resource_name,
base_path=base_path,
**attr
**attr,
)
return self._list(
_stack_event.StackEvent,
stack_name=obj.name,
stack_id=obj.id,
**attr
**attr,
)

View File

@ -79,7 +79,7 @@ class ShareAccessRule(resource.Resource):
session,
resource_request_key='allow_access',
resource_response_key='access',
**kwargs
**kwargs,
)
def delete(

View File

@ -18,6 +18,7 @@ test_devstack
Throw errors if we do not actually detect the services we're supposed to.
"""
import os
from testscenarios import load_tests_apply_scenarios as load_tests # noqa

View File

@ -32,7 +32,6 @@ from openstack.tests.functional import base
class TestFloatingIPPool(base.BaseFunctionalTest):
def test_list_floating_ip_pools(self):
pools = self.user_cloud.list_floating_ip_pools()
if not pools:

View File

@ -16,6 +16,7 @@ test_keypairs
Functional tests for keypairs methods
"""
from openstack.tests import fakes
from openstack.tests.functional import base

View File

@ -16,6 +16,7 @@ test_limits
Functional tests for limits method
"""
from openstack.compute.v2 import limits as _limits
from openstack.tests.functional import base

View File

@ -18,6 +18,7 @@ test_project
Functional tests for project resource.
"""
import pprint
from openstack import exceptions

View File

@ -16,6 +16,7 @@ test_recordset
Functional tests for recordset methods.
"""
import random
import string

View File

@ -16,6 +16,7 @@ test_volume
Functional tests for block storage methods.
"""
import testtools
from openstack import exceptions

View File

@ -109,7 +109,7 @@ class TestMetadefProperty(base.BaseImageTest):
metadef_property = self.conn.image.update_metadef_property(
self.metadef_property,
self.metadef_namespace.namespace,
**self.attrs
**self.attrs,
)
self.assertIsNotNone(metadef_property)
self.assertIsInstance(

View File

@ -90,7 +90,7 @@ class TestLoadBalancer(base.BaseFunctionalTest):
'listener': 100,
'health_monitor': 100,
'member': 100,
}
},
)
assert isinstance(test_quota, quota.Quota)
self.assertEqual(self.PROJECT_ID, test_quota.id)

View File

@ -75,7 +75,7 @@ class TestFloatingIP(base.BaseFunctionalTest):
# Create Router
sot = self.user_cloud.network.create_router(
name=self.ROT_NAME,
**{"external_gateway_info": {"network_id": self.EXT_NET_ID}}
**{"external_gateway_info": {"network_id": self.EXT_NET_ID}},
)
assert isinstance(sot, router.Router)
self.assertEqual(self.ROT_NAME, sot.name)

View File

@ -86,7 +86,7 @@ class TestPortForwarding(base.BaseFunctionalTest):
# Create Router
sot = self.user_cloud.network.create_router(
name=self.ROT_NAME,
**{"external_gateway_info": {"network_id": self.EXT_NET_ID}}
**{"external_gateway_info": {"network_id": self.EXT_NET_ID}},
)
assert isinstance(sot, router.Router)
self.assertEqual(self.ROT_NAME, sot.name)

View File

@ -29,7 +29,7 @@ class QuotaClassSetTest(base.BaseSharedFileSystemTest):
project_id,
**{
"backups": initial_backups_value + 1,
}
},
)
)
self.assertEqual(

View File

@ -98,7 +98,7 @@ class TestType(base.TestCase):
exceptions.BadRequestException,
sot.set_extra_specs,
sess,
**set_specs
**set_specs,
)
def test_delete_extra_specs(self):

View File

@ -1744,7 +1744,7 @@ class TestBaremetalNode(base.IronicTestCase):
exceptions.SDKException,
self.cloud.register_machine,
nics,
**node_to_post
**node_to_post,
)
self.assert_calls()
@ -1811,7 +1811,7 @@ class TestBaremetalNode(base.IronicTestCase):
nics,
timeout=0.001,
lock_timeout=0.001,
**node_to_post
**node_to_post,
)
self.assert_calls()
@ -1901,7 +1901,7 @@ class TestBaremetalNode(base.IronicTestCase):
nics,
wait=True,
timeout=0.001,
**node_to_post
**node_to_post,
)
self.assert_calls()
@ -1949,7 +1949,7 @@ class TestBaremetalNode(base.IronicTestCase):
'no ports for you',
self.cloud.register_machine,
nics,
**node_to_post
**node_to_post,
)
self.assert_calls()
@ -2015,7 +2015,7 @@ class TestBaremetalNode(base.IronicTestCase):
'no ports for you',
self.cloud.register_machine,
nics,
**node_to_post
**node_to_post,
)
self.assert_calls()

View File

@ -16,6 +16,7 @@ test_delete_server
Tests for the `delete_server` command.
"""
import uuid
from openstack import exceptions

View File

@ -94,7 +94,7 @@ class TestFirewallRule(FirewallTestCase):
self.assertRaises(
exceptions.BadRequestException,
self.cloud.create_firewall_rule,
**bad_rule
**bad_rule,
)
self.assert_calls()
@ -146,7 +146,7 @@ class TestFirewallRule(FirewallTestCase):
uri=self._make_mock_url(
'firewall_rules',
name=self.firewall_rule_name,
**filters
**filters,
),
json={'firewall_rules': [self.mock_firewall_rule]},
),
@ -446,7 +446,7 @@ class TestFirewallPolicy(FirewallTestCase):
self.assertRaises(
exceptions.NotFoundException,
self.cloud.create_firewall_policy,
**posted_policy
**posted_policy,
)
self.cloud.network.create_firewall_policy.assert_not_called()
self.assert_calls()

View File

@ -1030,7 +1030,7 @@ class TestConfigArgparse(base.TestCase):
cc = c.get_one(
region_name='region2',
argparse=None,
**base.USER_CONF['clouds']['_test_cloud_regions']
**base.USER_CONF['clouds']['_test_cloud_regions'],
)
# Not using assert_cloud_details because of cache settings which
# are not present without the file

View File

@ -30,7 +30,7 @@ class TestFromConf(base.TestCase):
oslocfg,
session=self.cloud.session,
name='from_conf.example.com',
**from_conf_kwargs
**from_conf_kwargs,
)
self.assertEqual('from_conf.example.com', config.name)

View File

@ -657,7 +657,7 @@ class TestTempURLUnicodePathAndKey(TestTempURL):
url = '/v1/\u00e4/c/\u00f3'
key = 'k\u00e9y'
expected_url = (
'%s?temp_url_sig=temp_url_signature' '&temp_url_expires=1400003600'
'%s?temp_url_sig=temp_url_signature&temp_url_expires=1400003600'
) % url
expected_body = '\n'.join(
[
@ -672,7 +672,7 @@ class TestTempURLUnicodePathBytesKey(TestTempURL):
url = '/v1/\u00e4/c/\u00f3'
key = 'k\u00e9y'.encode()
expected_url = (
'%s?temp_url_sig=temp_url_signature' '&temp_url_expires=1400003600'
'%s?temp_url_sig=temp_url_signature&temp_url_expires=1400003600'
) % url
expected_body = '\n'.join(
[

View File

@ -87,9 +87,7 @@ VENDOR_CONFIG = """
"vendor_hook": "openstack.tests.unit.test_connection:vendor_hook"
}}
}}
""".format(
auth_url=CONFIG_AUTH_URL
)
""".format(auth_url=CONFIG_AUTH_URL)
PUBLIC_CLOUDS_YAML = """
public-clouds:
@ -97,9 +95,7 @@ public-clouds:
auth:
auth_url: {auth_url}
vendor_hook: openstack.tests.unit.test_connection:vendor_hook
""".format(
auth_url=CONFIG_AUTH_URL
)
""".format(auth_url=CONFIG_AUTH_URL)
class _TestConnectionBase(base.TestCase):

6
pyproject.toml Normal file
View File

@ -0,0 +1,6 @@
[tool.ruff]
line-length = 79
[tool.ruff.format]
quote-style = "preserve"
docstring-code-format = true