From d5c17004a81761e5f8ad50182eb4231e92376352 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 23 Oct 2023 17:57:35 +0000 Subject: [PATCH 1/5] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - https://github.com/asottile/reorder_python_imports → https://github.com/asottile/reorder-python-imports - [github.com/asottile/reorder-python-imports: v3.9.0 → v3.12.0](https://github.com/asottile/reorder-python-imports/compare/v3.9.0...v3.12.0) - [github.com/psf/black: 23.3.0 → 23.10.0](https://github.com/psf/black/compare/23.3.0...23.10.0) - [github.com/PyCQA/flake8: 6.0.0 → 6.1.0](https://github.com/PyCQA/flake8/compare/6.0.0...6.1.0) - [github.com/pre-commit/pre-commit-hooks: v4.4.0 → v4.5.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.4.0...v4.5.0) - [github.com/asottile/pyupgrade: v3.3.2 → v3.15.0](https://github.com/asottile/pyupgrade/compare/v3.3.2...v3.15.0) --- .pre-commit-config.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b745f950..40f054f9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,33 +1,33 @@ ci: autofix_prs: false repos: - - repo: https://github.com/asottile/reorder_python_imports - rev: v3.9.0 + - repo: https://github.com/asottile/reorder-python-imports + rev: v3.12.0 hooks: - id: reorder-python-imports args: - --application-directories=.:wrapanapi - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 23.10.0 hooks: - id: black args: [--safe, --quiet, --line-length, "100"] require_serial: true - repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 + rev: 6.1.0 hooks: - id: flake8 args: - --max-line-length=100 - --ignore=W503,E203 - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer - id: debug-statements - repo: https://github.com/asottile/pyupgrade - rev: v3.3.2 + rev: v3.15.0 hooks: - id: pyupgrade args: [--py3-plus, --py38-plus] From 6ff33b0324eee1f1c5f518c3254b37aa3cf44c7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Gajdu=C5=A1ek?= Date: Wed, 18 Oct 2023 11:39:01 +0200 Subject: [PATCH 2/5] Bump 3.8 -> 3.11 for pyupgrade --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 40f054f9..25ff38c4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,4 +30,4 @@ repos: rev: v3.15.0 hooks: - id: pyupgrade - args: [--py3-plus, --py38-plus] + args: [--py3-plus, --py311-plus] From c59f3884418b4cf338d53b597b4510f3770fdbe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Gajdu=C5=A1ek?= Date: Wed, 25 Oct 2023 15:18:02 +0200 Subject: [PATCH 3/5] Address F811: redefinition of unused 'can_pause' and 'can_suspend' --- wrapanapi/entities/vm.py | 16 ++++++++++------ wrapanapi/systems/ec2.py | 3 --- wrapanapi/systems/google.py | 3 --- wrapanapi/systems/msazure.py | 3 --- wrapanapi/systems/openstack.py | 3 --- wrapanapi/systems/rhevm.py | 2 -- wrapanapi/systems/scvmm.py | 3 --- wrapanapi/systems/virtualcenter.py | 3 --- 8 files changed, 10 insertions(+), 26 deletions(-) diff --git a/wrapanapi/entities/vm.py b/wrapanapi/entities/vm.py index c61e7237..7c54e75a 100644 --- a/wrapanapi/entities/vm.py +++ b/wrapanapi/entities/vm.py @@ -460,10 +460,6 @@ class VmMixin(EntityMixin, metaclass=ABCMeta): Defines methods or properties a wrapanapi.systems.System that manages Vm's should have """ - # Implementations must define whether this system can suspend (True/False) - can_suspend = None - # Implementations must define whether this system can pause (True/False) - can_pause = None # Implementations may override the amount of sec to wait for a VM to reach steady state steady_wait_time = 180 @@ -485,11 +481,19 @@ def __init__(self, *args, **kwargs): @abstractproperty def can_suspend(self): - """Return True if this system can suspend VM's/instances, False if not.""" + """ + Return True if this system can suspend VM's/instances, False if not. + + Implementations must define whether this system can suspend (True/False) + """ @abstractproperty def can_pause(self): - """Return True if this system can pause VM's/instances, False if not.""" + """ + Return True if this system can pause VM's/instances, False if not. + + Implementations must define whether this system can pause (True/False) + """ @abstractmethod def get_vm(self, name, **kwargs): diff --git a/wrapanapi/systems/ec2.py b/wrapanapi/systems/ec2.py index 2a173ab0..6b5beb74 100644 --- a/wrapanapi/systems/ec2.py +++ b/wrapanapi/systems/ec2.py @@ -571,9 +571,6 @@ class EC2System(System, VmMixin, TemplateMixin, StackMixin, NetworkMixin): "num_template": lambda self: len(self.list_templates()), } - can_suspend = False - can_pause = False - def __init__(self, **kwargs): super().__init__(**kwargs) self._username = kwargs.get("username") diff --git a/wrapanapi/systems/google.py b/wrapanapi/systems/google.py index 705f08ec..485b1706 100644 --- a/wrapanapi/systems/google.py +++ b/wrapanapi/systems/google.py @@ -441,9 +441,6 @@ class GoogleCloudSystem(System, TemplateMixin, VmMixin): "num_template": lambda self: len(self.list_templates()), } - can_suspend = False - can_pause = False - default_scope = ["https://www.googleapis.com/auth/cloud-platform"] def __init__(self, project=None, zone=None, file_type=None, **kwargs): diff --git a/wrapanapi/systems/msazure.py b/wrapanapi/systems/msazure.py index b87bc999..fa8527fa 100644 --- a/wrapanapi/systems/msazure.py +++ b/wrapanapi/systems/msazure.py @@ -494,9 +494,6 @@ class AzureSystem(System, VmMixin, TemplateMixin): "num_template": lambda self: len(list(self.list_compute_images())), } - can_suspend = True - can_pause = False - def __init__(self, **kwargs): super().__init__(**kwargs) self.client_id = kwargs.get("username") diff --git a/wrapanapi/systems/openstack.py b/wrapanapi/systems/openstack.py index 9264dd72..ba0fb8aa 100644 --- a/wrapanapi/systems/openstack.py +++ b/wrapanapi/systems/openstack.py @@ -603,9 +603,6 @@ class OpenstackSystem(System, VmMixin, TemplateMixin): "num_template": lambda self: len(self.list_templates()), } - can_suspend = True - can_pause = True - def __init__(self, tenant, username, password, auth_url, **kwargs): self.keystone_version = kwargs.get("keystone_version") if not self.keystone_version: diff --git a/wrapanapi/systems/rhevm.py b/wrapanapi/systems/rhevm.py index 588202c2..1a42bbe1 100644 --- a/wrapanapi/systems/rhevm.py +++ b/wrapanapi/systems/rhevm.py @@ -788,8 +788,6 @@ class RHEVMSystem(System, VmMixin, TemplateMixin): "num_datastore": lambda self: len(self.list_datastore()), } - can_suspend = True - can_pause = False # Over-ride default steady_wait_time steady_wait_time = 6 * 60 diff --git a/wrapanapi/systems/scvmm.py b/wrapanapi/systems/scvmm.py index 3f9a6bf4..f1ddb14a 100644 --- a/wrapanapi/systems/scvmm.py +++ b/wrapanapi/systems/scvmm.py @@ -534,9 +534,6 @@ class SCVMMSystem(System, VmMixin, TemplateMixin): "num_template": lambda self: len(self.list_templates()), } - can_suspend = True - can_pause = False - def __init__(self, **kwargs): super().__init__(**kwargs) self.host = kwargs["hostname"] diff --git a/wrapanapi/systems/virtualcenter.py b/wrapanapi/systems/virtualcenter.py index 97b044d1..2090898f 100644 --- a/wrapanapi/systems/virtualcenter.py +++ b/wrapanapi/systems/virtualcenter.py @@ -923,9 +923,6 @@ class VMWareSystem(System, VmMixin, TemplateMixin): "num_datastore": lambda self: len(self.list_datastore()), } - can_suspend = True - can_pause = False - def __init__(self, hostname, username, password, **kwargs): super().__init__(**kwargs) self.hostname = hostname From 8179d709df796f2192bbd5784aaeb871d1bbede1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Gajdu=C5=A1ek?= Date: Wed, 25 Oct 2023 15:47:26 +0200 Subject: [PATCH 4/5] F401: Remove unused import - typing --- wrapanapi/systems/ec2.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/wrapanapi/systems/ec2.py b/wrapanapi/systems/ec2.py index 6b5beb74..24268bbe 100644 --- a/wrapanapi/systems/ec2.py +++ b/wrapanapi/systems/ec2.py @@ -1,7 +1,6 @@ import base64 import os import re -import typing import boto3 from boto3 import client as boto3client @@ -508,7 +507,7 @@ def get_tag_value(self, key) -> str: return tags[0].get("Value") return None - def get_tags(self, regex="") -> typing.List[dict]: + def get_tags(self, regex="") -> list[dict]: """ Returns a list of tags (a dict with keys 'Key' and 'Value'). Tags are taken from the resource properties. @@ -1808,7 +1807,7 @@ def cleanup_resources(self): self.remove_all_unused_volumes() self.remove_all_unused_ips() - def list_resources(self, query="", view="") -> typing.List[ResourceExplorerResource]: + def list_resources(self, query="", view="") -> list[ResourceExplorerResource]: """ Lists resources using AWS Resource Explorer (resource-explorer-2). From 9f31c2c4677d1e0c426b2f2df93f6f04150fd2f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Gajdu=C5=A1ek?= Date: Wed, 25 Oct 2023 16:17:33 +0200 Subject: [PATCH 5/5] Drop Python 3.8 support --- .github/workflows/pull_request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 1d499b45..b33afc7c 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python: [3.8, 3.9, 3.12] + python: [3.9, 3.12] steps: - name: Checkout WrapanAPI uses: actions/checkout@v3