Exemple #1
0
    def open_container(container_id):
        global HaveAtomicException
        if HaveAtomicException:
            logger.debug("atomic is either not installed or not accessable %s" % HaveAtomicException)
            HaveAtomicException = None

        if use_atomic_mount():
            mount_point = tempfile.mkdtemp()
            logger.debug("Opening Container Id %s On %s using atomic" % (container_id, mount_point))
            if runcommand(shlex.split("atomic mount") + [container_id, mount_point]) == 0:
                return AtomicTemporaryMountPoint(container_id, mount_point)
            else:
                logger.error('Could not mount Container Id %s On %s' % (container_id, mount_point))
                shutil.rmtree(mount_point, ignore_errors=True)
                return None

        else:
            driver = _docker_driver()
            if driver is None:
                return None

            mount_point = tempfile.mkdtemp()
            logger.debug("Opening Container Id %s On %s using docker client" % (container_id, mount_point))
            # docker mount creates a temp image
            # we have to use this temp image id to remove the device
            mount_point, cid = DockerMount(mount_point).mount(container_id)
            if driver == 'devicemapper':
                DockerMount.mount_path(os.path.join(mount_point, "rootfs"), mount_point, bind=True)
            if cid:
                return DockerTemporaryMountPoint(driver, container_id, mount_point, cid)
            else:
                logger.error('Could not mount Container Id %s On %s' % (container_id, mount_point))
                shutil.rmtree(mount_point, ignore_errors=True)
                return None
Exemple #2
0
    def open_image(image_id):
        global HaveAtomicException
        if HaveAtomicException and UseAtomic:
            logger.debug("atomic is either not installed or not accessable %s" %
                         HaveAtomicException)
            HaveAtomicException = None

        if use_atomic_mount():
            mount_point = tempfile.mkdtemp()
            logger.debug("Opening Image Id %s On %s using atomic" % (image_id, mount_point))
            if runcommand(shlex.split("atomic mount") + [image_id, mount_point]) == 0:
                return AtomicTemporaryMountPoint(image_id, mount_point)
            else:
                logger.error('Could not mount Image Id %s On %s' % (image_id, mount_point))
                shutil.rmtree(mount_point, ignore_errors=True)
                return None

        else:
            driver = _docker_driver()
            if driver is None:
                return None

            mount_point = tempfile.mkdtemp()
            logger.debug("Opening Image Id %s On %s using docker client" % (image_id, mount_point))
            # docker mount creates a temp image
            # we have to use this temp image id to remove the device
            mount_point, cid = DockerMount(mount_point).mount(image_id)
            if driver == 'devicemapper':
                DockerMount.mount_path(os.path.join(mount_point, "rootfs"), mount_point, bind=True)
            if cid:
                return DockerTemporaryMountPoint(driver, image_id, mount_point, cid)
            else:
                logger.error('Could not mount Image Id %s On %s' % (image_id, mount_point))
                shutil.rmtree(mount_point, ignore_errors=True)
                return None
Exemple #3
0
def mount_obj(path, obj, driver):
    """ mounts the obj to the given path """

    DockerMount(path).mount(obj)

    # only need to bind-mount on the devicemapper driver
    if driver == 'devicemapper':
        DockerMount.mount_path(os.path.join(path, "rootfs"), path, bind=True)
Exemple #4
0
def mount_obj(path, obj, driver):
    """ mounts the obj to the given path """

    DockerMount(path).mount(obj)

    # only need to bind-mount on the devicemapper driver
    if driver == 'devicemapper':
        DockerMount.mount_path(os.path.join(path, "rootfs"), path, bind=True)
Exemple #5
0
def mount_obj(path, obj, driver):
    """ mounts the obj to the given path """

    # docker mount creates a temp image
    # we have to use this temp image id to remove the device 
    path, new_cid = DockerMount(path).mount(obj)
    if driver == 'devicemapper':
        DockerMount.mount_path(os.path.join(path, "rootfs"), path, bind=True)

    return new_cid