diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b745f950..25ff38c4 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] + args: [--py3-plus, --py311-plus] 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..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. @@ -571,9 +570,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") @@ -1811,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). 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