From 6fb2e8510ef88ee9abb0839cf9a8247f97c1e262 Mon Sep 17 00:00:00 2001
From: haixin <haixin@inspur.com>
Date: Fri, 9 Oct 2020 10:44:11 +0800
Subject: [PATCH] remove usage of six library

remove usage of six library from the following directory:
1:common
2:data
3:db
4:message
5:network
6:scheduler

Change-Id: I9db0abf2b0847157074ca6ba84b5451bfe3f20d0
Signed-off-by: Goutham Pacha Ravi <gouthampravi@gmail.com>
---
 manila/common/config.py                       | 11 ++-----
 manila/compute/nova.py                        |  7 +++--
 manila/data/manager.py                        |  3 +-
 .../5077ffcc5f1c_add_share_instances.py       |  5 ++--
 manila/db/sqlalchemy/api.py                   | 29 +++++++++----------
 manila/message/api.py                         |  4 +--
 manila/network/__init__.py                    |  6 ++--
 manila/network/linux/interface.py             |  8 ++---
 manila/network/linux/ip_lib.py                |  3 +-
 .../network/neutron/neutron_network_plugin.py |  5 ++--
 manila/network/standalone_network_plugin.py   | 27 +++++++++--------
 manila/scheduler/evaluator/evaluator.py       | 13 ++++-----
 manila/scheduler/filters/driver.py            |  6 ++--
 manila/scheduler/filters/extra_specs_ops.py   |  3 +-
 manila/scheduler/filters/json.py              |  3 +-
 manila/scheduler/host_manager.py              |  5 ++--
 manila/scheduler/weighers/base.py             |  5 +---
 manila/scheduler/weighers/goodness.py         |  5 ++--
 18 files changed, 61 insertions(+), 87 deletions(-)

diff --git a/manila/common/config.py b/manila/common/config.py
index f225b235ee..bab5e74db6 100644
--- a/manila/common/config.py
+++ b/manila/common/config.py
@@ -31,11 +31,9 @@ from oslo_log import log
 from oslo_middleware import cors
 from oslo_policy import opts as policy_opts
 from oslo_utils import netutils
-import six
 
 from manila.common import constants
 from manila import exception
-from manila.i18n import _
 
 CONF = cfg.CONF
 log.register_options(CONF)
@@ -138,8 +136,8 @@ global_opts = [
     cfg.ListOpt('enabled_share_protocols',
                 default=['NFS', 'CIFS'],
                 help="Specify list of protocols to be allowed for share "
-                     "creation. Available values are '%s'" % six.text_type(
-                         constants.SUPPORTED_SHARE_PROTOCOLS)),
+                     "creation. Available values are '%s'" %
+                     list(constants.SUPPORTED_SHARE_PROTOCOLS)),
 ]
 
 CONF.register_opts(global_opts)
@@ -164,10 +162,7 @@ def verify_share_protocols():
     if msg:
         msg += ("Please specify one or more protocols using "
                 "configuration option 'enabled_share_protocols'.")
-        # NOTE(vponomaryov): use translation to unicode explicitly,
-        # because of 'lazy' translations.
-        msg = six.text_type(_(msg) % data)  # noqa H701
-        raise exception.ManilaException(message=msg)
+        raise exception.ManilaException(message=msg % data)
 
 
 def set_lib_defaults():
diff --git a/manila/compute/nova.py b/manila/compute/nova.py
index 5da9a75149..d49ec2d1f1 100644
--- a/manila/compute/nova.py
+++ b/manila/compute/nova.py
@@ -16,12 +16,13 @@
 Handles all requests to Nova.
 """
 
+import functools
+
 from keystoneauth1 import loading as ks_loading
 from novaclient import client as nova_client
 from novaclient import exceptions as nova_exception
 from novaclient import utils
 from oslo_config import cfg
-import six
 
 from manila.common import client_auth
 from manila.common.config import core_opts
@@ -121,7 +122,7 @@ def translate_server_exception(method):
     Note: keeps its traceback intact.
     """
 
-    @six.wraps(method)
+    @functools.wraps(method)
     def wrapper(self, ctx, instance_id, *args, **kwargs):
         try:
             res = method(self, ctx, instance_id, *args, **kwargs)
@@ -130,7 +131,7 @@ def translate_server_exception(method):
             if isinstance(e, nova_exception.NotFound):
                 raise exception.InstanceNotFound(instance_id=instance_id)
             elif isinstance(e, nova_exception.BadRequest):
