Smarter network_setup hooks

Adam Litke alitke at redhat.com
Mon Jan 6 13:32:07 UTC 2014


On 04/01/14 20:08 +0100, Miguel Angel wrote:
>Hi Adam
>
>Thanks for the feedback
>
>2014/1/3 Adam Litke <alitke at redhat.com>
>
>> On 03/01/14 12:20 +0000, Dan Kenigsberg wrote:
>>
>>> Recently, Miguel Angel Ajo (CCed) has added a nice functionality to the
>>> implementation of setupNetworks in Vdsm: two hook points where added:
>>> before and after the setupNetworks verb takes place.
>>> [....]
>>
>> Seems like a logical thing to do.  What specific mechanism do you
>> suggest for passing the JSON strings to the hook script?  If passed as
>> arguments to the hook script we would need to consider shell escaping
>> and argv length restrictions.
>>
>> As for the libvirt domain xml we pass to other hooks, we write a temporary
>file
>and we set an environment variable pointing to it before calling the script
>
>
>> What about writing these out to a special file and adding a new
>> getContext() call to the hooking module.  A script that is unconcerned
>> with the context would not require any changes.  But a script that
>> wants access would simply do:
>>
>>    ctx = hooking.getContext()
>>
>> and ctx would be the contents of the special file already decoded into
>> a native Python object for easy consumption.  This could easily be
>> extended to any hook which may want to provide some context to
>> implementors.
>>
>
>That would be nice, so scripts written in python wouldn't need to look for,
>and parse
>the file.
>
>This is an example of a simple hook:
>
>http://gerrit.ovirt.org/#/c/20330/7/tests/functional/networkTests.py  (look
>inside the ValidatesHook decorator)
>
>
>It'd be quite simplified. We would also need a "setContext()..." to update
>context with changes.

Yeah seems reasonable.  Then hook scripts can become much simpler and
easier to read and write:

ctx = hooking.getContext()
ctx['foo'] = 'bar'
hooking.setContext(ctx)

>
>
>>
>> One more question comes to mind:  Are there any pieces of information
>> that we would need to redact from the context (passwords or other
>> sensitive information)?
>>
>>
>I think there is no sensitive information as far as I know.
>
>Greetings,
>Miguel Ángel.



More information about the Arch mailing list