@@ -7,89 +7,4 @@ Go packages which enable interacting with Open vSwitch and related tools. Apache
7
7
- ` ovsdb ` : Package ovsdb implements an OVSDB client, as described in RFC 7047.
8
8
- ` ovsnl ` : Package ovsnl enables interaction with the Linux Open vSwitch generic netlink interface.
9
9
10
- ovs
11
- ---
12
-
13
- Package ` ovs ` is a wrapper around the ` ovs-vsctl ` and ` ovs-ofctl ` utilities, but
14
- in the future, it may speak OVSDB and OpenFlow directly with the same interface.
15
-
16
- ``` go
17
- // Create a *ovs.Client. Specify ovs.OptionFuncs to customize it.
18
- c := ovs.New (
19
- // Prepend "sudo" to all commands.
20
- ovs.Sudo (),
21
- )
22
-
23
- // $ sudo ovs-vsctl --may-exist add-br ovsbr0
24
- if err := c.VSwitch .AddBridge (" ovsbr0" ); err != nil {
25
- log.Fatalf (" failed to add bridge: %v " , err)
26
- }
27
-
28
- // $ sudo ovs-ofctl add-flow ovsbr0 priority=100,ip,actions=drop
29
- err := c.OpenFlow .AddFlow (" ovsbr0" , &ovs.Flow {
30
- Priority : 100 ,
31
- Protocol : ovs.ProtocolIPv4 ,
32
- Actions : []ovs.Action {ovs.Drop ()},
33
- })
34
- if err != nil {
35
- log.Fatalf (" failed to add flow: %v " , err)
36
- }
37
- ```
38
-
39
- ovsdb
40
- -----
41
-
42
- Package ` ovsdb ` allows you to communicate with an instance of ` ovsdb-server ` using
43
- the OVSDB protocol, specified in [ RFC 7047] ( https://tools.ietf.org/html/rfc7047 ) .
44
-
45
- ``` go
46
- // Dial an OVSDB connection and create a *ovsdb.Client.
47
- c , err := ovsdb.Dial (" unix" , " /var/run/openvswitch/db.sock" )
48
- if err != nil {
49
- log.Fatalf (" failed to dial: %v " , err)
50
- }
51
- // Be sure to close the connection!
52
- defer c.Close ()
53
-
54
- // Ask ovsdb-server for all of its databases.
55
- dbs , err := c.ListDatabases ()
56
- if err != nil {
57
- log.Fatalf (" failed to list databases: %v " , err)
58
- }
59
-
60
- for _ , d := range dbs {
61
- log.Println (d)
62
- }
63
- ```
64
-
65
- ovsnl
66
- -----
67
-
68
- Package ` ovsnl ` allows you to utilize OvS's Linux generic netlink interface to
69
- pull data from the kernel.
70
-
71
- ``` go
72
- // Dial a generic netlink connection and create a *ovsnl.Client.
73
- c , err := ovsnl.New ()
74
- if err != nil {
75
- // If OVS generic netlink families aren't available, do nothing.
76
- if os.IsNotExist (err) {
77
- log.Printf (" generic netlink OVS families not found: %v " , err)
78
- return
79
- }
80
-
81
- log.Fatalf (" failed to create client %v " , err)
82
- }
83
- // Be sure to close the generic netlink connection!
84
- defer c.Close ()
85
-
86
- // List available OVS datapaths.
87
- dps , err := c.Datapath .List ()
88
- if err != nil {
89
- log.Fatalf (" failed to list datapaths: %v " , err)
90
- }
91
-
92
- for _ , d := range dps {
93
- log.Printf (" datapath: %q , flows: %d " , d.Name , d.Stats .Flows )
94
- }
95
- ```
10
+ See each package's README for additional information.
0 commit comments