1
// Copyright 2013 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
9
"launchpad.net/juju-core/environs/config"
10
"launchpad.net/juju-core/schema"
13
const defaultStoragePort = 8040
16
configFields = schema.Fields{
17
"bootstrap-host": schema.String(),
18
"bootstrap-user": schema.String(),
19
"storage-listen-ip": schema.String(),
20
"storage-port": schema.Int(),
21
"storage-auth-key": schema.String(),
23
configDefaults = schema.Defaults{
25
"storage-listen-ip": "",
26
"storage-port": defaultStoragePort,
30
type environConfig struct {
32
attrs map[string]interface{}
35
func newEnvironConfig(config *config.Config, attrs map[string]interface{}) *environConfig {
36
return &environConfig{Config: config, attrs: attrs}
39
func (c *environConfig) bootstrapHost() string {
40
return c.attrs["bootstrap-host"].(string)
43
func (c *environConfig) bootstrapUser() string {
44
return c.attrs["bootstrap-user"].(string)
47
func (c *environConfig) storageListenIPAddress() string {
48
return c.attrs["storage-listen-ip"].(string)
51
func (c *environConfig) storagePort() int {
52
return int(c.attrs["storage-port"].(int64))
55
func (c *environConfig) storageAuthKey() string {
56
return c.attrs["storage-auth-key"].(string)
59
// storageAddr returns an address for connecting to the
60
// bootstrap machine's localstorage.
61
func (c *environConfig) storageAddr() string {
62
return fmt.Sprintf("%s:%d", c.bootstrapHost(), c.storagePort())
65
// storageListenAddr returns an address for the bootstrap
66
// machine to listen on for its localstorage.
67
func (c *environConfig) storageListenAddr() string {
68
return fmt.Sprintf("%s:%d", c.storageListenIPAddress(), c.storagePort())