Fixed some convoluted texts in remote.md and fixed a remote driver bug

Signed-off-by: Madhu Venugopal <madhu@docker.com>
This commit is contained in:
Madhu Venugopal 2015-05-07 00:48:12 -07:00
parent 03c18818ed
commit 27d34d67ab
3 changed files with 11 additions and 10 deletions

View File

@ -5,13 +5,13 @@ Remote driver is a special built-in driver. This driver in itself doesn't provid
## LibNetwork Integration ## LibNetwork Integration
When LibNetwork creates an instance of the Built-in `Remote` Driver via the `New()` function, it provides a `DriverCallback` which implements the `RegisterDriver()` to let the Built-in Remote Driver to register any of the `Dynamic` Drivers/Plugins with LibNetwork's `NetworkController` When LibNetwork creates an instance of the Built-in `Remote` Driver via the `New()` function, it passes a `DriverCallback` as a parameter which implements the `RegisterDriver()`. The Built-in Remote Driver can use this interface to register any of the `Dynamic` Drivers/Plugins with LibNetwork's `NetworkController`
Refer to [Remote Driver Test](https://github.com/docker/libnetwork/blob/drivers/remote/driver_test.go) which provides an example of how the Built-In Remote driver can register any Dynamic driver with LibNetwork. Please Refer to [Remote Driver Test](https://github.com/docker/libnetwork/blob/master/drivers/remote/driver_test.go) which provides an example of registering a Dynamic driver with LibNetwork.
This design ensures that the implementation details of Dynamic Driver Registration mechanism is completely owned by the inbuilt-Remote driver and it also doesnt expose any of the driver layer to the North of LibNetwork (none of the LibNetwork client APIs are impacted). This design ensures that the implementation details of Dynamic Driver Registration mechanism is completely owned by the inbuilt-Remote driver and it also doesnt expose any of the driver layer to the North of LibNetwork (none of the LibNetwork client APIs are impacted).
When the inbuilt `Remote` driver detects a `Dynamic` Driver it will have to call the `registerRemoteDriver` method. This Method will take care of creating a new `Remote` Driver instance and associate it with the new `NetworkType` which is handled by the `Dynamic` Driver. When the inbuilt `Remote` driver detects a `Dynamic` Driver it can call the `registerRemoteDriver` method. This method will take care of creating a new `Remote` Driver instance with the passed 'NetworkType' and register it with Libnetwork's 'NetworkController
## Implementation ## Implementation

View File

@ -16,7 +16,7 @@ var (
// ErrNoEndpoint is returned if no endpoint with the specified id exists // ErrNoEndpoint is returned if no endpoint with the specified id exists
ErrNoEndpoint = errors.New("No endpoint exists") ErrNoEndpoint = errors.New("No endpoint exists")
// ErrNotImplemented is returned when a Driver has not implemented an API yet // ErrNotImplemented is returned when a Driver has not implemented an API yet
ErrNotImplemented = errors.New("The API is not implemneted yet") ErrNotImplemented = errors.New("The API is not implemented yet")
) )
// Driver is an interface that every plugin driver needs to implement. // Driver is an interface that every plugin driver needs to implement.

View File

@ -10,23 +10,24 @@ import (
var errNoCallback = errors.New("No Callback handler registered with Driver") var errNoCallback = errors.New("No Callback handler registered with Driver")
const networkType = "remote" const remoteNetworkType = "remote"
type driver struct { type driver struct {
callback driverapi.DriverCallback networkType string
callback driverapi.DriverCallback
} }
// New instance of remote driver returned to LibNetwork // New instance of remote driver returned to LibNetwork
func New(dc driverapi.DriverCallback) (string, driverapi.Driver) { func New(dc driverapi.DriverCallback) (string, driverapi.Driver) {
d := &driver{} d := &driver{networkType: remoteNetworkType}
d.callback = dc d.callback = dc
return networkType, d return d.networkType, d
} }
// Internal Convenience method to register a remote driver. // Internal Convenience method to register a remote driver.
// The implementation of this method will change based on the dynamic driver registration design // The implementation of this method will change based on the dynamic driver registration design
func (d *driver) registerRemoteDriver(networkType string) (driverapi.Driver, error) { func (d *driver) registerRemoteDriver(networkType string) (driverapi.Driver, error) {
newDriver := &driver{} newDriver := &driver{networkType: networkType}
if d.callback == nil { if d.callback == nil {
return nil, errNoCallback return nil, errNoCallback
} }
@ -71,5 +72,5 @@ func (d *driver) Leave(nid, eid types.UUID, options map[string]interface{}) erro
} }
func (d *driver) Type() string { func (d *driver) Type() string {
return networkType return d.networkType
} }