~juju-qa/ubuntu/xenial/juju/xenial-2.0-beta3

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/state/address.go

  • Committer: Martin Packman
  • Date: 2016-03-30 19:31:08 UTC
  • mfrom: (1.1.41)
  • Revision ID: martin.packman@canonical.com-20160330193108-h9iz3ak334uk0z5r
Merge new upstream source 2.0~beta3

Show diffs side-by-side

added added

removed removed

Lines of Context:
109
109
// SetAPIHostPorts sets the addresses of the API server instances.
110
110
// Each server is represented by one element in the top level slice.
111
111
func (st *State) SetAPIHostPorts(netHostsPorts [][]network.HostPort) error {
112
 
        // Filter any addresses not on the default space, if possible.
113
 
        // All API servers need to be accessible there.
114
 
        var hpsToSet [][]network.HostPort
115
 
        for _, hps := range netHostsPorts {
116
 
                defaultSpaceHP, ok := network.SelectHostPortBySpace(hps, network.DefaultSpace)
117
 
                if !ok {
118
 
                        logger.Warningf("cannot determine API addresses in space %q to use as API endpoints; using all addresses", network.DefaultSpace)
119
 
                        hpsToSet = netHostsPorts
120
 
                        break
121
 
                }
122
 
                hpsToSet = append(hpsToSet, []network.HostPort{defaultSpaceHP})
123
 
        }
124
 
 
125
112
        doc := apiHostPortsDoc{
126
 
                APIHostPorts: fromNetworkHostsPorts(hpsToSet),
 
113
                APIHostPorts: fromNetworkHostsPorts(netHostsPorts),
127
114
        }
128
115
        buildTxn := func(attempt int) ([]txn.Op, error) {
129
116
                existing, err := st.APIHostPorts()
147
134
        if err := st.run(buildTxn); err != nil {
148
135
                return errors.Annotate(err, "cannot set API addresses")
149
136
        }
150
 
        logger.Debugf("setting API hostPorts: %v", hpsToSet)
 
137
        logger.Debugf("setting API hostPorts: %v", netHostsPorts)
151
138
        return nil
152
139
}
153
140