2014-10-23 04:45:23 +08:00
|
|
|
// +build linux
|
|
|
|
|
|
|
|
package libcontainer
|
|
|
|
|
2014-10-31 06:08:28 +08:00
|
|
|
import (
|
|
|
|
"github.com/docker/libcontainer/network"
|
2014-12-06 09:02:49 +08:00
|
|
|
"github.com/golang/glog"
|
2014-10-31 06:08:28 +08:00
|
|
|
)
|
2014-10-23 04:45:23 +08:00
|
|
|
|
|
|
|
type linuxContainer struct {
|
2014-10-23 07:53:28 +08:00
|
|
|
id string
|
|
|
|
root string
|
|
|
|
config *Config
|
|
|
|
state *State
|
|
|
|
cgroupManager CgroupManager
|
2014-10-23 04:45:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *linuxContainer) ID() string {
|
|
|
|
return c.id
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *linuxContainer) Config() *Config {
|
|
|
|
return c.config
|
|
|
|
}
|
|
|
|
|
2014-10-23 07:53:28 +08:00
|
|
|
func (c *linuxContainer) RunState() (RunState, error) {
|
2014-10-23 04:45:23 +08:00
|
|
|
panic("not implemented")
|
|
|
|
}
|
|
|
|
|
2014-10-23 07:27:06 +08:00
|
|
|
func (c *linuxContainer) Processes() ([]int, error) {
|
2014-12-06 09:06:58 +08:00
|
|
|
glog.Info("fetch container processes")
|
2014-12-06 09:02:49 +08:00
|
|
|
pids, err := c.cgroupManager.GetPids()
|
2014-10-23 04:45:23 +08:00
|
|
|
if err != nil {
|
|
|
|
return nil, newGenericError(err, SystemError)
|
|
|
|
}
|
|
|
|
return pids, nil
|
|
|
|
}
|
|
|
|
|
2014-10-23 07:27:06 +08:00
|
|
|
func (c *linuxContainer) Stats() (*ContainerStats, error) {
|
2014-12-06 09:06:58 +08:00
|
|
|
glog.Info("fetch container stats")
|
2014-10-23 04:45:23 +08:00
|
|
|
var (
|
|
|
|
err error
|
|
|
|
stats = &ContainerStats{}
|
|
|
|
)
|
|
|
|
|
2014-12-06 09:02:49 +08:00
|
|
|
if stats.CgroupStats, err = c.cgroupManager.GetStats(); err != nil {
|
2014-10-23 04:45:23 +08:00
|
|
|
return stats, newGenericError(err, SystemError)
|
|
|
|
}
|
|
|
|
if stats.NetworkStats, err = network.GetStats(&c.state.NetworkState); err != nil {
|
|
|
|
return stats, newGenericError(err, SystemError)
|
|
|
|
}
|
|
|
|
return stats, nil
|
|
|
|
}
|
2014-10-28 08:51:14 +08:00
|
|
|
|
|
|
|
func (c *linuxContainer) StartProcess(config *ProcessConfig) (int, error) {
|
2014-12-06 09:06:58 +08:00
|
|
|
glog.Info("start new container process")
|
2014-10-28 08:51:14 +08:00
|
|
|
panic("not implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *linuxContainer) Destroy() error {
|
2014-12-15 23:00:04 +08:00
|
|
|
state, err := c.RunState()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if state != Destroyed {
|
|
|
|
return newGenericError(nil, ContainerNotStopped)
|
|
|
|
}
|
|
|
|
|
2014-12-06 09:06:58 +08:00
|
|
|
glog.Info("destroy container")
|
2014-10-28 08:51:14 +08:00
|
|
|
panic("not implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *linuxContainer) Pause() error {
|
2014-12-06 09:06:58 +08:00
|
|
|
glog.Info("pause container")
|
2014-10-28 08:51:14 +08:00
|
|
|
panic("not implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *linuxContainer) Resume() error {
|
2014-12-06 09:06:58 +08:00
|
|
|
glog.Info("resume container")
|
2014-10-28 08:51:14 +08:00
|
|
|
panic("not implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *linuxContainer) Signal(pid, signal int) error {
|
2014-12-06 09:06:58 +08:00
|
|
|
glog.Infof("sending signal %d to pid %d", signal, pid)
|
2014-10-28 08:51:14 +08:00
|
|
|
panic("not implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *linuxContainer) Wait() (int, error) {
|
2014-12-06 09:06:58 +08:00
|
|
|
glog.Info("wait container")
|
2014-10-28 08:51:14 +08:00
|
|
|
panic("not implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *linuxContainer) WaitProcess(pid int) (int, error) {
|
2014-12-06 09:06:58 +08:00
|
|
|
glog.Infof("wait process %d", pid)
|
2014-10-28 08:51:14 +08:00
|
|
|
panic("not implemented")
|
|
|
|
}
|