/
interface.go
51 lines (40 loc) · 1.35 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
// Copyright 2013 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package kvm
import (
"github.com/juju/juju/container"
)
// StartParams is a simple parameter struct for Container.Start.
type StartParams struct {
Series string
Arch string
UserDataFile string
Network *container.NetworkConfig
Memory uint64 // MB
CpuCores uint64
RootDisk uint64 // GB
}
// Container represents a virtualized container instance and provides
// operations to create, maintain and destroy the container.
type Container interface {
// Name returns the name of the container.
Name() string
// Start runs the container as a daemon.
Start(params StartParams) error
// Stop terminates the running container.
Stop() error
// IsRunning returns wheter or not the container is running and active.
IsRunning() bool
// String returns information about the container, like the name, state,
// and process id.
String() string
}
// ContainerFactory represents the methods used to create Containers. This
// wraps the low level OS functions for dealing with the containers.
type ContainerFactory interface {
// New returns a container instance which can then be used for operations
// like Start() and Stop()
New(string) Container
// List returns all the existing containers on the system.
List() ([]Container, error)
}