driverapi.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package driverapi
  2. import (
  3. "errors"
  4. "github.com/docker/libnetwork/sandbox"
  5. "github.com/docker/libnetwork/types"
  6. )
  7. var (
  8. // ErrEndpointExists is returned if more than one endpoint is added to the network
  9. ErrEndpointExists = errors.New("Endpoint already exists (Only one endpoint allowed)")
  10. // ErrNoNetwork is returned if no network with the specified id exists
  11. ErrNoNetwork = errors.New("No network exists")
  12. // ErrNoEndpoint is returned if no endpoint with the specified id exists
  13. ErrNoEndpoint = errors.New("No endpoint exists")
  14. )
  15. // Driver is an interface that every plugin driver needs to implement.
  16. type Driver interface {
  17. // Push driver specific config to the driver
  18. Config(options map[string]interface{}) error
  19. // CreateNetwork invokes the driver method to create a network passing
  20. // the network id and network specific config. The config mechanism will
  21. // eventually be replaced with labels which are yet to be introduced.
  22. CreateNetwork(nid types.UUID, options map[string]interface{}) error
  23. // DeleteNetwork invokes the driver method to delete network passing
  24. // the network id.
  25. DeleteNetwork(nid types.UUID) error
  26. // CreateEndpoint invokes the driver method to create an endpoint
  27. // passing the network id, endpoint id and driver
  28. // specific config. The config mechanism will eventually be replaced
  29. // with labels which are yet to be introduced.
  30. CreateEndpoint(nid, eid types.UUID, options map[string]interface{}) (*sandbox.Info, error)
  31. // DeleteEndpoint invokes the driver method to delete an endpoint
  32. // passing the network id and endpoint id.
  33. DeleteEndpoint(nid, eid types.UUID) error
  34. // EndpointInfo retrieves from the driver the operational data related to the specified endpoint
  35. EndpointInfo(nid, eid types.UUID) (map[string]interface{}, error)
  36. // Join method is invoked when a Sandbox is attached to an endpoint.
  37. Join(nid, eid types.UUID, sboxKey string, options map[string]interface{}) error
  38. // Leave method is invoked when a Sandbox detaches from an endpoint.
  39. Leave(nid, eid types.UUID, options map[string]interface{}) error
  40. // Type returns the the type of this driver, the network type this driver manages
  41. Type() string
  42. }