Skip to content

Commit

Permalink
Use o.vo VersionPredicateField
Browse files Browse the repository at this point in the history
As of o.vo 0.8.0, VersionPredicateField has been added, so nova can get
rid of its copy and use o.vo's

Change-Id: Iedc76a04ea31f1e575cdfebd0e5ab7ea18fac3d6
  • Loading branch information
Ryan Rossiter committed Nov 18, 2015
1 parent 1b3fbfb commit 3c83a47
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 31 deletions.
20 changes: 1 addition & 19 deletions nova/objects/fields.py
Expand Up @@ -13,7 +13,6 @@
# under the License.

from collections import OrderedDict
from distutils import versionpredicate

import netaddr
from oslo_utils import strutils
Expand Down Expand Up @@ -57,6 +56,7 @@
DictProxyField = fields.DictProxyField
ObjectField = fields.ObjectField
ListOfObjectsField = fields.ListOfObjectsField
VersionPredicateField = fields.VersionPredicateField


# NOTE(danms): These are things we need to import for some of our
Expand Down Expand Up @@ -383,19 +383,6 @@ def __init__(self):
valid_values=MonitorMetricType.ALL)


# NOTE(sbauza): Remove this on next release of oslo.versionedobjects
class VersionPredicate(fields.String):
@staticmethod
def coerce(obj, attr, value):
try:
versionpredicate.VersionPredicate('check (%s)' % value)
except ValueError:
raise ValueError(_('Version %(val)s is not a valid predicate in '
'field %(attr)s') %
{'val': value, 'attr': attr})
return value


class PciDeviceStatus(Enum):

AVAILABLE = "available"
Expand Down Expand Up @@ -667,11 +654,6 @@ class MonitorMetricTypeField(BaseEnumField):
AUTO_TYPE = MonitorMetricType()


# FIXME(sbauza): Remove this after oslo.versionedobjects gets it
class VersionPredicateField(AutoTypedField):
AUTO_TYPE = VersionPredicate()


class PciDeviceStatusField(BaseEnumField):
AUTO_TYPE = PciDeviceStatus()

Expand Down
12 changes: 0 additions & 12 deletions nova/tests/unit/objects/test_fields.py
Expand Up @@ -582,18 +582,6 @@ def test_stringify_invalid(self):
self.assertRaises(ValueError, self.field.stringify, 'cpufrequency')


class TestVersionPredicate(TestString):
def setUp(self):
super(TestVersionPredicate, self).setUp()
self.field = fields.VersionPredicateField()
self.coerce_good_values = [('>=1.0', '>=1.0'),
('==1.1', '==1.1'),
('<1.1.0', '<1.1.0')]
self.coerce_bad_values = ['1', 'foo', '>1', 1.0, '1.0', '=1.0']
self.to_primitive_values = self.coerce_good_values[0:1]
self.from_primitive_values = self.coerce_good_values[0:1]


class TestInteger(TestField):
def setUp(self):
super(TestInteger, self).setUp()
Expand Down

0 comments on commit 3c83a47

Please sign in to comment.