From: John Mulligan Date: Thu, 20 Jan 2022 19:46:03 +0000 (-0500) Subject: cephadm: add a validate function to Packager X-Git-Tag: v16.2.8~163^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=46cfcc7bf6bd0eae947c78ca86d9ad3df5d8138e;p=ceph.git 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 --- diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 4889ec5e1eb..5a83d390041 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.')