Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #471

Merged
merged 5 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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]
16 changes: 10 additions & 6 deletions wrapanapi/entities/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -485,11 +481,19 @@ def __init__(self, *args, **kwargs):

@abstractproperty
mshriver marked this conversation as resolved.
Show resolved Hide resolved
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):
Expand Down
8 changes: 2 additions & 6 deletions wrapanapi/systems/ec2.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import base64
import os
import re
import typing

import boto3
from boto3 import client as boto3client
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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).

Expand Down
3 changes: 0 additions & 3 deletions wrapanapi/systems/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 0 additions & 3 deletions wrapanapi/systems/msazure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 0 additions & 3 deletions wrapanapi/systems/openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 0 additions & 2 deletions wrapanapi/systems/rhevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 0 additions & 3 deletions wrapanapi/systems/scvmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
3 changes: 0 additions & 3 deletions wrapanapi/systems/virtualcenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down