← Back to team overview

openstack team mailing list archive

Nova session question

 

hello,

I’m trying to read some values from the db of Nova, using Sql alchemy interface.
I found that I need to get a session, which is authenticated. I wrote
a simple program to read instance cores from the instances table, but
it’s not working. Can you please check and let me know how to proceed?

I tried 2 ways: Getting a context, and getting a session, however I
didnt get any output from this code snippet. Can someone point out the
error?


        ctx = context.RequestContext('admin', 'admin', is_admin=True)

        print "Got ctx", (ctx)
        print "DB conn flags", (FLAGS.sql_connection)

        session = get_session()

        session.begin()
        instances = session.query(models.Instance).all()

        for i in instances:
            print i         # Nothing is printed here as instances is empty

        results = db.service_get_all_compute_sorted(ctx)
        for result in results: # Nothing is returned here as well
            (service, instance_cores) = result
            print service, instance_cores




Thanks!
Jaiber



Follow ups