# Path: tests/base.py
# LOG = oslo_logging.getLogger(__name__)
# class TestCase(base.BaseTestCase):
#     def setUp(self):
#     def _common_cleanup(self):
#     def log_level(self, level):
#     def mock_object(self, obj, attr_name, new_attr=None, **kwargs):
#     def assertDictMatch(self, d1, d2, approx_equal=False, tolerance=0.001):
#         def raise_assertion(msg):
# 
# Path: virtman/snapshot.py
# CONF = cfg.CONF
# LOG = logging.getLogger(__name__)
# class Snapshot(object):
# class LocalSnapshot(Snapshot):
# class BlockDeviceSnapshot(Snapshot):
#     def __init__(self):
#     def create(self):
#     def destroy(self):
#     def _create_cache(snapshot_dev):
#     def _delete_cache(snapshot_dev):
#     def __init__(self, origin_path, instance_name, snapshot_dev=None):
#     def create(self):
#     def _create_snap_dev(self):
#     def destroy(self):
#     def _destroy_snap_dev(self):
#     def __init__(self, origin_path, instance_name, snapshot_connection):
#     def create(self):
#     def _create_snap_dev(self):
#     def destroy(self):
#     def _destroy_snap_dev(self):
# 
# Path: virtman/blockservice.py
# LOG = logging.getLogger(__name__)
# def findloop():
# def try_linkloop(loop_dev):
# def is_looped(loop_dev):
# def linkloop(loop_dev, path):
# def unlinkloop(loop_dev):
# 
# 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/openstack/common/processutils.py
# LOG = logging.getLogger(__name__)
#             _PIPE = subprocess.PIPE  # pylint: disable=E1101
# class InvalidArgumentError(Exception):
# class UnknownArgumentError(Exception):
# class ProcessExecutionError(Exception):
# class NoRootWrapSpecified(Exception):
#     def __init__(self, message=None):
#     def __init__(self, message=None):
#     def __init__(self, stdout=None, stderr=None, exit_code=None, cmd=None,
#                  description=None):
#     def __init__(self, message=None):
# def _subprocess_setup():
# def execute(*cmd, **kwargs):
# def trycmd(*args, **kwargs):
# def ssh_execute(ssh, cmd, process_input=None,
#                 addl_env=None, check_exit_code=True):


import mock
import os
import string
import logging
from tests import base
from virtman import snapshot
from virtman import blockservice
from virtman.drivers import connector
from virtman.drivers import dmsetup
from virtman.openstack.common import processutils as putils

device_info = {'path': '/dev/disk/by-path/ip-10.0.0.1:3260-iscsi-iqn.2010-10'
                       '.org.openstack:volume-snapshot1',
               'type': 'block'}


class TestSnapshot(base.TestCase):
    def setUp(self):
        super(TestSnapshot, self).setUp()
        self.snapshot = snapshot.Snapshot()

    def test_create(self):
        self.assertRaises(NotImplementedError, self.snapshot.create)

    def test_destroy(self):
        self.assertRaises(NotImplementedError, self.snapshot.destroy)


class TestLocalSnapshot(base.TestCase):
    def setUp(self):
        super(TestLocalSnapshot, self).setUp()
        self.instance = snapshot.LocalSnapshot(origin_path='/dev/mapper/origin',
                                               instance_name='vm_test',
                                               snapshot_dev='/blocks/snapshot')
        snapshot.LOG.logger.setLevel(logging.DEBUG)

    def test_create(self):
        self.mock_object(blockservice, 'findloop',
                         mock.Mock(return_value='/dev/loop1'))
        self.mock_object(blockservice, 'try_linkloop', mock.Mock())

# Path: tests/base.py
# LOG = oslo_logging.getLogger(__name__)
# class TestCase(base.BaseTestCase):
#     def setUp(self):
#     def _common_cleanup(self):
#     def log_level(self, level):
#     def mock_object(self, obj, attr_name, new_attr=None, **kwargs):
#     def assertDictMatch(self, d1, d2, approx_equal=False, tolerance=0.001):
#         def raise_assertion(msg):
# 
# Path: virtman/snapshot.py
# CONF = cfg.CONF
# LOG = logging.getLogger(__name__)
# class Snapshot(object):
# class LocalSnapshot(Snapshot):
# class BlockDeviceSnapshot(Snapshot):
#     def __init__(self):
#     def create(self):
#     def destroy(self):
#     def _create_cache(snapshot_dev):
#     def _delete_cache(snapshot_dev):
#     def __init__(self, origin_path, instance_name, snapshot_dev=None):
#     def create(self):
#     def _create_snap_dev(self):
#     def destroy(self):
#     def _destroy_snap_dev(self):
#     def __init__(self, origin_path, instance_name, snapshot_connection):
#     def create(self):
#     def _create_snap_dev(self):
#     def destroy(self):
#     def _destroy_snap_dev(self):
# 
# Path: virtman/blockservice.py
# LOG = logging.getLogger(__name__)
# def findloop():
# def try_linkloop(loop_dev):
# def is_looped(loop_dev):
# def linkloop(loop_dev, path):
# def unlinkloop(loop_dev):
# 
# 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/openstack/common/processutils.py
# LOG = logging.getLogger(__name__)
#             _PIPE = subprocess.PIPE  # pylint: disable=E1101
# class InvalidArgumentError(Exception):
# class UnknownArgumentError(Exception):
# class ProcessExecutionError(Exception):
# class NoRootWrapSpecified(Exception):
#     def __init__(self, message=None):
#     def __init__(self, message=None):
#     def __init__(self, stdout=None, stderr=None, exit_code=None, cmd=None,
#                  description=None):
#     def __init__(self, message=None):
# def _subprocess_setup():
# def execute(*cmd, **kwargs):
# def trycmd(*args, **kwargs):
# def ssh_execute(ssh, cmd, process_input=None,
#                 addl_env=None, check_exit_code=True):


# Path: tests/test_snapshot.py
import mock
import os
import string
import logging
from tests import base
from virtman import snapshot
from virtman import blockservice
from virtman.drivers import connector
from virtman.drivers import dmsetup
from virtman.openstack.common import processutils as putils


device_info = {'path': '/dev/disk/by-path/ip-10.0.0.1:3260-iscsi-iqn.2010-10'
                       '.org.openstack:volume-snapshot1',
               'type': 'block'}


class TestSnapshot(base.TestCase):
    def setUp(self):
        super(TestSnapshot, self).setUp()
        self.snapshot = snapshot.Snapshot()

    def test_create(self):
        self.assertRaises(NotImplementedError, self.snapshot.create)

    def test_destroy(self):
        self.assertRaises(NotImplementedError, self.snapshot.destroy)


class TestLocalSnapshot(base.TestCase):
    def setUp(self):
        super(TestLocalSnapshot, self).setUp()
        self.instance = snapshot.LocalSnapshot(origin_path='/dev/mapper/origin',
                                               instance_name='vm_test',
                                               snapshot_dev='/blocks/snapshot')
        snapshot.LOG.logger.setLevel(logging.DEBUG)

    def test_create(self):
        self.mock_object(blockservice, 'findloop',
                         mock.Mock(return_value='/dev/loop1'))
        self.mock_object(blockservice, 'try_linkloop', mock.Mock())

        self.mock_object(dmsetup, 'snapshot',