# Path: virtman/drivers/connector.py
# class ISCSIExecutor(ISCSIConnector):
#     def __init__(self):
# def connect_volume(connection):
# def disconnect_volume(connection, device_info):
# 
# Path: virtman/drivers/dmsetup.py
# class DmExecutor(dmsetup.Dmsetup):
#     def __init__(self):
# def remove_table(name):
# def reload_table(name, table):
# def multipath(name, disks):
# def reload_multipath(name, disks):
# def origin(origin_name, origin_dev):
# def snapshot(origin_path, snapshot_name, snapshot_dev):


import time
from virtman.drivers import connector
from virtman.drivers import dmsetup
from virtman.openstack.common import log as logging
        # Rebuild multipath device
        disks = [paths[key].device_path for key in paths.keys()
                 if key not in paths_to_remove and paths[key].connected]

        if len(disks) > 0:
            if not multipath_path:
                multipath_path = Paths.create_multipath(multipath_name, disks)
            else:
                multipath_path = multipath_path
                Paths.reload_multipath(multipath_name, disks)
            # TODO:fix here, wait for multipath device ready
            time.sleep(2)

        # Disconnect paths to remove
        for key in paths_to_remove:
            if paths[key].connected:
                Path.disconnect(paths[key])
            del paths[key]
        LOG.debug("Virtman: now multipath is %s" % multipath_path)
        return multipath_path

    @staticmethod
    def create_multipath(multipath_name, disks):
        """
        :type multipath_name: str
        :type disks: list
        :rtype : str
        """
        LOG.debug("Virtman: create multipath according connection %s:" %
                  disks)

# Path: virtman/drivers/connector.py
# class ISCSIExecutor(ISCSIConnector):
#     def __init__(self):
# def connect_volume(connection):
# def disconnect_volume(connection, device_info):
# 
# Path: virtman/drivers/dmsetup.py
# class DmExecutor(dmsetup.Dmsetup):
#     def __init__(self):
# def remove_table(name):
# def reload_table(name, table):
# def multipath(name, disks):
# def reload_multipath(name, disks):
# def origin(origin_name, origin_dev):
# def snapshot(origin_path, snapshot_name, snapshot_dev):


# Path: virtman/path.py
import time
from virtman.drivers import connector
from virtman.drivers import dmsetup
from virtman.openstack.common import log as logging

        # Rebuild multipath device
        disks = [paths[key].device_path for key in paths.keys()
                 if key not in paths_to_remove and paths[key].connected]

        if len(disks) > 0:
            if not multipath_path:
                multipath_path = Paths.create_multipath(multipath_name, disks)
            else:
                multipath_path = multipath_path
                Paths.reload_multipath(multipath_name, disks)
            # TODO:fix here, wait for multipath device ready
            time.sleep(2)

        # Disconnect paths to remove
        for key in paths_to_remove:
            if paths[key].connected:
                Path.disconnect(paths[key])
            del paths[key]
        LOG.debug("Virtman: now multipath is %s" % multipath_path)
        return multipath_path

    @staticmethod
    def create_multipath(multipath_name, disks):
        """
        :type multipath_name: str
        :type disks: list
        :rtype : str
        """
        LOG.debug("Virtman: create multipath according connection %s:" %
                  disks)

        multipath_path = dmsetup.multipath(multipath_name, disks)