@@ -74,6 +74,7 @@ class SRIOVServersTest(_PCIServersTestBase):
74
74
{
75
75
'vendor_id' : fakelibvirt .PCI_VEND_ID ,
76
76
'product_id' : fakelibvirt .VF_PROD_ID ,
77
+ 'physical_network' : 'physnet4' ,
77
78
},
78
79
)]
79
80
# PFs will be removed from pools unless they are specifically
@@ -168,20 +169,82 @@ def test_create_server_with_VF_no_PF(self):
168
169
flavor_id = flavor_id_pfs , networks = 'none' , expected_state = 'ERROR' ,
169
170
)
170
171
172
+ def test_create_server_with_neutron (self ):
173
+ """Create an instance using a neutron-provisioned SR-IOV VIF."""
174
+
175
+ pci_info = fakelibvirt .HostPCIDevicesInfo (num_pfs = 1 , num_vfs = 2 )
176
+
177
+ orig_create = nova .virt .libvirt .guest .Guest .create
178
+
179
+ def fake_create (cls , xml , host ):
180
+ tree = etree .fromstring (xml )
181
+ elem = tree .find ('./devices/interface/source/address' )
182
+
183
+ # compare address
184
+ expected = ('0x81' , '0x00' , '0x2' )
185
+ actual = (
186
+ elem .get ('bus' ), elem .get ('slot' ), elem .get ('function' ),
187
+ )
188
+ self .assertEqual (expected , actual )
189
+
190
+ return orig_create (xml , host )
191
+
192
+ self .stub_out (
193
+ 'nova.virt.libvirt.guest.Guest.create' ,
194
+ fake_create ,
195
+ )
196
+
197
+ self .start_compute (pci_info = pci_info )
198
+
199
+ # create the port
200
+ self .neutron .create_port ({'port' : self .neutron .network_4_port_1 })
201
+
202
+ # ensure the binding details are currently unset
203
+ port = self .neutron .show_port (
204
+ base .LibvirtNeutronFixture .network_4_port_1 ['id' ],
205
+ )['port' ]
206
+ self .assertNotIn ('binding:profile' , port )
207
+
208
+ # create a server using the VF via neutron
209
+ flavor_id = self ._create_flavor ()
210
+ self ._create_server (
211
+ flavor_id = flavor_id ,
212
+ networks = [
213
+ {'port' : base .LibvirtNeutronFixture .network_4_port_1 ['id' ]},
214
+ ],
215
+ )
216
+
217
+ # ensure the binding details sent to "neutron" were correct
218
+ port = self .neutron .show_port (
219
+ base .LibvirtNeutronFixture .network_4_port_1 ['id' ],
220
+ )['port' ]
221
+ self .assertIn ('binding:profile' , port )
222
+ self .assertEqual (
223
+ {
224
+ 'pci_vendor_info' : '8086:1515' ,
225
+ 'pci_slot' : '0000:81:00.2' ,
226
+ 'physical_network' : 'physnet4' ,
227
+ },
228
+ port ['binding:profile' ],
229
+ )
230
+
171
231
def test_get_server_diagnostics_server_with_VF (self ):
172
232
"""Ensure server disagnostics include info on VF-type PCI devices."""
173
233
174
234
pci_info = fakelibvirt .HostPCIDevicesInfo ()
175
235
self .start_compute (pci_info = pci_info )
176
236
237
+ # create the SR-IOV port
238
+ self .neutron .create_port ({'port' : self .neutron .network_4_port_1 })
239
+
177
240
# create a server using the VF and multiple networks
178
241
extra_spec = {'pci_passthrough:alias' : f'{ self .VFS_ALIAS_NAME } :1' }
179
242
flavor_id = self ._create_flavor (extra_spec = extra_spec )
180
243
server = self ._create_server (
181
244
flavor_id = flavor_id ,
182
245
networks = [
183
246
{'uuid' : base .LibvirtNeutronFixture .network_1 ['id' ]},
184
- {'uuid ' : base .LibvirtNeutronFixture .network_4 ['id' ]},
247
+ {'port ' : base .LibvirtNeutronFixture .network_4_port_1 ['id' ]},
185
248
],
186
249
)
187
250
0 commit comments