-
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
33 changed files
with
8,547 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 ovs | ||
|
||
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" | ||
) | ||
|
||
// ListBridges looks up all ovs bridges from the cache | ||
func ListBridges(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 ovs | ||
|
||
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" | ||
) | ||
|
||
// ListInterfaces looks up all ovs interfaces from the cache | ||
func ListInterfaces(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 ovs | ||
|
||
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 entry from the cache | ||
func GetOpenvSwitch(ovsClient libovsdbclient.Client) (*vswitchd.OpenvSwitch, error) { | ||
ctx, cancel := context.WithTimeout(context.Background(), types.OVSDBTimeout) | ||
defer cancel() | ||
openvSwitchList := []*vswitchd.OpenvSwitch{} | ||
err := ovsClient.List(ctx, &openvSwitchList) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if len(openvSwitchList) == 0 { | ||
return nil, fmt.Errorf("no openvSwitch entry found") | ||
} | ||
|
||
return openvSwitchList[0], err | ||
} |
Oops, something went wrong.