resource_manager.py 文件源码

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

项目:intel-manager-for-lustre 作者: intel-hpdd 项目源码 文件源码
def _delete_nid_resource(self, scannable_id, deleted_resource_id):
        from chroma_core.lib.storage_plugin.api.resources import LNETInterface, NetworkInterface as SrcNetworkInterface
        resource = StorageResourceRecord.objects.get(pk = deleted_resource_id).to_resource()

        # Must be run in a transaction to avoid leaving invalid things in the DB on failure.
        assert transaction.is_managed()

        # Shame to do this twice, but it seems that the scannable resource might not always be a host
        # according to this test_subscriber
        # But we will presume only a host can have a NetworkInterface or an LNetInterface
        if isinstance(resource, SrcNetworkInterface) or isinstance(resource, LNETInterface):
            scannable_resource = ResourceQuery().get_resource(scannable_id)
            host = ManagedHost.objects.get(pk = scannable_resource.host_id)

            if isinstance(resource, SrcNetworkInterface):
                log.error("Deleting NetworkInterface %s from %s" % (resource.name, host.fqdn))
                NetworkInterface.objects.filter(host = host,
                                                name = resource.name).delete()
            elif isinstance(resource, LNETInterface):
                log.error("Deleting Nid %s from %s" % (resource.name, host.fqdn))
                network_interface = NetworkInterface.objects.get(host = host,
                                                                 name = resource.name)          # Presumes Nid name == Interface Name, that is asserted when it is added!yes
                Nid.objects.filter(network_interface = network_interface).delete()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号