Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Identify Vnet GUID for conflicting VNI #99

Merged
merged 2 commits into from
Dec 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go-server-server/go/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ func ConfigVrouterVrfIdPost(w http.ResponseWriter, r *http.Request) {
guid := CacheGetVniId(uint32(attr.Vnid))
if guid != "" {
WriteRequestErrorWithSubCode(w, http.StatusConflict, RESRC_EXISTS,
"Object already exists: " + strconv.Itoa(attr.Vnid), []string{}, "")
"Object already exists {\"vni\":\"" + strconv.Itoa(attr.Vnid) + "\", \"vnet_name\":\"" + guid +"\"}", []string{}, "")
return
}

Expand Down
21 changes: 21 additions & 0 deletions test/test_restapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,27 @@ def test_post_vrouter(self, setup_restapi_client):
b'guid': b'vnet-guid-1'
}

def test_post_vrouter_duplicate(self, setup_restapi_client):
_, _, configdb, restapi_client = setup_restapi_client
restapi_client.post_generic_vxlan_tunnel()
r = restapi_client.post_config_vrouter_vrf_id("vnet-guid-1", {
'vnid': 1001
})
assert r.status_code == 204

vrouter_table = configdb.hgetall(VNET_TB + '|' + VNET_NAME_PREF + '1')
assert vrouter_table == {
b'vxlan_tunnel': b'default_vxlan_tunnel',
b'vni': b'1001',
b'guid': b'vnet-guid-1'
}

r = restapi_client.post_config_vrouter_vrf_id("vnet-guid-2", {
'vnid': 1001
})
assert r.status_code == 409
assert r.json()['error']['message'] == "Object already exists {\"vni\":\"1001\", \"vnet_name\":\"vnet-guid-1\"}"

def test_post_vrouter_default(self, setup_restapi_client):
_, _, configdb, restapi_client = setup_restapi_client
restapi_client.post_generic_vxlan_tunnel()
Expand Down