How to use the freezer.utils.utils.create_dir function in freezer

To help you get started, we’ve selected a few freezer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openstack / freezer / tests / unit / storages / test_local.py View on Github external
def create_dirs(self):
        tmpdir = tempfile.mkdtemp()
        if self.temp:
            backup_dir = tempfile.mkdtemp(
                dir=tmpdir, prefix=self.BACKUP_DIR_PREFIX)
            files_dir = tempfile.mkdtemp(
                dir=tmpdir, prefix=self.FILES_DIR_PREFIX)
            work_dir = tempfile.mkdtemp(
                dir=tmpdir, prefix=self.WORK_DIR_PREFIX)
        else:
            backup_dir = tmpdir + self.BACKUP_DIR_PREFIX
            files_dir = tmpdir + self.FILES_DIR_PREFIX
            work_dir = tmpdir + self.WORK_DIR_PREFIX
            utils.create_dir(backup_dir)
            utils.create_dir(work_dir)
            utils.create_dir(files_dir)
        self.create_content(files_dir)
        return backup_dir, files_dir, work_dir
github openstack / freezer / tests / unit / utils / test_utils.py View on Github external
def test_create_dir(self):

        dir1 = '/tmp'
        dir2 = '/tmp/testnoexistent1234'
        dir3 = '~'
        assert utils.create_dir(dir1) is None
        assert utils.create_dir(dir2) is None
        os.rmdir(dir2)
        assert utils.create_dir(dir3) is None
github openstack / freezer / tests / unit / utils / test_utils.py View on Github external
def test_create_dir(self):

        dir1 = '/tmp'
        dir2 = '/tmp/testnoexistent1234'
        dir3 = '~'
        assert utils.create_dir(dir1) is None
        assert utils.create_dir(dir2) is None
        os.rmdir(dir2)
        assert utils.create_dir(dir3) is None
github openstack / freezer / tests / unit / utils / test_utils.py View on Github external
def test_create_dir(self):

        dir1 = '/tmp'
        dir2 = '/tmp/testnoexistent1234'
        dir3 = '~'
        assert utils.create_dir(dir1) is None
        assert utils.create_dir(dir2) is None
        os.rmdir(dir2)
        assert utils.create_dir(dir3) is None
github openstack / freezer / tests / unit / storages / test_local.py View on Github external
def create_dirs(self):
        tmpdir = tempfile.mkdtemp()
        if self.temp:
            backup_dir = tempfile.mkdtemp(
                dir=tmpdir, prefix=self.BACKUP_DIR_PREFIX)
            files_dir = tempfile.mkdtemp(
                dir=tmpdir, prefix=self.FILES_DIR_PREFIX)
            work_dir = tempfile.mkdtemp(
                dir=tmpdir, prefix=self.WORK_DIR_PREFIX)
        else:
            backup_dir = tmpdir + self.BACKUP_DIR_PREFIX
            files_dir = tmpdir + self.FILES_DIR_PREFIX
            work_dir = tmpdir + self.WORK_DIR_PREFIX
            utils.create_dir(backup_dir)
            utils.create_dir(work_dir)
            utils.create_dir(files_dir)
        self.create_content(files_dir)
        return backup_dir, files_dir, work_dir
github openstack / freezer / freezer / common / config.py View on Github external
def prepare_logging(log_file=None):
    """
    Creates log directory and log file if no log files provided
    :return:
    """
    if not log_file:
        log_file = os.path.join(home, '.freezer', 'freezer.log')
    expanded_file_name = os.path.expanduser(log_file)
    expanded_dir_name = os.path.dirname(expanded_file_name)
    utils.create_dir(expanded_dir_name, do_log=False)
    return expanded_file_name
github openstack / freezer / freezer / scheduler / win_daemon.py View on Github external
def configure_logging(file_name):
        expanded_file_name = os.path.expanduser(file_name)
        expanded_dir_name = os.path.dirname(expanded_file_name)
        utils.create_dir(expanded_dir_name, do_log=False)
        logging.basicConfig(
            filename=expanded_file_name,
            level=logging.INFO,
            format=('%(asctime)s %(name)s %(levelname)s %(message)s'))
        # filter out some annoying messages
        # not the best position for this code
        log_filter = NoLogFilter()
        logging.getLogger("apscheduler.scheduler").\
            addFilter(log_filter)
        logging.getLogger("apscheduler.executors.default").\
            addFilter(log_filter)
        logging.getLogger("requests.packages.urllib3.connectionpool").\
            addFilter(log_filter)
        return expanded_file_name
github openstack / freezer / freezer / snapshot / lvm.py View on Github external
if not backup_opt_dict.lvm_snapname:
        backup_opt_dict.lvm_snapname = \
            "{0}_{1}".format(freezer_config.DEFAULT_LVM_SNAP_BASENAME,
                             lvm_uuid)

    # adjust/check lvm parameters according to provided path_to_backup
    lvm_info = get_lvm_info(backup_opt_dict.path_to_backup)

    if not backup_opt_dict.lvm_volgroup:
        backup_opt_dict.lvm_volgroup = lvm_info['volgroup']

    if not backup_opt_dict.lvm_srcvol:
        backup_opt_dict.lvm_srcvol = lvm_info['srcvol']

    if not backup_opt_dict.lvm_dirmount:
        utils.create_dir(freezer_config.DEFAULT_LVM_MOUNT_BASEDIR)
        backup_opt_dict.lvm_dirmount = \
            "{0}/mount_{1}".format(freezer_config.DEFAULT_LVM_MOUNT_BASEDIR,
                                   lvm_uuid)

    backup_opt_dict.path_to_backup = os.path.join(backup_opt_dict.lvm_dirmount,
                                                  lvm_info['snap_path'])

    if not validate_lvm_params(backup_opt_dict):
        LOG.info('No LVM requested/configured')
        return False

    utils.create_dir(backup_opt_dict.lvm_dirmount)

    if '%' in backup_opt_dict.lvm_snapsize:
        lvm_size_option = "--extents"
    else: