@@ -8627,6 +8627,73 @@ def test_unbind_ports_clean_arq(self, mock_neutron, mock_show,
8627
8627
self .assertEqual (call_args ['port' ]['binding:profile' ],
8628
8628
{'key' : 'val' })
8629
8629
8630
+ def test__get_vf_pci_device_profile_without_serial_num (self ):
8631
+ mydev = objects .PciDevice (
8632
+ address = 'foo' ,
8633
+ compute_node_id = '123' ,
8634
+ extra_info = {
8635
+ 'capabilities' : jsonutils .dumps ({
8636
+ 'sriov' : {
8637
+ 'pf_mac_address' : '52:54:00:1e:59:c6' ,
8638
+ 'vf_num' : 1 ,
8639
+ },
8640
+ 'network' : ['gso' , 'sg' , 'tso' , 'tx' ],
8641
+ }),
8642
+ },
8643
+ )
8644
+ self .assertEqual (self .api ._get_vf_pci_device_profile (mydev ),
8645
+ {'pf_mac_address' : '52:54:00:1e:59:c6' ,
8646
+ 'vf_num' : 1 ,
8647
+ 'capabilities' : ['gso' , 'sg' , 'tso' , 'tx' ]})
8648
+
8649
+ def test__get_vf_pci_device_profile_without_pf_mac_addr (self ):
8650
+ mydev = objects .PciDevice (
8651
+ address = 'foo' ,
8652
+ compute_node_id = '123' ,
8653
+ extra_info = {
8654
+ 'capabilities' : jsonutils .dumps ({
8655
+ 'vpd' : {'card_serial_number' : 'MT2113X00000' },
8656
+ 'sriov' : {'vf_num' : 1 },
8657
+ 'network' : ['gso' , 'sg' , 'tso' , 'tx' ],
8658
+ }),
8659
+ },
8660
+ )
8661
+ self .assertEqual (self .api ._get_vf_pci_device_profile (mydev ),
8662
+ {'card_serial_number' : 'MT2113X00000' ,
8663
+ 'vf_num' : 1 ,
8664
+ 'capabilities' : ['gso' , 'sg' , 'tso' , 'tx' ]})
8665
+
8666
+ def test__get_vf_pci_device_profile_without_vf_num (self ):
8667
+ mydev = objects .PciDevice (
8668
+ address = 'foo' ,
8669
+ compute_node_id = '123' ,
8670
+ extra_info = {
8671
+ 'capabilities' : jsonutils .dumps ({
8672
+ 'vpd' : {'card_serial_number' : 'MT2113X00000' },
8673
+ 'sriov' : {'pf_mac_address' : '52:54:00:1e:59:c6' },
8674
+ 'network' : ['gso' , 'sg' , 'tso' , 'tx' ],
8675
+ }),
8676
+ },
8677
+ )
8678
+ self .assertEqual (self .api ._get_vf_pci_device_profile (mydev ),
8679
+ {'card_serial_number' : 'MT2113X00000' ,
8680
+ 'pf_mac_address' : '52:54:00:1e:59:c6' ,
8681
+ 'capabilities' : ['gso' , 'sg' , 'tso' , 'tx' ]})
8682
+
8683
+ def test__get_vf_pci_device_profile_with_dev_capabilities (self ):
8684
+ mydev = objects .PciDevice (
8685
+ address = 'foo' ,
8686
+ compute_node_id = '123' ,
8687
+ extra_info = {
8688
+ 'capabilities' : jsonutils .dumps ({
8689
+ 'sriov' : {},
8690
+ 'network' : ['gso' , 'sg' , 'tso' , 'tx' ],
8691
+ }),
8692
+ },
8693
+ )
8694
+ self .assertEqual (self .api ._get_vf_pci_device_profile (mydev ),
8695
+ {'capabilities' : ['gso' , 'sg' , 'tso' , 'tx' ]})
8696
+
8630
8697
8631
8698
class TestAllocateForInstance (test .NoDBTestCase ):
8632
8699
def setUp (self ):
0 commit comments