I see the problem... The exception that's being raised is:
Traceback (most recent call last):
File "./test", line 26, in <module>
f = conn.compute.find_flavor('test')
File "/usr/lib/python2.7/site-packages/openstack/compute/v2/_proxy.py", line 66, in find_flavor
ignore_missing=ignore_missing)
File "/usr/lib/python2.7/site-packages/openstack/proxy2.py", line 105, in _find
**attrs)
File "/usr/lib/python2.7/site-packages/openstack/resource2.py", line 790, in find
return match.get(session)
File "/usr/lib/python2.7/site-packages/openstack/resource2.py", line 590, in get
response = session.get(request.uri, endpoint_filter=self.service)
File "/usr/lib/python2.7/site-packages/keystoneauth1/session.py", line 667, in get
return self.request(url, 'GET', **kwargs)
File "/usr/lib/python2.7/site-packages/positional/__init__.py", line 94, in inner
return func(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/keystoneauth1/session.py", line 570, in request
raise exceptions.from_response(resp, method, url)
keystoneauth1.exceptions.http.NotFound: Not Found (HTTP 404)
but the exception that's being expected and handled (realizing it's not an id, and moving on to find it by name) in openstack.resource2.find is openstack.exceptions.NotFoundException... similar name, but not the same thing.
I threw a breakpoint in openstack.session.map_exceptions, which appears to be the only place that raises NotFoundException, and it never triggered in this flow. Instead of using openstack.session, it appears to be using keystoneauth1.session... and then it hit me... This is how I created my session:
And that works for other things... but not here, because of the apparent expectation that the session is an instance of openstack.session.Session. But I don't think I can do what I've been doing (creating a session based on OS_* environment variables or --os-* CLI arguments) if I switch to an openstack.session.Session. And I expect this will trip up others who don't realize there are two different types of sessions and they can't use the very widely used keystoneauth1 version. Even though it actually seems to work for a while.
I see the problem... The exception that's being raised is:
Traceback (most recent call last): find_flavor( 'test') python2. 7/site- packages/ openstack/ compute/ v2/_proxy. py", line 66, in find_flavor missing= ignore_ missing) python2. 7/site- packages/ openstack/ proxy2. py", line 105, in _find python2. 7/site- packages/ openstack/ resource2. py", line 790, in find python2. 7/site- packages/ openstack/ resource2. py", line 590, in get get(request. uri, endpoint_ filter= self.service) python2. 7/site- packages/ keystoneauth1/ session. py", line 667, in get python2. 7/site- packages/ positional/ __init_ _.py", line 94, in inner python2. 7/site- packages/ keystoneauth1/ session. py", line 570, in request from_response( resp, method, url) exceptions. http.NotFound: Not Found (HTTP 404)
File "./test", line 26, in <module>
f = conn.compute.
File "/usr/lib/
ignore_
File "/usr/lib/
**attrs)
File "/usr/lib/
return match.get(session)
File "/usr/lib/
response = session.
File "/usr/lib/
return self.request(url, 'GET', **kwargs)
File "/usr/lib/
return func(*args, **kwargs)
File "/usr/lib/
raise exceptions.
keystoneauth1.
but the exception that's being expected and handled (realizing it's not an id, and moving on to find it by name) in openstack. resource2. find is openstack. exceptions. NotFoundExcepti on... similar name, but not the same thing.
I threw a breakpoint in openstack. session. map_exceptions, which appears to be the only place that raises NotFoundException, and it never triggered in this flow. Instead of using openstack.session, it appears to be using keystoneauth1. session. .. and then it hit me... This is how I created my session:
import argparse ArgumentParser( ) register_ auth_argparse_ arguments( parser, sys.argv[ 1:],default= 'v3password' ) register_ session_ argparse_ arguments( parser) load_auth_ from_argparse_ arguments( args) load_session_ from_argparse_ arguments( args, auth=auth) Connection( session= sess, authenticator=auth)
import sys
from keystoneauth1 import loading as ks_loading
from openstack import connection
parser = argparse.
ks_loading.
ks_loading.
args = parser.parse_args()
auth = ks_loading.
sess = ks_loading.
conn = connection.
And that works for other things... but not here, because of the apparent expectation that the session is an instance of openstack. session. Session. But I don't think I can do what I've been doing (creating a session based on OS_* environment variables or --os-* CLI arguments) if I switch to an openstack. session. Session. And I expect this will trip up others who don't realize there are two different types of sessions and they can't use the very widely used keystoneauth1 version. Even though it actually seems to work for a while.