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()
resource_manager.py 文件源码
python
阅读 26
收藏 0
点赞 0
评论 0
评论列表
文章目录