Skip to content

Commit 17eb1de

Browse files
authored
Merge pull request #51 from hwchiu/issue/50
Support the TCP connection for OVSDB
2 parents f74f7e2 + 9d4c0b3 commit 17eb1de

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

ovs/client.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,14 @@ func SetSSLParam(pkey string, cert string, cacert string) OptionFunc {
317317
}
318318
}
319319

320+
// SetTCPParam configures the OVSDB connection using a TCP format ip:port
321+
// for use with all ovs-vsctl commands.
322+
func SetTCPParam(addr string) OptionFunc {
323+
return func(c *Client) {
324+
c.flags= append(c.flags, fmt.Sprintf("--db=tcp:%s", addr))
325+
}
326+
}
327+
320328
// Sudo specifies that "sudo" should be prefixed to all OVS commands.
321329
func Sudo() OptionFunc {
322330
return func(c *Client) {

ovs/client_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ func TestNew(t *testing.T) {
101101
ofctlFlags: []string{"--private-key=privkey.pem", "--certificate=cert.pem", "--ca-cert=cacert.pem"},
102102
},
103103
},
104+
{
105+
desc: "SetTCPParam(addr)",
106+
options: []OptionFunc{
107+
SetTCPParam("127.0.0.1:6640"),
108+
},
109+
c: &Client{
110+
flags: []string{"--db=tcp:127.0.0.1:6640"},
111+
ofctlFlags: make([]string, 0),
112+
},
113+
},
114+
104115
}
105116

106117
for _, tt := range tests {

0 commit comments

Comments
 (0)