2015-04-30 01:56:59 -04:00
|
|
|
package null
|
|
|
|
|
|
|
|
import (
|
2015-06-08 11:24:43 -04:00
|
|
|
"sync"
|
|
|
|
|
2021-04-05 20:24:47 -04:00
|
|
|
"github.com/docker/docker/libnetwork/datastore"
|
|
|
|
"github.com/docker/docker/libnetwork/discoverapi"
|
|
|
|
"github.com/docker/docker/libnetwork/driverapi"
|
|
|
|
"github.com/docker/docker/libnetwork/types"
|
2015-04-30 01:56:59 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
const networkType = "null"
|
|
|
|
|
2015-06-08 11:24:43 -04:00
|
|
|
type driver struct {
|
2015-07-02 01:00:48 -04:00
|
|
|
network string
|
2015-06-08 11:24:43 -04:00
|
|
|
sync.Mutex
|
|
|
|
}
|
2015-04-30 01:56:59 -04:00
|
|
|
|
Make driver packages register themselves via DriverCallback
In the present code, each driver package provides a `New()` method
which constructs a driver of its type, which is then registered with
the controller.
However, this is not suitable for the `drivers/remote` package, since
it does not provide a (singleton) driver, but a mechanism for drivers
to be added dynamically. As a result, the implementation is oddly
dual-purpose, and a spurious `"remote"` driver is added to the
controller's list of available drivers.
Instead, it is better to provide the registration callback to each
package and let it register its own driver or drivers. That way, the
singleton driver packages can construct one and register it, and the
remote package can hook the callback up with whatever the dynamic
driver mechanism turns out to be.
NB there are some method signature changes; in particular to
controller.New, which can return an error if the built-in driver
packages fail to initialise.
Signed-off-by: Michael Bridgen <mikeb@squaremobius.net>
2015-05-11 08:46:29 -04:00
|
|
|
// Init registers a new instance of null driver
|
2015-09-18 17:00:36 -04:00
|
|
|
func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
|
2015-06-06 13:21:51 -04:00
|
|
|
c := driverapi.Capability{
|
2015-09-16 07:39:46 -04:00
|
|
|
DataScope: datastore.LocalScope,
|
2015-06-06 13:21:51 -04:00
|
|
|
}
|
|
|
|
return dc.RegisterDriver(networkType, &driver{}, c)
|
2015-04-30 01:56:59 -04:00
|
|
|
}
|
|
|
|
|
2016-02-26 14:54:35 -05:00
|
|
|
func (d *driver) NetworkAllocate(id string, option map[string]string, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
|
2016-02-26 14:53:13 -05:00
|
|
|
return nil, types.NotImplementedErrorf("not implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *driver) NetworkFree(id string) error {
|
|
|
|
return types.NotImplementedErrorf("not implemented")
|
|
|
|
}
|
|
|
|
|
2016-04-18 22:55:39 -04:00
|
|
|
func (d *driver) EventNotify(etype driverapi.EventType, nid, tableName, key string, value []byte) {
|
|
|
|
}
|
|
|
|
|
2017-03-02 02:57:37 -05:00
|
|
|
func (d *driver) DecodeTableEntry(tablename string, key string, value []byte) (string, map[string]string) {
|
|
|
|
return "", nil
|
|
|
|
}
|
|
|
|
|
2016-04-18 22:55:39 -04:00
|
|
|
func (d *driver) CreateNetwork(id string, option map[string]interface{}, nInfo driverapi.NetworkInfo, ipV4Data, ipV6Data []driverapi.IPAMData) error {
|
2015-06-08 11:24:43 -04:00
|
|
|
d.Lock()
|
|
|
|
defer d.Unlock()
|
|
|
|
|
|
|
|
if d.network != "" {
|
|
|
|
return types.ForbiddenErrorf("only one instance of \"%s\" network is allowed", networkType)
|
|
|
|
}
|
|
|
|
|
|
|
|
d.network = id
|
|
|
|
|
2015-04-30 01:56:59 -04:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-07-02 01:00:48 -04:00
|
|
|
func (d *driver) DeleteNetwork(nid string) error {
|
2015-06-08 11:24:43 -04:00
|
|
|
return types.ForbiddenErrorf("network of type \"%s\" cannot be deleted", networkType)
|
2015-04-30 01:56:59 -04:00
|
|
|
}
|
|
|
|
|
2015-10-03 19:11:50 -04:00
|
|
|
func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) error {
|
2015-05-14 02:23:45 -04:00
|
|
|
return nil
|
2015-04-30 01:56:59 -04:00
|
|
|
}
|
|
|
|
|
2015-07-02 01:00:48 -04:00
|
|
|
func (d *driver) DeleteEndpoint(nid, eid string) error {
|
2015-04-30 01:56:59 -04:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-07-02 01:00:48 -04:00
|
|
|
func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, error) {
|
2021-05-27 20:15:56 -04:00
|
|
|
return make(map[string]interface{}), nil
|
2015-05-04 14:49:53 -04:00
|
|
|
}
|
|
|
|
|
2015-04-30 17:52:46 -04:00
|
|
|
// Join method is invoked when a Sandbox is attached to an endpoint.
|
2015-07-02 01:00:48 -04:00
|
|
|
func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
2015-05-14 02:23:45 -04:00
|
|
|
return nil
|
2015-04-30 17:52:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Leave method is invoked when a Sandbox detaches from an endpoint.
|
2015-07-02 01:00:48 -04:00
|
|
|
func (d *driver) Leave(nid, eid string) error {
|
2015-04-30 17:52:46 -04:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-12-07 17:45:51 -05:00
|
|
|
func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *driver) RevokeExternalConnectivity(nid, eid string) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-04-30 01:56:59 -04:00
|
|
|
func (d *driver) Type() string {
|
|
|
|
return networkType
|
|
|
|
}
|
2015-09-18 15:54:08 -04:00
|
|
|
|
2016-12-18 22:56:34 -05:00
|
|
|
func (d *driver) IsBuiltIn() bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2015-09-18 15:54:08 -04:00
|
|
|
// DiscoverNew is a notification for a new discovery event, such as a new node joining a cluster
|
2016-01-28 14:54:03 -05:00
|
|
|
func (d *driver) DiscoverNew(dType discoverapi.DiscoveryType, data interface{}) error {
|
2015-09-18 15:54:08 -04:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// DiscoverDelete is a notification for a discovery delete event, such as a node leaving a cluster
|
2016-01-28 14:54:03 -05:00
|
|
|
func (d *driver) DiscoverDelete(dType discoverapi.DiscoveryType, data interface{}) error {
|
2015-09-18 15:54:08 -04:00
|
|
|
return nil
|
|
|
|
}
|