Search in sources :

Example 1 with GetVGInfoVDSCommandParameters

use of org.ovirt.engine.core.common.vdscommands.GetVGInfoVDSCommandParameters in project ovirt-engine by oVirt.

the class AddSANStorageDomainCommand method proceedVGLunsInDb.

protected void proceedVGLunsInDb() {
    final ArrayList<LUNs> luns = (ArrayList<LUNs>) runVdsCommand(VDSCommandType.GetVGInfo, new GetVGInfoVDSCommandParameters(getVds().getId(), getStorageDomain().getStorage())).getReturnValue();
    TransactionSupport.executeInNewTransaction(() -> {
        for (LUNs lun : luns) {
            lunHelper.proceedLUNInDb(lun, getStorageDomain().getStorageType(), getStorageDomain().getStorage());
        }
        return null;
    });
}
Also used : GetVGInfoVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.GetVGInfoVDSCommandParameters) ArrayList(java.util.ArrayList) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Example 2 with GetVGInfoVDSCommandParameters

use of org.ovirt.engine.core.common.vdscommands.GetVGInfoVDSCommandParameters in project ovirt-engine by oVirt.

the class ExtendSANStorageDomainCommand method updateLunsList.

@SuppressWarnings("unchecked")
private void updateLunsList() {
    VDS spmVds = getAllRunningVdssInPool().stream().filter(vds -> vds.getSpmStatus() == VdsSpmStatus.SPM).findFirst().orElse(null);
    if (spmVds == null) {
        log.error("Could not update LUNs' information of storage domain with VG ID '{}' in the DB.", getStorageDomain().getStorage());
        return;
    }
    try {
        ArrayList<LUNs> upToDateLuns = (ArrayList<LUNs>) runVdsCommand(VDSCommandType.GetVGInfo, new GetVGInfoVDSCommandParameters(spmVds.getId(), getStorageDomain().getStorage())).getReturnValue();
        getParameters().setLunsList(upToDateLuns);
    } catch (RuntimeException e) {
        log.error("Could not get the information for VG ID '{}'; the LUNs' information will not be updated.", getStorageDomain().getStorage());
        log.debug("Exception", e);
    }
}
Also used : GetVGInfoVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.GetVGInfoVDSCommandParameters) VDS(org.ovirt.engine.core.common.businessentities.VDS) ArrayList(java.util.ArrayList) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Example 3 with GetVGInfoVDSCommandParameters

use of org.ovirt.engine.core.common.vdscommands.GetVGInfoVDSCommandParameters in project ovirt-engine by oVirt.

the class GetUnregisteredBlockStorageDomainsQuery method getStorageDomainsByVolumeGroupIds.

/**
 * Create StorageDomain objects according to the specified VG-IDs list.
 *
 * @param vgIDs the VG-IDs list
 *
 * @return storage domains list
 */
@SuppressWarnings("unchecked")
protected List<StorageDomain> getStorageDomainsByVolumeGroupIds(List<String> vgIDs) {
    List<StorageDomain> storageDomains = new ArrayList<>();
    // Get existing PhysicalVolumes.
    Set<String> existingLunIds = lunDao.getAll().stream().map(LUNs::getId).collect(Collectors.toSet());
    for (String vgID : vgIDs) {
        VDSReturnValue returnValue;
        try {
            returnValue = executeGetVGInfo(new GetVGInfoVDSCommandParameters(getParameters().getVdsId(), vgID));
        } catch (RuntimeException e) {
            log.error("Could not get info for VG ID: '{}': {}", vgID, e.getMessage());
            log.debug("Exception", e);
            continue;
        }
        ArrayList<LUNs> luns = (ArrayList<LUNs>) returnValue.getReturnValue();
        if (luns.stream().anyMatch(l -> existingLunIds.contains(l.getId()))) {
            log.info("There are existing luns in the system which are part of VG id '{}'", vgID);
            continue;
        }
        // Get storage domain ID by a representative LUN
        LUNs lun = luns.get(0);
        Guid storageDomainId = lun.getStorageDomainId();
        // Get storage domain using GetStorageDomainInfo
        StorageDomain storageDomain = getStorageDomainById(storageDomainId);
        if (storageDomain != null) {
            storageDomains.add(storageDomain);
        }
    }
    return storageDomains;
}
Also used : GetVGInfoVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.GetVGInfoVDSCommandParameters) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 4 with GetVGInfoVDSCommandParameters

use of org.ovirt.engine.core.common.vdscommands.GetVGInfoVDSCommandParameters in project ovirt-engine by oVirt.

the class AddExistingBlockStorageDomainCommand method getLUNsFromVgInfo.

protected List<LUNs> getLUNsFromVgInfo() {
    List<LUNs> luns = new ArrayList<>();
    VDSReturnValue returnValue;
    try {
        returnValue = runVdsCommand(VDSCommandType.GetVGInfo, new GetVGInfoVDSCommandParameters(getParameters().getVdsId(), getStorageDomain().getStorage()));
    } catch (RuntimeException e) {
        log.error("Could not get info for VG ID '{}': {}", getStorageDomain().getStorage(), e.getMessage());
        log.debug("Exception", e);
        return luns;
    }
    luns.addAll((ArrayList<LUNs>) returnValue.getReturnValue());
    return luns;
}
Also used : GetVGInfoVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.GetVGInfoVDSCommandParameters) ArrayList(java.util.ArrayList) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Aggregations

ArrayList (java.util.ArrayList)4 LUNs (org.ovirt.engine.core.common.businessentities.storage.LUNs)4 GetVGInfoVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.GetVGInfoVDSCommandParameters)4 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)2 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)1 VDS (org.ovirt.engine.core.common.businessentities.VDS)1 Guid (org.ovirt.engine.core.compat.Guid)1