-                raise exception.InvalidInput(reason=six.text_type(e))
+                raise exception.InvalidInput(reason=str(e))
             else:
                 raise exception.ManilaException(e)
 
diff --git a/manila/data/manager.py b/manila/data/manager.py
index baa06bcbf3..f775135715 100644
--- a/manila/data/manager.py
+++ b/manila/data/manager.py
@@ -20,7 +20,6 @@ import os
 
 from oslo_config import cfg
 from oslo_log import log
-import six
 
 from manila.common import constants
 from manila import context
@@ -143,7 +142,7 @@ class DataManager(manager.Manager):
             LOG.info("Obtained following data copy information "
                      "of share %(share)s: %(info)s.",
                      {'share': share_id,
-                      'info': six.text_type(result)})
+                      'info': result})
             return result
         else:
             msg = _("Migration of share %s data copy progress cannot be "
diff --git a/manila/db/migrations/alembic/versions/5077ffcc5f1c_add_share_instances.py b/manila/db/migrations/alembic/versions/5077ffcc5f1c_add_share_instances.py
index 39b7b8e3ee..42d26b75e9 100644
--- a/manila/db/migrations/alembic/versions/5077ffcc5f1c_add_share_instances.py
+++ b/manila/db/migrations/alembic/versions/5077ffcc5f1c_add_share_instances.py
@@ -28,7 +28,6 @@ down_revision = '3db9992c30f3'
 
 from alembic import op
 from sqlalchemy import Column, DateTime, ForeignKey, String
-import six
 
 from manila.db.migrations import utils
 
@@ -241,7 +240,7 @@ def upgrade_export_locations_table(connection):
         op.execute(
             share_el_table.update().where(
                 share_el_table.c.id == export.id
-            ).values({'share_instance_id': six.text_type(share_instance.id)})
+            ).values({'share_instance_id': str(share_instance.id)})
         )
     with op.batch_alter_table("share_export_locations") as batch_op:
         batch_op.drop_constraint('sel_id_fk', type_='foreignkey')
@@ -272,7 +271,7 @@ def downgrade_export_locations_table(connection):
         op.execute(
             share_el_table.update().where(
                 share_el_table.c.id == export.id
-            ).values({'share_id': six.text_type(share_instance.share_id)})
+            ).values({'share_id': str(share_instance.share_id)})
         )
 
     with op.batch_alter_table("share_export_locations") as batch_op:
diff --git a/manila/db/sqlalchemy/api.py b/manila/db/sqlalchemy/api.py
index 7d8ccb699a..3e5c9377bd 100644
--- a/manila/db/sqlalchemy/api.py
+++ b/manila/db/sqlalchemy/api.py
@@ -39,7 +39,6 @@ from oslo_log import log
 from oslo_utils import excutils
 from oslo_utils import timeutils
 from oslo_utils import uuidutils
-import six
 from sqlalchemy import MetaData
 from sqlalchemy import or_
 from sqlalchemy.orm import joinedload
@@ -2023,7 +2022,7 @@ def _metadata_refs(metadata_dict, meta_class):
     metadata_refs = []
     if metadata_dict:
         for k, v in metadata_dict.items():
-            value = six.text_type(v) if isinstance(v, bool) else v
+            value = str(v) if isinstance(v, bool) else v
 
             metadata_ref = meta_class()
             metadata_ref['key'] = k
