Ejemplo n.º 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)
		}
	}
}
Ejemplo n.º 2
0
		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)
	})

	Describe("Create", func() {
		Context("when the bridge does not already exist", func() {
			It("creates a bridge", func() {
				_, err := b.Create(name, ip, subnet)
				Expect(err).ToNot(HaveOccurred())
			})

			It("sets the bridge name", func() {
				bridge, err := b.Create(name, ip, subnet)
				Expect(err).ToNot(HaveOccurred())

				Expect(bridge.Name).To(Equal(name))
			})

			It("sets the bridge address", func() {
				bridge, err := b.Create(name, ip, subnet)
				Expect(err).ToNot(HaveOccurred())

				addrs, err := bridge.Addrs()