@@ -606,23 +606,24 @@ def setUp(self):
606
606
'neutron_lib.plugins.directory.get_plugin' ).start ()
607
607
self .VNIC_FAKE_NORMAL = 'fake-vnic-normal'
608
608
self .VNIC_FAKE_OTHER = 'fake-vnic-other'
609
+ self .VNIC_FAKE_THIRD = 'fake-vnic-third'
609
610
610
611
# Replace constants.OVN_PORT_BINDING_PROFILE_PARAMS to allow synthesis
611
612
_params = constants .OVN_PORT_BINDING_PROFILE_PARAMS .copy ()
612
613
_params .extend ([
613
614
constants .OVNPortBindingProfileParamSet (
614
615
{'key' : [str , type (None )]},
615
616
self .VNIC_FAKE_NORMAL , None ),
616
- constants .OVNPortBindingProfileParamSet (
617
- {'key' : [str ], 'other_key' : [str ]},
618
- self .VNIC_FAKE_OTHER , None ),
619
617
constants .OVNPortBindingProfileParamSet (
620
618
{
621
619
'key' : [str ],
622
620
'other_key' : [int ],
623
621
'third_key' : [str ]
624
622
},
625
623
self .VNIC_FAKE_OTHER , constants .PORT_CAP_SWITCHDEV ),
624
+ constants .OVNPortBindingProfileParamSet (
625
+ {'key' : [str ], 'other_key' : [str ]},
626
+ self .VNIC_FAKE_THIRD , None ),
626
627
])
627
628
self .OVN_PORT_BINDING_PROFILE_PARAMS = mock .patch .object (
628
629
constants ,
@@ -737,6 +738,27 @@ def test_valid_input(self):
737
738
{portbindings .VNIC_TYPE : portbindings .VNIC_REMOTE_MANAGED ,
738
739
constants .OVN_PORT_BINDING_PROFILE : expect }))
739
740
741
+ def test_valid_input_surplus_capabilities (self ):
742
+ capabilities = ['rx' , 'tx' , 'sg' , 'tso' , 'gso' , 'gro' , 'rxvlan' ,
743
+ 'txvlan' , 'rxhash' , 'rdma' , 'txudptnl' ]
744
+ binding_profile = {
745
+ 'pci_vendor_info' : 'dead:beef' ,
746
+ 'pci_slot' : '0000:ca:fe.42' ,
747
+ 'physical_network' : 'physnet1' ,
748
+ 'card_serial_number' : 'AB2000X00042' ,
749
+ 'pf_mac_address' : '00:53:00:00:00:42' ,
750
+ 'vf_num' : 42 ,
751
+ constants .PORT_CAP_PARAM : capabilities
752
+ }
753
+ expect = binding_profile .copy ()
754
+ del (expect [constants .PORT_CAP_PARAM ])
755
+ self .assertEqual (
756
+ utils .BPInfo (expect , portbindings .VNIC_REMOTE_MANAGED ,
757
+ capabilities ),
758
+ utils .validate_and_get_data_from_binding_profile (
759
+ {portbindings .VNIC_TYPE : portbindings .VNIC_REMOTE_MANAGED ,
760
+ constants .OVN_PORT_BINDING_PROFILE : binding_profile }))
761
+
740
762
def test_valid_input_surplus_keys (self ):
741
763
# Confirm that extra keys are allowed
742
764
binding_profile = {
@@ -810,12 +832,12 @@ def test_overlapping_param_set_different_vnic_type(self):
810
832
utils .validate_and_get_data_from_binding_profile (
811
833
{portbindings .VNIC_TYPE : self .VNIC_FAKE_NORMAL ,
812
834
constants .OVN_PORT_BINDING_PROFILE : binding_profile }))
813
- # It is valid for VNIC_FAKE_OTHER
835
+ # It is valid for VNIC_FAKE_THIRD
814
836
expected_bp = binding_profile .copy ()
815
837
self .assertEqual (
816
- utils .BPInfo (expected_bp , self .VNIC_FAKE_OTHER , []),
838
+ utils .BPInfo (expected_bp , self .VNIC_FAKE_THIRD , []),
817
839
utils .validate_and_get_data_from_binding_profile (
818
- {portbindings .VNIC_TYPE : self .VNIC_FAKE_OTHER ,
840
+ {portbindings .VNIC_TYPE : self .VNIC_FAKE_THIRD ,
819
841
constants .OVN_PORT_BINDING_PROFILE : binding_profile }))
820
842
821
843
def test_overlapping_param_set_different_vnic_type_and_capability (self ):
@@ -825,13 +847,13 @@ def test_overlapping_param_set_different_vnic_type_and_capability(self):
825
847
'other_key' : 42 ,
826
848
'third_key' : 'value' ,
827
849
}
828
- # This param set is not valid for VNIC_FAKE_OTHER without capability
850
+ # This param set is not valid for VNIC_FAKE_THIRD without capability
829
851
expect = binding_profile .copy ()
830
852
del (expect ['third_key' ])
831
853
self .assertRaises (
832
854
neutron_lib .exceptions .InvalidInput ,
833
855
utils .validate_and_get_data_from_binding_profile ,
834
- {portbindings .VNIC_TYPE : self .VNIC_FAKE_OTHER ,
856
+ {portbindings .VNIC_TYPE : self .VNIC_FAKE_THIRD ,
835
857
constants .OVN_PORT_BINDING_PROFILE : binding_profile })
836
858
# This param set is also not valid as the capabilities do not match
837
859
binding_profile = {
0 commit comments