From 46cfcc7bf6bd0eae947c78ca86d9ad3df5d8138e Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Thu, 20 Jan 2022 14:46:03 -0500 Subject: [PATCH] cephadm: add a validate function to Packager The validate function is for testing the inputs to the Packager subclasses independently of writing the configuration to disk. It only raises an exception upon failed validation. Use it for the existing YumDnf validation exceptions. Signed-off-by: John Mulligan --- src/cephadm/cephadm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 4889ec5e1eb9..5a83d3900418 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -6196,6 +6196,10 @@ class Packager(object): self.branch = branch self.commit = commit + def validate(self) -> None: + """Validate parameters before writing any state to disk.""" + pass + def add_repo(self) -> None: raise NotImplementedError @@ -6473,7 +6477,7 @@ class YumDnf(Packager): return '%s/rpm-%s/%s' % (self.ctx.repo_url, self.stable, self.distro_code) - def add_repo(self) -> None: + def validate(self) -> None: if self.distro_code.startswith('fc'): raise Error('Ceph team does not build Fedora specific packages and therefore cannot add repos for this distro') if self.distro_code == 'el7': @@ -6481,6 +6485,8 @@ class YumDnf(Packager): raise Error('Ceph does not support pacific or later for this version of this linux distro and therefore cannot add a repo for it') if self.version and self.version.split('.')[0] >= '16': raise Error('Ceph does not support 16.y.z or later for this version of this linux distro and therefore cannot add a repo for it') + + def add_repo(self) -> None: if self.stable or self.version: content = '' for n, t in { @@ -6657,6 +6663,7 @@ def command_add_repo(ctx: CephadmContext) -> None: version=ctx.version, branch=ctx.dev, commit=ctx.dev_commit) + pkg.validate() pkg.add_repo() logger.info('Completed adding repo.') -- 2.47.3