@@ -4,30 +4,29 @@ Package client connects to, monitors and interacts with OVSDB servers (RFC7047).
44This package uses structs, that contain the 'ovs' field tag to determine which field goes to
55which column in the database. We refer to pointers to this structs as Models. Example:
66
7- type MyLogicalSwitch struct {
8- UUID string `ovsdb:"_uuid"` // _uuid tag is mandatory
9- Name string `ovsdb:"name"`
10- Ports []string `ovsdb:"ports"`
11- Config map[string]string `ovsdb:"other_config"`
12- }
7+ type MyLogicalSwitch struct {
8+ UUID string `ovsdb:"_uuid"` // _uuid tag is mandatory
9+ Name string `ovsdb:"name"`
10+ Ports []string `ovsdb:"ports"`
11+ Config map[string]string `ovsdb:"other_config"`
12+ }
1313
1414Based on these Models a Database Model (see ClientDBModel type) is built to represent
1515the entire OVSDB:
1616
17- clientDBModel, _ := client.NewClientDBModel("OVN_Northbound",
18- map[string]client.Model{
19- "Logical_Switch": &MyLogicalSwitch{},
20- })
21-
17+ clientDBModel, _ := client.NewClientDBModel("OVN_Northbound",
18+ map[string]client.Model{
19+ "Logical_Switch": &MyLogicalSwitch{},
20+ })
2221
2322The ClientDBModel represents the entire Database (or the part of it we're interested in).
2423Using it, the libovsdb.client package is able to properly encode and decode OVSDB messages
2524and store them in Model instances.
2625A client instance is created by simply specifying the connection information and the database model:
2726
28- ovs, _ := client.Connect(context.Background(), clientDBModel)
27+ ovs, _ := client.Connect(context.Background(), clientDBModel)
2928
30- Main API
29+ # Main API
3130
3231After creating a OvsdbClient using the Connect() function, we can use a number of CRUD-like
3332to interact with the database:
@@ -43,7 +42,7 @@ and passed to client.Transact().
4342Others, such as List() and Get(), interact with the client's internal cache and are able to
4443return Model instances (or a list thereof) directly.
4544
46- Conditions
45+ # Conditions
4746
4847Some API functions (Create() and Get()), can be run directly. Others, require us to use
4948a ConditionalAPI. The ConditionalAPI injects RFC7047 Conditions into ovsdb Operations as well as
@@ -111,15 +110,15 @@ cache element, an operation will be created matching on the "_uuid" column. The
111110quite large depending on the cache size and the provided function. Most likely there is a way to express the
112111same condition using Where() or WhereAll() which will be more efficient.
113112
114- Get
113+ # Get
115114
116115Get() operation is a simple operation capable of retrieving one Model based on some of its schema indexes. E.g:
117116
118117 ls := &LogicalSwitch{UUID:"myUUID"}
119118 err := ovs.Get(ls)
120119 fmt.Printf("Name of the switch is: &s", ls.Name)
121120
122- List
121+ # List
123122
124123List() searches the cache and populates a slice of Models. It can be used directly or using WhereCache()
125124
@@ -131,7 +130,7 @@ List() searches the cache and populates a slice of Models. It can be used direct
131130 return strings.HasPrefix(ls.Name, "ext_")
132131 }).List(lsList)
133132
134- Create
133+ # Create
135134
136135Create returns a list of operations to create the models provided. E.g:
137136
@@ -143,7 +142,7 @@ Update returns a list of operations to update the matching rows to match the val
143142 ls := &LogicalSwitch{ExternalIDs: map[string]string {"foo": "bar"}}
144143 ops, err := ovs.Where(...).Update(&ls, &ls.ExternalIDs}
145144
146- Mutate
145+ # Mutate
147146
148147Mutate returns a list of operations needed to mutate the matching rows as described by the list of Mutation objects. E.g:
149148
@@ -154,11 +153,10 @@ Mutate returns a list of operations needed to mutate the matching rows as descri
154153 Value: map[string]string{"foo":"bar"},
155154 })
156155
157- Delete
156+ # Delete
158157
159158Delete returns a list of operations needed to delete the matching rows. E.g:
160159
161160 ops, err := ovs.Where(...).Delete()
162-
163161*/
164162package client
0 commit comments