forked from juju/juju
-
Notifications
You must be signed in to change notification settings - Fork 0
/
instance.go
60 lines (47 loc) · 1.39 KB
/
instance.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
// Copyright 2013 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package kvm
import (
"fmt"
"github.com/juju/juju/instance"
"github.com/juju/juju/network"
)
type kvmInstance struct {
container Container
id string
}
var _ instance.Instance = (*kvmInstance)(nil)
// Id implements instance.Instance.Id.
func (kvm *kvmInstance) Id() instance.Id {
return instance.Id(kvm.id)
}
// Status implements instance.Instance.Status.
func (kvm *kvmInstance) Status() string {
if kvm.container.IsRunning() {
return "running"
}
return "stopped"
}
func (*kvmInstance) Refresh() error {
return nil
}
func (kvm *kvmInstance) Addresses() ([]network.Address, error) {
logger.Errorf("kvmInstance.Addresses not implemented")
return nil, nil
}
// OpenPorts implements instance.Instance.OpenPorts.
func (kvm *kvmInstance) OpenPorts(machineId string, ports []network.Port) error {
return fmt.Errorf("not implemented")
}
// ClosePorts implements instance.Instance.ClosePorts.
func (kvm *kvmInstance) ClosePorts(machineId string, ports []network.Port) error {
return fmt.Errorf("not implemented")
}
// Ports implements instance.Instance.Ports.
func (kvm *kvmInstance) Ports(machineId string) ([]network.Port, error) {
return nil, fmt.Errorf("not implemented")
}
// Add a string representation of the id.
func (kvm *kvmInstance) String() string {
return fmt.Sprintf("kvm:%s", kvm.id)
}