safe_utils.getcallargs was written to support python2.6 which did not
have inspect.getcallargs. Now that support for python2.6 has been
dropped it should be replaced with inspect.getcallargs.
Note:The interface that safe_utils.getcallargs provides did not match
inspect.getcallargs around the handling of the self parameter needing to
be passed in. It should be brought inline with inspect.getcallargs so
that it can be dropped. Nova fixed in 2910d75b28afd909af3b4ac392729ac3d5e64b65.
Change-Id: I2fbec0cc4d43b2fc424460b176bf26700f05f44a
The new class property allows introspection of the valid values,
used to ease testing by random field generation.
Change-Id: I749bc0acea4947450b4c02dca932a05a7a4ad534
When the Object field coerce method doesn't get an object, the
type put into the ValueError message is the empty string, which is
not useful.
This change uses the type name from the value so the error has
useful details.
Change-Id: I45386cfda17243a82864780da1701d3b35432ae0
Closes-Bug: #1552480
This patch ensures that the VersionedObjectRegistry.__new__ function
always returns the correct class thats being created so that overridden
functions are applied correctly, when using a subclassed object
registry. Without this patch when using multiple child object registries
only the first child's overridden functions work correctly.
Change-Id: I11fef67b5bd16377086027d72f8e417c2221b5b4
Closes-Bug: #1536113
The recently-added FakeStateMachineField raises exceptions with strings
that have improper grammar, such as:
FooObject's are not allowed transition out of ERROR state to ACTIVE ...
In addition to the grammar issue, the field's name in the object is not
provided which may make it very difficult to debug.
Finally, the tests for this field did not actually validate the string
of the exception.
This patch corrects the strings, includes the field name, and makes the
test actually validate that the output looks like we expect.
Change-Id: I7bee955fba15b9570416518b16ac64181bf7e320
Follow new infra setup for translations, see spec
http://specs.openstack.org/openstack-infra/infra-specs/specs/translation_setup.html
for full details.
This basically renames
oslo.versionedobjects/locale/oslo.versionedobjects.pot to
oslo_versionedobjects/locale/oslo_versionedobjects.pot. For this we need to update
setup.cfg.
Update also domain name in _i18n.py.
Change-Id: Idf4612ca6833b516576e169ad9ff0d111d75112e
Because some subobjects of VersionedObject my require arguments to be
passed into __init__(), there needs to be a way for the
test_compatibility_routines() fixture to pass required args/kwargs to
init on certain objects. This change adds the ability to pass 2 mappings
to test_compatibility_routines, one for args and one for kwargs.
The key of each mapping is the object class that needs the special init
args. The value in the args dict will be a list of arguments to pass
(becomes *args), and the value in the kwargs dict is a list of kwargs
to pass (becomes **kwargs). If there is no key defined, the default
value of the args dict is [], and the default of kwargs is {}. *[] is
the equivalent of sending no arguments, and **{} is the equivalent of
not sending kwargs.
Change-Id: I62646b99adca47a9c9fe0f466f7a23ac8fa4553e
Related-Bug: #1537882
The VersionedObjectRegistry had a helper method in it, _vers_tuple(),
that converted an object's string version to a tuple.
oslo_utils.version_utils does that for us, so this changes over
_vers_tuple() to return version_utils's result. The inline function was
left to save on horizontal space (2 calls of convert_version_to_tuple()
in an inequality starts looking ugly really quick).
Change-Id: I69777ed2c0486996c63ef592325a5757c0b4b0b3
There is a temp registry pattern [1] where you can backup the object
registry, register a class locally, and then restore the original
registry. This could be used for test objects that do not need to be
registered permanently but will have calls which lookup registration.
The FakeResource object in patch [2] is such a use case.
This change is to wrap the pattern rather than accessing
oslo.versionedobjects library internals.
[1] https://review.openstack.org/#/c/243826/4/cinder/test.py
[2] https://review.openstack.org/#/c/258026/
Change-Id: I02036becb32f8d3d11170c71e14e0a2db55d1f76
Nova has a copy of compare_obj and Cinder needs to start using the
same thing, so move compare_obj to the fixture module so other projects
that are already using oslo.versionedobjects fixtures can re-use this.
The if check at the beginning of the function was changed over because
one of the unit tests uncovered a case with undesirable failing.
Co-Authored-By: Ryan Rossiter <rlrossit@us.ibm.com>
Change-Id: I0bcfa7d4f501bd69b6343e4d719e98eb32a5a5cd
In function object.__get__(self, instance, owner), owner is always
the owner class, while instance is the instance that the attribute
was accessed through, or None when the attribute is accessed through
the owner. Setting owner default value makes no sense.
refer to:
http://python-reference.readthedocs.org/en/latest/docs/dunderdsc/get.html#get
Change-Id: I74c2105f3100711b62171db65bc0656393adf2b8
The original test_compatibility_routines() only called
obj_to_primitive() without the version manifest, which means the fixture
could not be used to test compatibility routines on manifest backports.
This adds a kwarg to test_compatibility_routines() that allows users to
specify if they want to use the version manifest in the calls to
obj_to_primitive().
Change-Id: I1ef6eed1c79a2f2fc8967518a8a3d09e89ab64e3
I guess I reused classes a little too much when testing the fingerprint
generation, because the fingerprint being generated out of the used
class was nondeterministic because something else was changing on the
class before/during the fingerprint generation. So now there is a class
created only for the test, and the fingerprint is generated on that
object (with only extra data to correctly isolate what's being tested).
Change-Id: I6ba68fa0a03546b93f0f983f86fde886976b7569