def METHOD_NAME(self, filename: str, hostname: str, attrs: Dict[str, Variant]) -> None:
    try:
        with self.path.joinpath(filename).open() as fp:
            contents = json.load(fp)
    except json.JSONDecodeError as exc:
        # Refuse to replace corrupted file
        raise bus.BusError('cockpit.Machines.Error', f'File {filename} is in invalid format: {exc}.') from exc
    except FileNotFoundError:
        # But an empty file is an expected case
        contents = {}
    contents.setdefault(hostname, {}).METHOD_NAME({key: value.value for key, value in attrs.items()})
    self.path.mkdir(parents=True, exist_ok=True)
    with open(self.path.joinpath(filename), 'w') as fp:
        json.dump(contents, fp, indent=2)