Skip to content

Commit

Permalink
Physical Interface can belong to only one Virtual Port Group
Browse files Browse the repository at this point in the history
partial-jira-bug: CEM-15158

A physical-interface object can not be part of two different VPGs
This change verifies incoming PI that it do not belong to other VPGs
and throws BadRequest if given PI belong to other VPG.

In current implementation, this validation happens at VMI resource
which will be retried in next coming changes
  • Loading branch information
snmurali committed Jul 5, 2020
1 parent 8c84b14 commit d063612
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,31 @@ def update_physical_intf_type(cls, obj_dict=None,
to_be_added_pi_uuids = list(set(new_uuid_list) - set(old_uuid_list))
to_be_deleted_pi_uuids = list(set(old_uuid_list) - set(new_uuid_list))

# ensure this PI do not belong to other VPGs
pis_attached_to_vpg = {}
for pi_uuid in to_be_added_pi_uuids:
ok, pi_obj_dict = db_conn.dbe_read(
obj_type='physical-interface',
obj_id=pi_uuid,
obj_fields=['virtual_port_group_back_refs'])
if not ok:
return ok, (400, pi_obj_dict)
vpg_refs = pi_obj_dict.get('virtual_port_group_back_refs')
if vpg_refs:
pis_attached_to_vpg[pi_uuid] = vpg_refs
if pis_attached_to_vpg:
vpg_uuid = obj_dict.get('uuid')
msg = ""
for pi, vpgs in pis_attached_to_vpg.items():
for vpg in vpgs:
msg += (
'PI (%s) VPG-UUID (%s) VPG-FQNAME (%s); ' % (
pi, vpg['uuid'], ":".join(vpg['to'])))
return (
False,
(400, "physical interfaces already added at other VPGs can not"
" be attached to this VPG (%s): %s" % (vpg_uuid, msg)))

for pi_uuid in to_be_added_pi_uuids or []:
try:
api_server.internal_request_update(
Expand Down

0 comments on commit d063612

Please sign in to comment.