~jameinel/juju-core/api-registry-tracks-type

« back to all changes in this revision

Viewing changes to environs/ec2/ec2.go

Merge trunk and resolve conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
        "launchpad.net/juju-core/state"
15
15
        "launchpad.net/juju-core/state/api"
16
16
        "launchpad.net/juju-core/state/api/params"
17
 
        "launchpad.net/juju-core/trivial"
 
17
        "launchpad.net/juju-core/utils"
18
18
        "launchpad.net/juju-core/version"
19
19
        "net/http"
20
20
        "strings"
33
33
// state transition (for instance an instance taking a while to release
34
34
// a security group after termination).  The former failure mode is
35
35
// dealt with by shortAttempt, the latter by longAttempt.
36
 
var shortAttempt = trivial.AttemptStrategy{
 
36
var shortAttempt = utils.AttemptStrategy{
37
37
        Total: 5 * time.Second,
38
38
        Delay: 200 * time.Millisecond,
39
39
}
40
40
 
41
 
var longAttempt = trivial.AttemptStrategy{
 
41
var longAttempt = utils.AttemptStrategy{
42
42
        Total: 3 * time.Minute,
43
43
        Delay: 1 * time.Second,
44
44
}
285
285
        if !hasCert {
286
286
                return fmt.Errorf("no CA certificate in environment configuration")
287
287
        }
288
 
        mongoURL := environs.MongoURL(e, tools.Series, tools.Arch)
289
288
        inst, err := e.startInstance(&startInstanceParams{
290
289
                machineId:    "0",
291
290
                machineNonce: state.BootstrapNonce,
292
291
                series:       tools.Series,
293
292
                constraints:  cons,
294
293
                info: &state.Info{
295
 
                        Password: trivial.PasswordHash(password),
 
294
                        Password: utils.PasswordHash(password),
296
295
                        CACert:   caCert,
297
296
                },
298
297
                apiInfo: &api.Info{
299
 
                        Password: trivial.PasswordHash(password),
 
298
                        Password: utils.PasswordHash(password),
300
299
                        CACert:   caCert,
301
300
                },
302
301
                tools:           tools,
303
 
                mongoURL:        mongoURL,
304
302
                stateServer:     true,
305
303
                config:          config,
306
304
                stateServerCert: cert,
403
401
                DataDir:         "/var/lib/juju",
404
402
                Tools:           scfg.tools,
405
403
                MachineNonce:    scfg.machineNonce,
406
 
                MongoURL:        scfg.mongoURL,
407
404
                MachineId:       scfg.machineId,
408
405
                AuthorizedKeys:  e.ecfg().AuthorizedKeys(),
409
406
                Config:          scfg.config,
417
414
        if err != nil {
418
415
                return nil, err
419
416
        }
420
 
        cdata := trivial.Gzip(data)
 
417
        cdata := utils.Gzip(data)
421
418
        log.Debugf("environs/ec2: ec2 user data; %d bytes: %q", len(cdata), data)
422
419
        return cdata, nil
423
420
}
430
427
        info            *state.Info
431
428
        apiInfo         *api.Info
432
429
        tools           *state.Tools
433
 
        mongoURL        string
434
430
        stateServer     bool
435
431
        config          *config.Config
436
432
        stateServerCert []byte
1031
1027
// http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html
1032
1028
func fetchMetadata(name string) (value string, err error) {
1033
1029
        uri := fmt.Sprintf("%s/2011-01-01/meta-data/%s", metadataHost, name)
1034
 
        defer trivial.ErrorContextf(&err, "cannot get %q", uri)
 
1030
        defer utils.ErrorContextf(&err, "cannot get %q", uri)
1035
1031
        for a := shortAttempt.Start(); a.Next(); {
1036
1032
                var resp *http.Response
1037
1033
                resp, err = http.Get(uri)