Skip to content

Commit

Permalink
Merge pull request #46588 from guits/cluster-fsid-common
Browse files Browse the repository at this point in the history
ceph-volume: make is_valid() optional

Reviewed-by: Teoman ONAY <tonay@redhat.com>
  • Loading branch information
adk3798 committed Jun 14, 2022
2 parents a151b50 + 7ffea89 commit 50a4355
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/ceph-volume/ceph_volume/configuration.py
Expand Up @@ -86,13 +86,14 @@ def optionxform(self, s):
s = '_'.join(s.split())
return s

def get_safe(self, section, key, default=None):
def get_safe(self, section, key, default=None, check_valid=True):
"""
Attempt to get a configuration value from a certain section
in a ``cfg`` object but returning None if not found. Avoids the need
to be doing try/except {ConfigParser Exceptions} every time.
"""
self.is_valid()
if check_valid:
self.is_valid()
try:
return self.get(section, key)
except (configparser.NoSectionError, configparser.NoOptionError):
Expand Down
2 changes: 1 addition & 1 deletion src/ceph-volume/ceph_volume/util/encryption.py
Expand Up @@ -18,7 +18,7 @@ def get_key_size_from_conf():
key_size = conf.ceph.get_safe(
'osd',
'osd_dmcrypt_key_size',
default='512')
default='512', check_valid=False)

if key_size not in ['256', '512']:
logger.warning(("Invalid value set for osd_dmcrypt_key_size ({}). "
Expand Down

0 comments on commit 50a4355

Please sign in to comment.