LGTM, thanks!
On Tue, Dec 17, 2013 at 10:28 AM, Santi Raffa <[email protected]> wrote: > This commit adds the gluster storage directory to ssconf (without > actually using its value just yet). > > Signed-off-by: Santi Raffa <[email protected]> > --- > lib/bootstrap.py | 18 +++++++++++++++++- > lib/cli.py | 10 ++++++++++ > lib/client/gnt_cluster.py | 4 +++- > lib/config.py | 8 ++++++++ > lib/objects.py | 5 +++++ > lib/pathutils.py | 3 +++ > lib/ssconf.py | 7 +++++++ > man/gnt-cluster.rst | 14 ++++++++------ > src/Ganeti/Constants.hs | 3 +++ > src/Ganeti/Objects.hs | 1 + > src/Ganeti/OpCodes.hs | 1 + > src/Ganeti/OpParams.hs | 7 +++++++ > src/Ganeti/Query/Server.hs | 2 ++ > src/Ganeti/Ssconf.hs | 1 + > test/hs/Test/Ganeti/OpCodes.hs | 3 +-- > 15 files changed, 77 insertions(+), 10 deletions(-) > > diff --git a/lib/bootstrap.py b/lib/bootstrap.py > index 6e939fd..24f4245 100644 > --- a/lib/bootstrap.py > +++ b/lib/bootstrap.py > @@ -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}, > diff --git a/lib/cli.py b/lib/cli.py > index 75df252..58f89ea 100644 > --- a/lib/cli.py > +++ b/lib/cli.py > @@ -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) > diff --git a/lib/client/gnt_cluster.py b/lib/client/gnt_cluster.py > index 27266b6..fb57568 100644 > --- a/lib/client/gnt_cluster.py > +++ b/lib/client/gnt_cluster.py > @@ -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": ( > diff --git a/lib/config.py b/lib/config.py > index 7a3ba3a..5b4b1a3 100644 > --- a/lib/config.py > +++ b/lib/config.py > @@ -1169,6 +1169,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, > diff --git a/lib/objects.py b/lib/objects.py > index 17d27bf..e2c9053 100644 > --- a/lib/objects.py > +++ b/lib/objects.py > @@ -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 > > diff --git a/lib/pathutils.py b/lib/pathutils.py > index 756aec4..30a4817 100644 > --- a/lib/pathutils.py > +++ b/lib/pathutils.py > @@ -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 > diff --git a/lib/ssconf.py b/lib/ssconf.py > index a027ab5..7cfbd1d 100644 > --- a/lib/ssconf.py > +++ b/lib/ssconf.py > @@ -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. > > diff --git a/man/gnt-cluster.rst b/man/gnt-cluster.rst > index 135ed7e..2f39f17 100644 > --- a/man/gnt-cluster.rst > +++ b/man/gnt-cluster.rst > @@ -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. > > diff --git a/src/Ganeti/Constants.hs b/src/Ganeti/Constants.hs > index da2f640..427e5db 100644 > --- a/src/Ganeti/Constants.hs > +++ b/src/Ganeti/Constants.hs > @@ -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" > > diff --git a/src/Ganeti/Objects.hs b/src/Ganeti/Objects.hs > index 78aa78d..b1a0747 100644 > --- a/src/Ganeti/Objects.hs > +++ b/src/Ganeti/Objects.hs > @@ -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 |] > diff --git a/src/Ganeti/OpCodes.hs b/src/Ganeti/OpCodes.hs > index 8e595fe..86cf3f4 100644 > --- a/src/Ganeti/OpCodes.hs > +++ b/src/Ganeti/OpCodes.hs > @@ -236,6 +236,7 @@ $(genOpCode "OpCode" > , pModifyEtcHosts > , pClusterFileStorageDir > , pClusterSharedFileStorageDir > + , pClusterGlusterStorageDir > ], > []) > , ("OpClusterRedistConf", > diff --git a/src/Ganeti/OpParams.hs b/src/Ganeti/OpParams.hs > index 34fbcdd..5721260 100644 > --- a/src/Ganeti/OpParams.hs > +++ b/src/Ganeti/OpParams.hs > @@ -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 = > diff --git a/src/Ganeti/Query/Server.hs b/src/Ganeti/Query/Server.hs > index 1e32e41..add8f6f 100644 > --- a/src/Ganeti/Query/Server.hs > +++ b/src/Ganeti/Query/Server.hs > @@ -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) > diff --git a/src/Ganeti/Ssconf.hs b/src/Ganeti/Ssconf.hs > index ca4f824..3f7a64b 100644 > --- a/src/Ganeti/Ssconf.hs > +++ b/src/Ganeti/Ssconf.hs > @@ -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) > diff --git a/test/hs/Test/Ganeti/OpCodes.hs > b/test/hs/Test/Ganeti/OpCodes.hs > index 2fd6a36..4259caf 100644 > --- a/test/hs/Test/Ganeti/OpCodes.hs > +++ b/test/hs/Test/Ganeti/OpCodes.hs > @@ -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 > -- > 1.7.10.4 > > -- Thomas Thrainer | Software Engineer | [email protected] | Google Germany GmbH Dienerstr. 12 80331 München Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Graham Law, Christine Elizabeth Flores
