]> 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>
Thu, 3 Feb 2022 14:57:55 +0000 (09:57 -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 4889ec5e1eb9d796611f9b2d4948dcffb93ee994..5a83d3900418cb7d42f9087bb9b90fbe05aeb0cb 100755 (executable)
@@ -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.')