def _lookup_ifaces(self, servers): """ Resolve the frontend/backend addresses (known by cthulhu via Ceph) to network interfaces (known by salt from its grains). """ server_to_grains = get_remote_grains([s['fqdn'] for s in servers]) for server in servers: fqdn = server['fqdn'] grains = server_to_grains[fqdn] server['frontend_iface'] = None server['backend_iface'] = None if grains is None: # No metadata available for this server continue else: try: if server['frontend_addr']: server['frontend_iface'] = self._addr_to_iface( server['frontend_addr'], grains['ip_interfaces']) if server['backend_addr']: server['backend_iface'] = self._addr_to_iface( server['backend_addr'], grains['ip_interfaces']) except KeyError: # Expected network metadata not available, we cannot infer # front/back interfaces so leave them null pass
def _lookup_ifaces(self, servers): """ Resolve the frontend/backend addresses (known by cthulhu via Ceph) to network interfaces (known by salt from its grains). """ server_to_grains = get_remote_grains([s['fqdn'] for s in servers]) for server in servers: fqdn = server['fqdn'] grains = server_to_grains[fqdn] server['frontend_iface'] = None server['backend_iface'] = None if grains is None: # No metadata available for this server continue else: try: if server['frontend_addr']: server['frontend_iface'] = self._addr_to_iface(server['frontend_addr'], grains['ip_interfaces']) if server['backend_addr']: server['backend_iface'] = self._addr_to_iface(server['backend_addr'], grains['ip_interfaces']) except KeyError: # Expected network metadata not available, we cannot infer # front/back interfaces so leave them null pass
def retrieve_grains(self, request, fqdn): grains = get_remote_grains([fqdn])[fqdn] if not grains: return Response(status=status.HTTP_404_NOT_FOUND) else: return Response(grains)