From eef70d500bf8217732ba97688b6c64ad513cd197 Mon Sep 17 00:00:00 2001 From: Tim Buckley Date: Tue, 28 Jun 2016 16:13:47 -0600 Subject: [PATCH] Require a backup name for backup/restore/admin Currently, it's possible to leave out the '--backup-name' parameter without raising an error. Due to the configured default value, this can result in creating or searching for backups that have names ending with a literal '_False'. This patch sets the default value to None (to avoid converting the False to a string) and adds a validation step to require '--backup-name' to be set for all backup, restore, and admin actions. Change-Id: Iebf8355b8b2f44546990c0f4b1847d4c4f82ccca Closes-Bug: #1594952 --- freezer/job.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/freezer/job.py b/freezer/job.py index 8e59d3ef..4a2bcfe6 100644 --- a/freezer/job.py +++ b/freezer/job.py @@ -65,10 +65,14 @@ class Job(object): Apply general validation rules. :return: True or raise an error """ + LOG.info("Validating args for the {0} job.".format(self.conf.action)) if not self.conf.action: raise ValueError("Please provide a valid action with --action") - LOG.info("Validating args for the {0} job.".format(self.conf.action)) + if self.conf.action in ('backup', 'restore', 'admin') \ + and self.conf.backup_media == 'fs' \ + and not self.conf.backup_name: + raise ValueError('A value for --backup-name is required') @abc.abstractmethod def execute(self):