@@ -1126,7 +1126,9 @@ def test__port_provisioned_port_retry_port_binding_unbound(
11261126 ml2_plugin .MAX_PROVISIONING_TRIES = 2
11271127 plugin = directory .get_plugin ()
11281128 port_id = 'fake_port_id'
1129- port = mock .Mock (id = port_id , admin_state_up = True )
1129+ device_owner = constants .DEVICE_OWNER_COMPUTE_PREFIX + 'nova'
1130+ port = mock .Mock (id = port_id , admin_state_up = True ,
1131+ device_owner = device_owner )
11301132 mock_get_port .return_value = port
11311133 with mock .patch .object (plugin , 'update_port_status' ) as mock_pstatus :
11321134 pb1 = mock .MagicMock (vif_type = portbindings .VIF_TYPE_UNBOUND )
@@ -1139,6 +1141,23 @@ def test__port_provisioned_port_retry_port_binding_unbound(
11391141 mock_pstatus .assert_called_once_with (self .context , port_id ,
11401142 constants .PORT_STATUS_ACTIVE )
11411143
1144+ @mock .patch ('neutron.plugins.ml2.plugin.db.get_port' )
1145+ @mock .patch .object (p_utils , 'get_port_binding_by_status_and_host' )
1146+ def test__port_provisioned_port_retry_port_binding_unbound_no_vm_port (
1147+ self , mock_get_pb , mock_get_port ):
1148+ plugin = directory .get_plugin ()
1149+ port_id = 'fake_port_id'
1150+ port = mock .Mock (id = port_id , admin_state_up = True ,
1151+ device_owner = 'other_value' )
1152+ mock_get_port .return_value = port
1153+ with mock .patch .object (plugin , 'update_port_status' ) as mock_pstatus :
1154+ pb1 = mock .MagicMock (vif_type = portbindings .VIF_TYPE_UNBOUND )
1155+ mock_get_pb .return_value = pb1
1156+ plugin ._port_provisioned ('port' , 'evt' , 'trigger' ,
1157+ payload = events .DBEventPayload (
1158+ self .context , resource_id = port_id ))
1159+ mock_pstatus .assert_not_called ()
1160+
11421161 def test_port_after_create_outside_transaction (self ):
11431162 self .tx_open = True
11441163
0 commit comments