[openstack-dev] [all][dev][python] constructing a deterministic representation of a python data structure

Amrith Kumar amrith at tesora.com
Thu Nov 3 19:35:00 UTC 2016


Dims, I don't think ovo addresses this issue. It isn't one of versioning that I'm attempting to address but rather as Gordon points out, of signing and verifying authenticity. Please see also my longer response to him on this.

-amrith

-----Original Message-----
From: Davanum Srinivas [mailto:davanum at gmail.com] 
Sent: Thursday, November 3, 2016 3:03 PM
To: OpenStack Development Mailing List (not for usage questions) <openstack-dev at lists.openstack.org>
Subject: Re: [openstack-dev] [all][dev][python] constructing a deterministic representation of a python data structure

Does oslo.versionedobjects solve some of your needs?

http://www.slideshare.net/davanum/ovo-deep-dive
https://gorka.eguileor.com/learning-something-new-about-oslo-versioned-objects/
http://www.danplanet.com/blog/2015/10/06/upgrades-in-nova-objects/

-- Dims

On Thu, Nov 3, 2016 at 2:24 PM, Amrith Kumar <amrith at tesora.com> wrote:
> TL;DR
>
>
>
> I want to take a python data structure (see later for details) and 
> represent it in a format that will be stable across python versions, 
> and platforms so that I can construct a stable hash. I’m looking for 
> pointers to some best practices on how to do this.
>
>
>
> The longer version
>
>
>
> Assume that there’s some function in python that is:
>
>
>
> def fn(*args, **kwargs):
>
>>
>
>
> I’d like to take (args, kwargs) and construct a hash of some 
> representation that is deterministic. Specifically, assume that fn() 
> is a method in the API (oslo.messaging transport …). I’d like to 
> construct the hash on the sender side and on the RPC server side and 
> make sure that the parameters are the same.
>
>
>
> So, just before calling call() or cast(), I could compute the hash and 
> stuff it into the dictionary that is being sent over, and I can do the 
> same on the receiving side. But since I cannot guarantee that the 
> representation on the receiving side is necessarily identical to the 
> representation on the sending side, I have issues computing the hash.
>
>
>
> In IRC, jroll suggested json; can one safely assume that json.dumps() 
> is a deterministic representation?
>
>
>
> Thanks for any pointers and suggestions.
>
>
>
> -amrith
>
>
> ______________________________________________________________________
> ____ OpenStack Development Mailing List (not for usage questions)
> Unsubscribe: 
> OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>



--
Davanum Srinivas :: https://twitter.com/dims

__________________________________________________________________________
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4805 bytes
Desc: not available
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20161103/9fbf54b7/attachment.bin>


More information about the OpenStack-dev mailing list