Make gnt-cluster upgrade honor backup-dir
authorKlaus Aehlig <aehlig@google.com>
Thu, 10 Jul 2014 08:41:39 +0000 (10:41 +0200)
committerKlaus Aehlig <aehlig@google.com>
Thu, 10 Jul 2014 13:29:56 +0000 (15:29 +0200)
Make gnt-cluster upgrade honor the --with-backup-dir configure option.
In this way, at configure time, it can be decided in which directory
the configuration backup tar balls are put.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Hrvoje Ribicic <riba@google.com>

Makefile.am
lib/client/gnt_cluster.py
lib/pathutils.py
src/AutoConf.hs.in
src/Ganeti/Constants.hs

index 63e2727..eef4fd2 100644 (file)
@@ -1790,6 +1790,7 @@ src/AutoConf.hs: Makefile src/AutoConf.hs.in $(PRINT_PY_CONSTANTS) \
            -DSSH_LOGIN_USER="$(SSH_LOGIN_USER)" \
            -DSSH_CONSOLE_USER="$(SSH_CONSOLE_USER)" \
            -DEXPORT_DIR="$(EXPORT_DIR)" \
+           -DBACKUP_DIR="$(backup_dir)" \
            -DOS_SEARCH_PATH="\"$(OS_SEARCH_PATH)\"" \
            -DES_SEARCH_PATH="\"$(ES_SEARCH_PATH)\"" \
            -DXEN_BOOTLOADER="$(XEN_BOOTLOADER)" \
index 4d328d8..edf65ba 100644 (file)
@@ -1855,9 +1855,10 @@ def _UpgradeBeforeConfigurationChange(versionstring):
     ToStderr("Failed to stop daemons on %s." % (", ".join(badnodes),))
     return (False, rollback)
 
-  backuptar = os.path.join(pathutils.LOCALSTATEDIR,
-                           "lib/ganeti%d.tar" % time.time())
+  backuptar = os.path.join(pathutils.BACKUP_DIR, "ganeti%d.tar" % time.time())
   ToStdout("Backing up configuration as %s" % backuptar)
+  if not _RunCommandAndReport(["mkdir", "-p", pathutils.BACKUP_DIR]):
+    return (False, rollback)
   if not _RunCommandAndReport(["tar", "cf", backuptar,
                                pathutils.DATA_DIR]):
     return (False, rollback)
index f075e22..5a21562 100644 (file)
@@ -35,6 +35,7 @@ DEFAULT_SHARED_FILE_STORAGE_DIR = "/srv/ganeti/shared-file-storage"
 DEFAULT_SHARED_FILE_STORAGE_DIR = \
     vcluster.AddNodePrefix(DEFAULT_SHARED_FILE_STORAGE_DIR)
 EXPORT_DIR = vcluster.AddNodePrefix(_constants.EXPORT_DIR)
+BACKUP_DIR = vcluster.AddNodePrefix(_constants.BACKUP_DIR)
 OS_SEARCH_PATH = _constants.OS_SEARCH_PATH
 ES_SEARCH_PATH = _constants.ES_SEARCH_PATH
 SSH_CONFIG_DIR = _constants.SSH_CONFIG_DIR
index 6454300..864ca91 100644 (file)
@@ -73,6 +73,9 @@ sshConsoleUser = "SSH_CONSOLE_USER"
 exportDir :: String
 exportDir = "EXPORT_DIR"
 
+backupDir :: String
+backupDir = "BACKUP_DIR"
+
 osSearchPath :: [String]
 osSearchPath = split OS_SEARCH_PATH
 
index b8b5b30..23e1a2f 100644 (file)
@@ -88,6 +88,9 @@ hasGnuLn = AutoConf.hasGnuLn
 exportDir :: String
 exportDir = AutoConf.exportDir
 
+backupDir :: String
+backupDir = AutoConf.backupDir
+
 osSearchPath :: [String]
 osSearchPath = AutoConf.osSearchPath