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

Add SAG implementation #1887

Closed
wants to merge 0 commits into from
Closed

Conversation

superchild
Copy link

What I did

  • Add static anycast gateway related commands support.
    Refer to SAG HLD#837

How I did it

  • Add new commands
    • config static-anycast-gateway mac_address add/del
    • config vlan static-anycast-gateway add/del
  • Add unit test cases

How to verify it

  • Executing unit tests

Signed-off-by: Jimi Chen jimi_chen@edge-core.com

config/main.py Outdated Show resolved Hide resolved
config/vlan.py Outdated Show resolved Hide resolved
show/main.py Outdated Show resolved Hide resolved
@superchild
Copy link
Author

@cbpaviz
Thanks for your comments, codes are modified according that.
Please help to check and review again.

cbpaviz
cbpaviz previously approved these changes Nov 16, 2021
@superchild
Copy link
Author

/azpw run

@mssonicbld
Copy link
Collaborator

/AzurePipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@superchild
Copy link
Author

/azp run

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 1887 in repo Azure/sonic-utilities

@superchild
Copy link
Author

/azpw run

@mssonicbld
Copy link
Collaborator

/AzurePipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@superchild
Copy link
Author

@cbpaviz Could you help to review again, I merged the code from master branch due to some confict.

@superchild
Copy link
Author

/azpw run

@mssonicbld
Copy link
Collaborator

/AzurePipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@superchild
Copy link
Author

/azpw run

@mssonicbld
Copy link
Collaborator

/AzurePipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@yxieca
Copy link
Contributor

yxieca commented Dec 27, 2021

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@superchild
Copy link
Author

@cbpaviz
Could you help to review again?
Thanks.

cbpaviz
cbpaviz previously approved these changes May 6, 2022
@superchild
Copy link
Author

@cbpaviz Could you help to review again, I merged the code from master branch due to some conflict.

@kulpatel
Copy link

@superchild , why SAG config commands are different compare to EC config commands (available in their config guid). is it intentional ?

@superchild
Copy link
Author

@kulpatel, this PR is discussed and reviewed by community, EC will also follow the same design after this merged.
The original design is slightly different from community's opinion.

config/main.py Outdated
@mac_address.command('del')
@click.argument('mac_address', metavar='<mac_address>', required=True, type=str)
@clicommon.pass_db
def del_mac(db, mac_address):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since only one mac address is allowed. mac_address is not a useful argument here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is removed in the updated PR #2881

config/vlan.py Outdated
@@ -95,6 +95,12 @@ def del_vlan(db, vid):
# We need to restart dhcp_relay service after dhcpv6_relay config change
dhcp_relay_util.handle_restart_dhcp_relay_service()

keys = [ (k, v) for k, v in db.cfgdb.get_table('VLAN_MEMBER') if k == 'Vlan{}'.format(vid) ]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this change related to this feature?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is reverted in the updated PR #2881

config/vlan.py Outdated
if not clicommon.is_valid_vlan_interface(db.cfgdb, vlan):
ctx.fail(f"Interface {vlan} does not exist")

db.cfgdb.mod_entry('VLAN_INTERFACE', vlan, {"static_anycast_gateway": "true"})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need check whether static_anycast_gateway has already been configured?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is removed in the updated PR #2881

config/main.py Outdated
sag_entry = db.cfgdb.get_entry('SAG', 'GLOBAL')
if sag_entry:
if sag_entry.get('gateway_mac').lower() == mac_address.lower():
db.cfgdb.mod_entry('SAG', 'GLOBAL', None)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need disable sag for each vlan?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is handled in sonic-swss.

config/vlan.py Outdated

log.log_info(f"'vlan static-anycast-gateway disable {vid}' executing...")

if not clicommon.is_vlanid_in_range(vid):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this check is needed, maybe we should do the same for enable_vlan_sag; otherwise, please remove this check

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is removed in the updated PR #2881

config/vlan.py Outdated
keys = [ (k, v) for k, v in db.cfgdb.get_table('VLAN_MEMBER') if k == 'Vlan{}'.format(vid) ]

if keys:
ctx.fail("VLAN ID {} can not be removed. First remove all members assigned to this VLAN.".format(vid))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use f-string

config/vlan.py Outdated
if keys:
ctx.fail("VLAN ID {} can not be removed. First remove all members assigned to this VLAN.".format(vid))

db.cfgdb.set_entry('VLAN', 'Vlan{}'.format(vid), None)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use f-string

show/main.py Outdated
@clicommon.pass_db
def sag(db):
"""Show static anycast gateway information"""
sag_entry = db.cfgdb.get_entry('SAG', 'GLOBAL')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if SAG is not configured?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is changed in the updated PR #2881

show/main.py Outdated
body = []
intf_dict = db.cfgdb.get_table('VLAN_INTERFACE')
if intf_dict:
for intf in intf_dict:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be more brief to use

for key,value in intf_dict.items():
    if value.get('static_anycast_gateway') == 'true':

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is removed in the updated PR #2881

show/vlan.py Outdated
cfg, _ = ctx
_, vlan_ip_data, _ = cfg

for key in vlan_ip_data:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need a for loop here? how about this:

if vlan in vlan_ip_data:

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is removed in the updated PR #2881

@superchild superchild closed this Jun 16, 2023
@superchild superchild force-pushed the sag-dev branch 2 times, most recently from 28a1396 to 3ba8241 Compare June 16, 2023 03:38
@superchild
Copy link
Author

@zhangyanzhao
Sorry for the wrong operation sync, this PR's commit history is gone.
I already reset the commit on my dev branch, could you please reopen this PR?
Or should I resend a new PR for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants