'For a hard reboot, we shouldn\'t need an additional call to glance
to get the image metadata.
This is important for automatically spinning up instances on a
host-reboot, since we won\'t have a user request context that\'ll allow
the Glance request to go through. We have to rely on the cached image
metadata, instead.
https://bugs.launchpad.net/nova/+bug/1339386'

@mock.patch('oslo_utils.fileutils.ensure_tree')
@mock.patch('oslo_service.loopingcall.FixedIntervalLoopingCall')
@mock.patch('nova.pci.manager.get_instance_pci_devs')
@mock.patch('nova.virt.libvirt.LibvirtDriver._prepare_pci_devices_for_use')
@mock.patch('nova.virt.libvirt.LibvirtDriver._create_domain_and_network')
@mock.patch('nova.virt.libvirt.LibvirtDriver._create_images_and_backing')
@mock.patch('nova.virt.libvirt.LibvirtDriver._get_instance_disk_info_from_config')
@mock.patch('nova.virt.libvirt.utils.write_to_file')
@mock.patch('nova.virt.libvirt.utils.get_instance_path')
@mock.patch('nova.virt.libvirt.LibvirtDriver._get_guest_config')
@mock.patch('nova.virt.libvirt.blockinfo.get_disk_info')
@mock.patch('nova.virt.libvirt.LibvirtDriver._destroy')
def test_hard_reboot_does_not_call_glance_show(self, mock_destroy, mock_get_disk_info, mock_get_guest_config, mock_get_instance_path, mock_write_to_file, mock_get_instance_disk_info, mock_create_images_and_backing, mock_create_domand_and_network, mock_prepare_pci_devices_for_use, mock_get_instance_pci_devs, mock_looping_call, mock_ensure_tree):

    drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
    instance = objects.Instance(**self.test_instance)
    network_info = mock.MagicMock()
    block_device_info = mock.MagicMock()
    mock_get_disk_info.return_value = {}
    mock_get_guest_config.return_value = mock.MagicMock()
    mock_get_instance_path.return_value = '/foo'
    mock_looping_call.return_value = mock.MagicMock()
    drvr._image_api = mock.MagicMock()
    drvr._hard_reboot(self.context, instance, network_info, block_device_info)
    self.assertFalse(drvr._image_api.get.called)
    mock_ensure_tree.assert_called_once_with('/foo')
