4471 Commits

Author SHA1 Message Date
Neil Jerram
aaa59b0bb6 Fix "comparason" typo in doc for ComparableVersionedObject
Change-Id: I4a8d05a9fac62bca92e79c24e6552bcc3c70d800
2015-06-22 12:32:14 +01:00
OpenStack Proposal Bot
e7918611bb Updated from global requirements
Change-Id: Ib4c5594751b7fda4470cc3c13b865e6fef567a12
2015-06-22 08:27:22 +00:00
Alexander Tivelkov
2da963c3b3 Compound fields now coerce their elements' values
Added a special datastructures (CoercedList, CoercedDict and CoercedSet)
which are able to coerce their values to appropriate element type.
The instances of these structures are returned when the values of
appropriate compound fields initially coerced. As a result, all
subsequent calls which are going to add new elements to the fields'
colelctions will be processed by the overridden methods of new
datastructures, thus the new elements will be coerced and the exceptions
risen if the coercing is not possible.

This also fixes a bug in TestObjMakeList which was specifying incorrect
obj_name for the elements in 'objects' collection of MyList test class.
It was not leading to failures as the items of this collection were not
being coerced  prior to this patch.

Change-Id: I004646ce643e7e51305cfb1cd4eb5e8647a83513
Closes-Bug: #1466057
2015-06-21 13:31:27 +03:00
Daniel P. Berrange
4f22c09499 fields: report what the wrong type was when coerce fails
The coerce method impls all raise an exception when the
python type provided for a field does not match what was
required. Sometimes it is pretty hard to figure out what
the wrong type was, so report this along with the desired
type

This changes the exception message from something like

 "A datetime.datetime is required in field start"

to

 "A datetime.datetime is required in field start, not a str"

which can help debugging.

Change-Id: I53535e7af2165285ef1804f03f0beebe8fc42a59
2015-06-18 17:01:34 +01:00
OpenStack Proposal Bot
5347feb6b8 Updated from global requirements
Change-Id: Ifb75591024ed0047ed1a893b5280f5d719d27ed2
2015-06-16 19:22:35 +00:00
Davanum Srinivas
4f1007a661 Decouple ObjectVersionChecker and VersionedObjectRegistry
ObjectVersionChecker just needs a list of classes, we don't need
to check the base.VersionedObjectRegistry everytime, so just
initialize the list of classes in the constructor and default
it to the base.VersionedObjectRegistry to get the current
behavior. Will make it easy to run ObjectVersionChecker against
custom registries.

Change-Id: I700daa278473dff5285e0b21afffc03671e390f9
2015-06-11 07:07:42 -04:00
OpenStack Proposal Bot
855a31b975 Updated from global requirements
Change-Id: I9fb197206d245a7850ecd98ac1ce79618a4ae93f
2015-06-09 20:04:31 +00:00
Davanum Srinivas
e61a3d3524 Remove unnecessary openstack-common.conf
Change-Id: I73cc63851d4e618f01e632cef812ca3817a357f9
0.4.0
2015-06-08 06:18:56 -04:00
OpenStack Proposal Bot
dec261fb37 Updated from global requirements
Change-Id: I62e2137e7143e986088b7109a9b18c26541c6f18
2015-06-03 17:38:29 +00:00
Jenkins
13abcc9eef Merge "fields: introduce BaseEnumField to allow subclassing" 2015-06-02 16:18:02 +00:00
Jenkins
b428392619 Merge "fields: add a FlexibleBoolean field type" 2015-06-02 16:15:16 +00:00
OpenStack Proposal Bot
a03c63598b Imported Translations from Transifex
For more information about this automatic import see:
https://wiki.openstack.org/wiki/Translations/Infrastructure

Change-Id: I5e07463572aff2d62e8924e597e1584412d31b83
0.3.0
2015-05-29 06:03:25 +00:00
OpenStack Proposal Bot
e7d0881c59 Imported Translations from Transifex
For more information about this automatic import see:
https://wiki.openstack.org/wiki/Translations/Infrastructure

