'Get available vcpu number of physical computer.
:returns: the number of cpu core instances can be used.'

def _get_vcpu_total(self):

    try:
        total_pcpus = self._host.get_cpu_count()
    except libvirt.libvirtError:
        LOG.warning('Cannot    get    the    number    of    cpu,    because    this    function    is    not    implemented    for    this    platform.    ')
        return 0
    if (not CONF.vcpu_pin_set):
        return total_pcpus
    available_ids = hardware.get_vcpu_pin_set()
    online_pcpus = None
    try:
        online_pcpus = self._host.get_online_cpus()
    except libvirt.libvirtError as ex:
        error_code = ex.get_error_code()
        LOG.warning("Couldn't    retrieve    the    online    CPUs    due    to    a    Libvirt    error:    %(error)s    with    error    code:    %(error_code)s", {'error': ex, 'error_code': error_code})
    if online_pcpus:
        if (not (available_ids <= online_pcpus)):
            msg = (_('Invalid    vcpu_pin_set    config,    one    or    more    of    the    specified    cpuset    is    not    online.    Online    cpuset(s):    %(online)s,    requested    cpuset(s):    %(req)s'), {'online': sorted(online_pcpus), 'req': sorted(available_ids)})
            raise exception.Invalid(msg)
    elif (sorted(available_ids)[(-1)] >= total_pcpus):
        raise exception.Invalid(_('Invalid    vcpu_pin_set    config,    out    of    hypervisor    cpu    range.'))
    return len(available_ids)
