Example #1
0
func (ctx *VmContext) allocateInterface(index int, pciAddr int, name string) (*InterfaceCreated, error) {
	var err error
	var inf *network.Settings
	var maps []pod.UserContainerPort

	if index == 0 {
		for _, c := range ctx.userSpec.Containers {
			for _, m := range c.Ports {
				maps = append(maps, m)
			}
		}
	}

	if HDriver.BuildinNetwork() {
		inf, err = ctx.DCtx.AllocateNetwork(ctx.Id, "", maps)
	} else {
		inf, err = network.Allocate(ctx.Id, "", false, maps)
	}

	if err != nil {
		glog.Error("interface creating failed: ", err.Error())

		return &InterfaceCreated{Index: index, PCIAddr: pciAddr, DeviceName: name}, err
	}

	return interfaceGot(index, pciAddr, name, inf)
}
Example #2
0
func (ctx *VmContext) allocateInterface(index int, pciAddr int, name string,
	maps []pod.UserContainerPort) (*InterfaceCreated, error) {
	var inf *network.Settings
	var err error

	if HDriver.BuildinNetwork() {
		inf, err = ctx.DCtx.AllocateNetwork(ctx.Id, "", maps)
	} else {
		inf, err = network.Allocate(ctx.Id, "", index, false, maps)
	}

	if err != nil {
		glog.Error("interface creating failed: ", err.Error())

		return &InterfaceCreated{Index: index, PCIAddr: pciAddr, DeviceName: name}, err
	}

	return interfaceGot(index, pciAddr, name, inf)
}
Example #3
0
func (lc *LibvirtContext) AllocateNetwork(vmId, requestedIP string,
	maps []pod.UserContainerPort) (*network.Settings, error) {
	return network.Allocate(vmId, requestedIP, true, maps)
}
Example #4
0
func (lc *LibvirtContext) AllocateNetwork(vmId, requestedIP string) (*network.Settings, error) {
	return network.Allocate(vmId, requestedIP, true)
}