Merge lp:~axwalk/juju-core/lp1225825-netlookupip-ip into lp:~go-bot/juju-core/trunk
Proposed by
Andrew Wilkins
Status: | Merged |
---|---|
Approved by: | John A Meinel |
Approved revision: | no longer in the source branch. |
Merged at revision: | 1831 |
Proposed branch: | lp:~axwalk/juju-core/lp1225825-netlookupip-ip |
Merge into: | lp:~go-bot/juju-core/trunk |
Diff against target: |
320 lines (+116/-49) 3 files modified
environs/manual/provisioner.go (+13/-0) instance/address.go (+20/-6) instance/address_test.go (+83/-43) |
To merge this branch: | bzr merge lp:~axwalk/juju-core/lp1225825-netlookupip-ip |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+186229@code.launchpad.net |
Commit message
environs/manual: reverse lookup target IP
Thus we may resolve additional addresses for the
machine. Also, we should get a consistent machine ID,
whether a name or an IP is specified.
Also, modify instance/
an IP address into net.LookupIP. This causes an error
if built with CGO_ENABLED=0.
Fixes #1225825
Description of the change
environs/manual: reverse lookup target IP
Thus we may resolve additional addresses for the
machine. Also, we should get a consistent machine ID,
whether a name or an IP is specified.
Also, modify instance/
an IP address into net.LookupIP. This causes an error
if built with CGO_ENABLED=0.
Fixes #1225825
To post a comment you must log in.
Reviewers: mp+186229_ code.launchpad. net,
Message:
Please take a look.
Description:
environs/manual: reverse lookup target IP
Thus we may resolve additional addresses for the
machine. Also, we should get a consistent machine ID,
whether a name or an IP is specified.
Also, modify instance/ HostAddresses to avoid passing
an IP address into net.LookupIP. This causes an error
if built with CGO_ENABLED=0.
Fixes #1225825
https:/ /code.launchpad .net/~axwalk/ juju-core/ lp1225825- netlookupip- ip/+merge/ 186229
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/13504044/
Affected files (+23, -2 lines): manual/ provisioner. go
A [revision details]
M environs/
M instance/address.go
Index: [revision details] 20130917082542- j1hu82fubd89omb o
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-
+New revision: <email address hidden>
Index: instance/address.go address. go'
=== modified file 'instance/
--- instance/address.go 2013-09-04 15:11:51 +0000
+++ instance/address.go 2013-09-18 02:36:52 +0000
@@ -61,12 +61,17 @@
// HostAddresses looks up the IP addresses of the specified hostAddr} , nil
// host, and translates them into instance.Address values.
-func HostAddresses(host string) ([]Address, error) {
+func HostAddresses(host string) (addrs []Address, err error) {
+ hostAddr := NewAddress(host)
+ if hostAddr.Type != HostName {
+ // IPs shouldn't be fed into LookupIP.
+ return []Address{
+ }
ipaddrs, err := net.LookupIP(host)
if err != nil {
return nil, err
}
- addrs := make([]Address, len(ipaddrs))
+ addrs = make([]Address, len(ipaddrs)+1)
for i, ipaddr := range ipaddrs {
switch len(ipaddr) {
case 4:
@@ -77,6 +82,7 @@
addrs[i].Value = ipaddr.String()
}
}
+ addrs[len(addrs)-1] = hostAddr
return addrs, err
}
Index: environs/ manual/ provisioner. go manual/ provisioner. go' manual/ provisioner. go 2013-09-03 01:56:25 +0000 manual/ provisioner. go 2013-09-18 02:36:52 +0000
=== modified file 'environs/
--- environs/
+++ environs/
@@ -6,6 +6,7 @@
import (
"errors"
"fmt"
+ "net"
"strings"
"launchpad. net/loggo" Index(sshHostWi thoutUser, "@"); at != -1 { outUser = sshHostWithoutU ser[at+ 1:] sshHostWithoutU ser); ip != nil { ip.String( )) Warningf( "failed to resolve %v: %v", ip, err) Infof(" resolved %v to %v", ip, names) HostAddresses( sshHostWithoutU ser) Infof(" addresses for %v: %v", sshHostWithoutUser, addrs)
@@ -71,10 +72,22 @@
if at := strings.
sshHostWith
}
+ if ip := net.ParseIP(
+ // Do a reverse-lookup on the IP. The IP may not have
+ // a DNS entry, so just log a warning if this fails.
+ names, err := net.LookupAddr(
+ if err != nil {
+ logger.
+ } else {
+ logger.
+ sshHostWithoutUser = names[0]
+ }
+ }
addrs, err := instance.
if err != nil {
return nil, err
}
+ logger.
provisioned, err := checkProvisione d(args. Host)
if err != nil {