def get_bmc_accessible_nodes(self):
"""Return `QuerySet` of nodes that this rack controller can access.
This looks at the IP address assigned to all BMC's and filters out
only the BMC's this rack controller can access. Returning all nodes
connected to those BMCs.
"""
subnet_ids = set()
for interface in self.interface_set.all().prefetch_related(
"ip_addresses"):
for ip_address in interface.ip_addresses.all():
if ip_address.ip and ip_address.subnet_id is not None:
subnet_ids.add(ip_address.subnet_id)
nodes = Node.objects.filter(
bmc__ip_address__ip__isnull=False,
bmc__ip_address__subnet_id__in=subnet_ids).distinct()
return nodes
评论列表
文章目录