16
16
| | fc02:1000::1/64 | Ethernet8 | untagged | 192.0.0.2 | |
17
17
| | | Ethernet12 | untagged | 192.0.0.3 | |
18
18
| | | Ethernet16 | untagged | 192.0.0.4 | |
19
+ | | | | | fc02:2000::1 | |
20
+ | | | | | fc02:2000::2 | |
19
21
+-----------+-----------------+-----------------+----------------+-----------------------+-------------+
20
22
| 2000 | 192.168.0.10/21 | Ethernet24 | untagged | 192.0.0.1 | enabled |
21
23
| | fc02:1011::1/64 | Ethernet28 | untagged | 192.0.0.2 | |
36
38
| | fc02:1000::1/64 | etp3 | untagged | 192.0.0.2 | |
37
39
| | | etp4 | untagged | 192.0.0.3 | |
38
40
| | | etp5 | untagged | 192.0.0.4 | |
41
+ | | | | | fc02:2000::1 | |
42
+ | | | | | fc02:2000::2 | |
39
43
+-----------+-----------------+-----------------+----------------+-----------------------+-------------+
40
44
| 2000 | 192.168.0.10/21 | etp7 | untagged | 192.0.0.1 | enabled |
41
45
| | fc02:1011::1/64 | etp8 | untagged | 192.0.0.2 | |
71
75
| | fc02:1000::1/64 | Ethernet8 | untagged | 192.0.0.2 | |
72
76
| | | Ethernet12 | untagged | 192.0.0.3 | |
73
77
| | | Ethernet16 | untagged | 192.0.0.4 | |
74
- | | | PortChannel1001 | untagged | | |
78
+ | | | PortChannel1001 | untagged | fc02:2000::1 | |
79
+ | | | | | fc02:2000::2 | |
75
80
+-----------+-----------------+-----------------+----------------+-----------------------+-------------+
76
81
| 2000 | 192.168.0.10/21 | Ethernet24 | untagged | 192.0.0.1 | enabled |
77
82
| | fc02:1011::1/64 | Ethernet28 | untagged | 192.0.0.2 | |
120
125
Restarting DHCP relay service...
121
126
"""
122
127
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
+
123
138
show_vlan_brief_output_with_new_dhcp_relay_address = """\
124
139
+-----------+-----------------+-----------------+----------------+-----------------------+-------------+
125
140
| VLAN ID | IP Address | Ports | Port Tagging | DHCP Helper Address | Proxy ARP |
129
144
| | | Ethernet12 | untagged | 192.0.0.3 | |
130
145
| | | Ethernet16 | untagged | 192.0.0.4 | |
131
146
| | | | | 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 | |
132
172
+-----------+-----------------+-----------------+----------------+-----------------------+-------------+
133
173
| 2000 | 192.168.0.10/21 | Ethernet24 | untagged | 192.0.0.1 | enabled |
134
174
| | fc02:1011::1/64 | Ethernet28 | untagged | 192.0.0.2 | |
149
189
| | fc02:1000::1/64 | Ethernet8 | untagged | 192.0.0.2 | |
150
190
| | | Ethernet12 | untagged | 192.0.0.3 | |
151
191
| | | Ethernet16 | untagged | 192.0.0.4 | |
192
+ | | | | | fc02:2000::1 | |
193
+ | | | | | fc02:2000::2 | |
152
194
+-----------+-----------------+-----------------+----------------+-----------------------+-------------+
153
195
| 1001 | | Ethernet20 | untagged | | disabled |
154
196
+-----------+-----------------+-----------------+----------------+-----------------------+-------------+
171
213
| | fc02:1000::1/64 | etp3 | untagged | 192.0.0.2 | |
172
214
| | | etp4 | untagged | 192.0.0.3 | |
173
215
| | | etp5 | untagged | 192.0.0.4 | |
216
+ | | | | | fc02:2000::1 | |
217
+ | | | | | fc02:2000::2 | |
174
218
+-----------+-----------------+-----------------+----------------+-----------------------+-------------+
175
219
| 1001 | | etp6 | untagged | | disabled |
176
220
+-----------+-----------------+-----------------+----------------+-----------------------+-------------+
@@ -535,6 +579,19 @@ def test_config_vlan_add_dhcp_relay_with_invalid_ip(self):
535
579
assert result .exit_code != 0
536
580
assert "Error: 192.0.0.1000 is invalid IP address" in result .output
537
581
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
538
595
539
596
def test_config_vlan_add_dhcp_relay_with_invalid_ip_2 (self ):
540
597
runner = CliRunner ()
@@ -561,6 +618,19 @@ def test_config_vlan_add_dhcp_relay_with_exist_ip(self):
561
618
assert result .exit_code == 0
562
619
assert "192.0.0.1 is already a DHCP relay destination for Vlan1000" in result .output
563
620
assert mock_run_command .call_count == 0
621
+
622
+ def test_config_vlan_add_dhcp_relay_with_exist_ipv6 (self ):
623
+ runner = CliRunner ()
624
+
625
+ with mock .patch ('utilities_common.cli.run_command' ) as mock_run_command :
626
+ result = runner .invoke (config .config .commands ["vlan" ].commands ["dhcp_relay" ].commands ["add" ],
627
+ ["1000" , "fc02:2000::1" ])
628
+ print (result .exit_code )
629
+ print (result .output )
630
+ # traceback.print_tb(result.exc_info[2])
631
+ assert result .exit_code == 0
632
+ assert "fc02:2000::1 is already a DHCP relay destination for Vlan1000" in result .output
633
+ assert mock_run_command .call_count == 0
564
634
565
635
def test_config_vlan_add_del_dhcp_relay_dest (self ):
566
636
runner = CliRunner ()
@@ -596,6 +666,40 @@ def test_config_vlan_add_del_dhcp_relay_dest(self):
596
666
print (result .output )
597
667
assert result .output == show_vlan_brief_output
598
668
669
+ def test_config_vlan_add_del_dhcp_relayv6_dest (self ):
670
+ runner = CliRunner ()
671
+ db = Db ()
672
+
673
+ # add new relay dest
674
+ with mock .patch ("utilities_common.cli.run_command" ) as mock_run_command :
675
+ result = runner .invoke (config .config .commands ["vlan" ].commands ["dhcp_relay" ].commands ["add" ],
676
+ ["1000" , "fc02:2000::3" ], obj = db )
677
+ print (result .exit_code )
678
+ print (result .output )
679
+ assert result .exit_code == 0
680
+ assert result .output == config_vlan_add_dhcp_relayv6_output
681
+ assert mock_run_command .call_count == 3
682
+
683
+ # show output
684
+ result = runner .invoke (show .cli .commands ["vlan" ].commands ["brief" ], [], obj = db )
685
+ print (result .output )
686
+ assert result .output == show_vlan_brief_output_with_new_dhcp_relayv6_address
687
+
688
+ # del relay dest
689
+ with mock .patch ("utilities_common.cli.run_command" ) as mock_run_command :
690
+ result = runner .invoke (config .config .commands ["vlan" ].commands ["dhcp_relay" ].commands ["del" ],
691
+ ["1000" , "fc02:2000::3" ], obj = db )
692
+ print (result .exit_code )
693
+ print (result .output )
694
+ assert result .exit_code == 0
695
+ assert result .output == config_vlan_del_dhcp_relayv6_output
696
+ assert mock_run_command .call_count == 3
697
+
698
+ # show output
699
+ result = runner .invoke (show .cli .commands ["vlan" ].commands ["brief" ], [], obj = db )
700
+ print (result .output )
701
+ assert result .output == show_vlan_brief_output
702
+
599
703
def test_config_vlan_remove_nonexist_dhcp_relay_dest (self ):
600
704
runner = CliRunner ()
601
705
@@ -608,6 +712,19 @@ def test_config_vlan_remove_nonexist_dhcp_relay_dest(self):
608
712
assert result .exit_code != 0
609
713
assert "Error: 192.0.0.100 is not a DHCP relay destination for Vlan1000" in result .output
610
714
assert mock_run_command .call_count == 0
715
+
716
+ def test_config_vlan_remove_nonexist_dhcp_relayv6_dest (self ):
717
+ runner = CliRunner ()
718
+
719
+ with mock .patch ('utilities_common.cli.run_command' ) as mock_run_command :
720
+ result = runner .invoke (config .config .commands ["vlan" ].commands ["dhcp_relay" ].commands ["del" ],
721
+ ["1000" , "fc02:2000::3" ])
722
+ print (result .exit_code )
723
+ print (result .output )
724
+ # traceback.print_tb(result.exc_info[2])
725
+ assert result .exit_code != 0
726
+ assert "Error: fc02:2000::3 is not a DHCP relay destination for Vlan1000" in result .output
727
+ assert mock_run_command .call_count == 0
611
728
612
729
def test_config_vlan_remove_dhcp_relay_dest_with_nonexist_vlanid (self ):
613
730
runner = CliRunner ()
0 commit comments