(self)
| 1317 | ) |
| 1318 | |
| 1319 | def validate(self) -> None: |
| 1320 | if not self.service_type: |
| 1321 | raise SpecValidationError('Cannot add Service: type required') |
| 1322 | |
| 1323 | if self.service_type in self.REQUIRES_CERTIFICATES: |
| 1324 | self._normalize_and_validate_tls() |
| 1325 | |
| 1326 | if self.service_type != 'osd': |
| 1327 | if self.service_type in self.REQUIRES_SERVICE_ID and not self.service_id: |
| 1328 | raise SpecValidationError('Cannot add Service: id required') |
| 1329 | if self.service_type not in self.REQUIRES_SERVICE_ID and self.service_id: |
| 1330 | raise SpecValidationError( |
| 1331 | f'Service of type \'{self.service_type}\' should not contain a service id') |
| 1332 | |
| 1333 | if self.service_id: |
| 1334 | if not re.match('^[a-zA-Z0-9_.-]+$', str(self.service_id)): |
| 1335 | raise SpecValidationError('Service id contains invalid characters, ' |
| 1336 | 'only [a-zA-Z0-9_.-] allowed') |
| 1337 | |
| 1338 | if self.placement is not None: |
| 1339 | self.placement.validate() |
| 1340 | if self.config: |
| 1341 | for k, v in self.config.items(): |
| 1342 | if k in self.MANAGED_CONFIG_OPTIONS: |
| 1343 | raise SpecValidationError( |
| 1344 | f'Cannot set config option {k} in spec: it is managed by cephadm' |
| 1345 | ) |
| 1346 | for network in self.networks or []: |
| 1347 | try: |
| 1348 | ip_network(network) |
| 1349 | except ValueError as e: |
| 1350 | raise SpecValidationError( |
| 1351 | f'Cannot parse network {network}: {e}' |
| 1352 | ) |
| 1353 | |
| 1354 | def __repr__(self) -> str: |
| 1355 | y = yaml.dump(cast(dict, self), default_flow_style=False) |
nothing calls this directly
no test coverage detected