Commit d3e6fd0e authored by Santi Raffa's avatar Santi Raffa Committed by Thomas Thrainer

ssconf: Add Gluster mount directory

This commit adds the gluster storage directory to ssconf (without
actually using its value just yet).
Signed-off-by: default avatarSanti Raffa <rsanti@google.com>
Signed-off-by: default avatarThomas Thrainer <thomasth@google.com>
Reviewed-by: default avatarThomas Thrainer <thomasth@google.com>
parent 58793040
......@@ -444,6 +444,20 @@ def _PrepareSharedFileStorage(
init_fn=init_fn, acceptance_fn=acceptance_fn)
def _PrepareGlusterStorage(
enabled_disk_templates, file_storage_dir, init_fn=_InitFileStorageDir,
acceptance_fn=None):
"""Checks if gluster storage is enabled and inits the dir.
@see: C{_PrepareFileBasedStorage}
"""
return _PrepareFileBasedStorage(
enabled_disk_templates, file_storage_dir,
pathutils.DEFAULT_GLUSTER_STORAGE_DIR, constants.DT_GLUSTER,
init_fn=init_fn, acceptance_fn=acceptance_fn)
def _InitCheckEnabledDiskTemplates(enabled_disk_templates):
"""Checks the sanity of the enabled disk templates.
......@@ -507,7 +521,8 @@ def _InitCheckDrbdHelper(drbd_helper, drbd_enabled):
def InitCluster(cluster_name, mac_prefix, # pylint: disable=R0913, R0914
master_netmask, master_netdev, file_storage_dir,
shared_file_storage_dir, candidate_pool_size, secondary_ip=None,
shared_file_storage_dir, gluster_storage_dir,
candidate_pool_size, secondary_ip=None,
vg_name=None, beparams=None, nicparams=None, ndparams=None,
hvparams=None, diskparams=None, enabled_hypervisors=None,
modify_etc_hosts=True, modify_ssh_setup=True,
......@@ -748,6 +763,7 @@ def InitCluster(cluster_name, mac_prefix, # pylint: disable=R0913, R0914
cluster_name=clustername.name,
file_storage_dir=file_storage_dir,
shared_file_storage_dir=shared_file_storage_dir,
gluster_storage_dir=gluster_storage_dir,
enabled_hypervisors=enabled_hypervisors,
beparams={constants.PP_DEFAULT: beparams},
nicparams={constants.PP_DEFAULT: nicparams},
......
......@@ -95,6 +95,7 @@ __all__ = [
"GATEWAY6_OPT",
"GLOBAL_FILEDIR_OPT",
"HID_OS_OPT",
"GLOBAL_GLUSTER_FILEDIR_OPT",
"GLOBAL_SHARED_FILEDIR_OPT",
"HOTPLUG_OPT",
"HVLIST_OPT",
......@@ -1318,6 +1319,15 @@ GLOBAL_SHARED_FILEDIR_OPT = cli_option(
pathutils.DEFAULT_SHARED_FILE_STORAGE_DIR,
metavar="SHAREDDIR", default=None)
GLOBAL_GLUSTER_FILEDIR_OPT = cli_option(
"--gluster-storage-dir",
dest="gluster_storage_dir",
help="Specify the default directory (cluster-wide) for mounting Gluster"
" file systems [%s]" %
pathutils.DEFAULT_GLUSTER_STORAGE_DIR,
metavar="GLUSTERDIR",
default=pathutils.DEFAULT_GLUSTER_STORAGE_DIR)
NOMODIFY_ETCHOSTS_OPT = cli_option("--no-etc-hosts", dest="modify_etc_hosts",
help="Don't modify %s" % pathutils.ETC_HOSTS,
action="store_false", default=True)
......
......@@ -273,6 +273,7 @@ def InitCluster(opts, args):
master_netdev=master_netdev,
file_storage_dir=opts.file_storage_dir,
shared_file_storage_dir=opts.shared_file_storage_dir,
gluster_storage_dir=opts.gluster_storage_dir,
enabled_hypervisors=hvlist,
hvparams=hvparams,
beparams=beparams,
......@@ -523,6 +524,7 @@ def ShowClusterConfig(opts, args):
("drbd usermode helper", result["drbd_usermode_helper"]),
("file storage path", result["file_storage_dir"]),
("shared file storage path", result["shared_file_storage_dir"]),
("gluster storage path", result["gluster_storage_dir"]),
("maintenance of node health", result["maintain_node_health"]),
("uid pool", uidpool.FormatUidPool(result["uid_pool"])),
("default instance allocator", result["default_iallocator"]),
......@@ -2042,7 +2044,7 @@ commands = {
PRIMARY_IP_VERSION_OPT, PREALLOC_WIPE_DISKS_OPT, NODE_PARAMS_OPT,
GLOBAL_SHARED_FILEDIR_OPT, USE_EXTERNAL_MIP_SCRIPT, DISK_PARAMS_OPT,
HV_STATE_OPT, DISK_STATE_OPT, ENABLED_DISK_TEMPLATES_OPT,
IPOLICY_STD_SPECS_OPT]
IPOLICY_STD_SPECS_OPT, GLOBAL_GLUSTER_FILEDIR_OPT]
+ INSTANCE_POLICY_OPTS + SPLIT_ISPECS_OPTS,
"[opts...] <cluster_name>", "Initialises a new cluster configuration"),
"destroy": (
......
......@@ -1168,6 +1168,13 @@ class ConfigWriter(object):
"""
return self._config_data.cluster.shared_file_storage_dir
@locking.ssynchronized(_config_lock, shared=1)
def GetGlusterStorageDir(self):
"""Get the Gluster storage dir for this cluster.
"""
return self._config_data.cluster.gluster_storage_dir
@locking.ssynchronized(_config_lock, shared=1)
def GetHypervisorType(self):
"""Get the hypervisor type for this cluster.
......@@ -2596,6 +2603,7 @@ class ConfigWriter(object):
constants.SS_CLUSTER_TAGS: cluster_tags,
constants.SS_FILE_STORAGE_DIR: cluster.file_storage_dir,
constants.SS_SHARED_FILE_STORAGE_DIR: cluster.shared_file_storage_dir,
constants.SS_GLUSTER_STORAGE_DIR: cluster.gluster_storage_dir,
constants.SS_MASTER_CANDIDATES: mc_data,
constants.SS_MASTER_CANDIDATES_IPS: mc_ips_data,
constants.SS_MASTER_IP: cluster.master_ip,
......
......@@ -1547,6 +1547,7 @@ class Cluster(TaggableObject):
"cluster_name",
"file_storage_dir",
"shared_file_storage_dir",
"gluster_storage_dir",
"enabled_hypervisors",
"hvparams",
"ipolicy",
......@@ -1665,6 +1666,10 @@ class Cluster(TaggableObject):
if self.shared_file_storage_dir is None:
self.shared_file_storage_dir = ""
# gluster_storage_dir added in 2.11
if self.gluster_storage_dir is None:
self.gluster_storage_dir = ""
if self.use_external_mip_script is None:
self.use_external_mip_script = False
......
......@@ -34,6 +34,9 @@ DEFAULT_FILE_STORAGE_DIR = vcluster.AddNodePrefix(DEFAULT_FILE_STORAGE_DIR)
DEFAULT_SHARED_FILE_STORAGE_DIR = "/srv/ganeti/shared-file-storage"
DEFAULT_SHARED_FILE_STORAGE_DIR = \
vcluster.AddNodePrefix(DEFAULT_SHARED_FILE_STORAGE_DIR)
DEFAULT_GLUSTER_STORAGE_DIR = "/var/run/ganeti/gluster"
DEFAULT_GLUSTER_STORAGE_DIR = \
vcluster.AddNodePrefix(DEFAULT_GLUSTER_STORAGE_DIR)
EXPORT_DIR = vcluster.AddNodePrefix(_constants.EXPORT_DIR)
OS_SEARCH_PATH = _constants.OS_SEARCH_PATH
ES_SEARCH_PATH = _constants.ES_SEARCH_PATH
......
......@@ -46,6 +46,7 @@ _VALID_KEYS = compat.UniqueFrozenset([
constants.SS_CLUSTER_TAGS,
constants.SS_FILE_STORAGE_DIR,
constants.SS_SHARED_FILE_STORAGE_DIR,
constants.SS_GLUSTER_STORAGE_DIR,
constants.SS_MASTER_CANDIDATES,
constants.SS_MASTER_CANDIDATES_IPS,
constants.SS_MASTER_IP,
......@@ -220,6 +221,12 @@ class SimpleStore(object):
"""
return self._ReadFile(constants.SS_SHARED_FILE_STORAGE_DIR)
def GetGlusterStorageDir(self):
"""Get the Gluster storage dir.
"""
return self._ReadFile(constants.SS_GLUSTER_STORAGE_DIR)
def GetMasterCandidates(self):
"""Return the list of master candidates.
......
......@@ -174,6 +174,7 @@ INIT
| [\--no-ssh-init]
| [\--file-storage-dir *dir*]
| [\--shared-file-storage-dir *dir*]
| [\--gluster-storage-dir *dir*]
| [\--enabled-hypervisors *hypervisors*]
| [{-H|\--hypervisor-parameters} *hypervisor*:*hv-param*=*value*[,*hv-param*=*value*...]]
| [{-B|\--backend-parameters} *be-param*=*value*[,*be-param*=*value*...]]
......@@ -268,12 +269,13 @@ without modifying the /etc/hosts file.
The ``--no-ssh-init`` option allows you to initialize the cluster
without creating or distributing SSH key pairs.
The ``--file-storage-dir`` and ``--shared-file-storage-dir`` options
allow you set the directory to use for storing the instance disk files
when using file storage backend, respectively shared file storage
backend, for instance disks. Note that the file and shared file storage
dir must be an allowed directory for file storage. Those directories
are specified in the ``@SYSCONFDIR@/ganeti/file-storage-paths`` file.
The ``--file-storage-dir``, ``--shared-file-storage-dir`` and
``--gluster-storage-dir`` options allow you set the directory to use for
storing the instance disk files when using respectively the file storage
backend, the shared file storage backend and the gluster storage
backend. Note that these directories must be an allowed directory for
file storage. Those directories are specified in the
``@SYSCONFDIR@/ganeti/file-storage-paths`` file.
The file storage directory can also be a subdirectory of an allowed one.
The file storage directory should be present on all nodes.
......
......@@ -3466,6 +3466,9 @@ ssFileStorageDir = "file_storage_dir"
ssSharedFileStorageDir :: String
ssSharedFileStorageDir = "shared_file_storage_dir"
ssGlusterStorageDir :: String
ssGlusterStorageDir = "gluster_storage_dir"
ssMasterCandidates :: String
ssMasterCandidates = "master_candidates"
......
......@@ -680,6 +680,7 @@ $(buildObject "Cluster" "cluster" $
, simpleField "cluster_name" [t| String |]
, simpleField "file_storage_dir" [t| String |]
, simpleField "shared_file_storage_dir" [t| String |]
, simpleField "gluster_storage_dir" [t| String |]
, simpleField "enabled_hypervisors" [t| [Hypervisor] |]
, simpleField "hvparams" [t| ClusterHvParams |]
, simpleField "os_hvp" [t| OsHvParams |]
......
......@@ -236,6 +236,7 @@ $(genOpCode "OpCode"
, pModifyEtcHosts
, pClusterFileStorageDir
, pClusterSharedFileStorageDir
, pClusterGlusterStorageDir
],
[])
, ("OpClusterRedistConf",
......
......@@ -105,6 +105,7 @@ module Ganeti.OpParams
, pFileStorageDir
, pClusterFileStorageDir
, pClusterSharedFileStorageDir
, pClusterGlusterStorageDir
, pVgName
, pEnabledHypervisors
, pHypervisor
......@@ -567,6 +568,12 @@ pClusterSharedFileStorageDir =
renameField "ClusterSharedFileStorageDir" $
optionalStringField "shared_file_storage_dir"
-- | Cluster-wide default directory for storing Gluster-backed disks.
pClusterGlusterStorageDir :: Field
pClusterGlusterStorageDir =
renameField "ClusterGlusterStorageDir" $
optionalStringField "gluster_storage_dir"
-- | Volume group name.
pVgName :: Field
pVgName =
......
......@@ -138,6 +138,8 @@ handleCall _ _ cdata QueryClusterInfo =
, ("file_storage_dir", showJSON $ clusterFileStorageDir cluster)
, ("shared_file_storage_dir",
showJSON $ clusterSharedFileStorageDir cluster)
, ("gluster_storage_dir",
showJSON $ clusterGlusterStorageDir cluster)
, ("maintain_node_health",
showJSON $ clusterMaintainNodeHealth cluster)
, ("ctime", showJSON $ clusterCtime cluster)
......
......@@ -63,6 +63,7 @@ $(declareSADT "SSKey"
, ("SSClusterTags", 'C.ssClusterTags)
, ("SSFileStorageDir", 'C.ssFileStorageDir)
, ("SSSharedFileStorageDir", 'C.ssSharedFileStorageDir)
, ("SSGlusterStorageDir", 'C.ssGlusterStorageDir)
, ("SSMasterCandidates", 'C.ssMasterCandidates)
, ("SSMasterCandidatesIps", 'C.ssMasterCandidatesIps)
, ("SSMasterIp", 'C.ssMasterIp)
......
......@@ -180,8 +180,7 @@ instance Arbitrary OpCodes.OpCode where
emptyMUD <*> emptyMUD <*> arbitrary <*>
arbitrary <*> emptyMUD <*> arbitrary <*> arbitrary <*> arbitrary <*>
arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*>
genMaybe genName <*>
genMaybe genName
arbitrary <*> genMaybe genName <*> genMaybe genName
"OP_CLUSTER_REDIST_CONF" -> pure OpCodes.OpClusterRedistConf
"OP_CLUSTER_ACTIVATE_MASTER_IP" ->
pure OpCodes.OpClusterActivateMasterIp
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment