Merge pull request #379 from nak3/const-aws

Use const value for AWS metadata URL
This commit is contained in:
Clint 2015-11-03 10:09:30 -06:00
commit 6a3763d105
1 changed files with 7 additions and 3 deletions

View File

@ -15,6 +15,10 @@ import (
"github.com/hashicorp/nomad/nomad/structs"
)
// This is where the AWS metadata server normally resides. We hardcode the
// "instance" path as well since it's the only one we access here.
const DEFAULT_AWS_URL = "http//169.254.169.254/latest/meta-data/"
// map of instance type to approximate speed, in Mbits/s
// http://serverfault.com/questions/324883/aws-bandwidth-and-content-delivery/326797#326797
// which itself cites these sources:
@ -89,7 +93,7 @@ func (f *EnvAWSFingerprint) Fingerprint(cfg *config.Config, node *structs.Node)
}
metadataURL := os.Getenv("AWS_ENV_URL")
if metadataURL == "" {
metadataURL = "http://169.254.169.254/latest/meta-data/"
metadataURL = DEFAULT_AWS_URL
}
// assume 2 seconds is enough time for inside AWS network
@ -161,7 +165,7 @@ func isAWS() bool {
// provide their own
metadataURL := os.Getenv("AWS_ENV_URL")
if metadataURL == "" {
metadataURL = "http://169.254.169.254/latest/meta-data/"
metadataURL = DEFAULT_AWS_URL
}
// assume 2 seconds is enough time for inside AWS network
@ -205,7 +209,7 @@ func (f *EnvAWSFingerprint) linkSpeed() int {
// the network speed
metadataURL := os.Getenv("AWS_ENV_URL")
if metadataURL == "" {
metadataURL = "http://169.254.169.254/latest/meta-data/"
metadataURL = DEFAULT_AWS_URL
}
// assume 2 seconds is enough time for inside AWS network