diff --git a/qa/ganeti-qa.py b/qa/ganeti-qa.py index 567732c07f8893d6a3dd7b9a1399ce29b69bde0e..f653fb5ed280d51aa92f307360bdf6a03a9d23af 100755 --- a/qa/ganeti-qa.py +++ b/qa/ganeti-qa.py @@ -177,6 +177,7 @@ def RunClusterTests(): ("cluster-modify", qa_cluster.TestClusterModifyISpecs), ("cluster-modify", qa_cluster.TestClusterModifyBe), ("cluster-modify", qa_cluster.TestClusterModifyDisk), + ("cluster-modify", qa_cluster.TestClusterModifyStorageTypes), ("cluster-rename", qa_cluster.TestClusterRename), ("cluster-info", qa_cluster.TestClusterVersion), ("cluster-info", qa_cluster.TestClusterInfo), diff --git a/qa/qa-sample.json b/qa/qa-sample.json index d5e5c869753c4e2b1321981228c342eae72f387a..660989c10d0918f7710ff0f66ae2f1b7ec4c543d 100644 --- a/qa/qa-sample.json +++ b/qa/qa-sample.json @@ -27,6 +27,7 @@ "vg-name": "xenvg", "# Cluster-level value of the exclusive-storage flag": null, "exclusive-storage": null, + "enabled-storage-types": "lvm-vg", "# Additional arguments for initializing cluster": null, "cluster-init-args": [], diff --git a/qa/qa_cluster.py b/qa/qa_cluster.py index 77d32268edb343bbe33397084f6ddc48be4b0295..8d4ff496b64d9038f46cfc7685894b32f5513be1 100644 --- a/qa/qa_cluster.py +++ b/qa/qa_cluster.py @@ -190,6 +190,8 @@ def TestClusterInit(rapi_user, rapi_secret): "gnt-cluster", "init", "--primary-ip-version=%d" % qa_config.get("primary_ip_version", 4), "--enabled-hypervisors=%s" % ",".join(qa_config.GetEnabledHypervisors()), + "--enabled-storage-types=%s" % + ",".join(qa_config.GetEnabledStorageTypes()) ] for spec_type in ("mem-size", "disk-size", "disk-count", "cpu-count", @@ -402,6 +404,33 @@ def TestClusterModifyDisk(): AssertCommand(["gnt-cluster", "modify", "-D", param], fail=True) +def TestClusterModifyStorageTypes(): + """gnt-cluster modify --enabled-storage-types=...""" + default_storage_type = qa_config.GetDefaultStorageType() + AssertCommand( + ["gnt-cluster", "modify", + "--enabled-storage-types=%s" % default_storage_type], + fail=False) + AssertCommand(["gnt-cluster", "info"]) + AssertCommand( + ["gnt-cluster", "modify", + "--enabled-storage-types=%s" % + ",".join(qa_config.GetEnabledStorageTypes())], + fail=False) + AssertCommand(["gnt-cluster", "info"]) + # bogus types + AssertCommand(["gnt-cluster", "modify", + "--enabled-storage-types=pinkbunny"], + fail=True) + # duplicate entries do no harm + AssertCommand( + ["gnt-cluster", "modify", + "--enabled-storage-types=%s,%s" % + (default_storage_type, default_storage_type)], + fail=False) + AssertCommand(["gnt-cluster", "info"]) + + def TestClusterModifyBe(): """gnt-cluster modify -B""" for fail, cmd in [ diff --git a/qa/qa_config.py b/qa/qa_config.py index cb509f819c789612e48c66e6b4fd36c1b71162f4..25b91ca8776a925718f4d30e63a5d94014aa8db7 100644 --- a/qa/qa_config.py +++ b/qa/qa_config.py @@ -38,6 +38,7 @@ _INSTANCE_CHECK_KEY = "instance-check" _ENABLED_HV_KEY = "enabled-hypervisors" _VCLUSTER_MASTER_KEY = "vcluster-master" _VCLUSTER_BASEDIR_KEY = "vcluster-basedir" +_ENABLED_STORAGE_TYPES_KEY = "enabled-storage-types" #: QA configuration (L{_QaConfig}) _config = None @@ -348,29 +349,51 @@ class _QaConfig(object): @rtype: list + """ + return self._GetStringListParameter( + _ENABLED_HV_KEY, + [constants.DEFAULT_ENABLED_HYPERVISOR]) + + def GetDefaultHypervisor(self): + """Returns the default hypervisor to be used. + + """ + return self.GetEnabledHypervisors()[0] + + def GetEnabledStorageTypes(self): + """Returns the list of enabled storage types. + + @rtype: list + + """ + return self._GetStringListParameter( + _ENABLED_STORAGE_TYPES_KEY, + list(constants.DEFAULT_ENABLED_STORAGE_TYPES)) + + def GetDefaultStorageType(self): + """Returns the default storage type to be used. + + """ + return self.GetEnabledStorageTypes()[0] + + def _GetStringListParameter(self, key, default_values): + """Retrieves a parameter's value that is supposed to be a list of strings. + + @rtype: list + """ try: - value = self._data[_ENABLED_HV_KEY] + value = self._data[key] except KeyError: - return [constants.DEFAULT_ENABLED_HYPERVISOR] + return default_values else: if value is None: return [] elif isinstance(value, basestring): - # The configuration key ("enabled-hypervisors") implies there can be - # multiple values. Multiple hypervisors are comma-separated on the - # command line option to "gnt-cluster init", so we need to handle them - # equally here. return value.split(",") else: return value - def GetDefaultHypervisor(self): - """Returns the default hypervisor to be used. - - """ - return self.GetEnabledHypervisors()[0] - def SetExclusiveStorage(self, value): """Set the expected value of the C{exclusive_storage} flag for the cluster. @@ -528,6 +551,20 @@ def GetDefaultHypervisor(*args): return GetConfig().GetDefaultHypervisor(*args) +def GetEnabledStorageTypes(*args): + """Wrapper for L{_QaConfig.GetEnabledStorageTypes}. + + """ + return GetConfig().GetEnabledStorageTypes(*args) + + +def GetDefaultStorageType(*args): + """Wrapper for L{_QaConfig.GetDefaultStorageType}. + + """ + return GetConfig().GetDefaultStorageType(*args) + + def GetMasterNode(): """Wrapper for L{_QaConfig.GetMasterNode}.