Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LIBCLOUD-700 Add support for setting the region #513

Conversation

@tonybaloney
Copy link
Contributor

tonybaloney commented May 8, 2015

when connecting to a Dimension Data cloud, added all public endpoints.

…Dimension Data cloud, added all public endpoints.
secure=secure, host=host,
port=port,
region=region, **kwargs)
self.connection.host = self.selected_region.get('host')

This comment has been minimized.

Copy link
@Kami

Kami May 8, 2015

Member

I believe this won't work correctly when user instantiates multiple drivers with a different region and runs those inside the same process.

You should use _ex_connection_kwargs approach. This way, host argument will be passed to the Connection class constructor when instantiating it instead of modifying a class level variable. Please see EC2 and some other drivers for an example.

@tonybaloney
Copy link
Contributor Author

tonybaloney commented May 8, 2015

I based it on the joyent driver, which follows a similar pattern (so of note that one may suffer the same issue!).

Running DimensionData and Rackspace side by side does give results for the DimensionData driver, then
pprint(driver.list_nodes())
NameError: name 'driver' is not defined

Will follow the EC2 pattern instead and resubmit changes

@tonybaloney
Copy link
Contributor Author

tonybaloney commented May 10, 2015

Updated and tested against multiple regions in the same process by:

DimensionData = get_driver(Provider.DIMENSIONDATA)

drivers = [DimensionData('anthony','****',region='dd-na'),
DimensionData('anthony','**
**',region='dd-au')]

for driver in drivers:
nodes = driver.list_nodes()
print(len(nodes))

Gives 14 and 154 as expected.

@Kami
Copy link
Member

Kami commented May 12, 2015

@tonybaloney Thanks, I will have a look.

Also, to clarify it, your example wouldn't uncover the bug. You would need to do something like this:

driver1 = cls(region='region-1')
driver2 = cls(region='region-2')

pprint(driver1.list_nodes())
pprint(driver2.list_nodes())
pprint(driver1.list_nodes())  # If there is a bug, this line would result in region from driver2 also being used here
@tonybaloney
Copy link
Contributor Author

tonybaloney commented May 14, 2015

print(len(driver1.list_nodes()))
print(len(driver2.list_nodes()))
print(len(driver1.list_nodes()))

gives 5, 154 and 5, so its not giving that bug

@asfgit asfgit closed this in 92c107d May 16, 2015
@Kami
Copy link
Member

Kami commented May 16, 2015

I made a minor change (use normal dictionary access instead of get - we should throw if dictionary doesn't contain "host" item since this most likely indicates a programmer error) and merged changes into trunk.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.