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

Class TunedProfileSpec

src/python-common/ceph/deployment/service_spec.py:3641–3690  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3639
3640
3641class TunedProfileSpec():
3642 def __init__(self,
3643 profile_name: str,
3644 placement: Optional[PlacementSpec] = None,
3645 settings: Optional[Dict[str, str]] = None,
3646 ):
3647 self.profile_name = profile_name
3648 self.placement = placement or PlacementSpec(host_pattern='*')
3649 self.settings = settings or {}
3650 self._last_updated: str = ''
3651
3652 @classmethod
3653 def from_json(cls, spec: Dict[str, Any]) -> 'TunedProfileSpec':
3654 data = {}
3655 if 'profile_name' not in spec:
3656 raise SpecValidationError('Tuned profile spec must include "profile_name" field')
3657 data['profile_name'] = spec['profile_name']
3658 if not isinstance(data['profile_name'], str):
3659 raise SpecValidationError('"profile_name" field must be a string')
3660 if 'placement' in spec:
3661 data['placement'] = PlacementSpec.from_json(spec['placement'])
3662 if 'settings' in spec:
3663 data['settings'] = spec['settings']
3664 return cls(**data)
3665
3666 def to_json(self) -> Dict[str, Any]:
3667 res: Dict[str, Any] = {}
3668 res['profile_name'] = self.profile_name
3669 res['placement'] = self.placement.to_json()
3670 res['settings'] = self.settings
3671 return res
3672
3673 def __eq__(self, other: Any) -> bool:
3674 if isinstance(other, TunedProfileSpec):
3675 if (
3676 self.placement == other.placement
3677 and self.profile_name == other.profile_name
3678 and self.settings == other.settings
3679 ):
3680 return True
3681 return False
3682 return NotImplemented
3683
3684 def __repr__(self) -> str:
3685 return f'TunedProfile({self.profile_name})'
3686
3687 def copy(self) -> 'TunedProfileSpec':
3688 # for making deep copies so you can edit the settings in one without affecting the other
3689 # mostly for testing purposes
3690 return TunedProfileSpec(self.profile_name, self.placement, self.settings.copy())
3691
3692
3693class CephExporterSpec(ServiceSpec):

Callers 5

rm_profileMethod · 0.90
get_storeMethod · 0.90
TestTunedProfilesClass · 0.90
copyMethod · 0.85
_apply_tuned_profilesMethod · 0.85

Calls

no outgoing calls

Tested by 1

get_storeMethod · 0.72