null.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. package null
  2. import (
  3. "sync"
  4. "github.com/docker/docker/libnetwork/datastore"
  5. "github.com/docker/docker/libnetwork/discoverapi"
  6. "github.com/docker/docker/libnetwork/driverapi"
  7. "github.com/docker/docker/libnetwork/types"
  8. )
  9. const NetworkType = "null"
  10. type driver struct {
  11. network string
  12. sync.Mutex
  13. }
  14. // Register registers a new instance of the null driver.
  15. func Register(r driverapi.Registerer) error {
  16. return r.RegisterDriver(NetworkType, &driver{}, driverapi.Capability{
  17. DataScope: datastore.LocalScope,
  18. })
  19. }
  20. func (d *driver) NetworkAllocate(id string, option map[string]string, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
  21. return nil, types.NotImplementedErrorf("not implemented")
  22. }
  23. func (d *driver) NetworkFree(id string) error {
  24. return types.NotImplementedErrorf("not implemented")
  25. }
  26. func (d *driver) EventNotify(etype driverapi.EventType, nid, tableName, key string, value []byte) {
  27. }
  28. func (d *driver) DecodeTableEntry(tablename string, key string, value []byte) (string, map[string]string) {
  29. return "", nil
  30. }
  31. func (d *driver) CreateNetwork(id string, option map[string]interface{}, nInfo driverapi.NetworkInfo, ipV4Data, ipV6Data []driverapi.IPAMData) error {
  32. d.Lock()
  33. defer d.Unlock()
  34. if d.network != "" {
  35. return types.ForbiddenErrorf("only one instance of \"%s\" network is allowed", NetworkType)
  36. }
  37. d.network = id
  38. return nil
  39. }
  40. func (d *driver) DeleteNetwork(nid string) error {
  41. return types.ForbiddenErrorf("network of type \"%s\" cannot be deleted", NetworkType)
  42. }
  43. func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) error {
  44. return nil
  45. }
  46. func (d *driver) DeleteEndpoint(nid, eid string) error {
  47. return nil
  48. }
  49. func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) {
  50. return make(map[string]interface{}), nil
  51. }
  52. // Join method is invoked when a Sandbox is attached to an endpoint.
  53. func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
  54. return nil
  55. }
  56. // Leave method is invoked when a Sandbox detaches from an endpoint.
  57. func (d *driver) Leave(nid, eid string) error {
  58. return nil
  59. }
  60. func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error {
  61. return nil
  62. }
  63. func (d *driver) RevokeExternalConnectivity(nid, eid string) error {
  64. return nil
  65. }
  66. func (d *driver) Type() string {
  67. return NetworkType
  68. }
  69. func (d *driver) IsBuiltIn() bool {
  70. return true
  71. }
  72. // DiscoverNew is a notification for a new discovery event, such as a new node joining a cluster
  73. func (d *driver) DiscoverNew(dType discoverapi.DiscoveryType, data interface{}) error {
  74. return nil
  75. }
  76. // DiscoverDelete is a notification for a discovery delete event, such as a node leaving a cluster
  77. func (d *driver) DiscoverDelete(dType discoverapi.DiscoveryType, data interface{}) error {
  78. return nil
  79. }