1- // Copyright 2017 DigitalOcean.
1+ // Copyright 2021 DigitalOcean.
22//
33// Licensed under the Apache License, Version 2.0 (the "License");
44// you may not use this file except in compliance with the License.
@@ -62,9 +62,9 @@ type DataPathReader interface {
6262// for the ovs DataPaths
6363type DataPathWriter interface {
6464 // AddDataPath is the method used to add a datapath to the switch
65- AddDataPath (string ) ([] byte , error )
65+ AddDataPath (string ) error
6666 // DelDataPath is the method used to remove a datapath from the switch
67- DelDataPath (string ) ([] string , error )
67+ DelDataPath (string ) error
6868}
6969
7070// ConnTrackReader is the interface defining the read operations
@@ -112,8 +112,7 @@ func NewDataPathService() *DataPathService {
112112
113113// Version retruns the ovs-dptcl --version currently installed
114114func (dp * DataPathService ) Version () (string , error ) {
115- args := []string {"--version" }
116- result , err := dp .CLI .Exec (args ... )
115+ result , err := dp .CLI .Exec ("--version" )
117116 if err != nil {
118117 return "" , err
119118 }
@@ -123,8 +122,7 @@ func (dp *DataPathService) Version() (string, error) {
123122
124123// GetDataPaths returns the output of the command 'ovs-dpctl dump-dps'
125124func (dp * DataPathService ) GetDataPaths () ([]string , error ) {
126- args := []string {"dump-dps" }
127- result , err := dp .CLI .Exec (args ... )
125+ result , err := dp .CLI .Exec ("dump-dps" )
128126 if err != nil {
129127 return nil , err
130128 }
@@ -135,31 +133,29 @@ func (dp *DataPathService) GetDataPaths() ([]string, error) {
135133// AddDataPath create a Datapath with the command 'ovs-dpctl add-dp <DP>'
136134// It takes one argument, the required DataPath Name and returns an error
137135// if it failed
138- func (dp * DataPathService ) AddDataPath (dpName string ) ([]byte , error ) {
139- args := []string {"add-dp" , dpName }
140-
141- return dp .CLI .Exec (args ... )
136+ func (dp * DataPathService ) AddDataPath (dpName string ) error {
137+ _ , err := dp .CLI .Exec ("add-dp" , dpName )
138+ return err
142139}
143140
144141// DelDataPath create a Datapath with the command 'ovs-dpctl del-dp <DP>'
145142// It takes one argument, the required DataPath Name and returns an error
146143// if it failed
147- func (dp * DataPathService ) DelDataPath (dpName string ) ([] byte , error ) {
148- args := [] string { "del-dp" , dpName }
144+ func (dp * DataPathService ) DelDataPath (dpName string ) error {
145+ _ , err := dp . CLI . Exec ( "del-dp" , dpName )
149146
150- return dp . CLI . Exec ( args ... )
147+ return err
151148}
152149
153150// GetCTLimits returns the conntrack limits for a given datapath
154151// equivalent to running: 'sudo ovs-dpctl ct-get-limits <datapath_name> zone=<#1>,<#2>,...'
155152func (dp * DataPathService ) GetCTLimits (dpName string , zones []uint64 ) (* ConnTrackOutput , error ) {
156153 // Start by building the args
157- args := []string {"ct-get-limits" }
158154 if dpName == "" {
159155 return nil , errMissingDataPathName
160156 }
161157
162- args = append ( args , dpName )
158+ args := [] string { "ct-get-limits" , dpName }
163159
164160 zoneParam := getZoneString (zones )
165161 if zoneParam != "" {
0 commit comments