add more codes
This commit is contained in:
@@ -10,27 +10,28 @@ type Manager interface {
|
||||
}
|
||||
|
||||
type Spec struct {
|
||||
ID string
|
||||
Name string
|
||||
Template string
|
||||
RootfsPool string
|
||||
RootfsSizeG int
|
||||
NICs []NICSpec
|
||||
Limits Limits
|
||||
Unprivileged bool
|
||||
ID string `json:"id" yaml:"id"`
|
||||
Name string `json:"name" yaml:"name"`
|
||||
Template string `json:"template" yaml:"template"`
|
||||
RootfsPool string `json:"rootfs_pool" yaml:"rootfs_pool"`
|
||||
RootfsSizeG int `json:"rootfs_size_g" yaml:"rootfs_size_g"`
|
||||
RootfsPath string `json:"rootfs_path" yaml:"rootfs_path"`
|
||||
NICs []NICSpec `json:"nics" yaml:"nics"`
|
||||
Limits Limits `json:"limits" yaml:"limits"`
|
||||
Unprivileged bool `json:"unprivileged" yaml:"unprivileged"`
|
||||
}
|
||||
|
||||
type NICSpec struct {
|
||||
Bridge string
|
||||
VLAN int
|
||||
HWAddr string
|
||||
MTU int
|
||||
Name string
|
||||
Bridge string `json:"bridge" yaml:"bridge"`
|
||||
VLAN int `json:"vlan" yaml:"vlan"`
|
||||
HWAddr string `json:"hwaddr" yaml:"hwaddr"`
|
||||
MTU int `json:"mtu" yaml:"mtu"`
|
||||
Name string `json:"name" yaml:"name"`
|
||||
}
|
||||
|
||||
type Limits struct {
|
||||
CPU int
|
||||
MemoryMB int
|
||||
CPU int `json:"cpus" yaml:"cpus"`
|
||||
MemoryMB int `json:"memory_mb" yaml:"memory_mb"`
|
||||
}
|
||||
|
||||
type Container struct {
|
||||
|
||||
@@ -101,7 +101,10 @@ func renderConfig(spec Spec) (string, error) {
|
||||
fmt.Fprintf(buf, "lxc.idmap = u 0 %d %d\n", uidStart, count)
|
||||
fmt.Fprintf(buf, "lxc.idmap = g 0 %d %d\n", uidStart, count)
|
||||
}
|
||||
rootfs := fmt.Sprintf("/var/lib/lxc/%s/rootfs", spec.Name)
|
||||
rootfs := spec.RootfsPath
|
||||
if rootfs == "" {
|
||||
rootfs = fmt.Sprintf("/var/lib/lxc/%s/rootfs", spec.Name)
|
||||
}
|
||||
fmt.Fprintf(buf, "lxc.rootfs.path = dir:%s\n", rootfs)
|
||||
for idx, nic := range spec.NICs {
|
||||
fmt.Fprintf(buf, "lxc.net.%d.type = veth\n", idx)
|
||||
|
||||
Reference in New Issue
Block a user