]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Replace neutron-specific LengthStrOpt with StrOpt
authorAkihiro Motoki <motoki@da.jp.nec.com>
Fri, 20 Nov 2015 05:08:34 +0000 (14:08 +0900)
committerAkihiro Motoki <motoki@da.jp.nec.com>
Fri, 20 Nov 2015 05:29:47 +0000 (14:29 +0900)
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

neutron/agent/common/config.py

index 5aaedd71c645a7151bf9fa920a3266d456853df0..fcb063d0687db30519e5006f947c526285471a70 100644 (file)
@@ -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")),
 ]