Source:
<code>private boolean createConfigDriveIso(VirtualMachineProfile profile, DeployDestination dest, DiskTO disk) throws ResourceUnavailableException { <START> DataStore dataStore = null; if (disk != null) { String dId = disk.getData().getDataStore().getUuid(); if (VirtualMachineManager.VmConfigDriveOnPrimaryPool.value()) { dataStore = _dataStoreMgr.getDataStore(dId, DataStoreRole.Primary); } else { List<DataStore> dataStores = _dataStoreMgr.listImageStores(); String url = disk.getData().getDataStore().getUrl(); for(DataStore ds : dataStores) { if (url.equals(ds.getUri()) && DataStoreRole.Image.equals(ds.getRole())) { dataStore = ds; break; } } } } else { dataStore = findDataStore(profile, dest); } <END> final Long agentId = findAgentId(profile, dest, dataStore); if (agentId == null || dataStore == null) { throw new ResourceUnavailableException("Config drive iso creation failed, agent or datastore not available", ConfigDriveNetworkElement.class, 0L); } LOG.debug("Creating config drive ISO for vm: " + profile.getInstanceName()); final String isoFileName = ConfigDrive.configIsoFileName(profile.getInstanceName()); final String isoPath = ConfigDrive.createConfigDrivePath(profile.getInstanceName()); final String isoData = ConfigDriveBuilder.buildConfigDrive(profile.getVmData(), isoFileName, profile.getConfigDriveLabel()); final HandleConfigDriveIsoCommand configDriveIsoCommand = new HandleConfigDriveIsoCommand(isoPath, isoData, dataStore.getTO(), true); final Answer answer = agentManager.easySend(agentId, configDriveIsoCommand); if (!answer.getResult()) { throw new ResourceUnavailableException(String.format("Config drive iso creation failed, details: %s", answer.getDetails()), ConfigDriveNetworkElement.class, 0L); } addConfigDriveDisk(profile, dataStore); return true; }</code><technical_language>put in getOrDecideOnWhichDataStoreToUseOrSomeNameLikeThat()</technical_language>

Target:
private boolean createConfigDriveIso(VirtualMachineProfile profile, DeployDestination dest, DiskTO disk) throws ResourceUnavailableException { DataStore dataStore = getDatastoreForConfigDriveIso(disk, profile, dest); final Long agentId = findAgentId(profile, dest, dataStore); if (agentId == null || dataStore == null) { throw new ResourceUnavailableException("Config drive iso creation failed, agent or datastore not available", ConfigDriveNetworkElement.class, 0L); } LOG.debug("Creating config drive ISO for vm: " + profile.getInstanceName()); final String isoFileName = ConfigDrive.configIsoFileName(profile.getInstanceName()); final String isoPath = ConfigDrive.createConfigDrivePath(profile.getInstanceName()); final String isoData = ConfigDriveBuilder.buildConfigDrive(profile.getVmData(), isoFileName, profile.getConfigDriveLabel()); final HandleConfigDriveIsoCommand configDriveIsoCommand = new HandleConfigDriveIsoCommand(isoPath, isoData, dataStore.getTO(), true); final Answer answer = agentManager.easySend(agentId, configDriveIsoCommand); if (!answer.getResult()) { throw new ResourceUnavailableException(String.format("Config drive iso creation failed, details: %s", answer.getDetails()), ConfigDriveNetworkElement.class, 0L); } addConfigDriveDisk(profile, dataStore); return true; }