Change-Id: I5e73fa072b9dd31f726c004c6d63111dbf7dcbf1
2015-05-28 06:03:39 +00:00
Daniel P. Berrange
ab13d2f6ea fields: introduce BaseEnumField to allow subclassing
Currently, objects will directly instantiate the EnumField
class, passing in the list of valid enum values. This is
sub-optimal as the same enum type may be needed in several
objects, and we want to ensure we're always using the same
list of valid values.

To address this, introduce a BaseEnumField class that provides
the custom __repr__() impl based on the enum values. Make the
existing EnumField subclass this, to allow for continued use
of anonymous enum fields, but discourage its use in favour of
creating named enum fields by directly subclassing BaseEnumField

Change-Id: I83199b0f791d3ac5591c7dfc1d14f4fa706d0a64
2015-05-19 14:55:32 +01:00
Daniel P. Berrange
df0cfdca52 fields: add a FlexibleBoolean field type
The current Boolean field type has a strict interpretation of
truth values which matches the python language interpretation.

For data that comes from the end user though, it is more useful
to have a flexible interpretation, that accepts commonly used
strings like 'yes', 'no', 'on', 'off', etc as handled by the
oslo_utils  bool_from_string() method

Since the Boolean field is part of the ABI/API, we cannot
change its semantics, so this introduces new FlexibleBoolean
and FlexibleBooleanField classes

Change-Id: Id785cdd99eca5ac469db9d7b4759957461873cee
2015-05-18 17:32:00 +01:00
Jenkins
c314bf34b1 Merge "Enhance documentation" 2015-05-15 17:24:51 +00:00
Jenkins
b91d7cab1c Merge "Add delattr support" 2015-05-15 14:15:06 +00:00
Victor Stinner
e2b9b2a9bc Enhance documentation
Rewrite README.rst and copy it to doc/source/index.rst to add a little
bit more content.

Generate documentation for APIs. fixture, safe_utils and test submodules
are not documented.

Fix indentation in obj_reset_changes() docstring.

Fix formatting of obj_make_list() docstring.

Co-Authored-By: Dan Smith <dansmith@redhat.com>
Change-Id: I8110919de072c5a5139e3797f256925c92656117
2015-05-15 11:32:15 +02:00
Dan Smith
1020b63655 Add delattr support
This allows deleting (unsetting) attributes on a VersionedObject.

Change-Id: I9643029a45135d532a0f734709ce93884ee08fd4
2015-05-14 08:23:11 -07:00
OpenStack Proposal Bot
ffef71d528 Imported Translations from Transifex
For more information about this automatic import see:
https://wiki.openstack.org/wiki/Translations/Infrastructure

Change-Id: Id8c048664c5f695640fce8dc9954180c5255144a
2015-05-14 06:08:21 +00:00
Victor Stinner
3ae09aebff Enhance dict compat of VersionedObjectDictCompat
Add more dictionary methods to VersionedObjectDictCompat:

 * __iter__()
 * keys(), iterkeys()
 * values(), itervalues()

Thanks to new methods, dict constructor now accepts
VersionedObjectDictCompat: it's possible to write directly dict(obj)
instead of having to write dict(obj.iteritems()).

On Python 3, items() now returns an iterator instead of a list, to
respect Python 3 dictionary API, as the new keys() and values() methods.

Keep iterkeys(), itervalues() and iteritems() on Python 3, even if
Python 3 dictionaries don't have these methods, just to ease the
transition from Python 2 to Python 3 in Nova.

Change-Id: I4c52d44c7ba49f98b1bbd123209fce7b70ade98d
2015-05-13 22:21:45 +02:00
Victor Stinner
1ff9ef63a9 Drop outdated notes and docstrings
VersionedObjectDictCompat code come from Nova. While Nova may drop the
dictionary compatibility, dropping a class in a library requires a
deprecation process, so notes are not really usefull.

Remove also useless docstrings: in oslo_versionedobjects, there is no
really "backward compatibility" issue since it's a new library. Again,
docstrings came from Nova, but I consider them useless in this library.

Replace also "compat" with "compatibility" in VersionedObjectDictCompat
docstring.

