-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use libovsdb package for collecting ovs metrics
Signed-off-by: nithyar <[email protected]>
- Loading branch information
Showing
34 changed files
with
8,641 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,4 @@ fi | |
|
||
go generate ./pkg/nbdb | ||
go generate ./pkg/sbdb | ||
go generate ./pkg/vswitchd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package ops | ||
|
||
import ( | ||
"context" | ||
libovsdbclient "github.com/ovn-org/libovsdb/client" | ||
"github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" | ||
"github.com/ovn-org/ovn-kubernetes/go-controller/pkg/vswitchd" | ||
) | ||
|
||
// ListOVSBridges looks up all bridges from the cache | ||
func ListOVSBridges(ovsClient libovsdbclient.Client) ([]*vswitchd.Bridge, error) { | ||
ctx, cancel := context.WithTimeout(context.Background(), types.OVSDBTimeout) | ||
defer cancel() | ||
searchedBridges := []*vswitchd.Bridge{} | ||
err := ovsClient.List(ctx, &searchedBridges) | ||
return searchedBridges, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package ops | ||
|
||
import ( | ||
"context" | ||
libovsdbclient "github.com/ovn-org/libovsdb/client" | ||
"github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" | ||
"github.com/ovn-org/ovn-kubernetes/go-controller/pkg/vswitchd" | ||
) | ||
|
||
// ListOVSInterfaces looks up all ovs interfaces from the cache | ||
func ListOVSInterfaces(ovsClient libovsdbclient.Client) ([]*vswitchd.Interface, error) { | ||
ctx, cancel := context.WithTimeout(context.Background(), types.OVSDBTimeout) | ||
defer cancel() | ||
searchedInterfaces := []*vswitchd.Interface{} | ||
err := ovsClient.List(ctx, &searchedInterfaces) | ||
return searchedInterfaces, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package ops | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
libovsdbclient "github.com/ovn-org/libovsdb/client" | ||
"github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" | ||
"github.com/ovn-org/ovn-kubernetes/go-controller/pkg/vswitchd" | ||
) | ||
|
||
// Get OpenvSwitch table from the cache | ||
func GetOVSOpenvSwitchTable(ovsClient libovsdbclient.Client) (*vswitchd.OpenvSwitch, error) { | ||
ctx, cancel := context.WithTimeout(context.Background(), types.OVSDBTimeout) | ||
defer cancel() | ||
openvSwitchTableList := []*vswitchd.OpenvSwitch{} | ||
err := ovsClient.List(ctx, &openvSwitchTableList) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if len(openvSwitchTableList) == 0 { | ||
return nil, fmt.Errorf("no openvSwitch table found") | ||
} | ||
|
||
return openvSwitchTableList[0], err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.