Exemplo n.º 1
0
func (c *containerLXD) RenderState() (*shared.ContainerState, error) {
	statusCode := shared.FromLXCState(int(c.c.State()))
	status := shared.ContainerStatus{
		Status:     statusCode.String(),
		StatusCode: statusCode,
	}

	if c.IsRunning() {
		pid, _ := c.InitPidGet()
		status.Init = pid
		status.Ips = c.iPsGet()
	}

	return &shared.ContainerState{
		Name:            c.name,
		Profiles:        c.profiles,
		Config:          c.baseConfig,
		ExpandedConfig:  c.config,
		Userdata:        []byte{},
		Status:          status,
		Devices:         c.baseDevices,
		ExpandedDevices: c.devices,
		Ephemeral:       c.ephemeral,
	}, nil
}
Exemplo n.º 2
0
func newStatus(c *lxc.Container, state lxc.State) shared.ContainerStatus {
	status := shared.ContainerStatus{State: state.String(), StateCode: shared.State(int(state))}
	if state == lxc.RUNNING {
		status.Init = c.InitPid()
		status.Ips = getIps(c)
	}
	return status
}