'Domain can fail to return the vcpu description in case it\'s
just starting up or shutting down. Make sure None is handled
gracefully.'

@mock.patch.object(host.Host, 'list_instance_domains')
def test_failing_vcpu_count(self, mock_list):

    class DiagFakeDomain(object, ):
        def __init__(self, vcpus):
            self._vcpus = vcpus
        def vcpus(self):
            if (self._vcpus is None):
                raise fakelibvirt.libvirtError('fake-error')
            else:
                return (([[1, 2, 3, 4]] * self._vcpus), ([True] * self._vcpus))
        def ID(self):
            return 1
        def name(self):
            return 'instance000001'
        def UUIDString(self):
            return '19479fee-07a5-49bb-9138-d3738280d63c'
    mock_list.return_value = [DiagFakeDomain(None), DiagFakeDomain(5)]
    drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
    self.assertEqual(6, drvr._get_vcpu_used())
    mock_list.assert_called_with(only_guests=True, only_running=True)
