[FLOC-3521] Support mapping public IP addresses in API client #2230
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
public_addressfield of Nodes returned form theflocker.apiclient.FlockerClientactually contains the internal cluster IP address, which can be a private IP address.Public IP addresses are very useful for clients using the API client module, but a node has no way of knowing which of its IP addresses is truly public, and in some cases, may not even know about a public IP address that routes to it (e.g. NAT addresses).
However, the code using
apiclientmay know the mapping, especially if it was somehow involved in starting the cluster. This is the case when a cluster is started usingrun-acceptance-testswhere the mapping from internal cluster hostnames to public IP addresses is exported as an environment variable.This PR allows the
apiclientuser, when creating aFlockerClient, to pass a mapping of internal hostname IP_ addresses to public IP addresses. Expand theNodeclass to include both the internal address, now as an additional field calledhostname(it's usual name in Flocker), and to setpublic_addressto the public IP address provided by a dictionary mapping hostname to public address.For Rackspace, the mapping provided by
run-acceptance-testsis{}which makes thehostnameandpublic_addressfields the same. This is appropriate since Rackspace IP addresses are public.For AWS,
run-acceptance-testsreturns a JSON structure{"10.0.0.1": "172.12.12.12"}which can be parsed into a Python dictionary for passing toFlockerClient.This will be used by the benchmarking code to SSH to individual cluster nodes to measure benchmark metrics.