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

Method validate

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

Source from the content-addressed store, hash-verified

2221 return data
2222
2223 def validate(self) -> None:
2224 # TODO: what other parameters should be validated as part of this function?
2225 super(NvmeofServiceSpec, self).validate()
2226
2227 if not self.pool:
2228 raise SpecValidationError('Cannot add NVMEOF: No Pool specified')
2229
2230 verify_boolean(self.enable_auth, "Enable authentication")
2231 if self.enable_auth or self.ssl:
2232 if self.certificate_source == CertificateSource.INLINE.value:
2233 if not all([self.server_key, self.server_cert, self.client_key,
2234 self.client_cert, self.root_ca_cert]):
2235 err_msg = 'enable_auth is true but '
2236 for cert_key_attr in ['ssl_key', 'ssl_cert', 'client_key',
2237 'client_cert', 'root_ca_cert']:
2238 val = getattr(self, cert_key_attr, None)
2239 if val is None or val == "":
2240 err_msg += f'{cert_key_attr}, '
2241 err_msg += 'attribute(s) not set in the spec'
2242 raise SpecValidationError(err_msg)
2243
2244 if self.transports not in ['tcp']:
2245 raise SpecValidationError('Invalid transport. Valid values are tcp')
2246
2247 verify_enum(self.log_level, "log level", ['debug', 'info', 'warning', 'error', 'critical'])
2248 verify_enum(self.spdk_log_level, "SPDK log level",
2249 ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'NOTICE'])
2250 verify_enum(self.spdk_protocol_log_level, "SPDK protocol log level",
2251 ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'NOTICE'])
2252 self.verify_spdk_ceph_connection_allocation()
2253 verify_non_negative_int(self.qos_timeslice_in_usecs, "QOS timeslice")
2254 verify_non_negative_int(self.notifications_interval, "SPDK notifications interval")
2255
2256 verify_non_negative_number(self.spdk_ping_interval_in_seconds, "SPDK ping interval")
2257 if (
2258 self.spdk_ping_interval_in_seconds is not None
2259 and self.spdk_ping_interval_in_seconds < 1.0
2260 ):
2261 raise SpecValidationError("SPDK ping interval should be at least 1 second")
2262
2263 verify_non_negative_int(self.allowed_consecutive_spdk_ping_failures,
2264 "Allowed consecutive SPDK ping failures")
2265 if (
2266 self.allowed_consecutive_spdk_ping_failures is not None
2267 and self.allowed_consecutive_spdk_ping_failures < 1
2268 ):
2269 raise SpecValidationError("Allowed consecutive SPDK ping failures should be at least 1")
2270
2271 verify_non_negative_int(self.state_update_interval_sec, "State update interval")
2272 verify_non_negative_int(self.break_update_interval_sec, "Break long updates interval")
2273 verify_non_negative_int(self.rebalance_period_sec, "Rebalance period")
2274 verify_non_negative_int(self.max_gws_in_grp, "Max gateways in group")
2275 verify_non_negative_int(self.max_ns_to_change_lb_grp,
2276 "Max namespaces to change load balancing group")
2277 verify_boolean(self.abort_on_errors, "Abort gateway on errors")
2278 verify_boolean(self.abort_on_update_error, "Abort gateway on an update error")
2279 verify_boolean(self.omap_file_ignore_unlock_errors, "Ignore OMAP file unlock errors")
2280 verify_boolean(self.omap_file_lock_on_read, "Lock OMAP on read")

Callers 1

_apply_nvmeofMethod · 0.95

Calls 10

SpecValidationErrorClass · 0.90
verify_booleanFunction · 0.90
verify_enumFunction · 0.90
verify_non_negative_intFunction · 0.90
verify_positive_intFunction · 0.90
verify_intFunction · 0.90
allFunction · 0.85
validateMethod · 0.45

Tested by

no test coverage detected