Skip to content

Commit

Permalink
Revert "Fix for Switch Port Modes and VLAN CLI Enhancement (#3108)"
Browse files Browse the repository at this point in the history
This reverts commit 92220dc.
  • Loading branch information
wen587 committed Mar 27, 2024
1 parent e35452b commit 73ec7d9
Show file tree
Hide file tree
Showing 17 changed files with 141 additions and 1,888 deletions.
40 changes: 7 additions & 33 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
from .config_mgmt import ConfigMgmtDPB, ConfigMgmt
from . import mclag
from . import syslog
from . import switchport
from . import dns

# mock masic APIs for unit test
Expand Down Expand Up @@ -106,7 +105,6 @@
PORT_SPEED = "speed"
PORT_TPID = "tpid"
DEFAULT_TPID = "0x8100"
PORT_MODE= "switchport_mode"

DOM_CONFIG_SUPPORTED_SUBPORTS = ['0', '1']

Expand Down Expand Up @@ -1215,9 +1213,6 @@ def config(ctx):
# DNS module
config.add_command(dns.dns)

# Switchport module
config.add_command(switchport.switchport)

@config.command()
@click.option('-y', '--yes', is_flag=True, callback=_abort_if_false,
expose_value=False, prompt='Existing files will be overwritten, continue?')
Expand Down Expand Up @@ -4591,40 +4586,19 @@ def add(ctx, interface_name, ip_addr, gw):
if interface_name is None:
ctx.fail("'interface_name' is None!")

# Add a validation to check this interface is not a member in vlan before
# changing it to a router port
vlan_member_table = config_db.get_table('VLAN_MEMBER')
if (interface_is_in_vlan(vlan_member_table, interface_name)):
click.echo("Interface {} is a member of vlan\nAborting!".format(interface_name))
return

portchannel_member_table = config_db.get_table('PORTCHANNEL_MEMBER')

if interface_is_in_portchannel(portchannel_member_table, interface_name):
ctx.fail("{} is configured as a member of portchannel."
.format(interface_name))


# Add a validation to check this interface is in routed mode before
# assigning an IP address to it

sub_intf = False

if clicommon.is_valid_port(config_db, interface_name):
is_port = True
elif clicommon.is_valid_portchannel(config_db, interface_name):
is_port = False
else:
sub_intf = True

if not sub_intf:
interface_mode = "routed"
if is_port:
interface_data = config_db.get_entry('PORT',interface_name)
elif not is_port:
interface_data = config_db.get_entry('PORTCHANNEL',interface_name)

if "mode" in interface_data:
interface_mode = interface_data["mode"]

if interface_mode != "routed":
ctx.fail("Interface {} is not in routed mode!".format(interface_name))
return


try:
ip_address = ipaddress.ip_interface(ip_addr)
except ValueError as err:
Expand Down
137 changes: 0 additions & 137 deletions config/switchport.py

This file was deleted.

Loading

1 comment on commit 73ec7d9

@ridahanif96
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @qiluo-msft can you help revert this case again and please review all pending PR related to this PR again so we can again resolve backward compatibility issues as per new suggestions

Please sign in to comment.