forked from juju/juju
-
Notifications
You must be signed in to change notification settings - Fork 0
/
provider_configurator.go
51 lines (41 loc) · 1.67 KB
/
provider_configurator.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright 2015 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package openstack
import (
"github.com/go-goose/goose/v5/nova"
"github.com/juju/errors"
"github.com/juju/schema"
"github.com/juju/juju/cloudconfig/cloudinit"
"github.com/juju/juju/environs"
)
// This interface is added to allow to customize OpenStack provider behaviour.
// This is used in other providers, that embeds OpenStack provider.
type ProviderConfigurator interface {
// GetConfigDefaults sets some configuration default values, if any
GetConfigDefaults() schema.Defaults
// This method allows to adjust default RunServerOptions,
// before new server is actually created.
ModifyRunServerOptions(options *nova.RunServerOpts)
// This method provides default cloud config.
// This config can be different for different providers.
GetCloudConfig(args environs.StartInstanceParams) (cloudinit.CloudConfig, error)
}
type defaultConfigurator struct{}
// ModifyRunServerOptions implements ProviderConfigurator interface.
func (c *defaultConfigurator) ModifyRunServerOptions(_ *nova.RunServerOpts) {
}
// GetCloudConfig implements ProviderConfigurator interface.
func (c *defaultConfigurator) GetCloudConfig(args environs.StartInstanceParams) (cloudinit.CloudConfig, error) {
cloudCfg, err := cloudinit.New(args.InstanceConfig.Base.OS)
return cloudCfg, errors.Trace(err)
}
// GetConfigDefaults implements ProviderConfigurator interface.
func (c *defaultConfigurator) GetConfigDefaults() schema.Defaults {
return schema.Defaults{
"use-default-secgroup": false,
"network": "",
"external-network": "",
"use-openstack-gbp": false,
"policy-target-group": "",
}
}