~ubuntu-branches/ubuntu/vivid/juju-core/vivid-proposed

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/provider/azure/environprovider.go

  • Committer: Package Import Robot
  • Author(s): Curtis C. Hovey
  • Date: 2015-09-29 19:43:29 UTC
  • mfrom: (47.1.4 wily-proposed)
  • Revision ID: package-import@ubuntu.com-20150929194329-9y496tbic30hc7vp
Tags: 1.24.6-0ubuntu1~15.04.1
Backport of 1.24.6 from wily. (LP: #1500916, #1497087)

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
        "github.com/juju/juju/environs/config"
13
13
)
14
14
 
15
 
// Register the Azure provider with Juju.
16
 
func init() {
17
 
        environs.RegisterProvider("azure", azureEnvironProvider{})
18
 
}
19
 
 
20
15
// Logger for the Azure provider.
21
16
var logger = loggo.GetLogger("juju.provider.azure")
22
17
 
39
34
        return environ, nil
40
35
}
41
36
 
42
 
// Prepare is specified in the EnvironProvider interface.
43
 
func (prov azureEnvironProvider) Prepare(ctx environs.BootstrapContext, cfg *config.Config) (environs.Environ, error) {
 
37
// RestrictedConfigAttributes is specified in the EnvironProvider interface.
 
38
func (prov azureEnvironProvider) RestrictedConfigAttributes() []string {
 
39
        return []string{"location"}
 
40
}
 
41
 
 
42
// PrepareForCreateEnvironment is specified in the EnvironProvider interface.
 
43
func (p azureEnvironProvider) PrepareForCreateEnvironment(cfg *config.Config) (*config.Config, error) {
44
44
        // Set availability-sets-enabled to true
45
45
        // by default, unless the user set a value.
46
46
        if _, ok := cfg.AllAttrs()["availability-sets-enabled"]; !ok {
47
47
                var err error
48
48
                cfg, err = cfg.Apply(map[string]interface{}{"availability-sets-enabled": true})
49
49
                if err != nil {
50
 
                        return nil, err
 
50
                        return nil, errors.Trace(err)
51
51
                }
52
52
        }
 
53
        return cfg, nil
 
54
}
 
55
 
 
56
// PrepareForBootstrap is specified in the EnvironProvider interface.
 
57
func (prov azureEnvironProvider) PrepareForBootstrap(ctx environs.BootstrapContext, cfg *config.Config) (environs.Environ, error) {
 
58
        cfg, err := prov.PrepareForCreateEnvironment(cfg)
 
59
        if err != nil {
 
60
                return nil, errors.Trace(err)
 
61
        }
53
62
        env, err := prov.Open(cfg)
54
63
        if err != nil {
55
 
                return nil, err
 
64
                return nil, errors.Trace(err)
56
65
        }
57
66
        if ctx.ShouldVerifyCredentials() {
58
67
                if err := verifyCredentials(env.(*azureEnviron)); err != nil {
59
 
                        return nil, err
 
68
                        return nil, errors.Trace(err)
60
69
                }
61
70
        }
62
71
        return env, nil