Change-Id: Ie42e9ef68f3acd657521454ff3cb5fbdc42ad416
2015-05-13 16:04:35 +02:00
Jenkins
f15cf79dad Merge "Add field name to error messages in object type checking" 2015-05-12 14:42:41 +00:00
Jenkins
280b073f5b Merge "Add enum fieldtype field" 2015-05-12 14:42:24 +00:00
Davanum Srinivas
224654429e Add field name to error messages in object type checking
The coerce() methods in object fields generate ValueError
exceptions if an incorrect type is used. Most of the messages
do not indicate which field was involved although that information
is available in the coerce() methods. This change adds the
field name to the error messages.

Ported from:
Ic94d52f6019c5a5a291675e321f96f5c65beaf10

Co-Authored-By: Paul Murray <pmurray@hp.com>
Closes-Bug:  #1430681

Change-Id: I4a359ea1478481e81f66c9c20e0bcac79ccd6a3a
2015-05-12 12:00:42 +00:00
Thomas Goirand
c7ff6a07cc Adds missing WebOb in requirements.txt
Unit tests are failing without it, and the file
oslo_versionedobjects/exception.py has:
import webob.exc

So it's looking like webob is missing from requirements.txt.
This patch fixes that. Note that this should be fixed in
the kilo branch later on.

Change-Id: Ib0ac48aeea4f8413740af89340e3b094312fa6b4
2015-05-09 22:46:22 +02:00
Davanum Srinivas
143c11d5a0 Add enum fieldtype field
In some case, one field should be limited to some value, like the
cpu architect field.

Make sure that when the value limitation is changed,
the fingerprint will be changed, so that a version bump should happen.

Ported (but changed for consistency) from:
I7848f8b934c169a76b1cfd875f7905273f9f914b

Co-Authored-By: yunhong jiang <yunhong.jiang@intel.com>
Co-Authored-By: Dan Smith <dansmith@redhat.com>
Change-Id: Iac498869d10d2238b3ddf704640cd152cb794099
2015-05-08 19:14:17 +00:00
Grzegorz Grasza
85bbdd8e95 Get the indirection_api from the current VersionedObject class
To avoid having to monkey-patch the VersionedObject class from the oslo
library, get the indirection_api from the current self or cls variables
(the class or instance inheriting from the VersionedObject class) in
remotable decorators.

Change-Id: I8fed628e3d82539e477b8b72532858095a9b8ef4
2015-05-06 16:06:29 +02:00
OpenStack Proposal Bot
8f5ca42d51 Updated from global requirements
Change-Id: Ib5efcf4adfaa73eab709e1ddac668c336fe594dc
2015-05-04 18:50:50 +00:00
OpenStack Proposal Bot
e6651c52e9 Imported Translations from Transifex
For more information about this automatic import see:
https://wiki.openstack.org/wiki/Translations/Infrastructure

Change-Id: I4cc185f441cb7a985a2988ae40ba054da97cd96d
2015-05-03 06:03:18 +00:00
Jenkins
4c0b0cb367 Merge "New config group for oslo_versionedobjects" 0.2.0 2015-04-21 14:24:47 +00:00
Jenkins
eec31cf5a1 Merge "Copy the default value for field" 2015-04-21 14:20:09 +00:00
Doug Hellmann
23d15eb8fc Uncap library requirements for liberty
Change-Id: Ifa56f9f6d721b06e8e725e6ebaaca0310ce4d4c5
Depends-On: Ib948b756b8e6ca47a4c9c44c48031e54b7386a06
2015-04-16 18:10:19 +00:00
Steve Martinelli
cfe2cd7dd1 Standardize setup.cfg summary for oslo libs
Rather than repeating the library name, have the summary use proper
names instead.

Change-Id: Ia27f842483a858791e97a59c7afd9eb2d378bf39
2015-04-04 02:05:55 -04:00
Doug Hellmann
29ac0fcaae Update to the latest version of hacking
Update the version of hacking to the one released for kilo, and fix
issues with code formatting that cause the new hacking checks to fail.

