This patch adds another field type definition to o.vo for a MAC Address.
Change-Id: Iee44223e5eff5565cc5e02571e5a96bb29490925
Co-authored-by: Dan Berrange <berrange@redhat.com>
There are objects that define a String field to hold a serialized json
blob and that blob can have sensitive information in it (tokens,
passwords, etc). When the object is logged, repr will log that sensitive
information. This puts a burden on the code that's doing the logging to
remember to sanitize the object's string form before logging it.
It'd be simpler and cleaner to just have a field type that extends
String so it's the same in all respects except for when it's
stringified. So in SensitiveString's stringify method it just masks the
password on the field value before returning it.
And no SensitiveString does not play an acoustic guitar at your local
coffee shop, he's actually super tough and emotionally walled up, that's
why he doesn't like exposing too much information about himself in the
logs.
Closes-Bug: #1321785
Change-Id: I56466eb8b5d8000ef010f2015f453a9e74dc66b8
following change id replaced timeutils.isotime(dt) with dt.isoformat():
Ied2643d3d891600e0e5cd31c7ef1ff6107e3a777
However this change breaks existing contract between Nova components
on the wire, so we need to resurrect a bit of the older code.
Change-Id: I151e889258a33fe6ce961b514c3967f521a218cf
oslo_utils.timeutils.isotime() is deprecated as of 1.6 so we need
to stop using it.
This patch replaces timeutils.isotime(dt) with dt.isoformat() as
the deprecation message suggests in oslo_utils.timeutils.
However this might be a backward incompatible change as
timeutils.isotime() produced '1955-11-05T18:00:00Z' format
but datetime.isoformat() produces '1955-11-05T18:00:00+00:00'
format.
Change-Id: Ied2643d3d891600e0e5cd31c7ef1ff6107e3a777
The following patch fixes field.Object's from_primitive()
to call a given object's obj_from_primitive() instead of
VersionedObject's obj_from_primitive(). By using the given
object instead of VersionedObject, the appropriate
OBJ_PROJECT_NAMESPACE is passed down to obj_from_primitive(),
and allows support for other projects namespaces.
Change-Id: I02e733f29ce2ee221270577f6dafdda706c74eb2
Closes-Bug: #1479041
Signed-off-by: Thang Pham <thang.g.pham@gmail.com>
This adds a new method called obj_make_compatible_from_manifest() to
the base object. This is to be used by the newer backport method (which
receives a version manifest from the client) in order to perform a more
prescriptive run of obj_make_compatible(). Since the latter is part of our
public library API, this does a slightly hacky think of stashing the
manifest so that it is visible to lower layers. We cache other such data
on the object like this in other places, so there is precedent for this.
However, it would be good to see if we can clean this up via refactoring
the internals in a way that won't break people (and/or just make a change
in a major version bump later). For now, I think this is the least likely-
to-break-people change we can make.
Change-Id: I0c33a34a3cb454d6d35e2092d72ebd41d4c12729
In order to coerce correctly some fields that are primarly dictionaries having
either strings or list of strings as values, we need to provide a new field type
which would accept only list of strings as values for dicts so anyone who would
want to use that type would just have to make sure to hydrate all the items by
putting them into a single list.
Change-Id: I708860357e17bcc70733187c3289dd859b09c60b
Providing a version string for a field means sometimes that we want to verify
that the string is correct for a versionpredicate.
By adding a new type of field coercing using VersionPredicate, we can make sure
that the field is correct.
Change-Id: I53213e8bfa1928936c0f6904e23dfa886233528b
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'
collections 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.
This patch restores the functionality of patch
2da963c3b313e14c4e60301e87f9c9260d7166cb which was reverted due
to found bug. This one fixes this bug by removing custom initializers for
coerced collections.
Change-Id: I9dc8fc408cefea921e4e27c0e75f98291674f867
Partial-Bug: #1469865
The Object class currently does a direct comparison of the
'obj_name()' value of the thing being coerced, against the
internal _obj_name field it was initialized with.
This does not allow for creation of object fields which
allow arbitrary subclasses - only the base class passes
the check.
Introduce a new 'subclasses' parameter, defaulting to
False, which traverses the python class hierarchy,
checking the obj_name() value on all parent classes
of the value being coerced.
Change-Id: Ie56b94e57a6e18292c10c926836592938540e515
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
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
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
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
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
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
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
Make the tests run under Python 3.4.
Tests now work with random hash seed.
Change-Id: I5f9f57e0bef2c015ab2ff4b5732ccdade5d3bfbe
Closes-Bug: 1417279
Closes-Bug: 1417285
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
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>
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.