Merge lp:~axwalk/juju-core/machiner-host-addresses into lp:~go-bot/juju-core/trunk
Proposed by
Andrew Wilkins
Status: | Merged |
---|---|
Approved by: | Andrew Wilkins |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2225 |
Proposed branch: | lp:~axwalk/juju-core/machiner-host-addresses |
Merge into: | lp:~go-bot/juju-core/trunk |
Diff against target: |
124 lines (+70/-0) 3 files modified
worker/machiner/export_test.go (+6/-0) worker/machiner/machiner.go (+39/-0) worker/machiner/machiner_test.go (+25/-0) |
To merge this branch: | bzr merge lp:~axwalk/juju-core/machiner-host-addresses |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+202383@code.launchpad.net |
Commit message
worker/machiner: set machine addresses in SetUp
The machiner worker is updated to, at setup time,
set the machine's addresses to all of the non-loopback
interface addresses as detected from within the
machine. This enables us to record addresses for
containers created by the local provider.
Description of the change
worker/machiner: set machine addresses in SetUp
The machiner worker is updated to, at setup time,
set the machine's addresses to all of the non-loopback
interface addresses as detected from within the
machine. This enables us to record addresses for
containers created by the local provider.
To post a comment you must log in.
Reviewers: mp+202383_ code.launchpad. net,
Message:
Please take a look.
Description:
worker/machiner: set machine addresses in SetUp
The machiner worker is updated to, at setup time,
set the machine's addresses to all of the non-loopback
interface addresses as detected from within the
machine. This enables us to record addresses for
containers created by the local provider.
https:/ /code.launchpad .net/~axwalk/ juju-core/ machiner- host-addresses/ +merge/ 202383
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/54710043/
Affected files (+74, -0 lines): machiner/ export_ test.go machiner/ machiner. go machiner/ machiner_ test.go
A [revision details]
A worker/
M worker/
M worker/
Index: [revision details] 20140120214742- p8sw7oef0btqzfb 0
=== 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: worker/ machiner/ export_ test.go machiner/ export_ test.go' machiner/ export_ test.go 1970-01-01 00:00:00 +0000 machiner/ export_ test.go 2014-01-20 22:01:41 +0000
=== added file 'worker/
--- worker/
+++ worker/
@@ -0,0 +1,6 @@
+// Copyright 2014 Canonical Ltd.
+// Licensed under the AGPLv3, see LICENCE file for details.
+
+package machiner
+
+var InterfaceAddrs = &interfaceAddrs
Index: worker/ machiner/ machiner. go machiner/ machiner. go' machiner/ machiner. go 2014-01-03 15:34:52 +0000 machiner/ machiner. go 2014-01-20 22:04:23 +0000
=== modified file 'worker/
--- worker/
+++ worker/
@@ -4,10 +4,12 @@
import (
"fmt"
+ "net"
"launchpad. net/loggo"
"launchpad. net/juju- core/agent" net/juju- core/instance" net/juju- core/state/ api/machiner" net/juju- core/state/ api/params" net/juju- core/state/ api/watcher"
+ "launchpad.
"launchpad.
"launchpad.
"launchpad.
@@ -41,6 +43,11 @@
}
mr.machine = m
+ // Set the addresses in state to the host's addresses. sses(m) ; err != nil { params. StatusStarted, "", nil); err != nil {
+ if err := setMachineAddre
+ return nil, err
+ }
+
// Mark the machine as started and log it.
if err := m.SetStatus(
return nil, fmt.Errorf("%s failed to set status started: %v", mr.tag,
err)
@@ -50,6 +57,40 @@
return m.Watch()
}
+var interfaceAddrs = net.InterfaceAddrs sses(m *machiner.Machine) error { hostAddresses, instance. NewAddress( ip.String( ))) Infof(" setting addresses for %v to %q"...
+
+// setMachineAddresses sets the addresses for this machine to all of the
+// host's non-loopback interface IP addresses. We only need to do this for
+// containers; instances' addresses are updated via the addressupdater
worker
+// by querying the provider.
+func setMachineAddre
+ addrs, err := interfaceAddrs()
+ if err != nil {
+ return err
+ }
+ var hostAddresses []instance.Address
+ for _, addr := range addrs {
+ var ip net.IP
+ switch addr := addr.(type) {
+ case *net.IPAddr:
+ ip = addr.IP
+ case *net.IPNet:
+ ip = addr.IP
+ default:
+ continue
+ }
+ if ip.IsLoopback() {
+ continue
+ }
+ hostAddresses = append(
+ }
+ if len(hostAddresses) == 0 {
+ return nil
+ }
+ logger.