Change-Id: I4c9906df3e71f33b5a13e1f68584d445d79daceb
2015-04-03 14:08:13 +00:00
Davanum Srinivas
ae5558fbe7 Copy the default value for field
Port If8e73b92e798cc16cac4952974f5e6210c1bc5e1 from Nova

Currently the default value will be used for all instances of the nova
objects. We should return only a copy.

Co-Authored-By: yunhong jiang <yunhong.jiang@intel.com>
Change-Id: I64c0bee754706ed1ed1e6329217cc30d145d11b9
2015-03-28 11:16:59 -04:00
OpenStack Proposal Bot
2ccb13a3f1 Updated from global requirements
Change-Id: I9a217c16951d52eed2c326aec2ccd11af39240a4
2015-03-21 00:17:16 +00:00
Davanum Srinivas
1a6bea74f6 New config group for oslo_versionedobjects
Lot of projects use fatal_exception_format_errors, we
need to separate out ours in its own group.

Closes-Bug: #1433647
Change-Id: I7a53ed2c5b2387214c4edba7295cb800e12f47a9
2015-03-19 13:57:45 -04:00
Davanum Srinivas
36be0e5709 Sync from oslo-incubator
Pulling in changes to remove oslo namespace in _i18n module
and the list_opts for better configuration support with
oslo-config-generator in versionutils module

(Tip of oslo-incubator is change id - Id69701978d7a1701885bf17507a1f369e1035747)

Change-Id: Ibc793966fb442a870785186257ab44f1afc3e0b1
0.1.1
2015-03-12 15:41:24 +00:00
Dan Smith
4201a4f980 Properly serialize/deserialize arguments in fake indirection api
The fixture was just serializing and deserializing method arguments
with JSON, but this is not indicative of what actually happens in
a real project (like nova) where arguments can be objects.

Change-Id: I299983a2e345a2b8075038553c6a4dd77d3fd5e8
2015-02-26 15:26:49 -08:00
Dan Smith
0b4668f90c Allow passing serializer and indirection API objects to Fixture
This makes it easier to ensure that you're using the same indirection
or serialization routines in tests as you are in production.

Change-Id: I4530ba5781ad81ad4a6b4af466af348551c3c3e4
2015-02-26 14:37:42 -08:00
Dan Smith
a63ef59bd4 Make serializer use the provided base class for the indirection api
This was found when converting nova to use o.vo. If we provide our own
base class (for namespacing reasons) we need the serializer to use it
(as intended) to find the indirection_api.

Change-Id: I480427fe97476e4e20fef453be6bb6ed28ae51ac
2015-02-26 14:21:34 -08:00
Jenkins
03017c94e2 Merge "Update README.rst" 0.1.0 2015-02-25 18:04:33 +00:00
Jenkins
fbaaa7ff3f Merge "Remove serialize_args(), per the work items" 2015-02-25 17:36:17 +00:00
Grzegorz Grasza
473e92f9ff Update README.rst
Add a description of what this library can be used for.

Change-Id: Ieb0c4123cf4a65e9ab75ff1582ef9deed8060ea5
2015-02-25 16:25:30 +01:00
Dan Smith
053c35c727 Remove serialize_args(), per the work items
This was another pretty Nova-specific helper function that embedded
serialization of certain data types in method arguments.

Change-Id: I44a9188c3578d10b5647d077f912b765a5696acf
2015-02-25 07:17:10 -08:00
Dan Smith
42baafb810 Allow subclasses to define the serialization namespaces
This allows the serialization and project namespaces to be overridden in
subclasses of VersionedObject. The project one should be set on each
using implementation, but the base serialization one is just there for
projects that already use this code and need it to be equal to what they
currently use.

Change-Id: Iecec043adc31441cc8865fa5e54d9a0ee4a5989a
2015-02-24 10:12:31 -08:00
Jenkins
73abff93fd Merge "Rename checks to fixture and update requirements" 2015-02-20 13:13:27 +00:00
Jenkins
ea74bc43cd Merge "Sync default-setting change from Nova" 2015-02-20 13:13:19 +00:00
Jenkins
a5e686fe5b Merge "Sync obj_reset_changes(recursive=) change from Nova" 2015-02-20 12:54:02 +00:00