← Back to team overview

openstack team mailing list archive

Re: Running code on instance start/terminate

 

Actually, I'm having problems in a much simpler layer. I've done the
following code thinking that I would start from there to find info:

---------------------
conn = amqp.Connection(host="localhost:5672", userid="guest",
password="guest", virtual_host="/", insist=False)
chan = conn.channel()
chan.queue_bind(queue="compute", exchange="nova", routing_key="
notifications.info")

def recv_callback(msg):
    print 'Received: ' + msg.body + ' from channel #' +
str(msg.channel.channel_id)

chan.basic_consume(queue='compute', no_ack=True, callback=recv_callback,
consumer_tag="testtag")
while True:
    chan.wait()
chan.basic_cancel("testtag")


chan.close()
conn.close()
---------------------

But I get no messages at all. The script just stays still. I've added
"--notification_driver=nova.notifier.rabbit_notifier" to nova.conf also.

Em 28 de março de 2012 18:46, Sandy Walsh <sandy.walsh@xxxxxxxxxxxxx>escreveu:

> Look at
> https://github.com/rackspace/stacktach/blob/master/worker.py
> (ignore the _process() call, just look at how the queue listeners are
> set up)
>
> my worker_conf.py looks something like
> DEPLOYMENTS = [
>    dict(
>        tenant_id=1,
>        url='http://stacktach.example.com',
>        rabbit_host="10.0.0.1",
>        rabbit_port=5672,
>        rabbit_userid="nova-staging",
>        rabbit_password="password",
>        rabbit_virtual_host="staging"),
>    dict(
>        tenant_id=2,
>        url='http://stacktach.example.com',
>        rabbit_host="10.99.0.1",
>        rabbit_port=5672,
>        rabbit_userid="nova",
>        rabbit_password="password",
>        rabbit_virtual_host="production"),
>   ]
>
>
> Or the queue listeners in
> https://github.com/Cerberus98/yagi
>
> Hope it helps!
> -Sandy
>
>
> On 03/28/2012 05:27 PM, Leander Bessa wrote:
> >>From what i have figured out so far, the exchange queue is "nova" and
> > the routing key in your case is "notifications.info
> > <http://notifications.info>".
> >
> > On Wed, Mar 28, 2012 at 9:05 PM, Rogério Vinhal Nunes
> > <rogervn@xxxxxxxxxxx <mailto:rogervn@xxxxxxxxxxx>> wrote:
> >
> >     I'm trying to find out information to make an application that
> >     consumes the compute info, but I'm having some trouble. Is there a
> >     better documentation I could follow and the precise details of the
> >     queue/exchange/routing_key needed to take information at the end of
> >     each run-instance and terminate-instance?
> >
> >     Also, I'm using amqplib and I saw that Openstack uses an internal
> >     library named Carrot that uses amqplib. Would it be better to use it
> >     instead?
> >
> >     Em 27 de março de 2012 12:42, Sandy Walsh <sandy.walsh@xxxxxxxxxxxxx
> >     <mailto:sandy.walsh@xxxxxxxxxxxxx>> escreveu:
> >
> >         I believe '.exists' is sent via a periodic update in
> >         compute.manager.
> >
> >
> >
> >         On 03/27/2012 12:08 PM, Leander Bessa wrote:
> >         > Hello,
> >         >
> >         > I've been following this topic and i've been trying to receive
> the
> >         > notifications directly from rabbitmq with python+pika. So i far
> >         > i've managed to receive the start/terminate events and
> >         everything in
> >         > between. What i am unable to find though is the topic regarding
> >         > _compute.instance.exists_
> >         > from http://wiki.openstack.org/SystemUsageData. Does this even
> >         exist, or
> >         > is there some extra configuration required with nova?
> >         >
> >         > Regards,
> >         >
> >         > Leander
> >         >
> >         > On Mon, Mar 26, 2012 at 4:54 PM, Russell Bryant
> >         <rbryant@xxxxxxxxxx <mailto:rbryant@xxxxxxxxxx>
> >         > <mailto:rbryant@xxxxxxxxxx <mailto:rbryant@xxxxxxxxxx>>>
> wrote:
> >         >
> >         >     -----BEGIN PGP SIGNED MESSAGE-----
> >         >     Hash: SHA1
> >         >
> >         >     On 03/26/2012 11:48 AM, Russell Bryant wrote:
> >         >     > On 03/26/2012 10:15 AM, Rogério Vinhal Nunes wrote:
> >         >     >> Hello,
> >         >     >>
> >         >     >> I'm developing a application to work along with
> >         openstack. My
> >         >     >> application needs to keep track of all instances being
> >         started
> >         >     >> or terminated such as feeding it information about the
> >         location,
> >         >     >> status and other information about launched and
> terminated
> >         >     >> instances. The current version makes timed queries to
> >         OpenStack
> >         >     >> database, but this is showing to be a little consuming
> and
> >         >     >> inefficient, so I would like to add a portion of code
> >         to make
> >         >     >> OpenStack actively feed my application information
> >         whenever an
> >         >     >> instance changes its status or location.
> >         >     >>
> >         >     >> What is the least intrusive way to do that? It would be
> >         very nice
> >         >     >> if OpenStack provided a way to run code on these
> situations
> >         >     >> without actually changing any code, such as defining a
> >         directory
> >         >     >> of scripts to run in every instance status change.
> >         >     >
> >         >     > Check out the notifications system:
> >         >     >
> >         >     > http://wiki.openstack.org/NotificationSystem
> >         >     >
> >         >
> >         >     That wasn't the page I thought it was ... I meant:
> >         >
> >         >        http://wiki.openstack.org/SystemUsageData
> >         >
> >         >     You can consume these events via AMQP if you configure
> >         nova to use the
> >         >     rabbit notifier.
> >         >
> >         >     - --
> >         >     Russell Bryant
> >         >     -----BEGIN PGP SIGNATURE-----
> >         >     Version: GnuPG v1.4.12 (GNU/Linux)
> >         >     Comment: Using GnuPG with Mozilla -
> >         http://enigmail.mozdev.org/
> >         >
> >         >
> >         iEYEARECAAYFAk9wkSgACgkQFg9ft4s9SAYFuACfUu23qtxiH6WLCJNyd9gBf8i1
> >         >     FwQAnifjwWkFHYxo+KhYt8TAWEzTaMYZ
> >         >     =UWlH
> >         >     -----END PGP SIGNATURE-----
> >         >
> >         >     _______________________________________________
> >         >     Mailing list: https://launchpad.net/~openstack
> >         <https://launchpad.net/%7Eopenstack>
> >         >     Post to     : openstack@xxxxxxxxxxxxxxxxxxx
> >         <mailto:openstack@xxxxxxxxxxxxxxxxxxx>
> >         >     <mailto:openstack@xxxxxxxxxxxxxxxxxxx
> >         <mailto:openstack@xxxxxxxxxxxxxxxxxxx>>
> >         >     Unsubscribe : https://launchpad.net/~openstack
> >         <https://launchpad.net/%7Eopenstack>
> >         >     More help   : https://help.launchpad.net/ListHelp
> >         >
> >         >
> >         >
> >         >
> >         > _______________________________________________
> >         > Mailing list: https://launchpad.net/~openstack
> >         <https://launchpad.net/%7Eopenstack>
> >         > Post to     : openstack@xxxxxxxxxxxxxxxxxxx
> >         <mailto:openstack@xxxxxxxxxxxxxxxxxxx>
> >         > Unsubscribe : https://launchpad.net/~openstack
> >         <https://launchpad.net/%7Eopenstack>
> >         > More help   : https://help.launchpad.net/ListHelp
> >
> >         _______________________________________________
> >         Mailing list: https://launchpad.net/~openstack
> >         <https://launchpad.net/%7Eopenstack>
> >         Post to     : openstack@xxxxxxxxxxxxxxxxxxx
> >         <mailto:openstack@xxxxxxxxxxxxxxxxxxx>
> >         Unsubscribe : https://launchpad.net/~openstack
> >         <https://launchpad.net/%7Eopenstack>
> >         More help   : https://help.launchpad.net/ListHelp
> >
> >
> >
> >     _______________________________________________
> >     Mailing list: https://launchpad.net/~openstack
> >     Post to     : openstack@xxxxxxxxxxxxxxxxxxx
> >     <mailto:openstack@xxxxxxxxxxxxxxxxxxx>
> >     Unsubscribe : https://launchpad.net/~openstack
> >     More help   : https://help.launchpad.net/ListHelp
> >
> >
> >
> >
> > _______________________________________________
> > Mailing list: https://launchpad.net/~openstack
> > Post to     : openstack@xxxxxxxxxxxxxxxxxxx
> > Unsubscribe : https://launchpad.net/~openstack
> > More help   : https://help.launchpad.net/ListHelp
>

Follow ups

References