LIBCLOUD-700 Add support for setting the region #513

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
2 participants
@tonybaloney
Contributor

tonybaloney commented May 8, 2015

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

LIBCLOUD-700 Add support for setting the region when connecting to a …
…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.

@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.

@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

This comment has been minimized.

Show comment
Hide comment
@tonybaloney

tonybaloney May 8, 2015

Contributor

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

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@tonybaloney

tonybaloney May 10, 2015

Contributor

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.

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@Kami

Kami May 12, 2015

Member

@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
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

This comment has been minimized.

Show comment
Hide comment
@tonybaloney

tonybaloney May 14, 2015

Contributor

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

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@Kami

Kami May 16, 2015

Member

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.

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