def _write_image_metadata(self, image_install_path, meta_data): image_dir = os.path.dirname(image_install_path) md5sum = linux.md5sum(image_install_path) size = os.path.getsize(image_install_path) meta = dict(meta_data.__dict__.items()) meta['size'] = size meta['md5sum'] = md5sum metapath = os.path.join(image_dir, 'meta_data.json') with open(metapath, 'w') as fd: fd.write(jsonobject.dumps(meta, pretty=True)) return (size, md5sum)