pyrax
pyrax copied to clipboard
Wrong object returned
There appears to be a bug in the caching of context objects. Consider the code below. If I add cached=False to the second call for get_client('nova', region), it works as expected.
Admittedly it's rather odd to ask for the same client twice in the same scope, but this behaviour may manifest itself in other ways as well?
import pyrax
token = ''
ddi =
region = ''
pyrax_ctx = pyrax.create_context("rackspace")
pyrax_ctx.auth_with_token(token, ddi)
nova_lon = pyrax_ctx.get_client('nova', region)
print type(nova_lon)
network_lon = pyrax_ctx.get_client('cloud_networks', region)
print type(network_lon)
nova_lon = pyrax_ctx.get_client('nova', region)
print type(nova_lon)
glance_lon = pyrax_ctx.get_client('glance', region)
print type(glance_lon)
Expected output:
<class 'novaclient.v2.client.Client'>
<class 'pyrax.cloudnetworks.CloudNetworkClient'>
<class 'novaclient.v2.client.Client'>
<class 'pyrax.image.ImageClient'>
Actual output:
<class 'novaclient.v2.client.Client'>
<class 'pyrax.cloudnetworks.CloudNetworkClient'>
<class 'pyrax.cloudnetworks.CloudNetworkClient'> <--- Why?
<class 'pyrax.image.ImageClient'>