resource_manager.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:intel-manager-for-lustre 作者: intel-hpdd 项目源码 文件源码
def _resource_persist_update_attributes(self, scannable_id, local_record_id, attrs):
        # Must be run in a transaction to avoid leaving invalid things in the DB on failure.
        assert transaction.is_managed()

        session = self._sessions[scannable_id]

        global_record_id = session.local_id_to_global_id[local_record_id]

        record = StorageResourceRecord.objects.get(pk = global_record_id)

        ''' Sometimes we are given reference to a BaseStorageResource and so we need to store the id
            not the type. This code does the translation '''
        cleaned_id_attrs = {}
        for key, val in attrs.items():
            if isinstance(val, BaseStorageResource):
                cleaned_id_attrs[key] = session.local_id_to_global_id[val._handle]
            else:
                cleaned_id_attrs[key] = val

        record.update_attributes(cleaned_id_attrs)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号