# Path: virtman/drivers/fcg.py
# CONF = cfg.CONF
# class FcgExecutor(FCG):
#     def __init__(self):
# def is_valid():
# def create_group():
# def add_disk(disk):
# def rm_disk(disk):
# 
# Path: virtman/drivers/volt.py
# CONF = cfg.CONF
# def singleton(cls):
#     def _singleton(*args, **kwargs):
#     def __init__(self):
# def login(session_name, peer_id, host, port, iqn, lun):
# def logout(session_name, peer_id):
# def get(session_name, host):
# def heartbeat():
# class VoltClient(client.Client):
# 
# Path: virtman/image.py
# LOG = logging.getLogger(__name__)
# class Image(object):
# class LocalImage(Image):
# class BlockDeviceImage(Image):
# class FakeImage(Image):
# class QCOW2Image(Image):
# class RAWImage(Image):
#     def __init__(self, image_name, image_connections, base_image):
#     def update_instance_status(self):
#     def create_snapshot(self, instance_name, snapshot):
#     def destroy_snapshot(self, instance_name):
#     def deploy_image(self):
#     def destroy_image(self):
#     def adjust_for_heartbeat(self, parents):
#     def __init__(self, image_name, image_connections,
#                  base_image=BlockDeviceBaseImage):
#     def create_snapshot(self, instance_name, snapshot_dev):
#     def destroy_snapshot(self, instance_name):
#     def deploy_image(self):
#     def destroy_image(self):
#     def adjust_for_heartbeat(self, parents):
#     def __init__(self, image_name, image_connections,
#                  base_image=BlockDeviceBaseImage):
#     def create_snapshot(self, instance_name, snapshot_connection):
#     def destroy_snapshot(self, instance_name):
#     def deploy_image(self):
#     def destroy_image(self):
#     def adjust_for_heartbeat(self, parents):
#     def __init__(self, image_name, image_connections,
#                  base_image=BlockDeviceBaseImage):
#     def create_snapshot(self, instance_name, snapshot):
#     def destroy_snapshot(self, instance_name):
#     def deploy_image(self):
#     def destroy_image(self):
#     def adjust_for_heartbeat(self, parents):
# 
# Path: virtman/utils/exception.py
# LOG = logging.getLogger(__name__)
# class VirtmanException(Exception):
# class CreateBaseImageFailed(VirtmanException):
# class CreateSnapshotFailed(VirtmanException):
# class TestException(VirtmanException):
#     def __init__(self, message=None, **kwargs):
#     def __unicode__(self):


import time
import os
import sys
import threading
import traceback
from oslo.config import cfg
from virtman.drivers import fcg
from virtman.drivers import volt
from virtman import image
from virtman.utils import exception
from virtman.openstack.common import log as logging
                     instance_name)
            return "1:" + "Virtman: the instance_name '%s' already exists!" % \
                   instance_name

        try:
            LOG.debug("Virtman: create VM image started, instance_name = %s, "
                      "image_name = %s" % (instance_name, image_name))
            self.instance_names[instance_name] = image_name

            # deploy base image
            if image_name not in self.images:
                LOG.debug("Virtman: now need to create image first!")
                image_cls = getattr(image, self.image_type)
                self.images[image_name] = image_cls(image_name,
                                                    image_connections)
                self.images[image_name].deploy_image()

            # create snapshot
            instance_path = None
            if self.images[image_name].origin_path:
                LOG.info("Virtman: middle!")
                instance_path = self.images[image_name].create_snapshot(
                    instance_name, snapshot)
                LOG.debug("Virtman: create VM completed, instance_name = %s, "
                          "image_name = %s, instance_path = %s" %
                          (instance_name, image_name, instance_path))
                # instance_path is like '/dev/mapper/snapshot_vm1'
        except Exception as ex:
            LOG.error("Virtman: create image failed, due to %s" % ex)
            LOG.error("Virtman: traceback is : %s" % traceback.print_exc())

