Updated net plugin to use the listener from base plugin
This commit is contained in:
Родитель
2e291a5b40
Коммит
bb58dcba87
|
@ -19,9 +19,8 @@ const (
|
|||
// NetPlugin object and its interface
|
||||
type netPlugin struct {
|
||||
*common.Plugin
|
||||
scope string
|
||||
listener *common.Listener
|
||||
nm *networkManager
|
||||
scope string
|
||||
nm *networkManager
|
||||
sync.Mutex
|
||||
}
|
||||
|
||||
|
@ -53,6 +52,7 @@ func NewPlugin(name string, version string) (NetPlugin, error) {
|
|||
|
||||
// Starts the plugin.
|
||||
func (plugin *netPlugin) Start(errChan chan error) error {
|
||||
// Initialize base plugin.
|
||||
err := plugin.Initialize(errChan)
|
||||
if err != nil {
|
||||
log.Printf("%s: Failed to start: %v", plugin.Name, err)
|
||||
|
@ -93,7 +93,7 @@ func (plugin *netPlugin) getCapabilities(w http.ResponseWriter, r *http.Request)
|
|||
log.Request(plugin.Name, &req, nil)
|
||||
|
||||
resp := getCapabilitiesResponse{Scope: plugin.scope}
|
||||
err := plugin.listener.Encode(w, &resp)
|
||||
err := plugin.Listener.Encode(w, &resp)
|
||||
|
||||
log.Response(plugin.Name, &resp, err)
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ func (plugin *netPlugin) createNetwork(w http.ResponseWriter, r *http.Request) {
|
|||
var req createNetworkRequest
|
||||
|
||||
// Decode request.
|
||||
err := plugin.listener.Decode(w, r, &req)
|
||||
err := plugin.Listener.Decode(w, r, &req)
|
||||
log.Request(plugin.Name, &req, err)
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -121,7 +121,7 @@ func (plugin *netPlugin) createNetwork(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// Encode response.
|
||||
resp := createNetworkResponse{}
|
||||
err = plugin.listener.Encode(w, &resp)
|
||||
err = plugin.Listener.Encode(w, &resp)
|
||||
|
||||
log.Response(plugin.Name, &resp, err)
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ func (plugin *netPlugin) deleteNetwork(w http.ResponseWriter, r *http.Request) {
|
|||
var req deleteNetworkRequest
|
||||
|
||||
// Decode request.
|
||||
err := plugin.listener.Decode(w, r, &req)
|
||||
err := plugin.Listener.Decode(w, r, &req)
|
||||
log.Request(plugin.Name, &req, err)
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -149,7 +149,7 @@ func (plugin *netPlugin) deleteNetwork(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// Encode response.
|
||||
resp := deleteNetworkResponse{}
|
||||
err = plugin.listener.Encode(w, &resp)
|
||||
err = plugin.Listener.Encode(w, &resp)
|
||||
|
||||
log.Response(plugin.Name, &resp, err)
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ func (plugin *netPlugin) createEndpoint(w http.ResponseWriter, r *http.Request)
|
|||
var req createEndpointRequest
|
||||
|
||||
// Decode request.
|
||||
err := plugin.listener.Decode(w, r, &req)
|
||||
err := plugin.Listener.Decode(w, r, &req)
|
||||
log.Request(plugin.Name, &req, err)
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -191,7 +191,7 @@ func (plugin *netPlugin) createEndpoint(w http.ResponseWriter, r *http.Request)
|
|||
Interface: nil,
|
||||
}
|
||||
|
||||
err = plugin.listener.Encode(w, &resp)
|
||||
err = plugin.Listener.Encode(w, &resp)
|
||||
|
||||
log.Response(plugin.Name, &resp, err)
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ func (plugin *netPlugin) deleteEndpoint(w http.ResponseWriter, r *http.Request)
|
|||
var req deleteEndpointRequest
|
||||
|
||||
// Decode request.
|
||||
err := plugin.listener.Decode(w, r, &req)
|
||||
err := plugin.Listener.Decode(w, r, &req)
|
||||
log.Request(plugin.Name, &req, err)
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -225,7 +225,7 @@ func (plugin *netPlugin) deleteEndpoint(w http.ResponseWriter, r *http.Request)
|
|||
|
||||
// Encode response.
|
||||
resp := deleteEndpointResponse{}
|
||||
err = plugin.listener.Encode(w, &resp)
|
||||
err = plugin.Listener.Encode(w, &resp)
|
||||
|
||||
log.Response(plugin.Name, &resp, err)
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ func (plugin *netPlugin) join(w http.ResponseWriter, r *http.Request) {
|
|||
var req joinRequest
|
||||
|
||||
// Decode request.
|
||||
err := plugin.listener.Decode(w, r, &req)
|
||||
err := plugin.Listener.Decode(w, r, &req)
|
||||
log.Request(plugin.Name, &req, err)
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -269,7 +269,7 @@ func (plugin *netPlugin) join(w http.ResponseWriter, r *http.Request) {
|
|||
GatewayIPv6: ep.IPv6Gateway.String(),
|
||||
}
|
||||
|
||||
err = plugin.listener.Encode(w, &resp)
|
||||
err = plugin.Listener.Encode(w, &resp)
|
||||
|
||||
log.Response(plugin.Name, &resp, err)
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ func (plugin *netPlugin) leave(w http.ResponseWriter, r *http.Request) {
|
|||
var req leaveRequest
|
||||
|
||||
// Decode request.
|
||||
err := plugin.listener.Decode(w, r, &req)
|
||||
err := plugin.Listener.Decode(w, r, &req)
|
||||
log.Request(plugin.Name, &req, err)
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -303,7 +303,7 @@ func (plugin *netPlugin) leave(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// Encode response.
|
||||
resp := leaveResponse{}
|
||||
err = plugin.listener.Encode(w, &resp)
|
||||
err = plugin.Listener.Encode(w, &resp)
|
||||
|
||||
log.Response(plugin.Name, &resp, err)
|
||||
}
|
||||
|
@ -313,7 +313,7 @@ func (plugin *netPlugin) endpointOperInfo(w http.ResponseWriter, r *http.Request
|
|||
var req endpointOperInfoRequest
|
||||
|
||||
// Decode request.
|
||||
err := plugin.listener.Decode(w, r, &req)
|
||||
err := plugin.Listener.Decode(w, r, &req)
|
||||
log.Request(plugin.Name, &req, err)
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -325,7 +325,7 @@ func (plugin *netPlugin) endpointOperInfo(w http.ResponseWriter, r *http.Request
|
|||
|
||||
// Encode response.
|
||||
resp := endpointOperInfoResponse{Value: value}
|
||||
err = plugin.listener.Encode(w, &resp)
|
||||
err = plugin.Listener.Encode(w, &resp)
|
||||
|
||||
log.Response(plugin.Name, &resp, err)
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче