def _lldp_connections(ip, data): if not _network_connections_in_results(data): return # No reason to run it... external_priorities = get_external_results_priorities(data) devices = find_devices(data) if len(devices) == 0: logger.warning('No device found for the IP address %s. ' 'There are some connections.' % ip.address) return elif len(devices) > 1: logger.warning('Many devices found for the IP address %s. ' 'There are some connections.' % ip.address) return _append_connections_to_device(devices[0], data, external_priorities)
def _mount_shares(ip, data): shares_in_device, shares_in_subdevice = _shares_in_results(data) if not shares_in_device and not shares_in_subdevice: return # No reason to run it. external_priorities = get_external_results_priorities(data) # main devices if shares_in_device: devices = find_devices(data) if len(devices) == 1: _append_shares_to_device(ip, devices[0], data, external_priorities) else: if len(devices) == 0: logger.warning('No device found for the IP address %s. ' 'There are some shares.' % ip.address) else: logger.warning('Many devices found for the IP address %s. ' 'There are some shares.' % ip.address) # subdevices if shares_in_subdevice: for plugin_name, plugin_result in data.iteritems(): if plugin_result['status'] == 'error': continue if 'device' not in plugin_result: continue for subdev_data in plugin_result['device'].get('subdevices', []): if 'disk_shares' not in subdev_data: continue serials = set() if subdev_data.get('serial_number'): serials.add(subdev_data['serial_number']) macs = set() for mac in subdev_data.get('mac_addresses', []): macs.add(mac) devices = Device.admin_objects.filter( Q(sn__in=serials) | Q(ethernet__mac__in=macs)).distinct() if len(devices) == 1: _append_shares_to_subdevice(ip, devices[0], subdev_data['disk_shares']) else: if len(devices) == 0: logger.warning( 'No subdevice found for the hypervisor IP ' 'address %s. SNs: %r; MACs: %r. There are some ' 'shares.' % (ip.address, serials, macs)) else: logger.warning( 'Many subdevices found for the hypervisor IP ' 'address %s. Devices: %r. There are some ' 'shares.' % (ip.address, devices))
def _lldp_connections(ip, data): if not _network_connections_in_results(data): return # No reason to run it... external_priorities = get_external_results_priorities(data) devices = find_devices(data) if len(devices) == 0: logger.warning( 'No device found for the IP address %s. ' 'There are some connections.' % ip.address ) return elif len(devices) > 1: logger.warning( 'Many devices found for the IP address %s. ' 'There are some connections.' % ip.address ) return _append_connections_to_device(devices[0], data, external_priorities)
def _mount_shares(ip, data): shares_in_device, shares_in_subdevice = _shares_in_results(data) if not shares_in_device and not shares_in_subdevice: return # No reason to run it. external_priorities = get_external_results_priorities(data) # main devices if shares_in_device: devices = find_devices(data) if len(devices) == 1: _append_shares_to_device(ip, devices[0], data, external_priorities) else: if len(devices) == 0: logger.warning( 'No device found for the IP address %s. ' 'There are some shares.' % ip.address ) else: logger.warning( 'Many devices found for the IP address %s. ' 'There are some shares.' % ip.address ) # subdevices if shares_in_subdevice: for plugin_name, plugin_result in data.iteritems(): if plugin_result['status'] == 'error': continue if 'device' not in plugin_result: continue for subdev_data in plugin_result['device'].get('subdevices', []): if 'disk_shares' not in subdev_data: continue serials = set() if subdev_data.get('serial_number'): serials.add(subdev_data['serial_number']) macs = set() for mac in subdev_data.get('mac_addresses', []): macs.add(mac) devices = Device.admin_objects.filter( Q(sn__in=serials) | Q(ethernet__mac__in=macs) ).distinct() if len(devices) == 1: _append_shares_to_subdevice( ip, devices[0], subdev_data['disk_shares'] ) else: if len(devices) == 0: logger.warning( 'No subdevice found for the hypervisor IP ' 'address %s. SNs: %r; MACs: %r. There are some ' 'shares.' % ( ip.address, serials, macs ) ) else: logger.warning( 'Many subdevices found for the hypervisor IP ' 'address %s. Devices: %r. There are some ' 'shares.' % ( ip.address, devices ) )