# Path: virtman/drivers/fcg.py
# CONF = cfg.CONF
# class FcgExecutor(FCG):
#     def __init__(self):
# def is_valid():
# def create_group():
# def add_disk(disk):
# def rm_disk(disk):
# 
# Path: virtman/drivers/volt.py
# CONF = cfg.CONF
# def singleton(cls):
#     def _singleton(*args, **kwargs):
#     def __init__(self):
# def login(session_name, peer_id, host, port, iqn, lun):
# def logout(session_name, peer_id):
# def get(session_name, host):
# def heartbeat():
# class VoltClient(client.Client):
# 
# Path: virtman/image.py
# LOG = logging.getLogger(__name__)
# class Image(object):
# class LocalImage(Image):
# class BlockDeviceImage(Image):
# class FakeImage(Image):
# class QCOW2Image(Image):
# class RAWImage(Image):
#     def __init__(self, image_name, image_connections, base_image):
#     def update_instance_status(self):
#     def create_snapshot(self, instance_name, snapshot):
#     def destroy_snapshot(self, instance_name):
#     def deploy_image(self):
#     def destroy_image(self):
#     def adjust_for_heartbeat(self, parents):
#     def __init__(self, image_name, image_connections,
#                  base_image=BlockDeviceBaseImage):
#     def create_snapshot(self, instance_name, snapshot_dev):
#     def destroy_snapshot(self, instance_name):
#     def deploy_image(self):
#     def destroy_image(self):
#     def adjust_for_heartbeat(self, parents):
#     def __init__(self, image_name, image_connections,
#                  base_image=BlockDeviceBaseImage):
#     def create_snapshot(self, instance_name, snapshot_connection):
#     def destroy_snapshot(self, instance_name):
#     def deploy_image(self):
#     def destroy_image(self):
#     def adjust_for_heartbeat(self, parents):
#     def __init__(self, image_name, image_connections,
#                  base_image=BlockDeviceBaseImage):
#     def create_snapshot(self, instance_name, snapshot):
#     def destroy_snapshot(self, instance_name):
#     def deploy_image(self):
#     def destroy_image(self):
#     def adjust_for_heartbeat(self, parents):
# 
# Path: virtman/utils/exception.py
# LOG = logging.getLogger(__name__)
# class VirtmanException(Exception):
# class CreateBaseImageFailed(VirtmanException):
# class CreateSnapshotFailed(VirtmanException):
# class TestException(VirtmanException):
#     def __init__(self, message=None, **kwargs):
#     def __unicode__(self):


# Path: virtman/compute_new.py
import time
import os
import sys
import threading
import traceback
from oslo.config import cfg
from virtman.drivers import fcg
from virtman.drivers import volt
from virtman import image
from virtman.utils import exception
from virtman.openstack.common import log as logging

                     instance_name)
            return "1:" + "Virtman: the instance_name '%s' already exists!" % \
                   instance_name

        try:
            LOG.debug("Virtman: create VM image started, instance_name = %s, "
                      "image_name = %s" % (instance_name, image_name))
            self.instance_names[instance_name] = image_name

            # deploy base image
            if image_name not in self.images:
                LOG.debug("Virtman: now need to create image first!")
                image_cls = getattr(image, self.image_type)
                self.images[image_name] = image_cls(image_name,
                                                    image_connections)
                self.images[image_name].deploy_image()

            # create snapshot
            instance_path = None
            if self.images[image_name].origin_path:
                LOG.info("Virtman: middle!")
                instance_path = self.images[image_name].create_snapshot(
                    instance_name, snapshot)
                LOG.debug("Virtman: create VM completed, instance_name = %s, "
                          "image_name = %s, instance_path = %s" %
                          (instance_name, image_name, instance_path))
                # instance_path is like '/dev/mapper/snapshot_vm1'
        except Exception as ex:
            LOG.error("Virtman: create image failed, due to %s" % ex)
            LOG.error("Virtman: traceback is : %s" % traceback.print_exc())

            if isinstance(ex, exception.CreateBaseImageFailed):