|
57 | 57 | from .config_mgmt import ConfigMgmtDPB, ConfigMgmt |
58 | 58 | from . import mclag |
59 | 59 | from . import syslog |
60 | | -from . import switchport |
61 | 60 | from . import dns |
62 | 61 |
|
63 | 62 | # mock masic APIs for unit test |
|
106 | 105 | PORT_SPEED = "speed" |
107 | 106 | PORT_TPID = "tpid" |
108 | 107 | DEFAULT_TPID = "0x8100" |
109 | | -PORT_MODE= "switchport_mode" |
110 | 108 |
|
111 | 109 | DOM_CONFIG_SUPPORTED_SUBPORTS = ['0', '1'] |
112 | 110 |
|
@@ -1215,9 +1213,6 @@ def config(ctx): |
1215 | 1213 | # DNS module |
1216 | 1214 | config.add_command(dns.dns) |
1217 | 1215 |
|
1218 | | -# Switchport module |
1219 | | -config.add_command(switchport.switchport) |
1220 | | - |
1221 | 1216 | @config.command() |
1222 | 1217 | @click.option('-y', '--yes', is_flag=True, callback=_abort_if_false, |
1223 | 1218 | expose_value=False, prompt='Existing files will be overwritten, continue?') |
@@ -4591,40 +4586,19 @@ def add(ctx, interface_name, ip_addr, gw): |
4591 | 4586 | if interface_name is None: |
4592 | 4587 | ctx.fail("'interface_name' is None!") |
4593 | 4588 |
|
| 4589 | + # Add a validation to check this interface is not a member in vlan before |
| 4590 | + # changing it to a router port |
| 4591 | + vlan_member_table = config_db.get_table('VLAN_MEMBER') |
| 4592 | + if (interface_is_in_vlan(vlan_member_table, interface_name)): |
| 4593 | + click.echo("Interface {} is a member of vlan\nAborting!".format(interface_name)) |
| 4594 | + return |
| 4595 | + |
4594 | 4596 | portchannel_member_table = config_db.get_table('PORTCHANNEL_MEMBER') |
4595 | 4597 |
|
4596 | 4598 | if interface_is_in_portchannel(portchannel_member_table, interface_name): |
4597 | 4599 | ctx.fail("{} is configured as a member of portchannel." |
4598 | 4600 | .format(interface_name)) |
4599 | | - |
4600 | | - |
4601 | | - # Add a validation to check this interface is in routed mode before |
4602 | | - # assigning an IP address to it |
4603 | | - |
4604 | | - sub_intf = False |
4605 | 4601 |
|
4606 | | - if clicommon.is_valid_port(config_db, interface_name): |
4607 | | - is_port = True |
4608 | | - elif clicommon.is_valid_portchannel(config_db, interface_name): |
4609 | | - is_port = False |
4610 | | - else: |
4611 | | - sub_intf = True |
4612 | | - |
4613 | | - if not sub_intf: |
4614 | | - interface_mode = "routed" |
4615 | | - if is_port: |
4616 | | - interface_data = config_db.get_entry('PORT',interface_name) |
4617 | | - elif not is_port: |
4618 | | - interface_data = config_db.get_entry('PORTCHANNEL',interface_name) |
4619 | | - |
4620 | | - if "mode" in interface_data: |
4621 | | - interface_mode = interface_data["mode"] |
4622 | | - |
4623 | | - if interface_mode != "routed": |
4624 | | - ctx.fail("Interface {} is not in routed mode!".format(interface_name)) |
4625 | | - return |
4626 | | - |
4627 | | - |
4628 | 4602 | try: |
4629 | 4603 | ip_address = ipaddress.ip_interface(ip_addr) |
4630 | 4604 | except ValueError as err: |
|
0 commit comments