Skip to content

Commit 5f978a3

Browse files
committedMar 16, 2018
resolve comments
Signed-off-by: Vladimir Lavor <vlavor@cisco.com>
1 parent dff4dcf commit 5f978a3

8 files changed

+228
-213
lines changed
 

‎cmd/vpp-agent-ctl/impl/data_cmd.go ‎cmd/vpp-agent-ctl/data_cmd.go

+63-63
Large diffs are not rendered by default.

‎cmd/vpp-agent-ctl/impl/etcd.go ‎cmd/vpp-agent-ctl/etcd.go

+8-9
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// VPP Agent plugins. In addition to testing, the vpp-agent-ctl tool can
1717
// be used to demonstrate the usage of VPP Agent plugins and their APIs.
1818

19-
package impl
19+
package main
2020

2121
import (
2222
"bufio"
@@ -33,7 +33,7 @@ import (
3333
)
3434

3535
// CreateEtcdClient uses environment variable or ETCD config file to establish connection
36-
func (ctl *VppAgentCtl) CreateEtcdClient(configFile string) (*etcdv3.BytesConnectionEtcd, keyval.ProtoBroker, error) {
36+
func (ctl *VppAgentCtl) createEtcdClient(configFile string) (*etcdv3.BytesConnectionEtcd, keyval.ProtoBroker, error) {
3737
var err error
3838

3939
if configFile == "" {
@@ -62,7 +62,7 @@ func (ctl *VppAgentCtl) CreateEtcdClient(configFile string) (*etcdv3.BytesConnec
6262
}
6363

6464
// ListAllAgentKeys prints all keys stored in the broker
65-
func (ctl *VppAgentCtl) ListAllAgentKeys() {
65+
func (ctl *VppAgentCtl) listAllAgentKeys() {
6666
ctl.Log.Debug("listAllAgentKeys")
6767

6868
it, err := ctl.broker.ListKeys(ctl.serviceLabel.GetAllAgentsPrefix())
@@ -79,7 +79,7 @@ func (ctl *VppAgentCtl) ListAllAgentKeys() {
7979
}
8080

8181
// EtcdGet uses ETCD connection to get value for specific key
82-
func (ctl *VppAgentCtl) EtcdGet(key string) {
82+
func (ctl *VppAgentCtl) etcdGet(key string) {
8383
ctl.Log.Debug("GET ", key)
8484

8585
data, found, _, err := ctl.bytesConnection.GetValue(key)
@@ -94,7 +94,7 @@ func (ctl *VppAgentCtl) EtcdGet(key string) {
9494
}
9595

9696
// EtcdPut stores key/data value
97-
func (ctl *VppAgentCtl) EtcdPut(key string, file string) {
97+
func (ctl *VppAgentCtl) etcdPut(key string, file string) {
9898
input, err := ctl.readData(file)
9999

100100
ctl.Log.Println("DB putting ", key, " ", string(input))
@@ -107,7 +107,7 @@ func (ctl *VppAgentCtl) EtcdPut(key string, file string) {
107107
}
108108

109109
// EtcdDel removes data under provided key
110-
func (ctl *VppAgentCtl) EtcdDel(key string) {
110+
func (ctl *VppAgentCtl) etcdDel(key string) {
111111
found, err := ctl.bytesConnection.Delete(key, datasync.WithPrefix())
112112
if err != nil {
113113
ctl.Log.Error(err)
@@ -121,7 +121,7 @@ func (ctl *VppAgentCtl) EtcdDel(key string) {
121121
}
122122

123123
// EtcdDump lists values under key. If no key is provided, all data is read.
124-
func (ctl *VppAgentCtl) EtcdDump(key string) {
124+
func (ctl *VppAgentCtl) etcdDump(key string) {
125125
ctl.Log.Debug("DUMP ", key)
126126

127127
data, err := ctl.bytesConnection.ListValues(key)
@@ -132,15 +132,14 @@ func (ctl *VppAgentCtl) EtcdDump(key string) {
132132

133133
var found bool
134134
for {
135-
found = true
136135
kv, stop := data.GetNext()
137136
if stop {
138137
break
139138
}
140139
ctl.Log.Println(kv.GetKey())
141140
ctl.Log.Println(string(kv.GetValue()))
142141
ctl.Log.Println()
143-
142+
found = true
144143
}
145144
if !found {
146145
ctl.Log.Debug("No value found for the key", key)

‎cmd/vpp-agent-ctl/topology/static_routing.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ RPD_NAME="rpd"
1616
#
1717

1818
# VSWITCH - add static route to 112.1.1.3/32 via 8.42.0.1
19-
../vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/vrf/0/fib/112.1.1.3/32/8.42.0.1 - << EOF
19+
vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/vrf/0/fib/112.1.1.3/32/8.42.0.1 - << EOF
2020
{
2121
"description": "Static route",
2222
"dst_ip_addr": "112.1.1.3/32",
@@ -25,7 +25,7 @@ RPD_NAME="rpd"
2525
EOF
2626

2727
# VSWITCH - create memif master to RPD
28-
../vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/interface/memif-to-rpd - << EOF
28+
vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/interface/memif-to-rpd - << EOF
2929
{
3030
"name": "memif-to-rpd",
3131
"type": 2,
@@ -43,7 +43,7 @@ EOF
4343
EOF
4444

4545
# RPD - create memif slave to VSWITCH
46-
../vpp-agent-ctl -put /vnf-agent/${RPD_NAME}/vpp/config/v1/interface/memif-to-vswitch - << EOF
46+
vpp-agent-ctl -put /vnf-agent/${RPD_NAME}/vpp/config/v1/interface/memif-to-vswitch - << EOF
4747
{
4848
"name": "memif-to-vswitch",
4949
"type": 2,
@@ -61,7 +61,7 @@ EOF
6161
EOF
6262

6363
# RPD - create a loopback interface
64-
../vpp-agent-ctl -put /vnf-agent/${RPD_NAME}/vpp/config/v1/interface/loop1 - << EOF
64+
vpp-agent-ctl -put /vnf-agent/${RPD_NAME}/vpp/config/v1/interface/loop1 - << EOF
6565
{
6666
"name": "loop1",
6767
"enabled": true,

‎cmd/vpp-agent-ctl/topology/topology.sh

+15-15
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ VNF_NAME="vnf-vpp"
1515
# This works for my VirtualBox ethernet interface:
1616
# modprobe igb_uio
1717
# vpp unix { interactive } dpdk { dev 0000:00:08.0 uio-driver igb_uio }
18-
../vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/interface/GigabitEthernet0/8/0 - << EOF
18+
vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/interface/GigabitEthernet0/8/0 - << EOF
1919
{
2020
"name": "GigabitEthernet0/8/0",
2121
"type": 1,
@@ -28,7 +28,7 @@ VNF_NAME="vnf-vpp"
2828
EOF
2929

3030
# VSWITCH - create a loopback interface
31-
../vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/interface/loop1 - << EOF
31+
vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/interface/loop1 - << EOF
3232
{
3333
"name": "loop1",
3434
"enabled": true,
@@ -41,7 +41,7 @@ EOF
4141
EOF
4242

4343
# VSWITCH - create a vxlan interface
44-
../vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/interface/vxlan1 - << EOF
44+
vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/interface/vxlan1 - << EOF
4545
{
4646
"name": "vxlan1",
4747
"type": 5,
@@ -55,7 +55,7 @@ EOF
5555
EOF
5656

5757
# VSWITCH - create a BVI loopback interface for B2 (extension to the cCMTS topology)
58-
../vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/interface/loop-bvi2 - << EOF
58+
vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/interface/loop-bvi2 - << EOF
5959
{
6060
"name": "loop-bvi2",
6161
"enabled": true,
@@ -67,7 +67,7 @@ EOF
6767
EOF
6868

6969
# VSWITCH - add static route to 6.0.0.0/24 via GigabitEthernet0/8/0
70-
../vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/vrf/0/fib/6.0.0.0/24/8.42.0.1 - << EOF
70+
vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/vrf/0/fib/6.0.0.0/24/8.42.0.1 - << EOF
7171
{
7272
"description": "Static route",
7373
"dst_ip_addr": "6.0.0.0/24",
@@ -77,7 +77,7 @@ EOF
7777
EOF
7878

7979
# VSWITCH - create memif master to RNG (bridge domain B2)
80-
../vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/interface/memif-to-rng - << EOF
80+
vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/interface/memif-to-rng - << EOF
8181
{
8282
"name": "memif-to-rng",
8383
"type": 2,
@@ -91,7 +91,7 @@ EOF
9191
EOF
9292

9393
# RNG - create memif slave to VSWITCH
94-
../vpp-agent-ctl -put /vnf-agent/${RNG_NAME}/vpp/config/v1/interface/memif-to-vswitch - << EOF
94+
vpp-agent-ctl -put /vnf-agent/${RNG_NAME}/vpp/config/v1/interface/memif-to-vswitch - << EOF
9595
{
9696
"name": "memif-to-vswitch",
9797
"type": 2,
@@ -110,7 +110,7 @@ EOF
110110

111111

112112
# VSWITCH - create memif master to USSCHED (bridge domain B2)
113-
../vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/interface/memif-to-ussched - << EOF
113+
vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/interface/memif-to-ussched - << EOF
114114
{
115115
"name": "memif-to-ussched",
116116
"type": 2,
@@ -124,7 +124,7 @@ EOF
124124
EOF
125125

126126
# USSCHED - create memif slave to VSWITCH
127-
../vpp-agent-ctl -put /vnf-agent/${USSCHED_NAME}/vpp/config/v1/interface/memif-to-vswitch - << EOF
127+
vpp-agent-ctl -put /vnf-agent/${USSCHED_NAME}/vpp/config/v1/interface/memif-to-vswitch - << EOF
128128
{
129129
"name": "memif-to-vswitch",
130130
"type": 2,
@@ -142,7 +142,7 @@ EOF
142142
EOF
143143

144144
# VSWITCH - create memif to VNF 1 (bridge domain B1)
145-
../vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/interface/memif-to-vnf-1 - << EOF
145+
vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/interface/memif-to-vnf-1 - << EOF
146146
{
147147
"name": "memif-to-vnf-1",
148148
"type": 2,
@@ -156,7 +156,7 @@ EOF
156156
EOF
157157

158158
# VNF - create memif slave 1 to VSWITCH
159-
../vpp-agent-ctl -put /vnf-agent/${VNF_NAME}/vpp/config/v1/interface/memif-to-vswitch-1 - << EOF
159+
vpp-agent-ctl -put /vnf-agent/${VNF_NAME}/vpp/config/v1/interface/memif-to-vswitch-1 - << EOF
160160
{
161161
"name": "memif-to-vswitch-1",
162162
"type": 2,
@@ -174,7 +174,7 @@ EOF
174174
EOF
175175

176176
# VSWITCH - create memif to vnf 2 (bridge domain B2)
177-
../vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/interface/memif-to-vnf-2 - << EOF
177+
vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/interface/memif-to-vnf-2 - << EOF
178178
{
179179
"name": "memif-to-vnf-2",
180180
"type": 2,
@@ -188,7 +188,7 @@ EOF
188188
EOF
189189

190190
# VNF - create memif slave 2 to VSWITCH
191-
../vpp-agent-ctl -put /vnf-agent/${VNF_NAME}/vpp/config/v1/interface/memif-to-vswitch-2 - << EOF
191+
vpp-agent-ctl -put /vnf-agent/${VNF_NAME}/vpp/config/v1/interface/memif-to-vswitch-2 - << EOF
192192
{
193193
"name": "memif-to-vswitch-2",
194194
"type": 2,
@@ -206,7 +206,7 @@ EOF
206206
EOF
207207

208208
# VSWITCH - create bridge domain B2 (needs to be called after the interfaces have been created)
209-
../vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/bd/B2 - << EOF
209+
vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/bd/B2 - << EOF
210210
{
211211
"name": "B2",
212212
"flood": true,
@@ -233,7 +233,7 @@ EOF
233233
EOF
234234

235235
# VSWITCH - create bridge domain B1 (needs to be called after the interfaces have been created)
236-
../vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/bd/B1 - << EOF
236+
vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/bd/B1 - << EOF
237237
{
238238
"name": "B1",
239239
"flood": true,

‎cmd/vpp-agent-ctl/topology/topology_modify.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ USSCHED_NAME="ussched-vpp"
66
VNF_NAME="vnf-vpp"
77

88
# VSWITCH - change IP & MAC of the loopback interface
9-
../vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/interface/loop1 - << EOF
9+
vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/interface/loop1 - << EOF
1010
{
1111
"name": "loop1",
1212
"enabled": true,
@@ -19,13 +19,13 @@ VNF_NAME="vnf-vpp"
1919
EOF
2020

2121
# VSWITCH - delete memif master to RNG (bridge domain B2)
22-
../vpp-agent-ctl -del /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/interface/memif-to-rng
22+
vpp-agent-ctl -del /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/interface/memif-to-rng
2323

2424
# RNG - delete memif slave to VSWITCH
25-
../vpp-agent-ctl -del /vnf-agent/${RNG_NAME}/vpp/config/v1/interface/memif-to-vswitch
25+
vpp-agent-ctl -del /vnf-agent/${RNG_NAME}/vpp/config/v1/interface/memif-to-vswitch
2626

2727
# VSWITCH - add one more static route
28-
../vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/vrf/0/fib/20.5.0.0/24/8.42.0.1 - << EOF
28+
vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/vrf/0/fib/20.5.0.0/24/8.42.0.1 - << EOF
2929
{
3030
"description": "Static route 2",
3131
"dst_ip_addr": "20.5.0.0/24",
@@ -35,7 +35,7 @@ EOF
3535
EOF
3636

3737
# VSWITCH - remove deleted interface + BVI interface from bridge domain
38-
../vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/bd/B2 - << EOF
38+
vpp-agent-ctl -put /vnf-agent/${VSWITCH_NAME}/vpp/config/v1/bd/B2 - << EOF
3939
{
4040
"name": "B2",
4141
"flood": true,

0 commit comments

Comments
 (0)
Please sign in to comment.