Merge lp://staging/~natefinch/juju-core/039-saveapiaddresses into lp://staging/~go-bot/juju-core/trunk

Proposed by Nate Finch
Status: Work in progress
Proposed branch: lp://staging/~natefinch/juju-core/039-saveapiaddresses
Merge into: lp://staging/~go-bot/juju-core/trunk
Diff against target: 34 lines (+10/-0)
1 file modified
cmd/jujud/machine.go (+10/-0)
To merge this branch: bzr merge lp://staging/~natefinch/juju-core/039-saveapiaddresses
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+213530@code.staging.launchpad.net

Description of the change

save apiaddresses to agent config

https://codereview.appspot.com/82780043/

To post a comment you must log in.
Revision history for this message
Nate Finch (natefinch) wrote :

Reviewers: mp+213530_code.launchpad.net,

Message:
Please take a look.

Description:
save apiaddresses to agent config

https://code.launchpad.net/~natefinch/juju-core/039-saveapiaddresses/+merge/213530

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/82780043/

Affected files (+20, -0 lines):
   A [revision details]
   M agent/agent.go
   M cmd/jujud/machine.go

Index: [revision details]
=== 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-20140331151115-oc6nja5tv9g8z7l1
+New revision: <email address hidden>

Index: agent/agent.go
=== modified file 'agent/agent.go'
--- agent/agent.go 2014-03-31 06:30:43 +0000
+++ agent/agent.go 2014-03-31 18:13:17 +0000
@@ -152,6 +152,9 @@
   // (if DataDir is set), the the caller is responsible for removing
   // the old configuration.
   Migrate(MigrateParams) error
+
+ // SetAPIAddresses sets the addresses that the agent will try to connect
to.
+ SetAPIAddresses(addrs []string)
  }

  type ConfigWriter interface {
@@ -441,6 +444,10 @@
   c.apiDetails.addresses = addrs
  }

+func (c *configInternal) SetAPIAddresses(addrs []string) {
+ c.apiDetails.addresses = addrs
+}
+
  func (c *configInternal) SetValue(key, value string) {
   if value == "" {
    delete(c.values, key)

Index: cmd/jujud/machine.go
=== modified file 'cmd/jujud/machine.go'
--- cmd/jujud/machine.go 2014-03-28 10:11:59 +0000
+++ cmd/jujud/machine.go 2014-03-31 18:14:18 +0000
@@ -334,6 +334,16 @@
    return nil, err
   }
   a.st = st
+
+ addrs, err := st.APIAddressesFromMachines()
+ if err != nil {
+ return nil, fmt.Errorf("Error getting API addresses from state: %v", err)
+ }
+ err = a.ChangeConfig(func(c agent.ConfigSetter) {
c.SetAPIAddresses(addrs) })
+ if err != nil {
+ return nil, fmt.Errorf("Error saving API addresses to agent config: %v",
err)
+ }
+
   close(a.stateOpened)
   reportOpenedState(st)

@@ -403,6 +413,7 @@
     st.Close()
    }
   }()
+
   m0, err := st.FindEntity(agentConfig.Tag())
   if err != nil {
    if errors.IsNotFoundError(err) {

2523. By Nate Finch

change to get the correct addresses

Revision history for this message
Nate Finch (natefinch) wrote :
Revision history for this message
William Reade (fwereade) wrote :

Code looks fine, but we need a test for this.

https://codereview.appspot.com/82780043/diff/20001/cmd/jujud/machine.go
File cmd/jujud/machine.go (right):

https://codereview.appspot.com/82780043/diff/20001/cmd/jujud/machine.go#newcode193
cmd/jujud/machine.go:193: return nil, fmt.Errorf("Error saving API
HostPorts to agent config: %v", err)
s/Error/error/

...and HostPorts is a pretty weird noun. Would "addresses" work better?

https://codereview.appspot.com/82780043/

Unmerged revisions

2523. By Nate Finch

change to get the correct addresses

2522. By Nate Finch

too many returns

2521. By Nate Finch

save api addresses

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to status/vote changes: