Sorry for the top posting, but seems like doing so is ok,

So an idea, feel free to use it or not...

But if a in-memory notification mechanism is desired then a library that I have been using and extracted from taskflow could be helpful here,

It doesn't bring in the full oslo.messaging notifications (since its only for in-memory after-all); but it could be just the thing needed to hook into observation points (with a more concrete definition/schema of what is/can be being observed being done by the nova folks):

https://notifier.readthedocs.org

https://pypi.python.org/pypi/notifier/

A really simple example:

>>> import notifier
>>> import time
>>> def watcher(event_type, details):
...    print("%s happened with details: %s" % (event_type, details))
...
>>> n = notifier.Notifier()
>>> n.register('vm-booted', watcher)
<Listener object at 0x7f1e6b738b90 calling into '<function watcher at 0x7f1e6f294c80>'>
>>> n.notify('vm-booted', details={'when': time.time()})
vm-booted happened with details: {'when': 1456855953.650803}
<Future at 0x7f1e6b738c10 state=finished returned _Notified>

Already in global-requirements btw,

-Josh

On 02/29/2016 08:59 AM, Sean Dague wrote:
The nova/hooks.py infrastructure has been with us since early Nova. It's
currently only annotated on a few locations - 'build_instance',
'create_instance', 'delete_instance', and 'instance_network_info'. It's
got a couple of unit tests on it, but nothing that actually tests real
behavior of the hooks we have specified.

It does get used in the wild, and we do break it with changes we didn't
ever anticipate would impact it -
https://bugs.launchpad.net/nova/+bug/1518321

However, when you look into how that is used, it's really really odd and
fragile -
https://github.com/richm/rdo-vm-factory/blob/master/rdo-ipa-nova/novahooks.py#L248


     def pre(self, *args, **kwargs):
         # args[7] is the injected_files parameter array
         # the value is ('filename', 'base64 encoded contents')
         ipaotp = str(uuid.uuid4())
         ipainject = ('/tmp/ipaotp', base64.b64encode(ipaotp))
         args[7].extend(self.inject_files)
         args[7].append(ipainject)

In our continued quest on being more explicit about plug points it feels
like we should other document the interface (which means creating
stability on the hook parameters) or we should deprecate this construct
as part of a bygone era.

I lean on deprecation because it feels like a thing we don't really want
to support going forward, but I can go either way.

        -Sean

P.S. I'm starting to look at in tree functional testing for all of this,
in the event that we decide not to deprecate it. It's definitely made a
little hard by the way all exceptions are caught when hooks go wrong.


__________________________________________________________________________
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

Reply via email to