From f4852f4c81a6594dfd56eb18503648b3f449dcd4 Mon Sep 17 00:00:00 2001 From: Sean Mooney Date: Tue, 3 Oct 2023 11:56:09 +0100 Subject: [PATCH] [codespell] fix final typos and enable ci This chnage adds the pre-commit config and tox targets to run codespell both indepenetly and via the pep8 target. This change correct all the final typos in the codebase as detected by codespell. Change-Id: Ic4fb5b3a5559bc3c43aca0a39edc0885da58eaa2 --- .pre-commit-config.yaml | 5 +++ doc/dictionary.txt | 3 +- doc/source/admin/sev.rst | 2 +- nova/accelerator/cyborg.py | 2 +- nova/api/openstack/__init__.py | 2 +- .../compute/rest_api_version_history.rst | 2 +- nova/api/openstack/compute/schemas/servers.py | 2 +- nova/api/openstack/compute/server_groups.py | 2 +- nova/api/openstack/identity.py | 2 +- nova/api/openstack/wsgi.py | 2 +- .../aggregate_instance_extra_specs.py | 4 +-- .../validation/extra_specs/capabilities.py | 4 +-- nova/cmd/manage.py | 6 ++-- nova/compute/api.py | 4 +-- nova/compute/manager.py | 10 +++--- nova/compute/multi_cell_list.py | 2 +- nova/compute/provider_config.py | 4 +-- nova/compute/utils.py | 6 ++-- nova/conductor/tasks/live_migrate.py | 2 +- nova/conf/vnc.py | 2 +- nova/conf/workarounds.py | 2 +- nova/db/main/api.py | 4 +-- .../versions/8f2f1571d55b_initial_version.py | 2 +- nova/db/migration.py | 2 +- nova/exception.py | 2 +- nova/limit/local.py | 2 +- nova/limit/placement.py | 2 +- nova/network/neutron.py | 6 ++-- nova/objects/network_request.py | 2 +- nova/objects/virtual_interface.py | 4 +-- nova/pci/stats.py | 2 +- nova/policies/quota_class_sets.py | 2 +- nova/privsep/qemu.py | 2 +- nova/scheduler/weights/hypervisor_version.py | 2 +- nova/scheduler/weights/num_instances.py | 2 +- nova/storage/rbd_utils.py | 2 +- nova/test.py | 2 +- .../functional/libvirt/test_power_manage.py | 2 +- nova/virt/driver.py | 12 +++---- nova/virt/fake.py | 2 +- nova/virt/hardware.py | 2 +- nova/virt/ironic/driver.py | 6 ++-- nova/virt/libvirt/driver.py | 36 +++++++++---------- nova/virt/libvirt/guest.py | 2 +- nova/virt/libvirt/host.py | 2 +- nova/virt/libvirt/migration.py | 2 +- nova/virt/libvirt/volume/mount.py | 2 +- nova/virt/vmwareapi/vm_util.py | 2 +- nova/volume/cinder.py | 4 +-- setup.cfg | 2 +- tox.ini | 10 ++++++ 51 files changed, 106 insertions(+), 90 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7e72b7502db9..2b781dae0fea 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,3 +34,8 @@ repos: hooks: - id: autopep8 files: '^.*\.py$' + - repo: https://github.com/codespell-project/codespell + rev: v2.2.4 + hooks: + - id: codespell + args: ['--ignore-words=doc/dictionary.txt'] \ No newline at end of file diff --git a/doc/dictionary.txt b/doc/dictionary.txt index 21ad5453d004..aa488a1fcf9e 100644 --- a/doc/dictionary.txt +++ b/doc/dictionary.txt @@ -9,4 +9,5 @@ wile usera dettach excpt -imigration \ No newline at end of file +imigration +childs \ No newline at end of file diff --git a/doc/source/admin/sev.rst b/doc/source/admin/sev.rst index 0328844a3fed..2f55bf688035 100644 --- a/doc/source/admin/sev.rst +++ b/doc/source/admin/sev.rst @@ -91,7 +91,7 @@ steps: needs to track how many slots are available and used in order to avoid attempting to exceed that limit in the hardware. - Since version 8.0.0, libvirt exposes maximun mumber of SEV guests + Since version 8.0.0, libvirt exposes maximum number of SEV guests which can run concurrently in its host, so the limit is automatically detected using this feature. diff --git a/nova/accelerator/cyborg.py b/nova/accelerator/cyborg.py index 020adc9dc912..ede2da7c6547 100644 --- a/nova/accelerator/cyborg.py +++ b/nova/accelerator/cyborg.py @@ -380,7 +380,7 @@ class _CyborgClient(object): once, the 2nd and later calls will throw errors. Cyborg deletes the ARQs without error, or returns 404 if there is ARQ - which already deleted. In either way, existed ARQs in arq_uuids wil be + which already deleted. In either way, existed ARQs in arq_uuids will be deleted. Such 404 error can be ignored safely. If this fails, an error is logged but no exception is raised diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py index abca626af107..da063f48d1c1 100644 --- a/nova/api/openstack/__init__.py +++ b/nova/api/openstack/__init__.py @@ -165,7 +165,7 @@ class ProjectMapper(APIMapper): def _get_project_id_token(self): # NOTE(sdague): project_id parameter is only valid if its hex # or hex + dashes (note, integers are a subset of this). This - # is required to hand our overlaping routes issues. + # is required to hand our overlapping routes issues. return '{project_id:[0-9a-f-]+}' def resource(self, member_name, collection_name, **kwargs): diff --git a/nova/api/openstack/compute/rest_api_version_history.rst b/nova/api/openstack/compute/rest_api_version_history.rst index 13fb0f692ba0..f44e2c7d00a3 100644 --- a/nova/api/openstack/compute/rest_api_version_history.rst +++ b/nova/api/openstack/compute/rest_api_version_history.rst @@ -1244,6 +1244,6 @@ Name (FQDN). --------------------------------------------------- Any evacuated instances will be now stopped at destination. This -requires minimun nova release 27.0.0, OpenStack release 2023.1 +requires minimum nova release 27.0.0, OpenStack release 2023.1 Antelope. Operators can still use previous microversion for older behavior. diff --git a/nova/api/openstack/compute/schemas/servers.py b/nova/api/openstack/compute/schemas/servers.py index 0869f8343483..aa70998704b3 100644 --- a/nova/api/openstack/compute/schemas/servers.py +++ b/nova/api/openstack/compute/schemas/servers.py @@ -685,7 +685,7 @@ query_params_v273['properties'].update({ query_params_v275 = copy.deepcopy(query_params_v273) # 1. Update sort_keys to allow only valid sort keys: # NOTE(gmann): Remove the ignored sort keys now because 'additionalProperties' -# is Flase for query schema. Starting from miceoversion 2.75, API will +# is False for query schema. Starting from miceoversion 2.75, API will # raise 400 for any not-allowed sort keys instead of ignoring them. VALID_SORT_KEYS_V275 = copy.deepcopy(VALID_SORT_KEYS_V273) VALID_SORT_KEYS_V275['enum'] = list( diff --git a/nova/api/openstack/compute/server_groups.py b/nova/api/openstack/compute/server_groups.py index 5d3ea97895ab..5dc0950cd3f6 100644 --- a/nova/api/openstack/compute/server_groups.py +++ b/nova/api/openstack/compute/server_groups.py @@ -165,7 +165,7 @@ class ServerGroupController(wsgi.Controller): # In existing behavior, if non-admin users requesting # all projects server groups they do not get error instead # get their own server groups. Once we switch to policy - # new defaults completly then we can remove the above check. + # new defaults completely then we can remove the above check. # Until then, let's keep the old behaviour. context.can(sg_policies.POLICY_ROOT % 'index:all_projects', target={'project_id': project_id}) diff --git a/nova/api/openstack/identity.py b/nova/api/openstack/identity.py index 15ec884aea8e..314895edb8e7 100644 --- a/nova/api/openstack/identity.py +++ b/nova/api/openstack/identity.py @@ -45,7 +45,7 @@ def verify_project_id(context, project_id): msg = _("Nova was unable to find Keystone service endpoint.") # TODO(astupnik). It may be reasonable to switch to HTTP 503 # (HTTP Service Unavailable) instead of HTTP Bad Request here. - # If proper Keystone servie is inaccessible, then technially + # If proper Keystone service is inaccessible, then technially # this is a server side error and not an error in Nova. raise webob.exc.HTTPBadRequest(explanation=msg) except kse.ClientException: diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py index 71aee62932e7..271ce5d3136c 100644 --- a/nova/api/openstack/wsgi.py +++ b/nova/api/openstack/wsgi.py @@ -142,7 +142,7 @@ class Request(wsgi.Request): # no match. This is also little tricky that 'default' value cannot be # None. At least one of default_tag or default must be supplied as # an argument to the method, to define the defaulting behavior. - # So passing a sentinal value to return None from this function. + # So passing a sentinel value to return None from this function. best_match = self.accept_language.lookup( i18n.get_available_languages(), default='fake_LANG') diff --git a/nova/api/validation/extra_specs/aggregate_instance_extra_specs.py b/nova/api/validation/extra_specs/aggregate_instance_extra_specs.py index 0cf23b28ff6b..32037ca51676 100644 --- a/nova/api/validation/extra_specs/aggregate_instance_extra_specs.py +++ b/nova/api/validation/extra_specs/aggregate_instance_extra_specs.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -"""Validators for (preferrably) ``aggregate_instance_extra_specs`` namespaced +"""Validators for (preferably) ``aggregate_instance_extra_specs`` namespaced extra specs. These are used by the ``AggregateInstanceExtraSpecsFilter`` scheduler filter. @@ -60,7 +60,7 @@ EXTRA_SPEC_VALIDATORS = [ }, ], value={ - # this is totally arbitary, since we need to support specific + # this is totally arbitrary, since we need to support specific # values 'type': str, }, diff --git a/nova/api/validation/extra_specs/capabilities.py b/nova/api/validation/extra_specs/capabilities.py index fa51770f2625..b0593c346dc6 100644 --- a/nova/api/validation/extra_specs/capabilities.py +++ b/nova/api/validation/extra_specs/capabilities.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -"""Validators for (preferrably) ``capabilities`` namespaced extra specs. +"""Validators for (preferably) ``capabilities`` namespaced extra specs. These are used by the ``ComputeCapabilitiesFilter`` scheduler filter. Note that we explicitly do not allow the unnamespaced variant of extra specs since this @@ -72,7 +72,7 @@ for capability in ( name=f'capabilities:{capability}', description=DESCRIPTION.format(capability=capability), value={ - # this is totally arbitary, since we need to support specific + # this is totally arbitrary, since we need to support specific # values 'type': str, }, diff --git a/nova/cmd/manage.py b/nova/cmd/manage.py index 938e5f4fc985..d9c56e729996 100644 --- a/nova/cmd/manage.py +++ b/nova/cmd/manage.py @@ -760,7 +760,7 @@ class CellV2Commands(object): return 0 def _map_cell0(self, database_connection=None): - """Faciliate creation of a cell mapping for cell0. + """Facilitate creation of a cell mapping for cell0. See map_cell0 for more. """ def cell0_default_connection(): @@ -855,7 +855,7 @@ class CellV2Commands(object): # iteration, we search for the special name and unmunge the UUID to # pick up where we left off. This is done until all mappings are # processed. The munging is necessary as there's a unique constraint on - # the UUID field and we need something reversable. For more + # the UUID field and we need something reversible. For more # information, see commit 9038738d0. if max_count is not None: @@ -3013,7 +3013,7 @@ class VolumeAttachmentCommands(object): We can do that here as the command requires that the instance is stopped, something that isn't always the case with the current driver - BDM approach and thus the two are kept seperate for the time being. + BDM approach and thus the two are kept separate for the time being. :param instance_uuid: UUID of instance :param volume_id: ID of volume attached to the instance diff --git a/nova/compute/api.py b/nova/compute/api.py index dc8097b417db..c31f4ec17d57 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -3005,7 +3005,7 @@ class API: The results will be sorted based on the list of sort keys in the 'sort_keys' parameter (first value is primary sort key, second value is - secondary sort ket, etc.). For each sort key, the associated sort + secondary sort key, etc.). For each sort key, the associated sort direction is based on the list of sort directions in the 'sort_dirs' parameter. @@ -4125,7 +4125,7 @@ class API: desired destination of the instance during the cold migration :param allow_cross_cell_resize: If True, cross-cell resize is allowed for this operation and the host could be in a different cell from - the one that the instance is currently in. If False, the speciifed + the one that the instance is currently in. If False, the specified host must be in the same cell as the instance. :returns: ComputeNode object of the requested host :raises: CannotMigrateToSameHost if the host is the same as the diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 7e40128f8cf4..3d30b758540b 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -2966,7 +2966,7 @@ class ComputeManager(manager.Manager): return arqs def _split_network_arqs(self, arqs, requested_networks): - """splif arq request by exra spec from ARQ requested by port. + """split arq request by extra spec from ARQ requested by port. Return ARQ groups tuple:(spec_arqs, port_arqs) Each item in the tuple is a dict like: @@ -3682,7 +3682,7 @@ class ComputeManager(manager.Manager): # manually as we want to maintain a 'reserved' state # throughout the reimage process from the cinder side so # we are excluding the root BDM from certain operations - # here i.e. deleteing it's mapping before the destroy call. + # here i.e. deleting it's mapping before the destroy call. block_device_info_copy = copy.deepcopy(block_device_info) root_bdm = compute_utils.get_root_bdm(context, instance, bdms) mapping = block_device_info_copy["block_device_mapping"] @@ -8169,7 +8169,7 @@ class ComputeManager(manager.Manager): compute_node_uuid = objects.ComputeNode.get_by_nodename( context, instance.node).uuid # we can have multiple request groups, it would be enough to restrict - # only one of them to the compute tree but for symetry we restrict + # only one of them to the compute tree but for symmetry we restrict # all of them for request_group in request_groups: request_group.in_tree = compute_node_uuid @@ -8228,7 +8228,7 @@ class ComputeManager(manager.Manager): exception.AmbiguousResourceProviderForPCIRequest, exception.UnexpectedResourceProviderNameForPCIRequest ): - # These are programing errors. So we clean up an re-raise to let + # These are programming errors. So we clean up an re-raise to let # the request fail with excutils.save_and_reraise_exception(): self.reportclient.remove_resources_from_instance_allocation( @@ -10158,7 +10158,7 @@ class ComputeManager(manager.Manager): if instance.flavor.extra_specs.get('accel:device_profile'): # TODO(brinzhang): After cyborg support batch query ARQs # for more than one instances, we will improve efficiency - # with this implemention. + # with this implementation. accel_uuids = cyclient.get_arq_uuids_for_instance(instance) self.shelve_offload_instance( context, instance, clean_shutdown=False, diff --git a/nova/compute/multi_cell_list.py b/nova/compute/multi_cell_list.py index 6745048e7f24..5eb61a126e52 100644 --- a/nova/compute/multi_cell_list.py +++ b/nova/compute/multi_cell_list.py @@ -205,7 +205,7 @@ class CrossCellLister(metaclass=abc.ABCMeta): This is the standard filtered/sorted list method for the data type we are trying to list out of the database. Additional kwargs are - passsed through. + passed through. :param ctx: A RequestContext :param filters: A dict of column=filter items diff --git a/nova/compute/provider_config.py b/nova/compute/provider_config.py index f12b6d2709d4..96c4284dcd1b 100644 --- a/nova/compute/provider_config.py +++ b/nova/compute/provider_config.py @@ -33,7 +33,7 @@ SUPPORTED_SCHEMA_VERSIONS = { # Supported provider config file schema SCHEMA_V1 = { - # This defintion uses JSON Schema Draft 7. + # This definition uses JSON Schema Draft 7. # https://json-schema.org/draft-07/json-schema-release-notes.html 'type': 'object', 'properties': { @@ -137,7 +137,7 @@ SCHEMA_V1 = { 'patternProperties': { # Allows any key name matching the resource class # pattern, check to prevent conflicts with virt - # driver owned resouces classes will be done after + # driver owned resources classes will be done after # schema validation. '^[A-Z0-9_]{1,255}$': { 'type': 'object', diff --git a/nova/compute/utils.py b/nova/compute/utils.py index 30efc24fc794..8e7813306420 100644 --- a/nova/compute/utils.py +++ b/nova/compute/utils.py @@ -159,7 +159,7 @@ def get_device_name_for_instance(instance, bdms, device): This method is a wrapper for get_next_device_name that gets the list of used devices and the root device from a block device mapping. - :raises TooManyDiskDevices: if the maxmimum allowed devices to attach to a + :raises TooManyDiskDevices: if the maximum allowed devices to attach to a single instance is exceeded. """ mappings = block_device.instance_block_mapping(instance, bdms) @@ -172,7 +172,7 @@ def default_device_names_for_instance(instance, root_device_name, """Generate missing device names for an instance. - :raises TooManyDiskDevices: if the maxmimum allowed devices to attach to a + :raises TooManyDiskDevices: if the maximum allowed devices to attach to a single instance is exceeded. """ @@ -212,7 +212,7 @@ def get_next_device_name(instance, device_name_list, /dev/vdc is specified but the backend uses /dev/xvdc), the device name will be converted to the appropriate format. - :raises TooManyDiskDevices: if the maxmimum allowed devices to attach to a + :raises TooManyDiskDevices: if the maximum allowed devices to attach to a single instance is exceeded. """ diff --git a/nova/conductor/tasks/live_migrate.py b/nova/conductor/tasks/live_migrate.py index cca97c53f711..1cd9dff783f6 100644 --- a/nova/conductor/tasks/live_migrate.py +++ b/nova/conductor/tasks/live_migrate.py @@ -45,7 +45,7 @@ def supports_vif_related_pci_allocations(context, host): def supports_vpmem_live_migration(context): - """Checks if the commpute host service is new enough to support + """Checks if the compute host service is new enough to support instance live migration with virtual persistent memory. :param context: The user request context. diff --git a/nova/conf/vnc.py b/nova/conf/vnc.py index d9f5e0a7a685..11d262ab900e 100644 --- a/nova/conf/vnc.py +++ b/nova/conf/vnc.py @@ -161,7 +161,7 @@ Related options: The fully qualified path to a PEM file containing the x509 certificate which the VNC proxy server presents to the compute node during VNC authentication. -Realted options: +Related options: * ``vnc.auth_schemes``: must include ``vencrypt`` * ``vnc.vencrypt_client_key``: must also be set diff --git a/nova/conf/workarounds.py b/nova/conf/workarounds.py index 943ec748858d..7ac59b307f79 100644 --- a/nova/conf/workarounds.py +++ b/nova/conf/workarounds.py @@ -457,7 +457,7 @@ the Ironic node (by deleting the nova instance) it takes a while for Nova to un-reserve that Ironic node in placement. Usually this is a good idea, because it avoids placement providing an Ironic as a valid candidate when it is still being cleaned. -Howerver, if you don't use automatic cleaning, it can cause an +However, if you don't use automatic cleaning, it can cause an extra delay before and Ironic node is available for building a new Nova instance. """), diff --git a/nova/db/main/api.py b/nova/db/main/api.py index 8815e7e56ebc..2b41f3c93b91 100644 --- a/nova/db/main/api.py +++ b/nova/db/main/api.py @@ -1590,7 +1590,7 @@ def instance_get_all_by_filters( def _get_query_nova_resource_by_changes_time(query, filters, model_object): """Filter resources by changes-since or changes-before. - Special keys are used to tweek the query further:: + Special keys are used to tweak the query further:: | 'changes-since' - only return resources updated after | 'changes-before' - only return resources updated before @@ -1646,7 +1646,7 @@ def instance_get_all_by_filters_sort(context, filters, limit=None, marker=None, | ] | } - Special keys are used to tweek the query further:: + Special keys are used to tweak the query further:: | 'changes-since' - only return instances updated after | 'changes-before' - only return instances updated before diff --git a/nova/db/main/migrations/versions/8f2f1571d55b_initial_version.py b/nova/db/main/migrations/versions/8f2f1571d55b_initial_version.py index da1cf3bac3f8..6cf644a026e3 100644 --- a/nova/db/main/migrations/versions/8f2f1571d55b_initial_version.py +++ b/nova/db/main/migrations/versions/8f2f1571d55b_initial_version.py @@ -178,7 +178,7 @@ def _create_shadow_tables(connection): 'shadow_instance_extra', ['instance_uuid']) - # 373_migration_uuid; we should't create indexes for shadow tables + # 373_migration_uuid; we shouldn't create indexes for shadow tables # (fixed in migration 16f1fbcab42b) op.create_index( diff --git a/nova/db/migration.py b/nova/db/migration.py index 2b185af1a625..b0d70c33045e 100644 --- a/nova/db/migration.py +++ b/nova/db/migration.py @@ -52,7 +52,7 @@ def _find_alembic_conf(database='main'): def _upgrade_alembic(engine, config, version): - # re-use the connection rather than creating a new one + # reuse the connection rather than creating a new one with engine.begin() as connection: config.attributes['connection'] = connection alembic_api.upgrade(config, version or 'head') diff --git a/nova/exception.py b/nova/exception.py index c3ada86c1e21..a9df60304c41 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -161,7 +161,7 @@ class Forbidden(NovaException): class NotSupported(NovaException): # This exception use return code as 400 and can be used - # directly or as base exception for operations whihc are not + # directly or as base exception for operations which are not # supported in Nova. Any feature that is not yet implemented # but plan to implement in future (example: Cyborg # integration operations), should use this exception as base diff --git a/nova/limit/local.py b/nova/limit/local.py index f4e02c802073..2e43d12cee6b 100644 --- a/nova/limit/local.py +++ b/nova/limit/local.py @@ -198,7 +198,7 @@ def _convert_keys_to_legacy_name( ) -> ty.Dict[str, int]: legacy = {} for new_name, old_name in LEGACY_LIMITS.items(): - # defensive incase oslo or keystone doesn't give us an answer + # defensive in case oslo or keystone doesn't give us an answer legacy[old_name] = new_dict.get(new_name) or 0 return legacy diff --git a/nova/limit/placement.py b/nova/limit/placement.py index ef67ce4860d6..4c904d9b8fda 100644 --- a/nova/limit/placement.py +++ b/nova/limit/placement.py @@ -197,7 +197,7 @@ def enforce_num_instances_and_flavor( def _convert_keys_to_legacy_name(new_dict): legacy = {} for new_name, old_name in LEGACY_LIMITS.items(): - # defensive incase oslo or keystone doesn't give us an answer + # defensive in case oslo or keystone doesn't give us an answer legacy[old_name] = new_dict.get(new_name) or 0 return legacy diff --git a/nova/network/neutron.py b/nova/network/neutron.py index e6d47c9a6b39..a9a0d57156e0 100644 --- a/nova/network/neutron.py +++ b/nova/network/neutron.py @@ -1626,7 +1626,7 @@ class API: self._get_vf_pci_device_profile(pci_dev)) if pci_dev.dev_type == obj_fields.PciDeviceType.SRIOV_PF: - # In general the MAC address information flows fom the neutron + # In general the MAC address information flows from the neutron # port to the device in the backend. Except for direct-physical # ports. In that case the MAC address flows from the physical # device, the PF, to the neutron port. So when such a port is @@ -2226,7 +2226,7 @@ class API: :param port_id: The id of port to be queried :return: A tuple of vNIC type, trusted status, network ID, resource - request of the port if any and port numa affintiy policy, + request of the port if any and port numa affinity policy, and device_profile. Trusted status only affects SR-IOV ports and will always be None for other port types. If no port numa policy is @@ -3783,7 +3783,7 @@ class API: # the migration object... if migration is not None: # NOTE(artom) ... except for live migrations, because the - # conductor has already done that whe calling + # conductor has already done that when calling # bind_ports_to_host(). if not migration.is_live_migration: pci_mapping = self._get_pci_mapping_for_migration( diff --git a/nova/objects/network_request.py b/nova/objects/network_request.py index 536acfe95a22..372f3cf694bc 100644 --- a/nova/objects/network_request.py +++ b/nova/objects/network_request.py @@ -42,7 +42,7 @@ class NetworkRequest(obj_base.NovaObject): # arq_uuid save cyborg managed port device, pass # arq info from conductor to compute 'arq_uuid': fields.UUIDField(nullable=True), - # tranfer port's device_profile info from api to conductor + # transfer port's device_profile info from api to conductor 'device_profile': fields.StringField(nullable=True) } diff --git a/nova/objects/virtual_interface.py b/nova/objects/virtual_interface.py index 7ce418aca202..d553c448b451 100644 --- a/nova/objects/virtual_interface.py +++ b/nova/objects/virtual_interface.py @@ -283,7 +283,7 @@ def fill_virtual_interface_list(context, max_count): return count_all, count_hit -# NOTE(mjozefcz): This is similiar to marker mechanism made for +# NOTE(mjozefcz): This is similar to marker mechanism made for # RequestSpecs object creation. # Since we have a lot of instances to be check this # will add a FAKE row that points to last instance @@ -305,7 +305,7 @@ def _set_or_delete_marker_for_migrate_instances(context, marker=None): instance.project_id = FAKE_UUID instance.user_id = FAKE_UUID instance.create() - # Thats fake instance, lets destroy it. + # That's fake instance, lets destroy it. # We need only its row to solve constraint issue. instance.destroy() diff --git a/nova/pci/stats.py b/nova/pci/stats.py index c6e4844b3442..942873d3726d 100644 --- a/nova/pci/stats.py +++ b/nova/pci/stats.py @@ -630,7 +630,7 @@ class PciDeviceStats(object): corresponds to the ``id`` of host NUMACell objects. :param rp_uuids: A list of PR uuids this request fulfilled from in placement. So here we have to consider only the pools matching with - thes RP uuids + these RP uuids :returns: A list of pools that can be used to support the request if this is possible, else None. """ diff --git a/nova/policies/quota_class_sets.py b/nova/policies/quota_class_sets.py index b01102b44e15..d2b27c02b1d4 100644 --- a/nova/policies/quota_class_sets.py +++ b/nova/policies/quota_class_sets.py @@ -25,7 +25,7 @@ quota_class_sets_policies = [ policy.DocumentedRuleDefault( name=POLICY_ROOT % 'show', check_str=base.ADMIN, - description="List quotas for specific quota classs", + description="List quotas for specific quota classes", operations=[ { 'method': 'GET', diff --git a/nova/privsep/qemu.py b/nova/privsep/qemu.py index 529c24faf311..978845e69881 100644 --- a/nova/privsep/qemu.py +++ b/nova/privsep/qemu.py @@ -83,7 +83,7 @@ def unprivileged_convert_image(source, dest, in_format, out_format, @nova.privsep.sys_admin_pctxt.entrypoint def privileged_qemu_img_info(path, format=None): - """Return an oject containing the parsed output from qemu-img info + """Return an object containing the parsed output from qemu-img info This is a privileged call to qemu-img info using the sys_admin_pctxt entrypoint allowing host block devices etc to be accessed. diff --git a/nova/scheduler/weights/hypervisor_version.py b/nova/scheduler/weights/hypervisor_version.py index 0cd7b0a824ce..cdc4c43fca96 100644 --- a/nova/scheduler/weights/hypervisor_version.py +++ b/nova/scheduler/weights/hypervisor_version.py @@ -11,7 +11,7 @@ # under the License. """ -Hypervisor Version Weigher. Weigh hosts by their relative hypervior version. +Hypervisor Version Weigher. Weigh hosts by their relative hypervisor version. The default is to select newer hosts. If you prefer to invert the behavior set the 'hypervisor_version_weight_multiplier' option diff --git a/nova/scheduler/weights/num_instances.py b/nova/scheduler/weights/num_instances.py index ec5b06cd85ac..e581d82ac5ab 100644 --- a/nova/scheduler/weights/num_instances.py +++ b/nova/scheduler/weights/num_instances.py @@ -35,7 +35,7 @@ class NumInstancesWeigher(weights.BaseHostWeigher): CONF.filter_scheduler.num_instances_weight_multiplier) def _weigh_object(self, host_state, weight_properties): - """Higher weights win. We want to chooose hosts with fewer instances + """Higher weights win. We want to choose hosts with fewer instances as the default, hence the negative value of the multiplier. """ return host_state.num_instances diff --git a/nova/storage/rbd_utils.py b/nova/storage/rbd_utils.py index 43e5e1dc7c3b..d0436c8e906d 100644 --- a/nova/storage/rbd_utils.py +++ b/nova/storage/rbd_utils.py @@ -128,7 +128,7 @@ class RBDDriver(object): connect_timeout=None): # NOTE(lyarwood): Ensure the rbd and rados modules have been imported - # correctly before continuing, this is done in a seperate private + # correctly before continuing, this is done in a separate private # method to allow us to skip this check in unit tests etc. self._check_for_import_failure() diff --git a/nova/test.py b/nova/test.py index 90727043448c..0830b284dbc9 100644 --- a/nova/test.py +++ b/nova/test.py @@ -735,7 +735,7 @@ class SubclassSignatureTestCase(testtools.TestCase, metaclass=abc.ABCMeta): # This is a wrapped function. The signature we're going to # see here is that of the wrapper, which is almost certainly # going to involve varargs and kwargs, and therefore is - # unlikely to be what we want. If the wrapper manupulates the + # unlikely to be what we want. If the wrapper manipulates the # arguments taken by the wrapped function, the wrapped function # isn't what we want either. In that case we're just stumped: # if it ever comes up, add more knobs here to work round it (or diff --git a/nova/tests/functional/libvirt/test_power_manage.py b/nova/tests/functional/libvirt/test_power_manage.py index e6c05ffe27e6..64123f4a83b0 100644 --- a/nova/tests/functional/libvirt/test_power_manage.py +++ b/nova/tests/functional/libvirt/test_power_manage.py @@ -229,7 +229,7 @@ class PowerManagementTestsGovernorNotSupported(PowerManagementTestsBase): self.useFixture(nova_fixtures.SysFileSystemFixture( cpufreq_enabled=False)) - # Definining the CPUs to be pinned. + # Defining the CPUs to be pinned. self.flags(cpu_dedicated_set='1-9', cpu_shared_set=None, group='compute') self.flags(vcpu_pin_set=None) diff --git a/nova/virt/driver.py b/nova/virt/driver.py index 8cd56bdd2121..c24b80826e20 100644 --- a/nova/virt/driver.py +++ b/nova/virt/driver.py @@ -618,7 +618,7 @@ class ComputeDriver(object): disk_bus=None, device_type=None, encryption=None): """Attach the disk to the instance at mountpoint using info. - :raises TooManyDiskDevices: if the maxmimum allowed devices to attach + :raises TooManyDiskDevices: if the maximum allowed devices to attach to a single instance is exceeded. """ raise NotImplementedError() @@ -1053,7 +1053,7 @@ class ComputeDriver(object): node, as well as the inventory, aggregates, and traits associated with those resource providers. - Implementors of this interface are expected to set ``allocation_ratio`` + Implementers of this interface are expected to set ``allocation_ratio`` and ``reserved`` values for inventory records, which may be based on configuration options, e.g. ``[DEFAULT]/cpu_allocation_ratio``, depending on the driver and resource class. If not provided, allocation @@ -1171,7 +1171,7 @@ class ComputeDriver(object): :param disk_info: instance disk information :param migrate_data: a LiveMigrateData object :returns: migrate_data modified by the driver - :raises TooManyDiskDevices: if the maxmimum allowed devices to attach + :raises TooManyDiskDevices: if the maximum allowed devices to attach to a single instance is exceeded. """ raise NotImplementedError() @@ -1725,7 +1725,7 @@ class ComputeDriver(object): The metadata of the image of the instance. :param nova.objects.BlockDeviceMapping root_bdm: The description of the root device. - :raises TooManyDiskDevices: if the maxmimum allowed devices to attach + :raises TooManyDiskDevices: if the maximum allowed devices to attach to a single instance is exceeded. """ raise NotImplementedError() @@ -1734,7 +1734,7 @@ class ComputeDriver(object): *block_device_lists): """Default the missing device names in the block device mapping. - :raises TooManyDiskDevices: if the maxmimum allowed devices to attach + :raises TooManyDiskDevices: if the maximum allowed devices to attach to a single instance is exceeded. """ raise NotImplementedError() @@ -1753,7 +1753,7 @@ class ComputeDriver(object): implementation if not set. :returns: The chosen device name. - :raises TooManyDiskDevices: if the maxmimum allowed devices to attach + :raises TooManyDiskDevices: if the maximum allowed devices to attach to a single instance is exceeded. """ raise NotImplementedError() diff --git a/nova/virt/fake.py b/nova/virt/fake.py index 25c21a0473fc..82f10d61a540 100644 --- a/nova/virt/fake.py +++ b/nova/virt/fake.py @@ -602,7 +602,7 @@ class FakeDriver(driver.ComputeDriver): allocations, block_device_info=None, power_on=True): injected_files = admin_password = None # Finish migration is just like spawning the guest on a destination - # host during resize/cold migrate, so re-use the spawn() fake to + # host during resize/cold migrate, so reuse the spawn() fake to # claim resources and track the instance on this "hypervisor". self.spawn(context, instance, image_meta, injected_files, admin_password, allocations, diff --git a/nova/virt/hardware.py b/nova/virt/hardware.py index acf621b894b0..00c1b4af8bee 100644 --- a/nova/virt/hardware.py +++ b/nova/virt/hardware.py @@ -2746,7 +2746,7 @@ def get_ephemeral_encryption_constraint( flavor: 'objects.Flavor', image_meta: 'objects.ImageMeta', ) -> bool: - """Get the ephemeral encryption constrants based on the flavor and image. + """Get the ephemeral encryption constraints based on the flavor and image. :param flavor: an objects.Flavor object :param image_meta: an objects.ImageMeta object diff --git a/nova/virt/ironic/driver.py b/nova/virt/ironic/driver.py index 7d862f10c505..34708878924d 100644 --- a/nova/virt/ironic/driver.py +++ b/nova/virt/ironic/driver.py @@ -606,7 +606,7 @@ class IronicDriver(virt_driver.ComputeDriver): try: # NOTE(dustinc): The generator returned by the SDK can only be - # interated once. Since there are cases where it needs to be + # iterated once. Since there are cases where it needs to be # iterated more than once, we should return it as a list. In the # future it may be worth refactoring these other usages so it can # be returned as a generator. @@ -892,7 +892,7 @@ class IronicDriver(virt_driver.ComputeDriver): reserved = False if self._node_resources_unavailable(node): - # Operators might mark a node as in maintainance, + # Operators might mark a node as in maintenance, # even when an instance is on the node, # either way lets mark this as reserved reserved = True @@ -1585,7 +1585,7 @@ class IronicDriver(virt_driver.ComputeDriver): def plug_vifs(self, instance, network_info): """Plug VIFs into networks. - This method is present for compatability. Any call will result + This method is present for compatibility. Any call will result in a DEBUG log entry being generated, and will otherwise be ignored, as Ironic manages VIF attachments through a node lifecycle. Please see ``attach_interface``, which is the diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 2be2ebc9ac6b..01f47defee49 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -512,7 +512,7 @@ class LibvirtDriver(driver.ComputeDriver): self.provider_tree: provider_tree.ProviderTree = None # driver traits will not change during the runtime of the agent - # so calcuate them once and save them + # so calculate them once and save them self._static_traits = None # The CPU models in the configuration are case-insensitive, but the CPU @@ -675,7 +675,7 @@ class LibvirtDriver(driver.ComputeDriver): # NOTE(acewit): If the [libvirt]disk_cachemodes is set as # `block=writeback` or `block=writethrough` or `block=unsafe`, - # whose correponding Linux's IO semantic is not O_DIRECT in + # whose corresponding Linux's IO semantic is not O_DIRECT in # file nova.conf, then it will result in an attachment failure # because of the libvirt bug # (https://bugzilla.redhat.com/show_bug.cgi?id=1086704) @@ -4314,7 +4314,7 @@ class LibvirtDriver(driver.ComputeDriver): raise exception.InstanceNotRescuable( instance_id=instance.uuid, reason=reason % virt_type) # NOTE(lyarwood): Stable device rescue provides the original disk - # mapping of the instance with the rescue device appened to the + # mapping of the instance with the rescue device appended to the # end. As a result we need to provide the original image_meta, the # new rescue_image_meta and block_device_info when calling # get_disk_info. @@ -5010,7 +5010,7 @@ class LibvirtDriver(driver.ComputeDriver): except exception.ImageNotFound: # We must flatten here in order to remove dependency with an orphan # backing file (as snapshot image will be dropped once - # unshelve/cross_cell_resize is successfull). + # unshelve/cross_cell_resize is successful). LOG.warning('Current disk image is created on top of a snapshot ' 'image and cannot be rebased to original image ' 'because it is no longer available in the image ' @@ -5156,7 +5156,7 @@ class LibvirtDriver(driver.ComputeDriver): instance=instance) guest.attach_device(cfg) - # TODO(sean-k-mooney): we should try and converge this fuction with + # TODO(sean-k-mooney): we should try and converge this function with # _detach_direct_passthrough_vifs which does the same operation correctly # for live migration def _detach_direct_passthrough_ports(self, context, instance, guest): @@ -5209,7 +5209,7 @@ class LibvirtDriver(driver.ComputeDriver): # interface element. # So using it for all devices would break vnic-type direct when # using the sriov_nic_agent ml2 driver or vif of vnic_type vdpa. - # Since PF ports cant have the same MAC that means that this + # Since PF ports can't have the same MAC that means that this # use case was for hardware offloaded OVS? many NICs do not allow # two VFs to have the same MAC on different VLANs due to the # ordering of the VLAN and MAC filters in there static packet @@ -5217,8 +5217,8 @@ class LibvirtDriver(driver.ComputeDriver): # non ovs offload case. We should look into this more closely # as from my testing in this patch we appear to use the interface # element for hardware offloaded ovs too. Infiniband and vnic_type - # direct-physical port type do need this code path, both those cant - # have duplicate MACs... + # direct-physical port type do need this code path, but those + # can't have duplicate MACs... self._detach_pci_devices(guest, direct_passthrough_pci_addresses) # for ports that are attached with interface elements we cannot use @@ -5426,7 +5426,7 @@ class LibvirtDriver(driver.ComputeDriver): cpu.mode = mode cpu.model = models[0] if models else None - # compare flavor trait and cpu models, select the first mathched model + # compare flavor trait and cpu models, select the first matched model if flavor and mode == "custom": flags = libvirt_utils.get_flags_by_flavor_specs(flavor) if flags: @@ -5502,9 +5502,9 @@ class LibvirtDriver(driver.ComputeDriver): elif arch == fields.Architecture.PPC64LE: cpu.model = "POWER8" # TODO(chateaulav): re-evaluate when libvirtd adds overall - # RISCV suuport as a supported architecture, as there is no + # RISCV support as a supported architecture, as there is no # cpu models associated, this simply associates X vcpus to the - # guest according to the flavor. Thes same issue should be + # guest according to the flavor. These same issue should be # present with mipsel due to same limitation, but has not been # tested. elif arch == fields.Architecture.MIPSEL: @@ -6353,7 +6353,7 @@ class LibvirtDriver(driver.ComputeDriver): # the guest has the native kernel driver (called "virtio-gpu" in # Linux) -- i.e. if the guest has the VirtIO GPU driver, it'll # be used; otherwise, the 'virtio' model will gracefully - # fallback to VGA compatibiliy mode. + # fallback to VGA compatibility mode. if ( guestarch in ( fields.Architecture.I686, @@ -8749,7 +8749,7 @@ class LibvirtDriver(driver.ComputeDriver): for cell in topology.cells: cpus = set(cpu.id for cpu in cell.cpus) - # NOTE(artom) We assume we'll never see hardware with multipe + # NOTE(artom) We assume we'll never see hardware with multiple # sockets in a single NUMA node - IOW, the socket_id for all CPUs # in a single cell will be the same. To make that assumption # explicit, we leave the cell's socket_id as None if that's the @@ -10681,7 +10681,7 @@ class LibvirtDriver(driver.ComputeDriver): # cancel migration job. self.live_migration_abort(instance) except libvirt.libvirtError: - LOG.warning("Error occured when trying to abort live ", + LOG.warning("Error occurred when trying to abort live ", "migration job, ignoring it.", instance=instance) raise finally: @@ -11683,7 +11683,7 @@ class LibvirtDriver(driver.ComputeDriver): shutil.rmtree(swtpm_dir) # apparently shutil.rmtree() isn't reliable on NFS so don't rely - # only on path existance here. + # only on path existence here. if copy_swtpm_dir and os.path.exists(swtpm_dir): libvirt_utils.restore_vtpm_dir(swtpm_dir) elif new_vtpm_config: @@ -12385,15 +12385,15 @@ class LibvirtDriver(driver.ComputeDriver): """ dom_caps = self._host.get_domain_capabilities() supported_models: ty.Set[str] = {fields.VIOMMUModel.AUTO} - # our min version of qemu/libvirt supprot q35 and virt machine types. + # our min version of qemu/libvirt support q35 and virt machine types. # They also support the smmuv3 and intel iommu modeles so if the qemu - # binary is avaiable we can report the trait. + # binary is available we can report the trait. if fields.Architecture.AARCH64 in dom_caps: supported_models.add(fields.VIOMMUModel.SMMUV3) if fields.Architecture.X86_64 in dom_caps: supported_models.add(fields.VIOMMUModel.INTEL) # the virtio iommu model requires a newer libvirt then our min - # libvirt so we need to check the version explcitly. + # libvirt so we need to check the version explicitly. if self._host.has_min_version(MIN_LIBVIRT_VIOMMU_VIRTIO_MODEL): supported_models.add(fields.VIOMMUModel.VIRTIO) return { diff --git a/nova/virt/libvirt/guest.py b/nova/virt/libvirt/guest.py index 3dda3e417242..aeafdcc539be 100644 --- a/nova/virt/libvirt/guest.py +++ b/nova/virt/libvirt/guest.py @@ -261,7 +261,7 @@ class Guest(object): LOG.debug(f'No interface of type: {type(cfg)} found in domain') return None # FIXME(sean-k-mooney): we should be able to print the list of - # interfaces however some tests use incomplete objects that cant + # interfaces however some tests use incomplete objects that can't # be printed due to incomplete mocks or defects in the libvirt # fixture. Lets address this later. # LOG.debug(f'within interfaces: {list(interfaces)}') diff --git a/nova/virt/libvirt/host.py b/nova/virt/libvirt/host.py index 6cb87e4c3ed6..23c9ec01f7a2 100644 --- a/nova/virt/libvirt/host.py +++ b/nova/virt/libvirt/host.py @@ -1774,7 +1774,7 @@ class Host(object): return self._supports_secure_boot # we only check the host architecture since the libvirt driver doesn't - # truely support non-host architectures currently + # truly support non-host architectures currently arch = self.get_capabilities().host.cpu.arch domain_caps = self.get_domain_capabilities() for machine_type in domain_caps[arch]: diff --git a/nova/virt/libvirt/migration.py b/nova/virt/libvirt/migration.py index 4726111a7658..0aacec56d8da 100644 --- a/nova/virt/libvirt/migration.py +++ b/nova/virt/libvirt/migration.py @@ -253,7 +253,7 @@ def _update_volume_xml(xml_doc, migrate_data, instance, get_volume_config): item_dst.tail = None disk_dev.insert(cnt, item_dst) - # If destination has additional items, thses items should be + # If destination has additional items, these items should be # added here. for item_dst in list(xml_doc2): if item_dst.tag != 'address': diff --git a/nova/virt/libvirt/volume/mount.py b/nova/virt/libvirt/volume/mount.py index 01338497b6a2..9f7e31680a35 100644 --- a/nova/virt/libvirt/volume/mount.py +++ b/nova/virt/libvirt/volume/mount.py @@ -98,7 +98,7 @@ class _HostMountStateManager(object): self.cond.notify_all() def host_up(self, host): - """Inialise a new _HostMountState when the libvirt connection comes + """Initialise a new _HostMountState when the libvirt connection comes up. host_up will destroy and re-initialise the current state if one diff --git a/nova/virt/vmwareapi/vm_util.py b/nova/virt/vmwareapi/vm_util.py index 7aaf5ca827f6..14314c22a426 100644 --- a/nova/virt/vmwareapi/vm_util.py +++ b/nova/virt/vmwareapi/vm_util.py @@ -1513,7 +1513,7 @@ def find_rescue_device(hardware_devices, instance): """Returns the rescue device. The method will raise an exception if the rescue device does not - exist. The resuce device has suffix '-rescue.vmdk'. + exist. The rescue device has suffix '-rescue.vmdk'. :param hardware_devices: the hardware devices for the instance :param instance: nova.objects.instance.Instance object :return: the rescue disk device object diff --git a/nova/volume/cinder.py b/nova/volume/cinder.py index 55e1095bfc57..7da241723763 100644 --- a/nova/volume/cinder.py +++ b/nova/volume/cinder.py @@ -770,7 +770,7 @@ class API(object): """Create a volume attachment. This requires microversion >= 3.44. The attachment_create call was introduced in microversion 3.27. We - need 3.44 as minmum here as we need attachment_complete to finish the + need 3.44 as minimum here as we need attachment_complete to finish the attaching process and it which was introduced in version 3.44. :param context: The nova request context. @@ -840,7 +840,7 @@ class API(object): 'code': getattr(ex, 'code', None)}) def attachment_get_all(self, context, instance_id=None, volume_id=None): - """Get all attchments by instance id or volume id + """Get all attachments by instance id or volume id :param context: The nova request context. :param instance_id: UUID of the instance attachment to get. diff --git a/setup.cfg b/setup.cfg index 9611273468ac..5dd37efc6167 100644 --- a/setup.cfg +++ b/setup.cfg @@ -103,6 +103,6 @@ check_untyped_defs = true warn_unused_ignores = true [codespell] -skip = *.po,*.js,*.css,*.html,*.svg,HACKING.py,*hacking*,*build*,*_static*,doc/dictionary.txt,*.pyc,*.inv,*.gz,*.jpg,*.png,*.vsd,*.graffle +skip = *.po,*.js,*.css,*.html,*.svg,HACKING.py,*hacking*,*build*,*_static*,doc/dictionary.txt,*.pyc,*.inv,*.gz,*.jpg,*.png,*.vsd,*.graffle,*.json count = quiet-level = 4 \ No newline at end of file diff --git a/tox.ini b/tox.ini index ab1d8373dbe1..3df9d470dffd 100644 --- a/tox.ini +++ b/tox.ini @@ -107,15 +107,25 @@ extras = commands = bash tools/mypywrap.sh {posargs} +[testenv:codespell] +description = + Run codespell to check spelling. +deps = + pre-commit +commands = + pre-commit run codespell --all-files --show-diff-on-failure + [testenv:pep8] description = Run style checks. deps = {[testenv]deps} + {[testenv:codespell]deps} autopep8 extras = commands = {[testenv:mypy]commands} + {[testenv:codespell]commands} # check if autopep8 would alter the formatting but don't actually change it # so we can gate on this in the ci autopep8 --exit-code --max-line-length=79 --diff -r nova doc setup.py