1616| | fc02:1000::1/64 | Ethernet8 | untagged | 192.0.0.2 | |
1717| | | Ethernet12 | untagged | 192.0.0.3 | |
1818| | | Ethernet16 | untagged | 192.0.0.4 | |
19+ | | | | | fc02:2000::1 | |
20+ | | | | | fc02:2000::2 | |
1921+-----------+-----------------+-----------------+----------------+-----------------------+-------------+
2022| 2000 | 192.168.0.10/21 | Ethernet24 | untagged | 192.0.0.1 | enabled |
2123| | fc02:1011::1/64 | Ethernet28 | untagged | 192.0.0.2 | |
3638| | fc02:1000::1/64 | etp3 | untagged | 192.0.0.2 | |
3739| | | etp4 | untagged | 192.0.0.3 | |
3840| | | etp5 | untagged | 192.0.0.4 | |
41+ | | | | | fc02:2000::1 | |
42+ | | | | | fc02:2000::2 | |
3943+-----------+-----------------+-----------------+----------------+-----------------------+-------------+
4044| 2000 | 192.168.0.10/21 | etp7 | untagged | 192.0.0.1 | enabled |
4145| | fc02:1011::1/64 | etp8 | untagged | 192.0.0.2 | |
7175| | fc02:1000::1/64 | Ethernet8 | untagged | 192.0.0.2 | |
7276| | | Ethernet12 | untagged | 192.0.0.3 | |
7377| | | Ethernet16 | untagged | 192.0.0.4 | |
74- | | | PortChannel1001 | untagged | | |
78+ | | | PortChannel1001 | untagged | fc02:2000::1 | |
79+ | | | | | fc02:2000::2 | |
7580+-----------+-----------------+-----------------+----------------+-----------------------+-------------+
7681| 2000 | 192.168.0.10/21 | Ethernet24 | untagged | 192.0.0.1 | enabled |
7782| | fc02:1011::1/64 | Ethernet28 | untagged | 192.0.0.2 | |
120125Restarting DHCP relay service...
121126"""
122127
128+ config_vlan_add_dhcp_relayv6_output = """\
129+ Added DHCP relay destination address fc02:2000::3 to Vlan1000
130+ Restarting DHCP relay service...
131+ """
132+
133+ config_vlan_del_dhcp_relayv6_output = """\
134+ Removed DHCP relay destination address fc02:2000::3 from Vlan1000
135+ Restarting DHCP relay service...
136+ """
137+
123138show_vlan_brief_output_with_new_dhcp_relay_address = """\
124139 +-----------+-----------------+-----------------+----------------+-----------------------+-------------+
125140| VLAN ID | IP Address | Ports | Port Tagging | DHCP Helper Address | Proxy ARP |
129144| | | Ethernet12 | untagged | 192.0.0.3 | |
130145| | | Ethernet16 | untagged | 192.0.0.4 | |
131146| | | | | 192.0.0.100 | |
147+ | | | | | fc02:2000::1 | |
148+ | | | | | fc02:2000::2 | |
149+ +-----------+-----------------+-----------------+----------------+-----------------------+-------------+
150+ | 2000 | 192.168.0.10/21 | Ethernet24 | untagged | 192.0.0.1 | enabled |
151+ | | fc02:1011::1/64 | Ethernet28 | untagged | 192.0.0.2 | |
152+ | | | | | 192.0.0.3 | |
153+ | | | | | 192.0.0.4 | |
154+ +-----------+-----------------+-----------------+----------------+-----------------------+-------------+
155+ | 3000 | | | | | disabled |
156+ +-----------+-----------------+-----------------+----------------+-----------------------+-------------+
157+ | 4000 | | PortChannel1001 | tagged | | disabled |
158+ +-----------+-----------------+-----------------+----------------+-----------------------+-------------+
159+ """
160+
161+ show_vlan_brief_output_with_new_dhcp_relayv6_address = """\
162+ +-----------+-----------------+-----------------+----------------+-----------------------+-------------+
163+ | VLAN ID | IP Address | Ports | Port Tagging | DHCP Helper Address | Proxy ARP |
164+ +===========+=================+=================+================+=======================+=============+
165+ | 1000 | 192.168.0.1/21 | Ethernet4 | untagged | 192.0.0.1 | disabled |
166+ | | fc02:1000::1/64 | Ethernet8 | untagged | 192.0.0.2 | |
167+ | | | Ethernet12 | untagged | 192.0.0.3 | |
168+ | | | Ethernet16 | untagged | 192.0.0.4 | |
169+ | | | | | fc02:2000::1 | |
170+ | | | | | fc02:2000::2 | |
171+ | | | | | fc02:2000::3 | |
132172+-----------+-----------------+-----------------+----------------+-----------------------+-------------+
133173| 2000 | 192.168.0.10/21 | Ethernet24 | untagged | 192.0.0.1 | enabled |
134174| | fc02:1011::1/64 | Ethernet28 | untagged | 192.0.0.2 | |
149189| | fc02:1000::1/64 | Ethernet8 | untagged | 192.0.0.2 | |
150190| | | Ethernet12 | untagged | 192.0.0.3 | |
151191| | | Ethernet16 | untagged | 192.0.0.4 | |
192+ | | | | | fc02:2000::1 | |
193+ | | | | | fc02:2000::2 | |
152194+-----------+-----------------+-----------------+----------------+-----------------------+-------------+
153195| 1001 | | Ethernet20 | untagged | | disabled |
154196+-----------+-----------------+-----------------+----------------+-----------------------+-------------+
171213| | fc02:1000::1/64 | etp3 | untagged | 192.0.0.2 | |
172214| | | etp4 | untagged | 192.0.0.3 | |
173215| | | etp5 | untagged | 192.0.0.4 | |
216+ | | | | | fc02:2000::1 | |
217+ | | | | | fc02:2000::2 | |
174218+-----------+-----------------+-----------------+----------------+-----------------------+-------------+
175219| 1001 | | etp6 | untagged | | disabled |
176220+-----------+-----------------+-----------------+----------------+-----------------------+-------------+
@@ -535,6 +579,19 @@ def test_config_vlan_add_dhcp_relay_with_invalid_ip(self):
535579 assert result .exit_code != 0
536580 assert "Error: 192.0.0.1000 is invalid IP address" in result .output
537581 assert mock_run_command .call_count == 0
582+
583+ def test_config_vlan_add_dhcp_relay_with_invalid_ipv6 (self ):
584+ runner = CliRunner ()
585+
586+ with mock .patch ('utilities_common.cli.run_command' ) as mock_run_command :
587+ result = runner .invoke (config .config .commands ["vlan" ].commands ["dhcp_relay" ].commands ["add" ],
588+ ["1000" , "fe80:2030:31:24" ])
589+ print (result .exit_code )
590+ print (result .output )
591+ # traceback.print_tb(result.exc_info[2])
592+ assert result .exit_code != 0
593+ assert "Error: fe80:2030:31:24 is invalid IP address" in result .output
594+ assert mock_run_command .call_count == 0
538595
539596 def test_config_vlan_add_dhcp_relay_with_exist_ip (self ):
540597 runner = CliRunner ()
@@ -548,6 +605,19 @@ def test_config_vlan_add_dhcp_relay_with_exist_ip(self):
548605 assert result .exit_code == 0
549606 assert "192.0.0.1 is already a DHCP relay destination for Vlan1000" in result .output
550607 assert mock_run_command .call_count == 0
608+
609+ def test_config_vlan_add_dhcp_relay_with_exist_ipv6 (self ):
610+ runner = CliRunner ()
611+
612+ with mock .patch ('utilities_common.cli.run_command' ) as mock_run_command :
613+ result = runner .invoke (config .config .commands ["vlan" ].commands ["dhcp_relay" ].commands ["add" ],
614+ ["1000" , "fc02:2000::1" ])
615+ print (result .exit_code )
616+ print (result .output )
617+ # traceback.print_tb(result.exc_info[2])
618+ assert result .exit_code == 0
619+ assert "fc02:2000::1 is already a DHCP relay destination for Vlan1000" in result .output
620+ assert mock_run_command .call_count == 0
551621
552622 def test_config_vlan_add_del_dhcp_relay_dest (self ):
553623 runner = CliRunner ()
@@ -583,6 +653,40 @@ def test_config_vlan_add_del_dhcp_relay_dest(self):
583653 print (result .output )
584654 assert result .output == show_vlan_brief_output
585655
656+ def test_config_vlan_add_del_dhcp_relayv6_dest (self ):
657+ runner = CliRunner ()
658+ db = Db ()
659+
660+ # add new relay dest
661+ with mock .patch ("utilities_common.cli.run_command" ) as mock_run_command :
662+ result = runner .invoke (config .config .commands ["vlan" ].commands ["dhcp_relay" ].commands ["add" ],
663+ ["1000" , "fc02:2000::3" ], obj = db )
664+ print (result .exit_code )
665+ print (result .output )
666+ assert result .exit_code == 0
667+ assert result .output == config_vlan_add_dhcp_relayv6_output
668+ assert mock_run_command .call_count == 3
669+
670+ # show output
671+ result = runner .invoke (show .cli .commands ["vlan" ].commands ["brief" ], [], obj = db )
672+ print (result .output )
673+ assert result .output == show_vlan_brief_output_with_new_dhcp_relayv6_address
674+
675+ # del relay dest
676+ with mock .patch ("utilities_common.cli.run_command" ) as mock_run_command :
677+ result = runner .invoke (config .config .commands ["vlan" ].commands ["dhcp_relay" ].commands ["del" ],
678+ ["1000" , "fc02:2000::3" ], obj = db )
679+ print (result .exit_code )
680+ print (result .output )
681+ assert result .exit_code == 0
682+ assert result .output == config_vlan_del_dhcp_relayv6_output
683+ assert mock_run_command .call_count == 3
684+
685+ # show output
686+ result = runner .invoke (show .cli .commands ["vlan" ].commands ["brief" ], [], obj = db )
687+ print (result .output )
688+ assert result .output == show_vlan_brief_output
689+
586690 def test_config_vlan_remove_nonexist_dhcp_relay_dest (self ):
587691 runner = CliRunner ()
588692
@@ -595,6 +699,19 @@ def test_config_vlan_remove_nonexist_dhcp_relay_dest(self):
595699 assert result .exit_code != 0
596700 assert "Error: 192.0.0.100 is not a DHCP relay destination for Vlan1000" in result .output
597701 assert mock_run_command .call_count == 0
702+
703+ def test_config_vlan_remove_nonexist_dhcp_relayv6_dest (self ):
704+ runner = CliRunner ()
705+
706+ with mock .patch ('utilities_common.cli.run_command' ) as mock_run_command :
707+ result = runner .invoke (config .config .commands ["vlan" ].commands ["dhcp_relay" ].commands ["del" ],
708+ ["1000" , "fc02:2000::3" ])
709+ print (result .exit_code )
710+ print (result .output )
711+ # traceback.print_tb(result.exc_info[2])
712+ assert result .exit_code != 0
713+ assert "Error: fc02:2000::3 is not a DHCP relay destination for Vlan1000" in result .output
714+ assert mock_run_command .call_count == 0
598715
599716 def test_config_vlan_remove_dhcp_relay_dest_with_nonexist_vlanid (self ):
600717 runner = CliRunner ()
0 commit comments