Generate LXC config upon start rather than at container creation

This commit is contained in:
Andrea Luzzardi 2013-02-13 18:14:46 -08:00
Родитель e871eadab1
Коммит 1793538a68
1 изменённых файлов: 9 добавлений и 9 удалений

Просмотреть файл

@ -90,9 +90,6 @@ func createContainer(id string, root string, command string, args []string, laye
if err := container.save(); err != nil { if err := container.save(); err != nil {
return nil, err return nil, err
} }
if err := container.generateLXCConfig(); err != nil {
return nil, err
}
return container, nil return container, nil
} }
@ -102,10 +99,11 @@ func loadContainer(containerPath string) (*Container, error) {
return nil, err return nil, err
} }
container := &Container{ container := &Container{
stdout: newWriteBroadcaster(), stdout: newWriteBroadcaster(),
stderr: newWriteBroadcaster(), stderr: newWriteBroadcaster(),
stdoutLog: new(bytes.Buffer), stdoutLog: new(bytes.Buffer),
stderrLog: new(bytes.Buffer), stderrLog: new(bytes.Buffer),
lxcConfigPath: path.Join(containerPath, "config.lxc"),
} }
if err := json.Unmarshal(data, container); err != nil { if err := json.Unmarshal(data, container); err != nil {
return nil, err return nil, err
@ -178,7 +176,7 @@ func (container *Container) save() (err error) {
if err != nil { if err != nil {
return return
} }
return ioutil.WriteFile(path.Join(container.Root, "config.json"), data, 0700) return ioutil.WriteFile(path.Join(container.Root, "config.json"), data, 0666)
} }
func (container *Container) generateLXCConfig() error { func (container *Container) generateLXCConfig() error {
@ -265,7 +263,9 @@ func (container *Container) Start() error {
if err := container.Filesystem.EnsureMounted(); err != nil { if err := container.Filesystem.EnsureMounted(); err != nil {
return err return err
} }
if err := container.generateLXCConfig(); err != nil {
return err
}
params := []string{ params := []string{
"-n", container.Id, "-n", container.Id,
"-f", container.lxcConfigPath, "-f", container.lxcConfigPath,