def update_hw_preset(cls, preset): preset_dict = cls.__preset_to_dict(preset) name = cls.__sanitize_preset_name(preset_dict['name']) preset = HardwarePreset.get(name=name) preset.apply(preset_dict) preset.save() return preset.to_dict()
def values(cls, preset_or_name): preset_or_name = preset_or_name or DEFAULT_HARDWARE_PRESET_NAME if isinstance(preset_or_name, basestring): preset = HardwarePreset.get(name=preset_or_name) else: preset = preset_or_name return preset.name, { u'cpu_cores': cls.cpu_cores(preset.cpu_cores), u'memory': cls.memory(preset.memory), u'disk': cls.disk(preset.disk) }
def values(cls, preset_or_name: Union[str, HardwarePreset]) \ -> Tuple[str, Dict[str, int]]: preset_or_name = preset_or_name or DEFAULT if isinstance(preset_or_name, str): preset = HardwarePreset.get(name=preset_or_name) else: preset = preset_or_name return preset.name, { 'cpu_cores': cls.cpu_cores(preset.cpu_cores), 'memory': cls.memory(preset.memory), 'disk': cls.disk(preset.disk) }
def get_hw_preset(name): return HardwarePreset.get(name=name).to_dict()
def test_initialize(self, *_): assert HardwarePreset.get(name=DEFAULT) assert HardwarePreset.get(name=CUSTOM)