# 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

iscsi_disk_format = "ip-%s-iscsi-%s-lun-%s"


class Path(object):

    def __init__(self, connection):
        self.connection = connection
        self.connected = False
        self.device_info = None
        self.device_path = ''

    def __str__(self):
        return self.connection_to_str(self.connection)

    @staticmethod
    def connection_to_str(connection):
        """
        :type connection: dict
        """
        return iscsi_disk_format % (connection['target_portal'],
                                    connection['target_iqn'],
                                    connection['target_lun'])

    @staticmethod
    def connect(path):
        """
        :type path: Path
        """
        LOG.debug("Virtman: connect to path: %s", str(path))

# 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


iscsi_disk_format = "ip-%s-iscsi-%s-lun-%s"


class Path(object):

    def __init__(self, connection):
        self.connection = connection
        self.connected = False
        self.device_info = None
        self.device_path = ''

    def __str__(self):
        return self.connection_to_str(self.connection)

    @staticmethod
    def connection_to_str(connection):
        """
        :type connection: dict
        """
        return iscsi_disk_format % (connection['target_portal'],
                                    connection['target_iqn'],
                                    connection['target_lun'])

    @staticmethod
    def connect(path):
        """
        :type path: Path
        """
        LOG.debug("Virtman: connect to path: %s", str(path))

        path.device_info = connector.connect_volume(path.connection)