'Initialise a _HostMountState by inspecting the current compute
host for mountpoints and the attachments in use on them.
:param host: A connected libvirt Host object
:param generation: An integer indicating the generation of this
_HostMountState object. This is 0 for the first
_HostMountState created, and incremented for each
created subsequently. It is used in log messages to
aid debugging.'

def __init__(self, host, generation):

    self.generation = generation
    self.mountpoints = collections.defaultdict(self._MountPoint)
    for guest in host.list_guests(only_running=False):
        for disk in guest.get_all_disks():
            if (disk.source_type != 'file'):
                continue
            mountpoint = os.path.dirname(disk.source_path)
            if (not os.path.ismount(mountpoint)):
                continue
            name = os.path.basename(disk.source_path)
            mount = self.mountpoints[mountpoint]
            mount.add_attachment(name, guest.uuid)
            LOG.debug('Discovered    volume    %(vol)s    in    use    for    existing    mountpoint    %(mountpoint)s', {'vol': name, 'mountpoint': mountpoint})
