Skip to content

LIBCLOUD-700 Add support for setting the region#513

Closed
tonybaloney wants to merge 2 commits intoapache:trunkfrom
NTTLimitedRD:LIBCLOUD-700_dimension_data_regions
Closed

LIBCLOUD-700 Add support for setting the region#513
tonybaloney wants to merge 2 commits intoapache:trunkfrom
NTTLimitedRD:LIBCLOUD-700_dimension_data_regions

Conversation

@tonybaloney
Copy link
Contributor

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

…Dimension Data cloud, added all public endpoints.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants