-
Notifications
You must be signed in to change notification settings - Fork 0
/
interface.go
75 lines (63 loc) · 2.38 KB
/
interface.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright 2013 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package container
import (
"github.com/juju/juju/cloudconfig/instancecfg"
"github.com/juju/juju/constraints"
"github.com/juju/juju/environs"
"github.com/juju/juju/instance"
)
const (
ConfigModelUUID = "model-uuid"
ConfigLogDir = "log-dir"
ConfigAvailabilityZone = "availability-zone"
)
// ManagerConfig contains the initialization parameters for the ContainerManager.
// The name of the manager is used to namespace the containers on the machine.
type ManagerConfig map[string]string
// Manager is responsible for starting containers, and stopping and listing
// containers that it has started.
type Manager interface {
// CreateContainer creates and starts a new container for the specified
// machine.
CreateContainer(
instanceConfig *instancecfg.InstanceConfig,
cons constraints.Value,
series string,
network *NetworkConfig,
storage *StorageConfig,
callback environs.StatusCallbackFunc) (instance.Instance, *instance.HardwareCharacteristics, error)
// DestroyContainer stops and destroyes the container identified by
// instance id.
DestroyContainer(instance.Id) error
// ListContainers return a list of containers that have been started by
// this manager.
ListContainers() ([]instance.Instance, error)
// IsInitialized check whether or not required packages have been installed
// to support this manager.
IsInitialized() bool
// Namespace returns the namespace of the manager. This namespace defines the
// prefix of all the hostnames.
Namespace() instance.Namespace
}
// Initialiser is responsible for performing the steps required to initialise
// a host machine so it can run containers.
type Initialiser interface {
// Initialise installs all required packages, sync any images etc so
// that the host machine can run containers.
Initialise() error
}
// PopValue returns the requested key from the config map. If the value
// doesn't exist, the function returns the empty string. If the value does
// exist, the value is returned, and the element removed from the map.
func (m ManagerConfig) PopValue(key string) string {
value := m[key]
delete(m, key)
return value
}
// WarnAboutUnused emits a warning about each value in the map.
func (m ManagerConfig) WarnAboutUnused() {
for key, value := range m {
logger.Infof("unused config option: %q -> %q", key, value)
}
}