Remove six from conductor module

This is part of the steps to remove usage of six library, which is no
longer needed since python 2 support was removed.

Change-Id: I9a750de4f1ba7017c9dfd67dbf87be138421d017
This commit is contained in:
Takashi Kajinami 2024-02-17 11:46:47 +09:00
parent 52ee359f08
commit 41fa21d43c
5 changed files with 22 additions and 28 deletions

View File

@ -25,7 +25,6 @@ from magnum.i18n import _
from magnum import objects
from magnum.objects import fields
import six
LOG = logging.getLogger(__name__)
@ -53,7 +52,7 @@ class Handler(object):
certificate.csr,
ca_cert_type,
context=context)
if six.PY3 and isinstance(signed_cert, six.binary_type):
if isinstance(signed_cert, bytes):
certificate.pem = signed_cert.decode()
else:
certificate.pem = signed_cert
@ -63,7 +62,7 @@ class Handler(object):
ca_cert = cert_manager.get_cluster_ca_certificate(
cluster, context=context, ca_cert_type=ca_cert_type)
certificate = objects.Certificate.from_object_cluster(cluster)
if six.PY3 and isinstance(ca_cert.get_certificate(), six.binary_type):
if isinstance(ca_cert.get_certificate(), bytes):
certificate.pem = ca_cert.get_certificate().decode()
else:
certificate.pem = ca_cert.get_certificate()
@ -101,13 +100,13 @@ class Handler(object):
cluster.status_reason = None
except Exception as e:
cluster.status = fields.ClusterStatus.UPDATE_FAILED
cluster.status_reason = six.text_type(e)
cluster.status_reason = str(e)
cluster.save()
conductor_utils.notify_about_cluster_operation(
context, taxonomy.ACTION_UPDATE, taxonomy.OUTCOME_FAILURE,
cluster)
if isinstance(e, exc.HTTPBadRequest):
e = exception.InvalidParameterValue(message=six.text_type(e))
e = exception.InvalidParameterValue(message=str(e))
raise e
raise

View File

@ -15,7 +15,6 @@
from heatclient import exc
from oslo_log import log as logging
from pycadf import cadftaxonomy as taxonomy
import six
from magnum.common import clients
from magnum.common import exception
@ -83,14 +82,14 @@ class Handler(object):
except Exception as e:
cluster.status = fields.ClusterStatus.CREATE_FAILED
cluster.status_reason = six.text_type(e)
cluster.status_reason = str(e)
cluster.save()
conductor_utils.notify_about_cluster_operation(
context, taxonomy.ACTION_CREATE, taxonomy.OUTCOME_FAILURE,
cluster)
if isinstance(e, exc.HTTPBadRequest):
e = exception.InvalidParameterValue(message=six.text_type(e))
e = exception.InvalidParameterValue(message=str(e))
raise e
raise
@ -160,7 +159,7 @@ class Handler(object):
cluster.status_reason = None
except Exception as e:
cluster.status = fields.ClusterStatus.UPDATE_FAILED
cluster.status_reason = six.text_type(e)
cluster.status_reason = str(e)
cluster.save()
# Restore the node_count
worker_ng.node_count = old_node_count
@ -169,7 +168,7 @@ class Handler(object):
context, taxonomy.ACTION_UPDATE, taxonomy.OUTCOME_FAILURE,
cluster)
if isinstance(e, exc.HTTPBadRequest):
e = exception.InvalidParameterValue(message=six.text_type(e))
e = exception.InvalidParameterValue(message=str(e))
raise e
raise
@ -219,7 +218,7 @@ class Handler(object):
context, taxonomy.ACTION_DELETE, taxonomy.OUTCOME_FAILURE,
cluster)
cluster.status = fields.ClusterStatus.DELETE_FAILED
cluster.status_reason = six.text_type(unexp)
cluster.status_reason = str(unexp)
cluster.save()
raise
@ -284,17 +283,17 @@ class Handler(object):
cluster.status_reason = None
except Exception as e:
cluster.status = fields.ClusterStatus.UPDATE_FAILED
cluster.status_reason = six.text_type(e)
cluster.status_reason = str(e)
cluster.save()
nodegroup.node_count = old_node_count
nodegroup.status = fields.ClusterStatus.UPDATE_FAILED
nodegroup.status_reason = six.text_type(e)
nodegroup.status_reason = str(e)
nodegroup.save()
conductor_utils.notify_about_cluster_operation(
context, taxonomy.ACTION_UPDATE, taxonomy.OUTCOME_FAILURE,
cluster)
if isinstance(e, exc.HTTPBadRequest):
e = exception.InvalidParameterValue(message=six.text_type(e))
e = exception.InvalidParameterValue(message=str(e))
raise e
raise
@ -349,16 +348,16 @@ class Handler(object):
raise
except Exception as e:
cluster.status = fields.ClusterStatus.UPDATE_FAILED
cluster.status_reason = six.text_type(e)
cluster.status_reason = str(e)
cluster.save()
nodegroup.status = fields.ClusterStatus.UPDATE_FAILED
nodegroup.status_reason = six.text_type(e)
nodegroup.status_reason = str(e)
nodegroup.save()
conductor_utils.notify_about_cluster_operation(
context, taxonomy.ACTION_UPDATE, taxonomy.OUTCOME_FAILURE,
cluster)
if isinstance(e, exc.HTTPBadRequest):
e = exception.InvalidParameterValue(message=six.text_type(e))
e = exception.InvalidParameterValue(message=str(e))
raise e
raise

