Exemple #1
0
func main() {
	b := devices.Bridge{}

	for i := 0; i < 10; i++ {
		_, subnet, _ := net.ParseCIDR("2.3.4.5/30")
		if _, err := b.Create("testbridge"+os.Args[1], net.ParseIP("1.2.3.4"), subnet); err != nil {
			fmt.Println(os.Stderr, "create bridge: ", err)
			os.Exit(2)
		}

		if err := b.Destroy("testbridge" + os.Args[1]); err != nil {
			fmt.Println(os.Stderr, "destroy bridge: ", err)
			os.Exit(3)
		}
	}
}
package devices_test

import (
	"fmt"
	"net"

	"github.com/cloudfoundry-incubator/garden-linux/network/devices"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Bridge Management", func() {
	var (
		b      devices.Bridge
		name   string
		addr   string
		ip     net.IP
		subnet *net.IPNet
	)

	BeforeEach(func() {
		name = fmt.Sprintf("gdn-test-intf-%d", GinkgoParallelNode())

		var err error
		addr = "10.9.0.1/30"
		ip, subnet, err = net.ParseCIDR(addr)
		Expect(err).ToNot(HaveOccurred())
	})

	AfterEach(func() {
		cleanup(name)