]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
tests/ceph-disk: Creating missing working dir
authorErwan Velu <erwan@redhat.com>
Tue, 23 Feb 2016 10:36:51 +0000 (11:36 +0100)
committerErwan Velu <erwan@redhat.com>
Wed, 24 Feb 2016 08:55:46 +0000 (09:55 +0100)
commitba05b7e700c67af172f3a7d79a1df5eccb01d515
tree46c11170e447f438a1b717626339921c53e94e70
parentdc5a9053ce69c0630091774f16ce421da67d26fb
tests/ceph-disk: Creating missing working dir

When running run-tox.sh in a very simple env,
the test will fail if '/var/lib/ceph/tmp' doesn't exist.

This patch adds a check to create this directory if required as mkdtemp doesn't do it for you.

Prior this patch, the following behavior was seen :

tests/test_main.py:342:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
ceph_disk/main.py:3753: in list_devices
    fstype=fs_type, options='')
ceph_disk/main.py:1217: in mount
    dir=STATEDIR + '/tmp',
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

suffix = '', prefix = 'mnt.', dir = '/var/lib/ceph/tmp'

    def mkdtemp(suffix="", prefix=template, dir=None):
        """User-callable function to create and return a unique temporary
        directory.  The return value is the pathname of the directory.

        Arguments are as for mkstemp, except that the 'text' argument is
        not accepted.

        The directory is readable, writable, and searchable only by the
        creating user.

        Caller is responsible for deleting the directory when done with it.
        """

        if dir is None:
            dir = gettempdir()

        names = _get_candidate_names()

        for seq in xrange(TMP_MAX):
            name = names.next()
            file = _os.path.join(dir, prefix + name + suffix)
            try:
>               _os.mkdir(file, 0700)
E               OSError: [Errno 2] No such file or directory: '/var/lib/ceph/tmp/mnt.KoAV85'

/usr/lib64/python2.7/tempfile.py:333: OSError

Signed-off-by: Erwan Velu <erwan@redhat.com>
src/ceph-disk/ceph_disk/main.py