22 Commits

Author SHA1 Message Date
Zuul
79b3d5bb5a Merge "Handle unregistered nested objects" 2020-03-07 20:58:38 +00:00
Stephen Finucane
da7cd17a2b Drop use of six
We no longer need much of the functionality this was providing.

Change-Id: I0f625b714950a712249757906974715358f9e6c6
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2020-02-07 10:35:08 -08:00
Stephen Finucane
bbceb088eb Handle unregistered nested objects
The 'obj_tree_get_versions' function is used by e.g. the
'test_compatibility_routines' fixture to sanity check object versioning
and we don't do things like remove objects that are referenced
elsewhere. Unfortunately if we do this exact thing, an unhelpful
'IndexError' is raised. Handle things better and raise a specific
exception with hints towards what may be the root cause.

Change-Id: I7c05c648a9efb018ef9718fa31a9cc075482db59
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Closes-bug: #1860652
2020-01-23 11:21:25 +00:00
jichen
fe2207f9f3 Add support version in exception output
The latest version of Incompatible check exception Shows
in the exception output but the supported version is not listed.

Change-Id: Ia9f433342b1b233e119613470a829608085de10c
Related-Bug: 1773393
2018-05-28 14:03:34 +08:00
hnyang
2c9258b4ed Remove log translations
Log messages are no longer being translated. This
removes all use of the _LE, _LI, and _LW translation markers to simplify
logging and to avoid confusion with new contributions.

See:
http://lists.openstack.org/pipermail/openstack-i18n/2016-November/002574.html
http://lists.openstack.org/pipermail/openstack-dev/2017-March/113365.html

Change-Id: Ibfe04fd84dc50d5d4ad6ad6736e6d8b74c8e41b4
Closes-Bug: 1674577
2017-12-29 11:31:37 -06:00
ChangBo Guo(gcb)
50618882d5 Replace safe_utils.getcallargs with inspect.getcallargs
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
2016-04-19 19:38:58 +08:00
ChangBo Guo(gcb)
b524bf5b71 Leverage dict comprehension in PEP-0274
PEP-0274 introduced dict comprehensions to replace dict constructor
with a sqeuence of key-pairs[1], these are benefits:
  First, it makes the code look neater.
  Second, it gains a micro-optimization.

We dropped python 2.6 support, we can leverage this now.
Note: This commit doesn't handle dict constructor with kwargs.

[1]http://legacy.python.org/dev/peps/pep-0274/

Change-Id: Ifca656d516809a6a52cf15bac3f6361e8d83aa58
2015-12-02 16:35:16 +08:00
Ryan Rossiter
e73c93c519 Check for obj_relationships in List objects
In obj_make_compatible() of List objects, only child_versions is used.
If obj_relationships is set on a List object, obj_make_compatible()
should also take that into consideration.

This change pulls out common code for finding the desired child version
for backporting, and then changes ObjectListBase's obj_make_compatible()
to check for child_versions first, and if that is empty, will use
obj_relationships for finding the child version.

Change-Id: I89217f1721c896bd2660354d4f4283e2e12ebe98
Closes-Bug: #1470617
2015-08-17 13:33:16 +00:00
Jenkins
f36a5011ec Merge "Add validation on target_version arg when calling obj_to_primitive" 2015-08-05 02:28:02 +00:00
Moshe Levi
79e0cb89d1 Add validation on target_version arg when calling obj_to_primitive
This patch add validation on the target_version arg as following:
1. When target_version == object version don't call obj_make_compatible
2. When target_version > object version raise exception

Change-Id: I0f8dbe3cbdb86752f026f3692d4badc9f6e693c3
2015-08-03 20:15:43 +03:00
Victor Stinner
0c3199f93d Fix error handling in the exception module on py3
* Replace dict.iteritems() with dict.items() in code handling errors in
  the exception module to fix Python 3 support.
* Add new unit tests on the exception module

Change-Id: Ib958421dbdd73fb442e17a8d0654c9eab8b7b70e
2015-07-29 15:24:04 +02: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
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
Jenkins
4c0b0cb367 Merge "New config group for oslo_versionedobjects" 2015-04-21 14:24:47 +00: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
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
Joshua Harlow
00715e147c Use six.wraps for py2/py3 compat
The six.wraps adds a little benefit over using
functools.wraps so we might as well just use it.

Change-Id: I00dd59b3c0422f4b2daba4517af76caf4c045654
2015-02-13 12:45:23 -08:00
Grzegorz Grasza
1b8336fbe8 Compatibility with Python 3
Make the tests run under Python 3.4.
Tests now work with random hash seed.

Change-Id: I5f9f57e0bef2c015ab2ff4b5732ccdade5d3bfbe
Closes-Bug: 1417279
Closes-Bug: 1417285
2015-02-12 09:46:28 -08:00
Grzegorz Grasza
c330f938c8 Remove references to Nova
Remove remaining references to "Nova" where possible, code cleanup.
Also removed IP fields

Co-Authored-By: Michal Jastrzebski (inc0) <michal.jastrzebski@intel.com>
Change-Id: Ibad8f9fc6453321055029ad69b0374261509b9d5
Closes-Bug: 1417287
2015-02-12 08:30:06 -08:00
Grzegorz Grasza
f739f2bdaf Fix initial test failures
Fix py26 compatibility by removing dict comprehension
Remove history.rst from docs generation since it causes an error

Change-Id: Iedc6e6caa6fe2650c83683347c5d9ddcb4d105e8
Closes-Bug: 1420302
Closes-Bug: #1420372
Co-Authored-By: Dan Smith <dansmith@redhat.com>
2015-02-10 12:32:13 -08:00
Doug Hellmann
1e146a916e clean up and get most test running
Remove extraneous utility code and tests.

Skip tests related to remote object verification until we can rewrite
them (see the adopt-oslo-versionedobjects spec for details).

Fix pep8 errors.

Update requirements.

Set python's hash seed in tox.ini for tests that compare things that
might come out in a different order.
2015-02-02 16:24:14 -05:00
Doug Hellmann
591c480caf rename files 2015-02-02 15:07:55 -05:00