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

MTV refactor, order files and classes #2246

Merged
merged 6 commits into from
Dec 25, 2024
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 ocp_resources/benchmark.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, Optional

from ocp_resources.constants import NOT_FOUND_ERROR_EXCEPTION_DICT, TIMEOUT_30SEC
from ocp_resources.utils.constants import NOT_FOUND_ERROR_EXCEPTION_DICT, TIMEOUT_30SEC
from ocp_resources.resource import NamespacedResource
from timeout_sampler import TimeoutSampler

Expand Down
2 changes: 1 addition & 1 deletion ocp_resources/cdi_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md

from typing import Any, Dict, List, Optional
from ocp_resources.constants import PROTOCOL_ERROR_EXCEPTION_DICT, TIMEOUT_4MINUTES
from ocp_resources.utils.constants import PROTOCOL_ERROR_EXCEPTION_DICT, TIMEOUT_4MINUTES
from ocp_resources.resource import Resource
from timeout_sampler import TimeoutSampler

Expand Down
2 changes: 1 addition & 1 deletion ocp_resources/daemonset.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import kubernetes

from ocp_resources.constants import PROTOCOL_ERROR_EXCEPTION_DICT, TIMEOUT_4MINUTES
from ocp_resources.utils.constants import PROTOCOL_ERROR_EXCEPTION_DICT, TIMEOUT_4MINUTES
from ocp_resources.resource import NamespacedResource
from timeout_sampler import TimeoutSampler

