42
42
from nova .objects import fields as obj_fields
43
43
from nova .objects import network_request as net_req_obj
44
44
from nova .objects import virtual_interface as obj_vif
45
- from nova .pci import manager as pci_manager
46
45
from nova .pci import request as pci_request
47
46
from nova .pci import utils as pci_utils
48
47
from nova .pci import whitelist as pci_whitelist
@@ -7738,11 +7737,11 @@ def test_populate_neutron_extension_values_binding(self, mock_get_client):
7738
7737
'vf_num' : 1 ,
7739
7738
}))
7740
7739
@mock .patch .object (pci_whitelist .Whitelist , 'get_devspec' )
7741
- @mock .patch . object ( pci_manager , 'get_instance_pci_devs ' )
7740
+ @mock .patch ( 'nova.objects.Instance.get_pci_devices ' )
7742
7741
def test_populate_neutron_extension_values_binding_sriov (
7743
7742
self , mock_get_instance_pci_devs , mock_get_pci_device_devspec ):
7744
7743
host_id = 'my_host_id'
7745
- instance = { ' host' : host_id }
7744
+ instance = objects . Instance ( host = host_id )
7746
7745
port_req_body = {'port' : {}}
7747
7746
pci_req_id = 'my_req_id'
7748
7747
pci_dev = {'vendor_id' : '1377' ,
@@ -7783,11 +7782,11 @@ def test_populate_neutron_extension_values_binding_sriov(
7783
7782
})
7784
7783
)
7785
7784
@mock .patch .object (pci_whitelist .Whitelist , 'get_devspec' )
7786
- @mock .patch . object ( pci_manager , 'get_instance_pci_devs ' )
7785
+ @mock .patch ( 'nova.objects.Instance.get_pci_devices ' )
7787
7786
def test_populate_neutron_extension_values_binding_sriov_card_serial (
7788
7787
self , mock_get_instance_pci_devs , mock_get_pci_device_devspec ):
7789
7788
host_id = 'my_host_id'
7790
- instance = { ' host' : host_id }
7789
+ instance = objects . Instance ( host = host_id )
7791
7790
port_req_body = {'port' : {}}
7792
7791
pci_req_id = 'my_req_id'
7793
7792
pci_dev = {'vendor_id' : 'a2d6' ,
@@ -7867,11 +7866,11 @@ def test_populate_neutron_extension_values_with_arq(self,
7867
7866
})
7868
7867
)
7869
7868
@mock .patch .object (pci_whitelist .Whitelist , 'get_devspec' )
7870
- @mock .patch . object ( pci_manager , 'get_instance_pci_devs ' )
7869
+ @mock .patch ( 'nova.objects.Instance.get_pci_devices ' )
7871
7870
def test_populate_neutron_extension_values_binding_sriov_with_cap (
7872
7871
self , mock_get_instance_pci_devs , mock_get_pci_device_devspec ):
7873
7872
host_id = 'my_host_id'
7874
- instance = { ' host' : host_id }
7873
+ instance = objects . Instance ( host = host_id )
7875
7874
port_req_body = {'port' : {
7876
7875
constants .BINDING_PROFILE : {
7877
7876
'capabilities' : ['switchdev' ]}}}
@@ -7907,12 +7906,12 @@ def test_populate_neutron_extension_values_binding_sriov_with_cap(
7907
7906
constants .BINDING_PROFILE ])
7908
7907
7909
7908
@mock .patch .object (pci_whitelist .Whitelist , 'get_devspec' )
7910
- @mock .patch . object ( pci_manager , 'get_instance_pci_devs ' )
7909
+ @mock .patch ( 'nova.objects.Instance.get_pci_devices ' )
7911
7910
def test_populate_neutron_extension_values_binding_sriov_pf (
7912
7911
self , mock_get_instance_pci_devs , mock_get_devspec
7913
7912
):
7914
7913
host_id = 'my_host_id'
7915
- instance = { ' host' : host_id }
7914
+ instance = objects . Instance ( host = host_id )
7916
7915
port_req_body = {'port' : {}}
7917
7916
7918
7917
pci_dev = objects .PciDevice (
@@ -8041,11 +8040,11 @@ def test__get_pci_device_profile_pf(self, mock_get_pci_device_devspec):
8041
8040
)
8042
8041
8043
8042
@mock .patch .object (pci_whitelist .Whitelist , 'get_devspec' )
8044
- @mock .patch . object ( pci_manager , 'get_instance_pci_devs ' )
8043
+ @mock .patch ( 'nova.objects.Instance.get_pci_devices ' )
8045
8044
def test_populate_neutron_extension_values_binding_sriov_fail (
8046
8045
self , mock_get_instance_pci_devs , mock_get_pci_device_devspec ):
8047
8046
host_id = 'my_host_id'
8048
- instance = { ' host' : host_id }
8047
+ instance = objects . Instance ( host = host_id )
8049
8048
port_req_body = {'port' : {}}
8050
8049
pci_req_id = 'my_req_id'
8051
8050
pci_objs = [objects .PciDevice (vendor_id = '1377' ,
@@ -8062,7 +8061,7 @@ def test_populate_neutron_extension_values_binding_sriov_fail(
8062
8061
self .api ._populate_neutron_binding_profile ,
8063
8062
instance , pci_req_id , port_req_body , None )
8064
8063
8065
- @mock .patch . object ( pci_manager , 'get_instance_pci_devs ' , return_value = [])
8064
+ @mock .patch ( 'nova.objects.Instance.get_pci_devices ' , return_value = [])
8066
8065
def test_populate_neutron_binding_profile_pci_dev_not_found (
8067
8066
self , mock_get_instance_pci_devs ):
8068
8067
api = neutronapi .API ()
@@ -8073,7 +8072,7 @@ def test_populate_neutron_binding_profile_pci_dev_not_found(
8073
8072
api ._populate_neutron_binding_profile ,
8074
8073
instance , pci_req_id , port_req_body , None )
8075
8074
mock_get_instance_pci_devs .assert_called_once_with (
8076
- instance , pci_req_id )
8075
+ request_id = pci_req_id )
8077
8076
8078
8077
@mock .patch .object (
8079
8078
pci_utils , 'is_physical_function' ,
@@ -8089,7 +8088,7 @@ def test_populate_neutron_binding_profile_pci_dev_not_found(
8089
8088
new = mock .MagicMock (side_effect = (lambda vf_a : {
8090
8089
'0000:0a:00.0' : '52:54:00:1e:59:c6' }.get (vf_a )))
8091
8090
)
8092
- @mock .patch . object ( pci_manager , 'get_instance_pci_devs ' )
8091
+ @mock .patch ( 'nova.objects.Instance.get_pci_devices ' )
8093
8092
def test_pci_parse_whitelist_called_once (
8094
8093
self , mock_get_instance_pci_devs
8095
8094
):
@@ -8108,7 +8107,7 @@ def test_pci_parse_whitelist_called_once(
8108
8107
# after the 'device_spec' is set in this test case.
8109
8108
api = neutronapi .API ()
8110
8109
host_id = 'my_host_id'
8111
- instance = { ' host' : host_id }
8110
+ instance = objects . Instance ( host = host_id )
8112
8111
pci_req_id = 'my_req_id'
8113
8112
port_req_body = {'port' : {}}
8114
8113
pci_dev = {'vendor_id' : '1377' ,
@@ -8144,7 +8143,7 @@ def _populate_pci_mac_address_fakes(self):
8144
8143
vf .update_device (pci_dev )
8145
8144
return instance , pf , vf
8146
8145
8147
- @mock .patch . object ( pci_manager , 'get_instance_pci_devs ' )
8146
+ @mock .patch ( 'nova.objects.Instance.get_pci_devices ' )
8148
8147
@mock .patch .object (pci_utils , 'get_mac_by_pci_address' )
8149
8148
def test_populate_pci_mac_address_pf (self , mock_get_mac_by_pci_address ,
8150
8149
mock_get_instance_pci_devs ):
@@ -8158,7 +8157,7 @@ def test_populate_pci_mac_address_pf(self, mock_get_mac_by_pci_address,
8158
8157
self .api ._populate_pci_mac_address (instance , 0 , req )
8159
8158
self .assertEqual (expected_port_req_body , req )
8160
8159
8161
- @mock .patch . object ( pci_manager , 'get_instance_pci_devs ' )
8160
+ @mock .patch ( 'nova.objects.Instance.get_pci_devices ' )
8162
8161
@mock .patch .object (pci_utils , 'get_mac_by_pci_address' )
8163
8162
def test_populate_pci_mac_address_vf (self , mock_get_mac_by_pci_address ,
8164
8163
mock_get_instance_pci_devs ):
@@ -8170,7 +8169,7 @@ def test_populate_pci_mac_address_vf(self, mock_get_mac_by_pci_address,
8170
8169
self .api ._populate_pci_mac_address (instance , 42 , port_req_body )
8171
8170
self .assertEqual (port_req_body , req )
8172
8171
8173
- @mock .patch . object ( pci_manager , 'get_instance_pci_devs ' )
8172
+ @mock .patch ( 'nova.objects.Instance.get_pci_devices ' )
8174
8173
@mock .patch .object (pci_utils , 'get_mac_by_pci_address' )
8175
8174
def test_populate_pci_mac_address_vf_fail (self ,
8176
8175
mock_get_mac_by_pci_address ,
@@ -8185,7 +8184,7 @@ def test_populate_pci_mac_address_vf_fail(self,
8185
8184
self .api ._populate_pci_mac_address (instance , 42 , port_req_body )
8186
8185
self .assertEqual (port_req_body , req )
8187
8186
8188
- @mock .patch . object ( pci_manager , 'get_instance_pci_devs ' )
8187
+ @mock .patch ( 'nova.objects.Instance.get_pci_devices ' )
8189
8188
@mock .patch ('nova.network.neutron.LOG.error' )
8190
8189
def test_populate_pci_mac_address_no_device (self , mock_log_error ,
8191
8190
mock_get_instance_pci_devs ):
0 commit comments