iso8601.UTC is correct datetime UTC field object.
iso8601.UTC is correct datetime UTC field object.
iso8601 >= 0.1.12 includes only iso8601.UTC for python3
while both UTC and Utc() for python2. Less then 0.1.12
included both UTC and Utc() for both python2/3.
Change-Id: Ie7957959e836d2f78409d4197c6a2d7ad9e8457b
Closes-Bug: #1713354
This is done so that nullable Object field's schema can be given the null or
object type property.
implements bp json-schema-for-versioned-object
Change-Id: I43b04a76cccc9d4f893162535050fed6940bee6c
1.As mentioned in [1], we should avoid using
six.iteritems to achieve iterators. We can use
dict.items instead, as it will return iterators
in PY3 as well. And dict.items/keys will more readable.
2.In py2, the performance about list should be negligible,
see the link [2].
[1] https://wiki.openstack.org/wiki/Python3
[2] http://lists.openstack.org/pipermail/openstack-dev/2015-June/066391.html
Change-Id: I6bf760e6f3db50696dc87230c444f9ed493615f0
When the 'Object' field stringifys a value, it is
currently hardcoded to report the object name that
the field was initialized with. This used to be
sufficient, until the 'subclasses' parameter was
added. When subclasses=True, the value may be any
arbitrary subclass, so we should be reporting the
actual object name associated with the value.
Closes-Bug: #1638577
Change-Id: I0bb4ade30a60554710a12f0f058945ef43826eff
Created a base class StringPattern that implements similar JSON schema for
patterned field types - UUID, PCI, MAC, IP Address
implements bp json-schema-for-versioned-object
Change-Id: Ie44ad83ce0cb41bec538adcd336dacdcafebd3ea
The Enum field is a subclass of String. However, when dumping schema, it
was not dumping its data type so the schema dumped was useless. This
patch fixes the issue.
Change-Id: I373f13412003a68fa0207ba44658b96ed7dc46a0
This implements the get_schema() method of the following FieldType:
Object, IPV6Address, NonNegativeInteger, NonNegativeFloat,
IPV4AndV6Address, Dict(fixed from last patch)
implements bp json-schema-for-versioned-object
Change-Id: I6bce3ba7bb32ed2dd8ed6e7f313411bbfef5eff0
This implements the get_schema() method of the following FieldType
classes:
UUID, MACAddress, PCIAddress, DateTime, IPV4Address, IPV6Address,
IPV4Network, IPV6Network, Dict
Implements blueprint json-schema-for-versioned-object
Change-Id: Ie139f01e0bf04c8e4ebdef00a72b30d04a73a6a4
Adds IPV4AndV6Address, NonNegativeFloat, NonNegativeInteger field
types and their respective fields, which can be used later on in
different projects.
Change-Id: I58369998b7fab32c391813c06e9000867aa7887b
This implements the get_schema method of common Field and FieldType classes.
This method will be used by the to_json_schema method in Versioned objects
to partially generate the schema of the object's fields.
Fields implemented in this patch: string, enum, integer, float, boolean, list
This also fixes check for default value for Field.
Implements blueprint json-schema-for-versioned-object
Change-Id: Ibd84cb4e33c375044611c6ffa137ee67d21a93e5
This adds a method that generates a versioned object's fields
in json schema. In addition, each field would also generate
its respective json schema property.
Implements blueprint json-schema-for-versioned-object
Change-Id: I5914606e4db79a15b573cfc4a6b9b8807199e402
Include the full path to the module in the error message
for both the expected and actual object.
Change-Id: I2b5ff3afdbc622a66ba9f78cf8ed61d892694793
Closes-Bug: 1592625
This fixes a bug that I found while making another change, along with
a test that exercises the code that pokes it.
Change-Id: Ibb1ca5e171c6329a46a5d853a3ab8613f58d067f
A recent patch exposed valid_values via property, and cocerced the
result to a tuple to convey the immutable nature of them. This was
a good thought, but unfortunately breaks __repr__ stability, which
we use in the fixture to calculate the object hashes.
We could make the __repr__ dig into the raw types on the field
instead of using the property, but this is probably not the best and
smallest change at this point. If we can get everyone to start using
tuples for their value_values list, then we could land a change to
coerce and enforce that. Right now, we just need to fix the
unexpected regression.
Change-Id: I09b78e7f816fc26c69a3e9435c9d92d5acb5821b
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
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
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
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
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>