@@ -2516,8 +2515,8 @@ def _check_for_existing_access(context, resource, resource_id, access_type,
 
             matching_rules = [
                 rule for rule in rules if
-                ipaddress.ip_network(six.text_type(access_to)) ==
-                ipaddress.ip_network(six.text_type(rule['access_to']))
+                ipaddress.ip_network(str(access_to)) ==
+                ipaddress.ip_network(str(rule['access_to']))
             ]
             return len(matching_rules) > 0
         else:
@@ -2842,7 +2841,7 @@ def _share_snapshot_get_all_with_filters(context, project_id=None,
             msg = _("Wrong 'usage' key provided - '%(key)s'. "
                     "Expected keys are '%(ek)s'.") % {
                         'key': filters['usage'],
-                        'ek': six.text_type(usage_filter_keys)}
+                        'ek': usage_filter_keys}
             raise exception.InvalidInput(reason=msg)
 
     # Apply sorting
@@ -3221,7 +3220,7 @@ def share_snapshot_instance_export_locations_update(
     export_locations_as_dicts = []
     for el in export_locations:
         export_location = el
-        if isinstance(el, six.string_types):
+        if isinstance(el, str):
             export_location = {
                 "path": el,
                 "is_admin_only": False,
@@ -3496,7 +3495,7 @@ def share_export_locations_update(context, share_instance_id, export_locations,
     for el in export_locations:
         # NOTE(vponomaryov): transform old export locations view to new one
         export_location = el
-        if isinstance(el, six.string_types):
+        if isinstance(el, str):
             export_location = {
                 "path": el,
                 "is_admin_only": False,
@@ -4216,7 +4215,7 @@ def driver_private_data_update(context, entity_id, details,
             in_new_details = data_ref['key'] in new_details
 
             if in_new_details:
-                new_value = six.text_type(new_details.pop(data_ref['key']))
+                new_value = str(new_details.pop(data_ref['key']))
                 data_ref.update({
                     "value": new_value,
                     "deleted": 0,
@@ -4235,7 +4234,7 @@ def driver_private_data_update(context, entity_id, details,
             data_ref.update({
                 "entity_uuid": entity_id,
                 "key": key,
-                "value": six.text_type(value)
+                "value": str(value)
             })
             data_ref.save(session=session)
 
@@ -4808,7 +4807,7 @@ def purge_deleted_records(context, age_in_days):
             try:
                 mds = [m for m in models.__dict__.values() if
                        (hasattr(m, '__tablename__') and
-                        m.__tablename__ == six.text_type(table))]
+                        m.__tablename__ == str(table))]
                 if len(mds) > 0:
                     # collect all soft-deleted records
                     with session.begin_nested():
@@ -4949,12 +4948,12 @@ def share_group_get_all_by_share_server(context, share_server_id, filters=None,
 def share_group_create(context, values):
     share_group = models.ShareGroup()
     if not values.get('id'):
-        values['id'] = six.text_type(uuidutils.generate_uuid())
+        values['id'] = uuidutils.generate_uuid()
 
     mappings = []
     for item in values.get('share_types') or []:
         mapping = models.ShareGroupShareTypeMapping()
-        mapping['id'] = six.text_type(uuidutils.generate_uuid())
+        mapping['id'] = uuidutils.generate_uuid()
         mapping['share_type_id'] = item
         mapping['share_group_id'] = values['id']
         mappings.append(mapping)
@@ -5208,7 +5207,7 @@ def share_group_snapshot_get_all_by_project(
 def share_group_snapshot_create(context, values):
     share_group_snapshot = models.ShareGroupSnapshot()
     if not values.get('id'):
-        values['id'] = six.text_type(uuidutils.generate_uuid())
+        values['id'] = uuidutils.generate_uuid()
 
     session = get_session()
     with session.begin():
@@ -5267,7 +5266,7 @@ def share_group_snapshot_member_get(context, member_id, session=None):
 def share_group_snapshot_member_create(context, values):
     member = models.ShareSnapshotInstance()
     if not values.get('id'):
-        values['id'] = six.text_type(uuidutils.generate_uuid())
+        values['id'] = uuidutils.generate_uuid()
 
     _change_size_to_instance_size(values)
 
@@ -5319,7 +5318,7 @@ def share_group_type_create(context, values, projects=None):
                 if not share_type:
                     raise exception.ShareTypeDoesNotExist(share_type=item)
                 mapping = models.ShareGroupTypeShareTypeMapping()
-                mapping['id'] = six.text_type(uuidutils.generate_uuid())
+                mapping['id'] = uuidutils.generate_uuid()
                 mapping['share_type_id'] = share_type['id']
                 mapping['share_group_type_id'] = values['id']
                 mappings.append(mapping)
diff --git a/manila/message/api.py b/manila/message/api.py
index 1b7e63c96e..3c11f4c52a 100644
--- a/manila/message/api.py
+++ b/manila/message/api.py
@@ -17,7 +17,6 @@ import datetime
 from oslo_config import cfg
 from oslo_log import log as logging
 from oslo_utils import timeutils
-import six
 
 from manila.db import base
 from manila.message import message_field
@@ -76,8 +75,7 @@ class API(base.Base):
     def get_all(self, context, search_opts=None, limit=None,
                 offset=None, sort_key=None, sort_dir=None):
         """Return messages for the given context."""
-        LOG.debug("Searching for messages by: %s",
-                  six.text_type(search_opts))
+        LOG.debug("Searching for messages by: %s", search_opts)
 
         search_opts = search_opts or {}
         messages = self.db.message_get_all(context, filters=search_opts,
diff --git a/manila/network/__init__.py b/manila/network/__init__.py
index 343fb6cc53..2996627482 100644
--- a/manila/network/__init__.py
+++ b/manila/network/__init__.py
@@ -17,7 +17,6 @@ import abc
 
 from oslo_config import cfg
 from oslo_utils import importutils
-import six
 
 from manila.db import base as db_base
 from manila import exception
@@ -64,8 +63,7 @@ def API(config_group_name=None, label='user'):
     return cls(config_group_name=config_group_name, label=label)
 
 
-@six.add_metaclass(abc.ABCMeta)
-class NetworkBaseAPI(db_base.Base):
+class NetworkBaseAPI(db_base.Base, metaclass=abc.ABCMeta):
     """User network plugin for setting up main net interfaces."""
 
     def __init__(self, config_group_name=None, db_driver=None):
@@ -75,7 +73,7 @@ class NetworkBaseAPI(db_base.Base):
         else:
             CONF.register_opts(network_base_opts)
         self.configuration = getattr(CONF,
-                                     six.text_type(config_group_name), CONF)
+                                     str(config_group_name), CONF)
         super(NetworkBaseAPI, self).__init__(db_driver=db_driver)
 
     def _verify_share_network(self, share_server_id, share_network):
diff --git a/manila/network/linux/interface.py b/manila/network/linux/interface.py
index f254849ccf..16302166ca 100644
--- a/manila/network/linux/interface.py
+++ b/manila/network/linux/interface.py
@@ -18,7 +18,6 @@ import abc
 import netaddr
 from oslo_config import cfg
 from oslo_log import log
-import six
 
 from manila import exception
 from manila.i18n import _
@@ -54,8 +53,7 @@ def device_name_synchronized(f):
     return wrapped_func
 
 
-@six.add_metaclass(abc.ABCMeta)
-class LinuxInterfaceDriver(object):
+class LinuxInterfaceDriver(metaclass=abc.ABCMeta):
 
     # from linux IF_NAMESIZE
     DEV_NAME_LEN = 14
@@ -117,14 +115,14 @@ class LinuxInterfaceDriver(object):
             # this is a concurrency problem, it would not fix the problem.
             addr_list = device.addr.list()
         except Exception as e:
-            if 'does not exist' in six.text_type(e):
+            if 'does not exist' in str(e):
                 LOG.warning(
                     "Device %s does not exist anymore.", device.name)
             else:
                 raise
         for addr in addr_list:
             if addr['ip_version'] == 4:
-                cidrs.add(six.text_type(netaddr.IPNetwork(addr['cidr']).cidr))
+                cidrs.add(str(netaddr.IPNetwork(addr['cidr']).cidr))
         return cidrs
 
     def check_bridge_exists(self, bridge):
diff --git a/manila/network/linux/ip_lib.py b/manila/network/linux/ip_lib.py
index 543ea3138d..3d246c7cde 100644
--- a/manila/network/linux/ip_lib.py
+++ b/manila/network/linux/ip_lib.py
@@ -14,7 +14,6 @@
 #    under the License.
 
 import netaddr
-import six
 
 from manila.i18n import _
 from manila import utils
@@ -462,7 +461,7 @@ def device_exists(device_name, namespace=None):
     try:
         address = IPDevice(device_name, namespace).link.address
     except Exception as e:
-        if 'does not exist' in six.text_type(e):
+        if 'does not exist' in str(e):
             return False
         raise
     return bool(address)
diff --git a/manila/network/neutron/neutron_network_plugin.py b/manila/network/neutron/neutron_network_plugin.py
index 3ef031221f..d56ff4d442 100644
--- a/manila/network/neutron/neutron_network_plugin.py
+++ b/manila/network/neutron/neutron_network_plugin.py
@@ -15,7 +15,6 @@
 #    under the License.
 
 import ipaddress
-import six
 import socket
 
 from oslo_config import cfg
@@ -189,7 +188,7 @@ class NeutronNetworkPlugin(network.NetworkBaseAPI):
             remaining_allocations, port_list)
 
         LOG.debug("Found matching allocations in Neutron:"
-                  " %s", six.text_type(selected_ports))
+                  " %s", selected_ports)
 
         for selected_port in selected_ports:
             port_dict = {
@@ -275,7 +274,7 @@ class NeutronNetworkPlugin(network.NetworkBaseAPI):
 
         for ip in fixed_ips:
             try:
-                address = ipaddress.ip_address(six.text_type(ip['ip_address']))
+                address = ipaddress.ip_address(str(ip['ip_address']))
                 if address.version == ip_version:
                     return ip['ip_address']
             except ValueError:
diff --git a/manila/network/standalone_network_plugin.py b/manila/network/standalone_network_plugin.py
index 528855451e..acc468aed6 100644
--- a/manila/network/standalone_network_plugin.py
+++ b/manila/network/standalone_network_plugin.py
@@ -16,7 +16,6 @@
 import netaddr
 from oslo_config import cfg
 from oslo_log import log
-import six
 
 from manila.common import constants
 from manila import exception
@@ -107,7 +106,7 @@ class StandaloneNetworkPlugin(network.NetworkBaseAPI):
             dict(
                 config_group=self.config_group_name,
                 ip_version=self.ip_version,
-                net=six.text_type(self.net),
+                net=str(self.net),
                 gateway=self.gateway,
                 network_type=self.network_type,
                 segmentation_id=self.segmentation_id,
@@ -152,18 +151,18 @@ class StandaloneNetworkPlugin(network.NetworkBaseAPI):
         self.net = self._get_network()
         self.allowed_cidrs = self._get_list_of_allowed_addresses()
         self.reserved_addresses = (
-            six.text_type(self.net.network),
+            str(self.net.network),
             self.gateway,
-            six.text_type(self.net.broadcast))
+            str(self.net.broadcast))
         self.mtu = self.configuration.standalone_network_plugin_mtu
 
     def _get_network(self):
         """Returns IPNetwork object calculated from gateway and netmask."""
-        if not isinstance(self.gateway, six.string_types):
+        if not isinstance(self.gateway, str):
             raise exception.NetworkBadConfigurationException(
                 _("Configuration option 'standalone_network_plugin_gateway' "
                   "is required and has improper value '%s'.") % self.gateway)
-        if not isinstance(self.mask, six.string_types):
+        if not isinstance(self.mask, str):
             raise exception.NetworkBadConfigurationException(
                 _("Configuration option 'standalone_network_plugin_mask' is "
                   "required and has improper value '%s'.") % self.mask)
@@ -213,8 +212,8 @@ class StandaloneNetworkPlugin(network.NetworkBaseAPI):
 
                 if range_instance not in self.net:
                     data = dict(
-                        range=six.text_type(range_instance),
-                        net=six.text_type(self.net),
+                        range=str(range_instance),
+                        net=str(self.net),
                         gateway=self.gateway,
                         netmask=self.net.netmask)
                     msg = _("One of provided allowed IP ranges ('%(range)s') "
@@ -225,14 +224,14 @@ class StandaloneNetworkPlugin(network.NetworkBaseAPI):
                         reason=msg)
 
                 cidrs.extend(
-                    six.text_type(cidr) for cidr in range_instance.cidrs())
+                    str(cidr) for cidr in range_instance.cidrs())
         else:
             if self.net.version != self.ip_version:
                 msg = _("Configured invalid IP version '%(conf_v)s', network "
                         "has version ""'%(net_v)s'") % dict(
                             conf_v=self.ip_version, net_v=self.net.version)
                 raise exception.NetworkBadConfigurationException(reason=msg)
-            cidrs.append(six.text_type(self.net))
+            cidrs.append(str(self.net))
 
         return cidrs
 
@@ -247,7 +246,7 @@ class StandaloneNetworkPlugin(network.NetworkBaseAPI):
             return ips
         iterator = netaddr.iter_unique_ips(*self.allowed_cidrs)
         for ip in iterator:
-            ip = six.text_type(ip)
+            ip = str(ip)
             if (ip in self.reserved_addresses or
                     self.db.network_allocations_get_by_ip_address(context,
                                                                   ip)):
@@ -269,8 +268,8 @@ class StandaloneNetworkPlugin(network.NetworkBaseAPI):
         data = {
             'network_type': self.network_type,
             'segmentation_id': self.segmentation_id,
-            'cidr': six.text_type(self.net.cidr),
-            'gateway': six.text_type(self.gateway),
+            'cidr': str(self.net.cidr),
+            'gateway': str(self.gateway),
             'ip_version': self.ip_version,
             'mtu': self.mtu,
         }
@@ -345,7 +344,7 @@ class StandaloneNetworkPlugin(network.NetworkBaseAPI):
 
         for ip in ips:
             if any(ip in cidr for cidr in cidrs):
-                allocation = six.text_type(ip)
+                allocation = str(ip)
                 selected_allocations.append(allocation)
 
         for allocation in selected_allocations:
diff --git a/manila/scheduler/evaluator/evaluator.py b/manila/scheduler/evaluator/evaluator.py
index 2b6d3d446b..431cebfc5e 100644
--- a/manila/scheduler/evaluator/evaluator.py
+++ b/manila/scheduler/evaluator/evaluator.py
@@ -17,7 +17,6 @@ import operator
 import re
 
 import pyparsing
-import six
 
 from manila import exception
 from manila.i18n import _
@@ -40,16 +39,16 @@ class EvalConstant(object):
 
     def eval(self):
         result = self.value
-        if (isinstance(result, six.string_types) and
+        if (isinstance(result, str) and
                 re.match(r"^[a-zA-Z_]+\.[a-zA-Z_]+$", result)):
             (which_dict, entry) = result.split('.')
             try:
                 result = _vars[which_dict][entry]
             except KeyError as e:
-                msg = _("KeyError: %s") % six.text_type(e)
+                msg = _("KeyError: %s") % e
                 raise exception.EvaluatorParseException(reason=msg)
             except TypeError as e:
-                msg = _("TypeError: %s") % six.text_type(e)
+                msg = _("TypeError: %s") % e
                 raise exception.EvaluatorParseException(reason=msg)
 
         try:
@@ -58,7 +57,7 @@ class EvalConstant(object):
             try:
                 result = float(result)
             except ValueError as e:
-                msg = _("ValueError: %s") % six.text_type(e)
+                msg = _("ValueError: %s") % e
                 raise exception.EvaluatorParseException(reason=msg)
 
         return result
@@ -104,7 +103,7 @@ class EvalMultOp(object):
                 elif op == '/':
                     prod /= float(val.eval())
             except ZeroDivisionError as e:
-                msg = _("ZeroDivisionError: %s") % six.text_type(e)
+                msg = _("ZeroDivisionError: %s") % e
                 raise exception.EvaluatorParseException(reason=msg)
         return prod
 
@@ -292,7 +291,7 @@ def evaluate(expression, **kwargs):
     try:
         result = _parser.parseString(expression, parseAll=True)[0]
     except pyparsing.ParseException as e:
-        msg = _("ParseException: %s") % six.text_type(e)
+        msg = _("ParseException: %s") % e
         raise exception.EvaluatorParseException(reason=msg)
 
     return result.eval()
diff --git a/manila/scheduler/filters/driver.py b/manila/scheduler/filters/driver.py
index 539bad76dd..483383a0fd 100644
--- a/manila/scheduler/filters/driver.py
+++ b/manila/scheduler/filters/driver.py
@@ -13,8 +13,6 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import six
-
 from oslo_log import log as logging
 
 from manila.scheduler.evaluator import evaluator
@@ -69,7 +67,7 @@ class DriverFilter(base_host.BaseHostFilter):
 
         msg = "Filter function result for host %(host)s: %(result)s."
         args = {'host': stats['host_stats']['host'],
-                'result': six.text_type(filter_result)}
+                'result': str(filter_result)}
         LOG.info(msg, args)
 
         return filter_result
@@ -97,7 +95,7 @@ class DriverFilter(base_host.BaseHostFilter):
 
         if ('filter_function' in host_state.capabilities and
                 host_state.capabilities['filter_function'] is not None):
-            filter_function = six.text_type(
+            filter_function = str(
                 host_state.capabilities['filter_function'])
 
         stats = utils.generate_stats(host_state, filter_properties)
diff --git a/manila/scheduler/filters/extra_specs_ops.py b/manila/scheduler/filters/extra_specs_ops.py
index 429caf99ea..df76b032ee 100644
--- a/manila/scheduler/filters/extra_specs_ops.py
+++ b/manila/scheduler/filters/extra_specs_ops.py
@@ -14,7 +14,6 @@
 #    under the License.
 
 import operator
-import six
 
 from oslo_utils import strutils
 
@@ -41,7 +40,7 @@ _op_methods = {'=': lambda x, y: float(x) >= float(y),
 
 def match(value, req):
     # Make case-insensitive
-    if (isinstance(value, six.string_types)):
+    if (isinstance(value, str)):
         value = value.lower()
     req = req.lower()
     words = req.split()
diff --git a/manila/scheduler/filters/json.py b/manila/scheduler/filters/json.py
index 48e2359cd2..e654ae749d 100644
--- a/manila/scheduler/filters/json.py
+++ b/manila/scheduler/filters/json.py
@@ -16,7 +16,6 @@
 import operator
 
 from oslo_serialization import jsonutils
-import six
 
 from manila.scheduler.filters import base_host
 
@@ -121,7 +120,7 @@ class JsonFilter(base_host.BaseHostFilter):
         for arg in query[1:]:
             if isinstance(arg, list):
                 arg = self._process_filter(arg, host_state)
-            elif isinstance(arg, six.string_types):
+            elif isinstance(arg, str):
                 arg = self._parse_string(arg, host_state)
             if arg is not None:
                 cooked_args.append(arg)
diff --git a/manila/scheduler/host_manager.py b/manila/scheduler/host_manager.py
index 2ef081bedb..320811d480 100644
--- a/manila/scheduler/host_manager.py
+++ b/manila/scheduler/host_manager.py
@@ -29,7 +29,6 @@ except ImportError:
 from oslo_config import cfg
 from oslo_log import log
 from oslo_utils import timeutils
-import six
 
 from manila import db
 from manila import exception
@@ -373,11 +372,11 @@ class HostState(object):
 
         self.allocated_capacity_gb += share['size']
 
-        if (isinstance(self.free_capacity_gb, six.string_types)
+        if (isinstance(self.free_capacity_gb, str)
                 and self.free_capacity_gb != 'unknown'):
             raise exception.InvalidCapacity(
                 name='free_capacity_gb',
-                value=six.text_type(self.free_capacity_gb)
+                value=self.free_capacity_gb
             )
 
         if self.free_capacity_gb != 'unknown':
diff --git a/manila/scheduler/weighers/base.py b/manila/scheduler/weighers/base.py
index f45264a8ff..6aa0b8eb15 100644
--- a/manila/scheduler/weighers/base.py
+++ b/manila/scheduler/weighers/base.py
@@ -19,8 +19,6 @@ Pluggable Weighing support
 
 import abc
 
-import six
-
 from manila.scheduler import base_handler
 
 
@@ -63,8 +61,7 @@ class WeighedObject(object):
         return "<WeighedObject '%s': %s>" % (self.obj, self.weight)
 
 
-@six.add_metaclass(abc.ABCMeta)
-class BaseWeigher(object):
+class BaseWeigher(metaclass=abc.ABCMeta):
     """Base class for pluggable weighers.
 
     The attributes maxval and minval can be specified to set up the maximum
diff --git a/manila/scheduler/weighers/goodness.py b/manila/scheduler/weighers/goodness.py
index 6801fac9f8..5966c4d7da 100644
--- a/manila/scheduler/weighers/goodness.py
+++ b/manila/scheduler/weighers/goodness.py
@@ -14,7 +14,6 @@
 #    under the License.
 
 from oslo_log import log as logging
-import six
 
 from manila.scheduler.evaluator import evaluator
 from manila.scheduler import utils
@@ -85,7 +84,7 @@ class GoodnessWeigher(base_host.BaseHostWeigher):
 
         msg = "Goodness function result for host %(host)s: %(result)s."
         args = {'host': stats['host_stats']['host'],
-                'result': six.text_type(goodness_rating)}
+                'result': str(goodness_rating)}
         LOG.info(msg, args)
 
         return goodness_rating
@@ -113,7 +112,7 @@ class GoodnessWeigher(base_host.BaseHostWeigher):
 
         if ('goodness_function' in host_state.capabilities and
                 host_state.capabilities['goodness_function'] is not None):
-            goodness_function = six.text_type(
+            goodness_function = str(
                 host_state.capabilities['goodness_function'])
 
         stats = utils.generate_stats(host_state, weight_properties)