From: Akihiro Motoki Date: Fri, 20 Nov 2015 05:08:34 +0000 (+0900) Subject: Replace neutron-specific LengthStrOpt with StrOpt X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=c7528a9986d0dfe65e2231dd3e6ecf3159d9d6cc;p=openstack-build%2Fneutron-build.git Replace neutron-specific LengthStrOpt with StrOpt max_length option was added to StrOpt in oslo.config 2.7.0. Neutron-specific LengthStrOpt is no longer required. Change-Id: Icfecb5c8c68c942fca847e27a0c1862f18bdcdca Closes-Bug: #1518178 --- diff --git a/neutron/agent/common/config.py b/neutron/agent/common/config.py index 5aaedd71c..fcb063d06 100644 --- a/neutron/agent/common/config.py +++ b/neutron/agent/common/config.py @@ -16,7 +16,6 @@ import os from oslo_config import cfg -from oslo_config import types from oslo_log import log as logging from neutron.common import config @@ -68,35 +67,11 @@ PROCESS_MONITOR_OPTS = [ '(seconds), use 0 to disable')), ] - -# TODO(hichihara): Remove these two classes, once oslo fixes types.string -# and cfg.StrOpt. -class LengthString(types.String): - def __init__(self, maxlen=None): - super(LengthString, self).__init__() - self.maxlen = maxlen - - def __call__(self, value): - value = super(LengthString, self).__call__(value) - if self.maxlen and len(value) > self.maxlen: - raise ValueError(_("String value '%(value)s' exceeds max length " - "%(len)d") % {'value': value, - 'len': self.maxlen}) - return value - - -class LengthStrOpt(cfg.Opt): - def __init__(self, name, maxlen=None, **kwargs): - super(LengthStrOpt, self).__init__(name, - type=LengthString(maxlen=maxlen), - **kwargs) - - AVAILABILITY_ZONE_OPTS = [ # The default AZ name "nova" is selected to match the default # AZ name in Nova and Cinder. - LengthStrOpt('availability_zone', maxlen=255, default='nova', - help=_("Availability zone of this node")), + cfg.StrOpt('availability_zone', max_length=255, default='nova', + help=_("Availability zone of this node")), ]