lvm snapshot unique name
The freezer-agent generates unique names for lvm snapshots and relative mount point, unless provided with a specific value by the user. The behavior is basically the same, the only change is to the default values of the following parameters which now use a uuid-generated string: --lvm-dirmount --lvm-snapname Implements blueprint lvm-unique-names Change-Id: I52c3557b64515e3139cc5e453ae1309c84c9b36e
This commit is contained in:
parent
0ca9b075d0
commit
9b2db858da
@ -33,9 +33,9 @@ LOG = log.getLogger(__name__)
|
||||
|
||||
home = os.path.expanduser("~")
|
||||
|
||||
DEFAULT_LVM_SNAPNAME = 'freezer_backup_snap'
|
||||
DEFAULT_LVM_SNAPSIZE = '1G'
|
||||
DEFAULT_LVM_DIRMOUNT = '/var/lib/freezer'
|
||||
DEFAULT_LVM_MOUNT_BASENAME = '/var/lib/freezer'
|
||||
DEFAULT_LVM_SNAP_BASENAME = 'freezer_backup_snap'
|
||||
DEFAULT_SSH_PORT = 22
|
||||
|
||||
DEFAULT_PARAMS = {
|
||||
@ -46,10 +46,10 @@ DEFAULT_PARAMS = {
|
||||
'container': 'freezer_backups', 'no_incremental': False,
|
||||
'max_segment_size': 33554432, 'lvm_srcvol': False,
|
||||
'download_limit': -1, 'hostname': False, 'remove_from_date': False,
|
||||
'restart_always_level': False, 'lvm_dirmount': DEFAULT_LVM_DIRMOUNT,
|
||||
'restart_always_level': False, 'lvm_dirmount': None,
|
||||
'dereference_symlink': '',
|
||||
'config': False, 'mysql_conf': False,
|
||||
'insecure': False, 'lvm_snapname': DEFAULT_LVM_SNAPNAME,
|
||||
'insecure': False, 'lvm_snapname': None,
|
||||
'lvm_snapperm': 'ro', 'snapshot': False,
|
||||
'max_priority': False, 'max_level': False, 'path_to_backup': False,
|
||||
'encrypt_pass_file': False, 'volume': False, 'proxy': False,
|
||||
@ -116,9 +116,8 @@ _COMMON = [
|
||||
"Default no volume"),
|
||||
cfg.StrOpt('lvm-snapname',
|
||||
dest='lvm_snapname',
|
||||
help="Set the lvm snapshot name to use. If the snapshot name "
|
||||
"already exists, the old one will be used a no new one will"
|
||||
" be created. Default {0}.".format(DEFAULT_LVM_SNAPNAME)),
|
||||
help="Set the name of the snapshot that will be created."
|
||||
" If not provided, a unique name will be generated."),
|
||||
cfg.StrOpt('lvm-snap-perm',
|
||||
choices=['ro', 'rw'],
|
||||
dest='lvm_snapperm',
|
||||
@ -133,7 +132,8 @@ _COMMON = [
|
||||
cfg.StrOpt('lvm-dirmount',
|
||||
dest='lvm_dirmount',
|
||||
help="Set the directory you want to mount the lvm snapshot to. "
|
||||
"Default to {0}".format(DEFAULT_LVM_DIRMOUNT)),
|
||||
"If not provided, a unique name will be generated with the"
|
||||
"basename {0} ".format(DEFAULT_LVM_MOUNT_BASENAME)),
|
||||
cfg.StrOpt('lvm-volgroup',
|
||||
dest='lvm_volgroup',
|
||||
help="Specify the volume group of your logical volume. This is "
|
||||
|
@ -20,7 +20,9 @@ import logging
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import uuid
|
||||
|
||||
from freezer.common import config as freezer_config
|
||||
from freezer import utils
|
||||
|
||||
|
||||
@ -34,7 +36,10 @@ def lvm_snap_remove(backup_opt_dict):
|
||||
:return: None, raises on error
|
||||
"""
|
||||
os.chdir(backup_opt_dict.work_dir)
|
||||
_umount(backup_opt_dict.lvm_dirmount)
|
||||
try:
|
||||
_umount(backup_opt_dict.lvm_dirmount)
|
||||
except Exception as e:
|
||||
logging.warning("Snapshot unmount errror: {0}".format(e))
|
||||
lv = os.path.join('/dev',
|
||||
backup_opt_dict.lvm_volgroup,
|
||||
backup_opt_dict.lvm_snapname)
|
||||
@ -72,6 +77,11 @@ def lvm_snap(backup_opt_dict):
|
||||
backup_opt_dict.path_to_backup
|
||||
backup_opt_dict.path_to_backup = ''
|
||||
|
||||
if not backup_opt_dict.lvm_snapname:
|
||||
backup_opt_dict.lvm_snapname = \
|
||||
"{0}_{1}".format(freezer_config.DEFAULT_LVM_SNAP_BASENAME,
|
||||
uuid.uuid4().hex)
|
||||
|
||||
if backup_opt_dict.lvm_auto_snap:
|
||||
# adjust/check lvm parameters according to provided lvm_auto_snap
|
||||
lvm_info = get_lvm_info(backup_opt_dict.lvm_auto_snap)
|
||||
@ -82,6 +92,11 @@ def lvm_snap(backup_opt_dict):
|
||||
if not backup_opt_dict.lvm_srcvol:
|
||||
backup_opt_dict.lvm_srcvol = lvm_info['srcvol']
|
||||
|
||||
if not backup_opt_dict.lvm_dirmount:
|
||||
backup_opt_dict.lvm_dirmount = \
|
||||
"{0}_{1}".format(freezer_config.DEFAULT_LVM_MOUNT_BASENAME,
|
||||
uuid.uuid4().hex)
|
||||
|
||||
path_to_backup = os.path.join(backup_opt_dict.lvm_dirmount,
|
||||
lvm_info['snap_path'])
|
||||
if backup_opt_dict.path_to_backup:
|
||||
|
Loading…
x
Reference in New Issue
Block a user