use of org.ovirt.engine.core.common.businessentities.StorageDomainStatic in project ovirt-engine by oVirt.
the class VmInfoBuildUtils method getGlusterVolInfo.
/**
* Finds Storage Domain by disk and extracts gluster host and volume info.
* @param disk Disk located on Gluster's SD
* @return volume info array. First element is a brick's hostname, second element - volume name.
*/
public String[] getGlusterVolInfo(Disk disk) {
StorageDomainStatic dom = this.storageDomainStaticDao.get(((DiskImage) disk).getStorageIds().get(0));
StorageServerConnections con = this.storageServerConnectionDao.getAllForDomain(dom.getId()).get(0);
// host:/volume
String path = con.getConnection();
String[] volInfo = path.split(":");
if (volInfo.length != 2) {
log.error("Invalid volInfo value: {}", path);
return null;
}
volInfo[1] = volInfo[1].replaceFirst("^/", "");
return volInfo;
}
use of org.ovirt.engine.core.common.businessentities.StorageDomainStatic in project ovirt-engine by oVirt.
the class GetStorageDomainsWithAttachedStoragePoolGuidQuery method filterAttachedStorageDomains.
protected List<StorageDomainStatic> filterAttachedStorageDomains() {
List<StorageDomain> connectedStorageDomainsToVds = new ArrayList<>();
for (StorageDomain storageDomain : getParameters().getStorageDomainList()) {
if (!connectStorageDomain(storageDomain)) {
logErrorMessage(storageDomain);
} else {
connectedStorageDomainsToVds.add(storageDomain);
}
}
// Some domains may have Hosted Engine VM running while importing them.
// We want to avoid disconnecting before the import in that case, otherwise they'll crash
List<Guid> heStorageDomainIds = storageDomainDao.getHostedEngineStorageDomainIds();
List<StorageDomainStatic> storageDomainsWithAttachedStoragePoolId = getAttachedStorageDomains(connectedStorageDomainsToVds);
for (StorageDomain storageDomain : connectedStorageDomainsToVds) {
if (heStorageDomainIds.contains(storageDomain.getId())) {
log.info("Skipping disconnect Storage Domain {} from VDS '{}' because Hosted Engine VM is running on it.", storageDomain.getName(), getVdsId());
continue;
}
if (!disconnectStorageDomain(storageDomain)) {
log.warn("Could not disconnect Storage Domain {} from VDS '{}'. ", storageDomain.getName(), getVdsId());
}
}
return storageDomainsWithAttachedStoragePoolId;
}
use of org.ovirt.engine.core.common.businessentities.StorageDomainStatic in project ovirt-engine by oVirt.
the class GetStorageDomainsWithAttachedStoragePoolGuidQuery method getAttachedStorageDomains.
protected List<StorageDomainStatic> getAttachedStorageDomains(List<StorageDomain> storageDomains) {
VDSReturnValue vdsReturnValue = null;
List<StorageDomainStatic> storageDomainsWithAttachedStoragePoolId = new ArrayList<>();
// another Storage Pool
for (StorageDomain storageDomain : storageDomains) {
try {
vdsReturnValue = runVdsCommand(VDSCommandType.HSMGetStorageDomainInfo, new HSMGetStorageDomainInfoVDSCommandParameters(getVdsId(), storageDomain.getId()));
} catch (RuntimeException e) {
logErrorMessage(storageDomain);
continue;
}
if (!vdsReturnValue.getSucceeded()) {
logErrorMessage(storageDomain);
continue;
}
Pair<StorageDomainStatic, Guid> domainFromIrs = (Pair<StorageDomainStatic, Guid>) vdsReturnValue.getReturnValue();
if (domainFromIrs.getSecond() != null) {
storageDomainsWithAttachedStoragePoolId.add(domainFromIrs.getFirst());
}
}
return storageDomainsWithAttachedStoragePoolId;
}
use of org.ovirt.engine.core.common.businessentities.StorageDomainStatic in project ovirt-engine by oVirt.
the class AddExistingFileStorageDomainCommand method concreteCheckExistingStorageDomain.
protected boolean concreteCheckExistingStorageDomain(Pair<StorageDomainStatic, Guid> domain) {
boolean returnValue = false;
StorageDomainStatic domainFromIrs = domain.getFirst();
if (StringUtils.isEmpty(getStorageDomain().getStorageStaticData().getStorage()) && StringUtils.isEmpty(domainFromIrs.getStorage()) && domainFromIrs.getConnection() != null && getStorageDomain().getStorageStaticData().getConnection() != null) {
returnValue = StringUtils.equals(domainFromIrs.getConnection().getConnection(), getStorageDomain().getStorageStaticData().getConnection().getConnection());
} else if (!StringUtils.isEmpty(getStorageDomain().getStorageStaticData().getStorage()) && !StringUtils.isEmpty(domainFromIrs.getStorage())) {
returnValue = StringUtils.equals(domainFromIrs.getStorage(), getStorageDomain().getStorageStaticData().getStorage());
}
if (!returnValue) {
addValidationMessage(EngineMessage.ERROR_CANNOT_ADD_EXISTING_STORAGE_DOMAIN_CONNECTION_DATA_ILLEGAL);
}
return returnValue;
}
use of org.ovirt.engine.core.common.businessentities.StorageDomainStatic in project ovirt-engine by oVirt.
the class AddStorageDomainCommand method addStorageDomainInDb.
protected void addStorageDomainInDb() {
TransactionSupport.executeInNewTransaction(() -> {
StorageDomainStatic storageStaticData = getStorageDomain().getStorageStaticData();
storageDomainStaticDao.save(storageStaticData);
getCompensationContext().snapshotNewEntity(storageStaticData);
StorageDomainDynamic newStorageDynamic = new StorageDomainDynamic(null, getStorageDomain().getId(), null);
getReturnValue().setActionReturnValue(getStorageDomain().getId());
storageDomainDynamicDao.save(newStorageDynamic);
getCompensationContext().snapshotNewEntity(newStorageDynamic);
getCompensationContext().stateChanged();
return null;
});
if (getStorageDomain().getStorageDomainType().isDataDomain()) {
createDefaultDiskProfile();
}
}
Aggregations