def _get_memory_mb_used(self):
    'Get the used memory size(MB) of physical computer.\n\n        :returns: the total usage of memory(MB).\n\n        '
    if (sys.platform.upper() not in ['LINUX2', 'LINUX3']):
        return 0
    with open('/proc/meminfo') as fp:
        m = fp.read().split()
    idx1 = m.index('MemFree:')
    idx2 = m.index('Buffers:')
    idx3 = m.index('Cached:')
    if (CONF.libvirt.virt_type == 'xen'):
        used = 0
        for dom in self._list_instance_domains(only_guests=False):
            try:
                dom_mem = int(dom.info()[2])
            except libvirt.libvirtError as e:
                LOG.warn((_LW("couldn't obtain the memory from domain: %(uuid)s, exception: %(ex)s") % {'uuid': dom.UUIDString(), 'ex': e}))
                continue
            if (dom.ID() != 0):
                used += dom_mem
            else:
                used += (dom_mem - ((int(m[(idx1 + 1)]) + int(m[(idx2 + 1)])) + int(m[(idx3 + 1)])))
        return (used / units.Ki)
    else:
        avail = ((int(m[(idx1 + 1)]) + int(m[(idx2 + 1)])) + int(m[(idx3 + 1)]))
        return (self._get_memory_mb_total() - (avail / units.Ki))
Get the used memory size(MB) of physical computer.

:returns: the total usage of memory(MB).
def _get_memory_mb_used(self):
    'Get the used memory size(MB) of physical computer.\n\n        :returns: the total usage of memory(MB).\n\n        '
    if (sys.platform.upper() not in ['LINUX2', 'LINUX3']):
        return 0
    with open('/proc/meminfo') as fp:
        m = fp.read().split()
    idx1 = m.index('MemFree:')
    idx2 = m.index('Buffers:')
    idx3 = m.index('Cached:')
    if (CONF.libvirt.virt_type == 'xen'):
        used = 0
        for dom in self._list_instance_domains(only_guests=False):
            try:
                dom_mem = int(dom.info()[2])
            except libvirt.libvirtError as e:
                LOG.warn((_LW("couldn't obtain the memory from domain: %(uuid)s, exception: %(ex)s") % {'uuid': dom.UUIDString(), 'ex': e}))
                continue
            if (dom.ID() != 0):
                used += dom_mem
            else:
                used += (dom_mem - ((int(m[(idx1 + 1)]) + int(m[(idx2 + 1)])) + int(m[(idx3 + 1)])))
        return (used / units.Ki)
    else:
        avail = ((int(m[(idx1 + 1)]) + int(m[(idx2 + 1)])) + int(m[(idx3 + 1)]))
        return (self._get_memory_mb_total() - (avail / units.Ki))