Expand Down
2 changes: 1 addition & 1 deletion ocp_resources/datavolume.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ocp_resources.constants import (
from ocp_resources.utils.constants import (
TIMEOUT_1MINUTE,
TIMEOUT_2MINUTES,
TIMEOUT_4MINUTES,
Expand Down
2 changes: 1 addition & 1 deletion ocp_resources/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Any, Dict, Optional
from timeout_sampler import TimeoutSampler, TimeoutWatch

from ocp_resources.constants import PROTOCOL_ERROR_EXCEPTION_DICT, TIMEOUT_4MINUTES
from ocp_resources.utils.constants import PROTOCOL_ERROR_EXCEPTION_DICT, TIMEOUT_4MINUTES
from ocp_resources.resource import NamespacedResource, MissingRequiredArgumentError


Expand Down
2 changes: 1 addition & 1 deletion ocp_resources/endpoint_slice.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ocp_resources.constants import TIMEOUT_4MINUTES
from ocp_resources.utils.constants import TIMEOUT_4MINUTES
from ocp_resources.resource import MissingRequiredArgumentError, NamespacedResource


Expand Down
2 changes: 1 addition & 1 deletion ocp_resources/endpoints.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ocp_resources.constants import TIMEOUT_4MINUTES
from ocp_resources.utils.constants import TIMEOUT_4MINUTES
from ocp_resources.resource import MissingRequiredArgumentError, NamespacedResource


Expand Down
3 changes: 1 addition & 2 deletions ocp_resources/forklift_controller.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from ocp_resources.mtv import MTV
from ocp_resources.resource import NamespacedResource


class ForkliftController(NamespacedResource, MTV):
class ForkliftController(NamespacedResource):
"""
Migration Toolkit For Virtualization (MTV) ForkliftController Resource
"""
Expand Down
5 changes: 2 additions & 3 deletions ocp_resources/hook.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from ocp_resources.constants import TIMEOUT_4MINUTES
from ocp_resources.mtv import MTV
from ocp_resources.utils.constants import TIMEOUT_4MINUTES
from ocp_resources.resource import NamespacedResource


class Hook(NamespacedResource, MTV):
class Hook(NamespacedResource):
"""
Migration Tool for Virtualization (MTV) Plan's Hook Resource.
"""
Expand Down
6 changes: 2 additions & 4 deletions ocp_resources/host.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from ocp_resources.constants import TIMEOUT_4MINUTES
from ocp_resources.mtv import MTV
from ocp_resources.utils.constants import TIMEOUT_4MINUTES
from ocp_resources.resource import NamespacedResource


class Host(NamespacedResource, MTV):
class Host(NamespacedResource):
myakove marked this conversation as resolved.
Show resolved Hide resolved
"""
Migration Toolkit For Virtualization (MTV) Host resource.
"""
Expand Down Expand Up @@ -41,7 +40,6 @@ def __init__(
self.provider_namespace = provider_namespace
self.secret_name = secret_name or f"{self.name}-secret"
self.secret_namespace = secret_namespace or self.namespace
self.condition_message_ready = self.ConditionMessage.HOST_READY

def to_dict(self) -> None:
super().to_dict()
Expand Down
2 changes: 1 addition & 1 deletion ocp_resources/hostpath_provisioner.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from ocp_resources.constants import TIMEOUT_4MINUTES
from ocp_resources.utils.constants import TIMEOUT_4MINUTES
from ocp_resources.resource import Resource


Expand Down
2 changes: 1 addition & 1 deletion ocp_resources/hyperconverged.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ocp_resources.constants import TIMEOUT_4MINUTES
from ocp_resources.utils.constants import TIMEOUT_4MINUTES
from ocp_resources.resource import NamespacedResource


Expand Down
2 changes: 1 addition & 1 deletion ocp_resources/image_stream.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ocp_resources.constants import TIMEOUT_4MINUTES
from ocp_resources.utils.constants import TIMEOUT_4MINUTES
from ocp_resources.resource import NamespacedResource


Expand Down
2 changes: 1 addition & 1 deletion ocp_resources/job.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import kubernetes

from ocp_resources.constants import TIMEOUT_4MINUTES
from ocp_resources.utils.constants import TIMEOUT_4MINUTES
from ocp_resources.resource import NamespacedResource


Expand Down
2 changes: 1 addition & 1 deletion ocp_resources/lease.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ocp_resources.constants import TIMEOUT_4MINUTES
from ocp_resources.utils.constants import TIMEOUT_4MINUTES
from ocp_resources.resource import NamespacedResource


Expand Down
2 changes: 1 addition & 1 deletion ocp_resources/machine_health_check.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ocp_resources.constants import TIMEOUT_4MINUTES
from ocp_resources.utils.constants import TIMEOUT_4MINUTES
from ocp_resources.resource import NamespacedResource


Expand Down
2 changes: 1 addition & 1 deletion ocp_resources/machine_set.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ocp_resources.constants import TIMEOUT_4MINUTES
from ocp_resources.utils.constants import TIMEOUT_4MINUTES
from ocp_resources.resource import NamespacedResource
from timeout_sampler import TimeoutExpiredError, TimeoutSampler

Expand Down
6 changes: 2 additions & 4 deletions ocp_resources/migration.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from ocp_resources.constants import TIMEOUT_4MINUTES
from ocp_resources.mtv import MTV
from ocp_resources.utils.constants import TIMEOUT_4MINUTES
from ocp_resources.resource import NamespacedResource


class Migration(NamespacedResource, MTV):
class Migration(NamespacedResource):
"""
Migration Toolkit For Virtualization (MTV) Migration object.

Expand Down Expand Up @@ -41,7 +40,6 @@ def __init__(
self.plan_name = plan_name
self.plan_namespace = plan_namespace
self.cut_over = cut_over
self.condition_message_succeeded = self.ConditionMessage.MIGRATION_SUCCEEDED

def to_dict(self) -> None:
super().to_dict()
Expand Down
151 changes: 0 additions & 151 deletions ocp_resources/mtv.py

This file was deleted.

24 changes: 20 additions & 4 deletions ocp_resources/network_map.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from ocp_resources.constants import TIMEOUT_4MINUTES
from ocp_resources.mtv import MTV
from ocp_resources.utils.constants import TIMEOUT_4MINUTES
from ocp_resources.resource import NamespacedResource


class NetworkMap(NamespacedResource, MTV):
class NetworkMap(NamespacedResource):
"""
Migration Toolkit For Virtualization (MTV) NetworkMap object.

Expand Down Expand Up @@ -56,7 +55,24 @@ def __init__(
self.source_provider_namespace = source_provider_namespace
self.destination_provider_name = destination_provider_name
self.destination_provider_namespace = destination_provider_namespace
self.condition_message_ready = self.ConditionMessage.NETWORK_MAP_READY

@property
def map_to_dict(self):
return {
"spec": {
"map": self.mapping,
"provider": {
"source": {
"name": self.source_provider_name,
"namespace": self.source_provider_namespace,
},
"destination": {
"name": self.destination_provider_name,
"namespace": self.destination_provider_namespace,
},
},
}
}

def to_dict(self) -> None:
super().to_dict()
Expand Down
2 changes: 1 addition & 1 deletion ocp_resources/node_maintenance.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ocp_resources.constants import TIMEOUT_4MINUTES
from ocp_resources.utils.constants import TIMEOUT_4MINUTES
from ocp_resources.resource import Resource


Expand Down
2 changes: 1 addition & 1 deletion ocp_resources/node_network_configuration_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from kubernetes.dynamic.exceptions import ConflictError

from ocp_resources.constants import TIMEOUT_4MINUTES
from ocp_resources.utils.constants import TIMEOUT_4MINUTES
from ocp_resources.exceptions import NNCPConfigurationFailed
from ocp_resources.node import Node
from ocp_resources.node_network_configuration_enactment import (
Expand Down
2 changes: 1 addition & 1 deletion ocp_resources/node_network_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from kubernetes.dynamic.exceptions import ConflictError

from ocp_resources.constants import TIMEOUT_4MINUTES
from ocp_resources.utils.constants import TIMEOUT_4MINUTES
from ocp_resources.resource import Resource
from timeout_sampler import TimeoutSampler

Expand Down
2 changes: 1 addition & 1 deletion ocp_resources/ocs_initialization.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ocp_resources.constants import TIMEOUT_4MINUTES
from ocp_resources.utils.constants import TIMEOUT_4MINUTES
from ocp_resources.resource import NamespacedResource


Expand Down
2 changes: 1 addition & 1 deletion ocp_resources/operator_group.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ocp_resources.constants import TIMEOUT_4MINUTES
from ocp_resources.utils.constants import TIMEOUT_4MINUTES
from ocp_resources.resource import NamespacedResource


Expand Down
2 changes: 1 addition & 1 deletion ocp_resources/operator_source.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ocp_resources.constants import TIMEOUT_4MINUTES
from ocp_resources.utils.constants import TIMEOUT_4MINUTES
from ocp_resources.resource import NamespacedResource


Expand Down
2 changes: 1 addition & 1 deletion ocp_resources/persistent_volume_claim.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from ocp_resources.constants import TIMEOUT_4MINUTES
from ocp_resources.utils.constants import TIMEOUT_4MINUTES
from ocp_resources.resource import NamespacedResource


Expand Down
Loading