~rogpeppe/juju-core/azure

« back to all changes in this revision

Viewing changes to environs/local/environprovider.go

[r=thumper] Add the initial bootstrap implementation.

This isn't all that is needed to bootstrap, but it is the start.
In particular, this adds the mongo upstart service. This branch
also adds a very simple instance implementation for the local
instances.

https://codereview.appspot.com/11325043/

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
        "launchpad.net/juju-core/environs/config"
13
13
        "launchpad.net/juju-core/instance"
14
14
        "launchpad.net/juju-core/utils"
 
15
        "launchpad.net/juju-core/version"
15
16
)
16
17
 
17
18
var logger = loggo.GetLogger("juju.environs.local")
27
28
}
28
29
 
29
30
// Open implements environs.EnvironProvider.Open.
30
 
func (environProvider) Open(cfg *config.Config) (environs.Environ, error) {
 
31
func (environProvider) Open(cfg *config.Config) (env environs.Environ, err error) {
31
32
        logger.Infof("opening environment %q", cfg.Name())
 
33
        if _, ok := cfg.AgentVersion(); !ok {
 
34
                cfg, err = cfg.Apply(map[string]interface{}{
 
35
                        "agent-version": version.CurrentNumber().String(),
 
36
                })
 
37
                if err != nil {
 
38
                        return nil, err
 
39
                }
 
40
        }
32
41
        environ := &localEnviron{name: cfg.Name()}
33
 
        err := environ.SetConfig(cfg)
 
42
        err = environ.SetConfig(cfg)
34
43
        if err != nil {
35
44
                logger.Errorf("failure setting config: %v", err)
36
45
                return nil, err
108
117
 
109
118
// InstanceId implements environs.EnvironProvider.InstanceId.
110
119
func (environProvider) InstanceId() (instance.Id, error) {
111
 
        return "", fmt.Errorf("not implemented")
 
120
        // This hack only works until we get containers started.
 
121
        return instance.Id("localhost"), nil
112
122
}
113
123
 
114
124
func (environProvider) newConfig(cfg *config.Config) (*environConfig, error) {