View File

@ -14,7 +14,6 @@
from oslo_log import log as logging
from oslo_utils import encodeutils
import six
from magnum.common import cert_manager
from magnum.common import exception
@ -26,7 +25,7 @@ import os
import shutil
import tempfile
CONDUCTOR_CLIENT_NAME = six.u('Magnum-Conductor')
CONDUCTOR_CLIENT_NAME = 'Magnum-Conductor'
LOG = logging.getLogger(__name__)
CONF = magnum.conf.CONF

View File

@ -18,7 +18,6 @@ import functools
from heatclient import exc
from oslo_log import log as logging
import six
from magnum.common import exception
from magnum.common import profiler
@ -86,12 +85,12 @@ class Handler(object):
nodegroup.save()
except Exception as e:
nodegroup.status = fields.ClusterStatus.CREATE_FAILED
nodegroup.status_reason = six.text_type(e)
nodegroup.status_reason = str(e)
nodegroup.save()
cluster.status = fields.ClusterStatus.UPDATE_FAILED
cluster.save()
if isinstance(e, exc.HTTPBadRequest):
e = exception.InvalidParameterValue(message=six.text_type(e))
e = exception.InvalidParameterValue(message=str(e))
raise e
raise
return nodegroup
@ -110,12 +109,12 @@ class Handler(object):
nodegroup.save()
except Exception as e:
nodegroup.status = fields.ClusterStatus.UPDATE_FAILED
nodegroup.status_reason = six.text_type(e)
nodegroup.status_reason = str(e)
nodegroup.save()
cluster.status = fields.ClusterStatus.UPDATE_FAILED
cluster.save()
if isinstance(e, exc.HTTPBadRequest):
e = exception.InvalidParameterValue(message=six.text_type(e))
e = exception.InvalidParameterValue(message=str(e))
raise e
raise
@ -144,7 +143,7 @@ class Handler(object):
raise exception.NgOperationInProgress(nodegroup=nodegroup.name)
except Exception as e:
nodegroup.status = fields.ClusterStatus.DELETE_FAILED
nodegroup.status_reason = six.text_type(e)
nodegroup.status_reason = str(e)
nodegroup.save()
cluster.status = fields.ClusterStatus.UPDATE_FAILED
cluster.save()

View File

@ -16,7 +16,6 @@
import abc
from oslo_log import log
import six
from magnum.common import profiler
import magnum.conf
@ -29,8 +28,7 @@ CONF = magnum.conf.CONF
@profiler.trace_cls("rpc")
@six.add_metaclass(abc.ABCMeta)
class MonitorBase(object):
class MonitorBase(object, metaclass=abc.ABCMeta):
def __init__(self, context, cluster):
self.context = context