@@ -1126,7 +1126,9 @@ def test__port_provisioned_port_retry_port_binding_unbound(
1126
1126
ml2_plugin .MAX_PROVISIONING_TRIES = 2
1127
1127
plugin = directory .get_plugin ()
1128
1128
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 )
1130
1132
mock_get_port .return_value = port
1131
1133
with mock .patch .object (plugin , 'update_port_status' ) as mock_pstatus :
1132
1134
pb1 = mock .MagicMock (vif_type = portbindings .VIF_TYPE_UNBOUND )
@@ -1139,6 +1141,23 @@ def test__port_provisioned_port_retry_port_binding_unbound(
1139
1141
mock_pstatus .assert_called_once_with (self .context , port_id ,
1140
1142
constants .PORT_STATUS_ACTIVE )
1141
1143
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
+
1142
1161
def test_port_after_create_outside_transaction (self ):
1143
1162
self .tx_open = True
1144
1163
0 commit comments