# Path: igor/log.py
# def configure(fn):
# def backlog():
# def getLogger(name):
# 
# Path: igor/utils.py
# def run(cmd, with_retval=False):
#     import subprocess
#     logger.debug("Running: %s" % cmd)
#     child = subprocess.Popen(cmd, shell=True,
#                              stdout=subprocess.PIPE,
#                              stderr=subprocess.PIPE)
#     (stdout, stderr) = child.communicate()
#     # pylint: disable-msg=E1101
#     child.wait()
#     if stderr:
#         logger.warning(stderr)
#     r = str(stdout).strip()
#     if with_retval:
#         r = (child.returncode, str(stdout).strip())
#     # pylint: enable-msg=E1101
#     return r


from igor import log
from igor.utils import run
import os
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Author: Fabian Deutsch <fabiand@fedoraproject.org>
#
# -*- coding: utf-8 -*-



logger = log.getLogger(__name__)


class PhysicalVolume(object):
    image = None
    uuid = None

    def __init__(self, image):
        self.image = image

    def create(self):
        if not os.path.exists(self.image):
            raise Exception("Backing image does not exist: %s" % self.image)
        with self.losetup() as losetup:
            dev = losetup.device

# Path: igor/log.py
# def configure(fn):
# def backlog():
# def getLogger(name):
# 
# Path: igor/utils.py
# def run(cmd, with_retval=False):
#     import subprocess
#     logger.debug("Running: %s" % cmd)
#     child = subprocess.Popen(cmd, shell=True,
#                              stdout=subprocess.PIPE,
#                              stderr=subprocess.PIPE)
#     (stdout, stderr) = child.communicate()
#     # pylint: disable-msg=E1101
#     child.wait()
#     if stderr:
#         logger.warning(stderr)
#     r = str(stdout).strip()
#     if with_retval:
#         r = (child.returncode, str(stdout).strip())
#     # pylint: enable-msg=E1101
#     return r


# Path: igor/daemon/lvm.py
from igor import log
from igor.utils import run
import os

#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Author: Fabian Deutsch <fabiand@fedoraproject.org>
#
# -*- coding: utf-8 -*-



logger = log.getLogger(__name__)


class PhysicalVolume(object):
    image = None
    uuid = None

    def __init__(self, image):
        self.image = image

    def create(self):
        if not os.path.exists(self.image):
            raise Exception("Backing image does not exist: %s" % self.image)
        with self.losetup() as losetup:
            dev = losetup.device

            run("pvcreate -ff -y -v '%s'" % dev)