Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3506,10 +3506,10 @@ public void detachAndAttachConfigDriveISO(final Connect conn, final String vmNam
public synchronized String attachOrDetachISO(final Connect conn, final String vmName, String isoPath, final boolean isAttach, final Integer diskSeq) throws LibvirtException, URISyntaxException,
InternalErrorException {
final DiskDef iso = new DiskDef();
if (isAttach && StringUtils.isNotBlank(isoPath) && isoPath.lastIndexOf("/") > 0) {
if (isoPath.startsWith(getConfigPath() + "/" + ConfigDrive.CONFIGDRIVEDIR) && isoPath.contains(vmName)) {
if (isAttach && StringUtils.isNotBlank(isoPath)) {
if (isoPath.startsWith(getConfigPath() + "/" + ConfigDrive.CONFIGDRIVEDIR) || isoPath.contains(vmName)) {
iso.defISODisk(isoPath, diskSeq, DiskDef.DiskType.FILE);
} else {
} else if (isoPath.lastIndexOf("/") > 0) {
final int index = isoPath.lastIndexOf("/");
final String path = isoPath.substring(0, index);
final String name = isoPath.substring(index + 1);
Expand All @@ -3533,7 +3533,6 @@ public synchronized String attachOrDetachISO(final Connect conn, final String vm
cleanupDisk(disk);
}
}

}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ private boolean findSourceNode(Document doc, Node diskNode, String vmName, Strin
Node sourceNode = diskChildNode;
NamedNodeMap sourceNodeAttributes = sourceNode.getAttributes();
Node sourceNodeAttribute = sourceNodeAttributes.getNamedItem("file");
if ( sourceNodeAttribute.getNodeValue().contains(vmName)) {
if (sourceNodeAttribute != null && sourceNodeAttribute.getNodeValue().contains(vmName)) {
diskNode.removeChild(diskChildNode);
Element newChildSourceNode = doc.createElement("source");
newChildSourceNode.setAttribute("file", isoPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,17 +325,19 @@ public KVMStoragePool getStoragePoolByURI(String uri) {
String uuid = null;
String sourceHost = "";
StoragePoolType protocol = null;
final String scheme = (storageUri.getScheme() != null) ? storageUri.getScheme().toLowerCase() : "";
List<String> acceptedSchemes = List.of("nfs", "networkfilesystem", "filesystem");
if (acceptedSchemes.contains(scheme)) {
sourcePath = storageUri.getPath();
sourcePath = sourcePath.replace("//", "/");
sourceHost = storageUri.getHost();
uuid = UUID.nameUUIDFromBytes(new String(sourceHost + sourcePath).getBytes()).toString();
protocol = scheme.equals("filesystem") ? StoragePoolType.Filesystem: StoragePoolType.NetworkFilesystem;
if (storageUri.getScheme() == null || !acceptedSchemes.contains(storageUri.getScheme().toLowerCase())) {
throw new CloudRuntimeException("Empty or unsupported storage pool uri scheme");
}

// secondary storage registers itself through here
final String scheme = storageUri.getScheme().toLowerCase();
sourcePath = storageUri.getPath();
sourcePath = sourcePath.replace("//", "/");
sourceHost = storageUri.getHost();
uuid = UUID.nameUUIDFromBytes(new String(sourceHost + sourcePath).getBytes()).toString();
protocol = scheme.equals("filesystem") ? StoragePoolType.Filesystem: StoragePoolType.NetworkFilesystem;

// storage registers itself through here
return createStoragePool(uuid, sourceHost, 0, sourcePath, "", protocol, null, false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,10 +733,9 @@ private boolean decStoragePoolRefCount(String uuid) {

@Override
public KVMStoragePool createStoragePool(String name, String host, int port, String path, String userInfo, StoragePoolType type, Map<String, String> details, boolean isPrimaryStorage) {
logger.info("Attempting to create storage pool " + name + " (" + type.toString() + ") in libvirt");

StoragePool sp = null;
Connect conn = null;
logger.info("Attempting to create storage pool {} ({}) in libvirt", name, type);
StoragePool sp;
Connect conn;
try {
conn = LibvirtConnection.getConnection();
} catch (LibvirtException e) {
Expand Down
Loading