-
Notifications
You must be signed in to change notification settings - Fork 661
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
Add SAG implementation #1887
Conversation
@cbpaviz |
/azpw run |
/AzurePipelines run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Commenter does not have sufficient privileges for PR 1887 in repo Azure/sonic-utilities |
/azpw run |
/AzurePipelines run |
Azure Pipelines successfully started running 1 pipeline(s). |
@cbpaviz Could you help to review again, I merged the code from master branch due to some confict. |
/azpw run |
/AzurePipelines run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azpw run |
/AzurePipelines run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
@cbpaviz |
@cbpaviz Could you help to review again, I merged the code from master branch due to some conflict. |
@superchild , why SAG config commands are different compare to EC config commands (available in their config guid). is it intentional ? |
@kulpatel, this PR is discussed and reviewed by community, EC will also follow the same design after this merged. |
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): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) ] |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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"}) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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':
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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:
There was a problem hiding this comment.
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
28a1396
to
3ba8241
Compare
@zhangyanzhao |
What I did
Refer to SAG HLD#837
How I did it
How to verify it
Signed-off-by: Jimi Chen jimi_chen@edge-core.com