Skip to content
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
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ dependencies = [
"azure-mgmt-network",
"azure-mgmt-resource",
"azure-mgmt-storage",
"azure-mgmt-subscription",
"azure-storage-blob",
"boto",
"boto3",
Expand All @@ -60,7 +61,7 @@ dependencies = [
"lxml",
"miq-version",
"msrestazure",
"openshift==0.3.4",
"openshift>=0.13.0",
"ovirt-engine-sdk-python~=4.3",
"packaging",
"podman>5.0.0",
Expand Down
22 changes: 21 additions & 1 deletion wrapanapi/systems/container/rhopenshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,21 @@
from kubernetes import client as kubeclient
from kubernetes.client.rest import ApiException
from miq_version import TemplateName, Version
from openshift import client as ociclient
from wait_for import TimedOutError, wait_for

# Try to import openshift client module
# In openshift>=0.13, the static client module was removed in favor of the dynamic client
# For backward compatibility, we attempt the import but allow it to fail gracefully
try:
from openshift import client as ociclient

_OPENSHIFT_CLIENT_AVAILABLE = True
except (ImportError, AttributeError):
# openshift.client module doesn't exist in openshift>=0.13
# The OpenShift functionality will not work until code is migrated to dynamic client
ociclient = None
_OPENSHIFT_CLIENT_AVAILABLE = False

from wrapanapi.systems.base import System

# this service allows to access db outside of openshift
Expand Down Expand Up @@ -196,6 +208,14 @@ def _identifying_attrs(self):
return {"hostname": self.hostname, "port": self.port}

def _connect(self):
if not _OPENSHIFT_CLIENT_AVAILABLE or ociclient is None:
raise ImportError(
"The openshift.client module is not available. "
"OpenShift requires openshift<=0.13 which is incompatible with Python 3.9+, "
"or the code needs to be migrated to use the openshift.dynamic client API. "
"See https://github.com/openshift/openshift-restclient-python for guidance."
)

url = "{proto}://{host}:{port}".format(
proto=self.protocol, host=self.hostname, port=self.port
)
Expand Down
4 changes: 2 additions & 2 deletions wrapanapi/systems/msazure.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
from azure.mgmt.iothub import IotHubClient
from azure.mgmt.network import NetworkManagementClient
from azure.mgmt.network.models import NetworkSecurityGroup, SecurityRule
from azure.mgmt.resource import SubscriptionClient
from azure.mgmt.resource.resources import ResourceManagementClient
from azure.mgmt.resource.subscriptions.models import SubscriptionState
from azure.mgmt.storage import StorageManagementClient
from azure.mgmt.subscription import SubscriptionClient
from azure.mgmt.subscription.models import SubscriptionState
from azure.storage.blob import BlobServiceClient
from dateutil import parser
from msrestazure.azure_exceptions import CloudError
Expand Down