NetworkInterface now contains both VethHost and VethChild

This commit is contained in:
Abin Shahab 2014-10-13 21:03:07 +00:00
parent d009264986
commit 808fd821ac
4 changed files with 17 additions and 7 deletions

View File

@ -29,7 +29,13 @@ type ContainersDesc struct {
type ContainerDesc struct { type ContainerDesc struct {
Id string Id string
Network_interface string Network_interface *NetworkInterface
}
type NetworkInterface struct {
VethHost string
VethChild string
NsPath string
} }
func Unmarshal(containerDescFile string) (ContainersDesc, error) { func Unmarshal(containerDescFile string) (ContainersDesc, error) {

View File

@ -11,7 +11,8 @@ func TestUnmarshal(t *testing.T) {
} }
t.Logf("Cdesc: %s", cDesc) t.Logf("Cdesc: %s", cDesc)
if cDesc.All_hosts[0].Network_interface != "veth7ASIQc" { if cDesc.All_hosts[0].Network_interface.VethHost != "veth24031eth1" &&
cDesc.All_hosts[0].Network_interface.VethChild != "eth1" {
t.Errorf("Cannot find network interface in %s", cDesc) t.Errorf("Cannot find network interface in %s", cDesc)
} }
} }

View File

@ -47,7 +47,7 @@ type lxcContainerHandler struct {
stopWatcher chan error stopWatcher chan error
watches map[string]struct{} watches map[string]struct{}
fsInfo fs.FsInfo fsInfo fs.FsInfo
network_interface string network_interface *NetworkInterface
} }
func newLxcContainerHandler(name string, cgroupSubsystems *cgroupSubsystems, machineInfoFactory info.MachineInfoFactory) (container.ContainerHandler, error) { func newLxcContainerHandler(name string, cgroupSubsystems *cgroupSubsystems, machineInfoFactory info.MachineInfoFactory) (container.ContainerHandler, error) {
@ -56,7 +56,7 @@ func newLxcContainerHandler(name string, cgroupSubsystems *cgroupSubsystems, mac
return nil, err return nil, err
} }
cDesc, err := Unmarshal(*containersDesc) cDesc, err := Unmarshal(*containersDesc)
var network_interface string var network_interface *NetworkInterface
for _, container := range cDesc.All_hosts { for _, container := range cDesc.All_hosts {
cName := "/lxc/" + container.Id cName := "/lxc/" + container.Id
glog.Infof("container %s Name %s \n\n", container, name) glog.Infof("container %s Name %s \n\n", container, name)
@ -176,8 +176,8 @@ func (self *lxcContainerHandler) GetSpec() (info.ContainerSpec, error) {
func (self *lxcContainerHandler) GetStats() (*info.ContainerStats, error) { func (self *lxcContainerHandler) GetStats() (*info.ContainerStats, error) {
var stats *info.ContainerStats var stats *info.ContainerStats
var err error var err error
if len(self.network_interface) > 0 { if self.network_interface != nil {
n := network.NetworkState{VethHost: self.network_interface, VethChild: "unknown", NsPath: "unknown"} n := network.NetworkState{VethHost: self.network_interface.VethHost, VethChild: self.network_interface.VethChild, NsPath: "unknown"}
s := dockerlibcontainer.State{NetworkState: n} s := dockerlibcontainer.State{NetworkState: n}
stats, err = libcontainer.GetStats(self.cgroup, &s) stats, err = libcontainer.GetStats(self.cgroup, &s)
} else { } else {

View File

@ -17,7 +17,10 @@
"role": "compute_node", "role": "compute_node",
"net": null, "net": null,
"netinit": "false", "netinit": "false",
"network_interface": "veth7ASIQc", "network_interface": {
"VethChild": "eth1",
"VethHost": "veth24031eth1"
},
"mounts": [ "mounts": [
{ {
"host-dir": "/var/run/nm-sdc1", "host-dir": "/var/run/nm-sdc1",