From dac96263be2623ba0721b5da5f59dda4c98d373d Mon Sep 17 00:00:00 2001 From: Andrew Watson Date: Thu, 26 Feb 2015 14:53:36 -0500 Subject: [PATCH 1/2] Fix #629 by adding PrivateIPAddress to config.json Signed-off-by: Andrew Watson --- drivers/amazonec2/amazonec2.go | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/amazonec2/amazonec2.go b/drivers/amazonec2/amazonec2.go index 871c3c88d8..800ced9d3f 100644 --- a/drivers/amazonec2/amazonec2.go +++ b/drivers/amazonec2/amazonec2.go @@ -44,6 +44,7 @@ type Driver struct { InstanceId string InstanceType string IPAddress string + PrivateIPAddress string MachineName string SecurityGroupId string SecurityGroupName string @@ -269,12 +270,19 @@ func (d *Driver) Create() error { } d.InstanceId = instance.InstanceId + d.IPAddress = instance.IpAddress + + if len(instance.NetworkInterfaceSet) > 0 { + d.PrivateIPAddress = instance.NetworkInterfaceSet[0].PrivateIpAddress + } d.waitForInstance() - log.Debugf("created instance ID %s, IP address %s", + log.Debugf("created instance ID %s, IP address %s, Private IP address %s", d.InstanceId, - d.IPAddress) + d.IPAddress, + instance.NetworkInterfaceSet[0].PrivateIpAddress, + ) log.Infof("Waiting for SSH on %s:%d", d.IPAddress, 22) @@ -312,14 +320,11 @@ func (d *Driver) Create() error { } func (d *Driver) GetURL() (string, error) { - ip, err := d.GetIP() - if err != nil { - return "", err - } - if ip == "" { + + if d.IPAddress == "" { return "", nil } - return fmt.Sprintf("tcp://%s:%d", ip, dockerPort), nil + return fmt.Sprintf("tcp://%s:%d", d.IPAddress, dockerPort), nil } func (d *Driver) GetIP() (string, error) { @@ -327,8 +332,8 @@ func (d *Driver) GetIP() (string, error) { if err != nil { return "", err } - d.IPAddress = inst.IpAddress - return d.IPAddress, nil + + return inst.IpAddress, nil } func (d *Driver) GetState() (state.State, error) { From 0d83d89dd28ddcb6324176e4685bf812037498ab Mon Sep 17 00:00:00 2001 From: Andy Watson Date: Thu, 26 Feb 2015 23:26:23 -0500 Subject: [PATCH 2/2] PR updates Signed-off-by: Andy Watson --- drivers/amazonec2/amazonec2.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/amazonec2/amazonec2.go b/drivers/amazonec2/amazonec2.go index 800ced9d3f..a41fd038e6 100644 --- a/drivers/amazonec2/amazonec2.go +++ b/drivers/amazonec2/amazonec2.go @@ -281,7 +281,7 @@ func (d *Driver) Create() error { log.Debugf("created instance ID %s, IP address %s, Private IP address %s", d.InstanceId, d.IPAddress, - instance.NetworkInterfaceSet[0].PrivateIpAddress, + d.PrivateIPAddress, ) log.Infof("Waiting for SSH on %s:%d", d.IPAddress, 22)