]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: add a validate function to Packager
authorJohn Mulligan <jmulligan@redhat.com>
Thu, 20 Jan 2022 19:46:03 +0000 (14:46 -0500)
committerAdam King <adking@redhat.com>
Fri, 28 Jan 2022 16:31:05 +0000 (11:31 -0500)
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 <jmulligan@redhat.com>
src/cephadm/cephadm

index ca1d86063a770f8c351be9880c5fe8613caf1bb9..563aeb5e097da86a2ee05564af3694d7634cd248 100755 (executable)
@@ -6698,6 +6698,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
 
@@ -6975,7 +6979,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':
@@ -6983,6 +6987,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 {
@@ -7159,6 +7165,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.')