MCPcopy Create free account
hub / github.com/ceph/ceph / validate

Method validate

src/python-common/ceph/deployment/service_spec.py:1771–1833  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1769 return ports
1770
1771 def validate(self) -> None:
1772
1773 if self.ssl:
1774 if not self.ssl_cert and self.rgw_frontend_ssl_certificate:
1775 combined_cert = self.rgw_frontend_ssl_certificate
1776 if isinstance(combined_cert, list):
1777 combined_cert = '\n'.join(combined_cert)
1778 self.certificate_source = CertificateSource.INLINE.value
1779 self.ssl_cert, self.ssl_key = parse_combined_pem_file(combined_cert)
1780 self.rgw_frontend_ssl_certificate = None
1781 if not (self.ssl_cert and self.ssl_key):
1782 raise SpecValidationError("Failed to parse rgw_frontend_ssl_certificate field.")
1783
1784 # This validation is done after adjusting the SSL field so when
1785 # RGW Spec is updated with the right fields before validation
1786 super(RGWSpec, self).validate()
1787
1788 if self.rgw_realm and not self.rgw_zone:
1789 raise SpecValidationError(
1790 'Cannot add RGW: Realm specified but no zone specified')
1791 if self.rgw_zone and not self.rgw_realm:
1792 raise SpecValidationError('Cannot add RGW: Zone specified but no realm specified')
1793
1794 if self.rgw_frontend_type is not None:
1795 if self.rgw_frontend_type not in ['beast', 'civetweb']:
1796 raise SpecValidationError(
1797 'Invalid rgw_frontend_type value. Valid values are: beast, civetweb.\n'
1798 'Additional rgw type parameters can be passed using rgw_frontend_extra_args.'
1799 )
1800
1801 if self.generate_cert and not self.ssl:
1802 raise SpecValidationError('"ssl" field must be set to true when "generate_cert" '
1803 'is set to true')
1804
1805 if self.generate_cert and self.rgw_frontend_ssl_certificate:
1806 raise SpecValidationError('"generate_cert" field and "rgw_frontend_ssl_certificate" '
1807 'field are mutually exclusive')
1808
1809 if self.data_pool_attributes:
1810 if self.data_pool_attributes.get('type', 'ec') == 'ec':
1811 if any(attr not in self.data_pool_attributes.keys() for attr in ['k', 'm']):
1812 raise SpecValidationError(
1813 '"k" and "m" are required parameters for ec pool (defaults to ec pool)'
1814 )
1815 if 'erasure_code_profile' in self.data_pool_attributes.keys():
1816 raise SpecValidationError(
1817 'invalid option in data_pool_attribues "erasure_code_profile"'
1818 'ec profile will be generated automatically based on provided attributes'
1819 )
1820
1821 valid_compression_modes = ('sw', 'hw')
1822 if self.qat:
1823 compression = self.qat.get('compression')
1824 if compression and compression not in valid_compression_modes:
1825 raise SpecValidationError(
1826 f"Invalid compression mode {compression}. Only 'sw' and 'hw' are allowed"
1827 )
1828

Callers 15

_apply_rgwMethod · 0.95
parseMethod · 0.45
from_jsonMethod · 0.45
validateMethod · 0.45
_from_json_implMethod · 0.45
validateMethod · 0.45
validateMethod · 0.45
validateMethod · 0.45
validateMethod · 0.45
validateMethod · 0.45
validateMethod · 0.45

Calls 7

parse_combined_pem_fileFunction · 0.90
SpecValidationErrorClass · 0.90
anyClass · 0.85
joinMethod · 0.45
getMethod · 0.45
keysMethod · 0.45
from_jsonMethod · 0.45

Tested by 1