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

Revert "Switch Port Modes and VLAN CLI Enhancement (#2419)" #3007

Merged
merged 2 commits into from
Oct 7, 2023
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
38 changes: 7 additions & 31 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,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 @@ -102,8 +101,6 @@
CFG_PORTCHANNEL_NO="<0-9999>"

PORT_MTU = "mtu"
PORT_MODE= "switchport_mode"

PORT_SPEED = "speed"
PORT_TPID = "tpid"
DEFAULT_TPID = "0x8100"
Expand Down Expand Up @@ -1193,7 +1190,6 @@ def config(ctx):
config.add_command(nat.nat)
config.add_command(vlan.vlan)
config.add_command(vxlan.vxlan)
config.add_command(switchport.switchport)

#add mclag commands
config.add_command(mclag.mclag)
Expand Down Expand Up @@ -4503,39 +4499,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
138 changes: 0 additions & 138 deletions config/switchport.py

This file was deleted.

Loading
Loading