func (cv CreateVeth) Execute(context executor.Context) error {
	err := context.LinkFactory().CreateVeth(cv.Name, cv.PeerName, cv.MTU)
	if err != nil {
		return fmt.Errorf("create veth: %s", err)
	}
	return nil
}
func (c DeleteLink) Execute(context executor.Context) error {
	err := context.LinkFactory().DeleteLinkByName(c.LinkName)
	if err != nil {
		return fmt.Errorf("delete link: %s", err)
	}

	return nil
}
func (cv CreateVxlan) Execute(context executor.Context) error {
	err := context.LinkFactory().CreateVxlan(cv.Name, cv.VNI)
	if err != nil {
		return fmt.Errorf("create vxlan: %s", err)
	}

	return nil
}
func (slm SetLinkMaster) Execute(context executor.Context) error {
	err := context.LinkFactory().SetMaster(slm.Slave, slm.Master)
	if err != nil {
		return fmt.Errorf("set link master: %s", err)
	}

	return nil
}
func (cb CreateBridge) Execute(context executor.Context) error {
	err := context.LinkFactory().CreateBridge(cb.Name)
	if err != nil {
		return fmt.Errorf("create bridge: %s", err)
	}

	return nil
}
func (cv CreateDummy) Execute(context executor.Context) error {
	err := context.LinkFactory().CreateDummy(cv.Name)
	if err != nil {
		return fmt.Errorf("create dummy: %s", err)
	}

	return nil
}
func (s SetLinkUp) Execute(context executor.Context) error {
	err := context.LinkFactory().SetUp(s.LinkName)
	if err != nil {
		return fmt.Errorf("set link up: %s", err)
	}

	return nil
}
func (cmd *GetHardwareAddress) Execute(context executor.Context) error {
	hwAddr, err := context.LinkFactory().HardwareAddress(cmd.LinkName)
	if err != nil {
		return fmt.Errorf("get hardware address: %s", err)
	}

	cmd.Result = hwAddr

	return nil
}
func (c CleanupSandbox) Execute(context executor.Context) error {
	logger := context.Logger().Session("cleanup-sandbox", lager.Data{"sandbox-name": c.SandboxName})
	logger.Info("start")
	defer logger.Info("complete")

	sandboxRepo := context.SandboxRepository()
	sbox, err := sandboxRepo.Get(c.SandboxName)
	if err != nil {
		if err == sandbox.NotFoundError {
			return nil
		}

		logger.Error("get-sandbox-failed", err)
		return fmt.Errorf("get sandbox: %s", err)
	}

	// TODO: move into sandbox
	sbox.Lock()
	defer sbox.Unlock()

	vethLinkCount, err := sbox.VethDeviceCount()
	if err != nil {
		return fmt.Errorf("counting veth devices: %s", err)
	}

	logger.Info("veth-links-remaining", lager.Data{"count": vethLinkCount})

	if vethLinkCount == 0 {
		err = sbox.Namespace().Execute(func(*os.File) error {
			err := context.LinkFactory().DeleteLinkByName(c.VxlanDeviceName)
			if err != nil {
				if context.LinkFactory().Exists(c.VxlanDeviceName) {
					return fmt.Errorf("destroying vxlan %s: %s", c.VxlanDeviceName, err)
				}
			}
			return nil
		})
		if err != nil {
			return fmt.Errorf("in namespace %s: %s", c.SandboxName, err)
		}

		err = sandboxRepo.Destroy(c.SandboxName)
		switch err {
		case nil:
		case sandbox.AlreadyDestroyedError:
		case sandbox.NotFoundError:
		default:
			return fmt.Errorf("sandbox destroy: %s", err)
		}
	}

	return nil
}
func (s MoveLink) Execute(context executor.Context) error {
	sbox, err := context.SandboxRepository().Get(s.SandboxName)
	if err != nil {
		return fmt.Errorf("get sandbox: %s", err)
	}

	err = context.LinkFactory().SetNamespace(s.Name, sbox.Namespace().Fd())
	if err != nil {
		return fmt.Errorf("move link: %s", err)
	}

	return nil
}
func (l LinkExists) Satisfied(context executor.Context) (bool, error) {
	return context.LinkFactory().Exists(l.Name), nil
}
func (sd StartDNSServer) Execute(context executor.Context) error {
	listenerFactory := context.ListenerFactory()

	listenAddress, err := net.ResolveUDPAddr("udp", sd.ListenAddress)
	if err != nil {
		return fmt.Errorf("resolve udp address: %s", err)
	}

	sbox, err := context.SandboxRepository().Get(sd.SandboxName)
	if err != nil {
		return fmt.Errorf("get sandbox: %s", err)
	}

	sbox.Lock()
	defer sbox.Unlock()

	namespace := sbox.Namespace()

	var conn *net.UDPConn
	err = namespace.Execute(func(*os.File) error {
		linkFactory := context.LinkFactory()
		err := linkFactory.CreateDummy(DNS_INTERFACE_NAME)
		if err != nil {
			return fmt.Errorf("create dummy: %s", err)
		}

		dnsAddress := &net.IPNet{
			IP:   listenAddress.IP,
			Mask: net.CIDRMask(32, 32),
		}

		err = context.AddressManager().AddAddress(DNS_INTERFACE_NAME, dnsAddress)
		if err != nil {
			return fmt.Errorf("add address: %s", err)
		}

		err = linkFactory.SetUp(DNS_INTERFACE_NAME)
		if err != nil {
			return fmt.Errorf("set up: %s", err)
		}

		conn, err = listenerFactory.ListenUDP("udp", listenAddress)
		if err != nil {
			return fmt.Errorf("listen udp: %s", err)
		}

		return nil
	})
	if err != nil {
		return fmt.Errorf("namespace execute: %s", err)
	}

	dnsServerRunner := context.DNSServerFactory().New(conn, namespace)

	err = sbox.LaunchDNS(dnsServerRunner)
	if err != nil {
		return fmt.Errorf("sandbox launch dns: %s", err)
	}

	return nil
}
		BeforeEach(func() {
			ex.Execute(command)

			Expect(command.ExecuteCallCount()).To(Equal(1))
			context = command.ExecuteArgsForCall(0)
		})

		Describe("AddressManager", func() {
			It("returns the address manager", func() {
				Expect(context.AddressManager()).To(Equal(addressManager))
			})
		})

		Describe("LinkFactory", func() {
			It("returns the link factory", func() {
				Expect(context.LinkFactory()).To(Equal(linkFactory))
			})
		})

		Describe("RouteManager", func() {
			It("returns the route manager", func() {
				Expect(context.RouteManager()).To(Equal(routeManager))
			})
		})

		Describe("SandboxNamespaceRepository", func() {
			It("returns the SandboxNamespaceRepository", func() {
				Expect(context.SandboxNamespaceRepository()).To(Equal(sandboxNamespaceRepository))
			})
		})