Search in sources :

Example 1 with SdcMappingInfo

use of org.apache.cloudstack.storage.datastore.api.SdcMappingInfo in project cloudstack by apache.

the class ScaleIOGatewayClientImpl method unmapVolumeFromAllSdcs.

@Override
public boolean unmapVolumeFromAllSdcs(final String volumeId) {
    Preconditions.checkArgument(StringUtils.isNotEmpty(volumeId), "Volume id cannot be null");
    Volume volume = getVolume(volumeId);
    if (volume == null) {
        return false;
    }
    List<SdcMappingInfo> mappedSdcList = volume.getMappedSdcList();
    if (mappedSdcList == null || mappedSdcList.isEmpty()) {
        return true;
    }
    Boolean unmapVolumeFromAllSdcsStatus = post("/instances/Volume::" + volumeId + "/action/removeMappedSdc", "{\"allSdcs\": \"\"}", Boolean.class);
    if (unmapVolumeFromAllSdcsStatus != null) {
        return unmapVolumeFromAllSdcsStatus;
    }
    return false;
}
Also used : Volume(org.apache.cloudstack.storage.datastore.api.Volume) SdcMappingInfo(org.apache.cloudstack.storage.datastore.api.SdcMappingInfo)

Example 2 with SdcMappingInfo

use of org.apache.cloudstack.storage.datastore.api.SdcMappingInfo in project cloudstack by apache.

the class ScaleIOGatewayClientImpl method isVolumeMappedToSdc.

@Override
public boolean isVolumeMappedToSdc(final String volumeId, final String sdcId) {
    Preconditions.checkArgument(StringUtils.isNotEmpty(volumeId), "Volume id cannot be null");
    Preconditions.checkArgument(StringUtils.isNotEmpty(sdcId), "Sdc Id cannot be null");
    if (StringUtils.isAnyEmpty(volumeId, sdcId)) {
        return false;
    }
    Volume volume = getVolume(volumeId);
    if (volume == null) {
        return false;
    }
    List<SdcMappingInfo> mappedSdcList = volume.getMappedSdcList();
    if (mappedSdcList != null && !mappedSdcList.isEmpty()) {
        for (SdcMappingInfo mappedSdc : mappedSdcList) {
            if (sdcId.equalsIgnoreCase(mappedSdc.getSdcId())) {
                return true;
            }
        }
    }
    return false;
}
Also used : Volume(org.apache.cloudstack.storage.datastore.api.Volume) SdcMappingInfo(org.apache.cloudstack.storage.datastore.api.SdcMappingInfo)

Aggregations

SdcMappingInfo (org.apache.cloudstack.storage.datastore.api.SdcMappingInfo)2 Volume (org.apache.cloudstack.storage.datastore.api.Volume)2