'Ensure that if the RPC call to release_dhcp raises a
RPCPinnedToOldVersion, we fall back to the previous behaviour of
calling release_dhcp in the local linux_net driver. In the previous
test, release_dhcp was mocked to call the driver, since this is what
happens on a successful RPC call. In this test, we mock it to raise,
but the expected behaviour is exactly the same - namely that
release_dhcp is called in the linux_net driver, which is why the two
tests are otherwise identical.'

@mock.patch.object(linux_net, 'release_dhcp')
@mock.patch('nova.network.rpcapi.NetworkAPI.release_dhcp')
@mock.patch('nova.db.virtual_interface_get')
@mock.patch('nova.db.fixed_ip_get_by_address')
@mock.patch('nova.db.network_get')
@mock.patch('nova.db.fixed_ip_update')
def test_deallocate_fixed_rpc_pinned(self, fixed_update, net_get, fixed_get, vif_get, release_dhcp, net_release_dhcp):

    net_get.return_value = dict(test_network.fake_network, **networks[1])
    vif_get.return_value = vifs[0]
    release_dhcp.side_effect = exception.RPCPinnedToOldVersion()
    context1 = context.RequestContext('user', fakes.FAKE_PROJECT_ID)
    instance = db.instance_create(context1, {'project_id': fakes.FAKE_PROJECT_ID})
    elevated = context1.elevated()
    fix_addr = db.fixed_ip_associate_pool(elevated, 1, instance['uuid'])
    fixed_get.return_value = dict(test_fixed_ip.fake_fixed_ip, address=fix_addr.address, instance_uuid=instance.uuid, allocated=True, virtual_interface_id=3, network=dict(test_network.fake_network, **networks[1]))
    self.flags(force_dhcp_release=True)
    self.network.deallocate_fixed_ip(context1, fix_addr.address, 'fake')
    net_release_dhcp.assert_called_once_with(networks[1]['bridge'], fix_addr.address, 'DE:AD:BE:EF:00:00')
    fixed_update.assert_called_once_with(context1, fix_addr.address, {'allocated': False})
