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 @@ -37,11 +37,11 @@ public class ApiServiceConfiguration implements Configurable {public static fina
public static final ConfigKey<String> MonitoringWallPortalPort = new ConfigKey<String>("Advanced", String.class, "monitoring.wall.portal.port",
"3000", "Monitoring Service Wall Portal Port.(ex:3000)", true);
public static final ConfigKey<String> MonitoringWallPortalVmUri = new ConfigKey<String>("Advanced", String.class, "monitoring.wall.portal.vm.uri",
"/d/uservm?kiosk&theme=light", "Monitoring Service Wall Portal VM Uri.(ex:/d/uservm?kiosk&theme=light)", true);
"/d/uservm?kiosk", "Monitoring Service Wall Portal VM Uri.(ex:/d/uservm?kiosk)", true);
public static final ConfigKey<String> MonitoringWallPortalHostUri = new ConfigKey<String>("Advanced", String.class, "monitoring.wall.portal.host.uri",
"/d/Q3Jkjf54zs?kiosk&theme=light", "Monitoring Service Wall Portal Host Uri.(ex:/d/Q3Jkjf54zs?kiosk&theme=light)", true);
"/d/Q3Jkjf54zs?kiosk", "Monitoring Service Wall Portal Host Uri.(ex:/d/Q3Jkjf54zs?kiosk)", true);
public static final ConfigKey<String> MonitoringWallPortalClusterUri = new ConfigKey<String>("Advanced", String.class, "monitoring.wall.portal.cluster.uri",
"/d/fasdasdasdw?kiosk&theme=light", "Monitoring Service Wall Portal Cluster Uri.(ex:/d/fasdasdasdw?kiosk&theme=light)", true);
"/d/fasdasdasdw?kiosk", "Monitoring Service Wall Portal Cluster Uri.(ex:/d/fasdasdasdw?kiosk)", true);
public static final ConfigKey<Boolean> EventDeleteEnabled = new ConfigKey<>("Advanced", Boolean.class, "event.delete.enabled",
"false", "true if Event Delete Button is enabled, false otherwise)", false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3792,6 +3792,81 @@ protected KVMStoragePoolManager getPoolManager() {
return storagePoolManager;
}

public void detachAndAttachConfigDriveISO(final Connect conn, final String vmName, VirtualMachineTO to) {
// detach and re-attach configdrive ISO
List<DiskDef> disks = getDisks(conn, vmName);
DiskDef configdrive = null;
for (DiskDef disk : disks) {
if (disk.getDeviceType() == DiskDef.DeviceType.CDROM && CONFIG_DRIVE_ISO_DISK_LABEL.equals(disk.getDiskLabel())) {
configdrive = disk;
}
}

if (configdrive != null) {
try {
LOGGER.debug(String.format("Detaching ConfigDrive ISO of the VM %s, at path %s", vmName, configdrive.getDiskPath()));
String result = attachOrDetachConfigDriveISO(conn, vmName, to, configdrive.getDiskPath(), false, CONFIG_DRIVE_ISO_DEVICE_ID);
if (result != null) {
LOGGER.warn(String.format("Detach ConfigDrive ISO of the VM %s, at path %s with %s: ", vmName, configdrive.getDiskPath(), result));
}
LOGGER.debug(String.format("Attaching ConfigDrive ISO of the VM %s, at path %s", vmName, configdrive.getDiskPath()));
result = attachOrDetachConfigDriveISO(conn, vmName, to, configdrive.getDiskPath(), true, CONFIG_DRIVE_ISO_DEVICE_ID);
if (result != null) {
LOGGER.warn(String.format("Attach ConfigDrive ISO of the VM %s, at path %s with %s: ", vmName, configdrive.getDiskPath(), result));
}
} catch (final LibvirtException | InternalErrorException | URISyntaxException e) {
final String msg = "Detach and attach ConfigDrive ISO failed due to " + e.toString();
LOGGER.warn(msg, e);
}
}
}

public synchronized String attachOrDetachConfigDriveISO(final Connect conn, final String vmName, VirtualMachineTO to, String cdPath, final boolean isAttach, final Integer diskSeq) throws LibvirtException, URISyntaxException,
InternalErrorException {
String isoPath = "";
DiskTO configDriveDisk = null;
for (DiskTO disk : to.getDisks()) {
if (disk.getPath() != null && disk.getPath().contains("configdrive")) {
configDriveDisk = disk;
break;
}
}
isoPath = getVolumePath(conn, configDriveDisk, to.isConfigDriveOnHostCache());
DiskDef iso = new DiskDef();
if (isAttach && StringUtils.isNotBlank(isoPath) && configDriveDisk !=null && isoPath.lastIndexOf("/") > 0) {
if (isoPath.startsWith(getConfigPath() + "/" + ConfigDrive.CONFIGDRIVEDIR) && isoPath.contains(vmName)) {
iso.defISODisk(isoPath, diskSeq, DiskDef.DiskType.FILE);
} else {
final DataTO diskData = configDriveDisk.getData();
final String dataName = configDriveDisk.getPath();
final DataStoreTO store = diskData.getDataStore();
isoPath = store.getUrl().split("\\?")[0] + File.separator + dataName;

final int index = isoPath.lastIndexOf("/");
final String path = isoPath.substring(0, index);
final String name = isoPath.substring(index + 1);
final KVMStoragePool storagePool = storagePoolManager.getStoragePoolByURI(path);
final KVMPhysicalDisk isoVol = storagePool.getPhysicalDisk(name);
final DiskDef.DiskType diskType = getDiskType(isoVol);
isoPath = isoVol.getPath();
iso.defISODisk(isoPath, diskSeq, diskType);
}
} else {
iso.defISODisk(null, diskSeq, DiskDef.DiskType.FILE);
}
final String result = attachOrDetachDevice(conn, true, vmName, iso.toString());
if (result == null && !isAttach) {
final List<DiskDef> disks = getDisks(conn, vmName);
for (final DiskDef disk : disks) {
if (disk.getDeviceType() == DiskDef.DeviceType.CDROM
&& (diskSeq == null || disk.getDiskLabel().equals(iso.getDiskLabel()))) {
cleanupDisk(disk);
}
}
}
return result;
}

public void detachAndAttachConfigDriveISO(final Connect conn, final String vmName) {
// detach and re-attach configdrive ISO
List<DiskDef> disks = getDisks(conn, vmName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import org.libvirt.Domain;
import org.libvirt.DomainBlockInfo;
import org.libvirt.LibvirtException;
import org.libvirt.StoragePool;
import org.libvirt.StorageVol;

import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -120,7 +122,6 @@ private UnmanagedInstanceTO getUnmanagedInstance(LibvirtComputingResource libvir

final UnmanagedInstanceTO instance = new UnmanagedInstanceTO();
instance.setName(domain.getName());

instance.setCpuCores((int) LibvirtComputingResource.countDomainRunningVcpus(domain));
if (parser.getCpuTuneDef() !=null) {
instance.setCpuSpeed(parser.getCpuTuneDef().getShares()/instance.getCpuCores());
Expand Down Expand Up @@ -221,7 +222,17 @@ private List<UnmanagedInstanceTO.Disk> getUnmanagedInstanceDisks(List<LibvirtVMD
disk.setDatastoreType(diskDef.getDiskType().toString());
disk.setDatastorePort(diskDef.getSourceHostPort());
disk.setImagePath(diskDef.getSourcePath());
disk.setDatastoreName(disk.getDatastorePath());
try {
String rbdImagePath = "";
if (diskDef.getSourcePath().contains("/dev/rbd")) {
rbdImagePath = diskDef.getSourcePath().replace("/dev/rbd/", "");
}
StorageVol storageVolLookupByPath = conn.storageVolLookupByPath("".equals(rbdImagePath) ? diskDef.getSourcePath() : rbdImagePath);
StoragePool sp = storageVolLookupByPath.storagePoolLookupByVolume();
disk.setDatastoreName(sp.getName());
} catch (LibvirtException e) {
throw new RuntimeException(e);
}
disk.setFileBaseName(getDiskRelativePath(diskDef));
disks.add(disk);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ Use VIR_DOMAIN_XML_SECURE (value = 1) prior to v1.0.0.
dconn = libvirtUtilitiesHelper.retrieveQemuConnection(destinationUri);

if (to.getType() == VirtualMachine.Type.User) {
libvirtComputingResource.detachAndAttachConfigDriveISO(conn, vmName);
libvirtComputingResource.detachAndAttachConfigDriveISO(conn, vmName, to);
}

//run migration in thread so we can monitor it
Expand Down 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 @@ -544,20 +544,8 @@ private StoragePool getStoragePool(final UnmanagedInstanceTO.Disk disk, final Da
final String dsPath = disk.getDatastorePath();
final String dsType = disk.getDatastoreType();
final String dsName = disk.getDatastoreName();
logger.debug("### DataStore [Host:%s, Path:%s, Type:%s, Uuid:%s" ,dsHost, dsPath, dsType, dsName);
if (dsType != null) {
List<StoragePoolVO> pools = primaryDataStoreDao.listPoolByHostPath(dsHost, dsPath);
for (StoragePool pool : pools) {
if (pool.getDataCenterId() == zone.getId() &&
(pool.getClusterId() == null || pool.getClusterId().equals(cluster.getId())) &&
volumeApiService.doesTargetStorageSupportDiskOffering(pool, diskOfferingTags)) {
storagePool = pool;
break;
}
}
}

if (storagePool == null) {
logger.debug(String.format("### DataStore [Host:%s, Path:%s, Type:%s, Name:%s]" , dsHost, dsPath, dsType, dsName));
if (dsName != null) {
List<StoragePoolVO> pools = primaryDataStoreDao.listPoolsByCluster(cluster.getId());
pools.addAll(primaryDataStoreDao.listByDataCenterId(zone.getId()));
for (StoragePool pool : pools) {
Expand All @@ -570,6 +558,17 @@ private StoragePool getStoragePool(final UnmanagedInstanceTO.Disk disk, final Da
}
}
}
if (storagePool == null) {
List<StoragePoolVO> pools = primaryDataStoreDao.listPoolByHostPath(dsHost, dsPath);
for (StoragePool pool : pools) {
if (pool.getDataCenterId() == zone.getId() &&
(pool.getClusterId() == null || pool.getClusterId().equals(cluster.getId())) &&
volumeApiService.doesTargetStorageSupportDiskOffering(pool, diskOfferingTags)) {
storagePool = pool;
break;
}
}
}
if (storagePool == null) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, String.format("Storage pool for disk %s(%s) with datastore: %s not found in zone ID: %s", disk.getLabel(), disk.getDiskId(), disk.getDatastoreName(), zone.getUuid()));
}
Expand Down
4 changes: 2 additions & 2 deletions ui/src/views/plugins/IFrameWall.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ export default {
var uri = wallPortalProtocol + '://' + wallPortalDomain + ':' + wallPortalPort
if (typeof hypervisortype !== 'undefined' && hypervisortype !== null && hypervisortype !== '') {
const clusterUriPath = items.filter(x => x.name === 'monitoring.wall.portal.cluster.uri')[0]?.value
this.uriInfo = uri + clusterUriPath
this.uriInfo = uri + clusterUriPath + '&theme=light'
} else {
const hostUriPath = items.filter(x => x.name === 'monitoring.wall.portal.host.uri')[0]?.value
this.uriInfo = uri + hostUriPath + '&var-host=' + this.resource.ipaddress
this.uriInfo = uri + hostUriPath + '&theme=light&var-host=' + this.resource.ipaddress
}
this.uriCreateOk = true
})
Expand Down
Loading