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