Move the master socket in the ganeti run dir
[ganeti-local] / lib / backend.py
index 08e013f..382eec5 100644 (file)
@@ -139,6 +139,9 @@ def LeaveCluster():
   utils.RemoveFile(priv_key)
   utils.RemoveFile(pub_key)
 
+  # Return a reassuring string to the caller, and quit
+  raise errors.QuitGanetiException(False, 'Shutdown scheduled')
+
 
 def GetNodeInfo(vgname):
   """Gives back a hash with different informations about the node.
@@ -979,6 +982,7 @@ def UploadFile(file_name, data, mode, uid, gid, atime, mtime):
     constants.CLUSTER_CONF_FILE,
     constants.ETC_HOSTS,
     constants.SSH_KNOWN_HOSTS_FILE,
+    constants.VNC_PASSWORD_FILE,
     ]
   allowed_files.extend(ssconf.SimpleStore().GetFileList())
   if file_name not in allowed_files:
@@ -1477,7 +1481,7 @@ def _TransformFileStorageDir(file_storage_dir):
 
   Args:
     file_storage_dir: string with path
-  
+
   Returns:
     normalized file_storage_dir (string) if valid, None otherwise
 
@@ -1592,6 +1596,31 @@ def RenameFileStorageDir(old_file_storage_dir, new_file_storage_dir):
   return result
 
 
+def CloseBlockDevices(disks):
+  """Closes the given block devices.
+
+  This means they will be switched to secondary mode (in case of DRBD).
+
+  """
+  bdevs = []
+  for cf in disks:
+    rd = _RecursiveFindBD(cf)
+    if rd is None:
+      return (False, "Can't find device %s" % cf)
+    bdevs.append(rd)
+
+  msg = []
+  for rd in bdevs:
+    try:
+      rd.Close()
+    except errors.BlockDeviceError, err:
+      msg.append(str(err))
+  if msg:
+    return (False, "Can't make devices secondary: %s" % ",".join(msg))
+  else:
+    return (True, "All devices secondary")
+
+
 class HooksRunner(object):
   """Hook runner.