def prepare_drivegroup(self, drive_group: DriveGroupSpec) -> List[ Tuple[str, DriveSelection]]: # 1) use fn_filter to determine matching_hosts matching_hosts = drive_group.placement.pattern_matches_hosts( [x for x in self.mgr.cache.get_hosts()]) # 2) Map the inventory to the InventoryHost object host_ds_map = [] # set osd_id_claims def _find_inv_for_host(hostname: str, inventory_dict: dict): # This is stupid and needs to be loaded with the host for _host, _inventory in inventory_dict.items(): if _host == hostname: return _inventory raise OrchestratorError("No inventory found for host: {}".format(hostname)) # 3) iterate over matching_host and call DriveSelection logger.debug(f"Checking matching hosts -> {matching_hosts}") for host in matching_hosts: inventory_for_host = _find_inv_for_host(host, self.mgr.cache.devices) logger.debug(f"Found inventory for host {inventory_for_host}") drive_selection = DriveSelection(drive_group, inventory_for_host) logger.debug(f"Found drive selection {drive_selection}") host_ds_map.append((host, drive_selection)) return host_ds_map
def prepare_drivegroup(self, drive_group: DriveGroupSpec) -> List[Tuple[str, DriveSelection]]: # 1) use fn_filter to determine matching_hosts matching_hosts = drive_group.placement.filter_matching_hostspecs( self.mgr.inventory.all_specs()) # 2) Map the inventory to the InventoryHost object host_ds_map = [] # set osd_id_claims def _find_inv_for_host(hostname: str, inventory_dict: dict) -> List[Device]: # This is stupid and needs to be loaded with the host for _host, _inventory in inventory_dict.items(): if _host == hostname: return _inventory raise OrchestratorError("No inventory found for host: {}".format(hostname)) # 3) iterate over matching_host and call DriveSelection logger.debug(f"Checking matching hosts -> {matching_hosts}") for host in matching_hosts: inventory_for_host = _find_inv_for_host(host, self.mgr.cache.devices) logger.debug(f"Found inventory for host {inventory_for_host}") # List of Daemons on that host dd_for_spec = self.mgr.cache.get_daemons_by_service(drive_group.service_name()) dd_for_spec_and_host = [dd for dd in dd_for_spec if dd.hostname == host] drive_selection = DriveSelection(drive_group, inventory_for_host, existing_daemons=len(dd_for_spec_and_host)) logger.debug(f"Found drive selection {drive_selection}") host_ds_map.append((host, drive_selection)) return host_ds_map
def prepare_drivegroup( self, drive_group: DriveGroupSpec) -> List[Tuple[str, DriveSelection]]: # 1) use fn_filter to determine matching_hosts matching_hosts = drive_group.placement.filter_matching_hostspecs( self.mgr.cache.get_schedulable_hosts()) # 2) Map the inventory to the InventoryHost object host_ds_map = [] # set osd_id_claims def _find_inv_for_host(hostname: str, inventory_dict: dict) -> List[Device]: # This is stupid and needs to be loaded with the host for _host, _inventory in inventory_dict.items(): if _host == hostname: return _inventory raise OrchestratorError( "No inventory found for host: {}".format(hostname)) # 3) iterate over matching_host and call DriveSelection logger.debug(f"Checking matching hosts -> {matching_hosts}") for host in matching_hosts: inventory_for_host = _find_inv_for_host(host, self.mgr.cache.devices) logger.debug(f"Found inventory for host {inventory_for_host}") # List of Daemons on that host dd_for_spec = self.mgr.cache.get_daemons_by_service( drive_group.service_name()) dd_for_spec_and_host = [ dd for dd in dd_for_spec if dd.hostname == host ] drive_selection = DriveSelection( drive_group, inventory_for_host, existing_daemons=len(dd_for_spec_and_host)) logger.debug(f"Found drive selection {drive_selection}") if drive_group.method and drive_group.method == 'raw': # ceph-volume can currently only handle a 1:1 mapping # of data/db/wal devices for raw mode osds. If db/wal devices # are defined and the number does not match the number of data # devices, we need to bail out if drive_selection.data_devices( ) and drive_selection.db_devices(): if len(drive_selection.data_devices()) != len( drive_selection.db_devices()): raise OrchestratorError( 'Raw mode only supports a 1:1 ratio of data to db devices. Found ' f'{len(drive_selection.data_devices())} potential data device(s) and ' f'{len(drive_selection.db_devices())} potential db device(s) on host {host}' ) if drive_selection.data_devices( ) and drive_selection.wal_devices(): if len(drive_selection.data_devices()) != len( drive_selection.wal_devices()): raise OrchestratorError( 'Raw mode only supports a 1:1 ratio of data to wal devices. Found ' f'{len(drive_selection.data_devices())} potential data device(s) and ' f'{len(drive_selection.wal_devices())} potential wal device(s) on host {host}' ) host_ds_map.append((host, drive_selection)) return host_ds_map