Search in sources :

Example 1 with Sdc

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

the class ScaleIOGatewayClientImpl method listConnectedSdcIps.

@Override
public List<String> listConnectedSdcIps() {
    List<String> sdcIps = new ArrayList<>();
    List<Sdc> sdcs = listSdcs();
    if (sdcs != null) {
        for (Sdc sdc : sdcs) {
            if (MDM_CONNECTED_STATE.equalsIgnoreCase(sdc.getMdmConnectionState())) {
                sdcIps.add(sdc.getSdcIp());
            }
        }
    }
    return sdcIps;
}
Also used : Sdc(org.apache.cloudstack.storage.datastore.api.Sdc) ArrayList(java.util.ArrayList)

Example 2 with Sdc

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

the class ScaleIOPrimaryDataStoreDriver method revokeAccess.

@Override
public void revokeAccess(DataObject dataObject, Host host, DataStore dataStore) {
    try {
        if (DataObjectType.VOLUME.equals(dataObject.getType())) {
            final VolumeVO volume = volumeDao.findById(dataObject.getId());
            LOGGER.debug("Revoking access for PowerFlex volume: " + volume.getPath());
            final ScaleIOGatewayClient client = getScaleIOClient(dataStore.getId());
            final Sdc sdc = client.getConnectedSdcByIp(host.getPrivateIpAddress());
            if (sdc == null) {
                throw new CloudRuntimeException("Unable to revoke access for volume: " + dataObject.getId() + ", no Sdc connected with host ip: " + host.getPrivateIpAddress());
            }
            client.unmapVolumeFromSdc(ScaleIOUtil.getVolumePath(volume.getPath()), sdc.getId());
        } else if (DataObjectType.TEMPLATE.equals(dataObject.getType())) {
            final VMTemplateStoragePoolVO templatePoolRef = vmTemplatePoolDao.findByPoolTemplate(dataStore.getId(), dataObject.getId(), null);
            LOGGER.debug("Revoking access for PowerFlex template volume: " + templatePoolRef.getInstallPath());
            final ScaleIOGatewayClient client = getScaleIOClient(dataStore.getId());
            final Sdc sdc = client.getConnectedSdcByIp(host.getPrivateIpAddress());
            if (sdc == null) {
                throw new CloudRuntimeException("Unable to revoke access for template: " + dataObject.getId() + ", no Sdc connected with host ip: " + host.getPrivateIpAddress());
            }
            client.unmapVolumeFromSdc(ScaleIOUtil.getVolumePath(templatePoolRef.getInstallPath()), sdc.getId());
        } else if (DataObjectType.SNAPSHOT.equals(dataObject.getType())) {
            SnapshotInfo snapshot = (SnapshotInfo) dataObject;
            LOGGER.debug("Revoking access for PowerFlex volume snapshot: " + snapshot.getPath());
            final ScaleIOGatewayClient client = getScaleIOClient(dataStore.getId());
            final Sdc sdc = client.getConnectedSdcByIp(host.getPrivateIpAddress());
            if (sdc == null) {
                throw new CloudRuntimeException("Unable to revoke access for snapshot: " + dataObject.getId() + ", no Sdc connected with host ip: " + host.getPrivateIpAddress());
            }
            client.unmapVolumeFromSdc(ScaleIOUtil.getVolumePath(snapshot.getPath()), sdc.getId());
        }
    } catch (Exception e) {
        LOGGER.warn("Failed to revoke access due to: " + e.getMessage(), e);
    }
}
Also used : VMTemplateStoragePoolVO(com.cloud.storage.VMTemplateStoragePoolVO) SnapshotInfo(org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo) Sdc(org.apache.cloudstack.storage.datastore.api.Sdc) VolumeVO(com.cloud.storage.VolumeVO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ScaleIOGatewayClient(org.apache.cloudstack.storage.datastore.client.ScaleIOGatewayClient) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Example 3 with Sdc

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

the class ScaleIOPrimaryDataStoreDriver method grantAccess.

@Override
public boolean grantAccess(DataObject dataObject, Host host, DataStore dataStore) {
    try {
        if (DataObjectType.VOLUME.equals(dataObject.getType())) {
            final VolumeVO volume = volumeDao.findById(dataObject.getId());
            LOGGER.debug("Granting access for PowerFlex volume: " + volume.getPath());
            // Unlimited
            Long bandwidthLimitInKbps = Long.valueOf(0);
            // Check Bandwidht Limit parameter in volume details
            final VolumeDetailVO bandwidthVolumeDetail = volumeDetailsDao.findDetail(volume.getId(), Volume.BANDWIDTH_LIMIT_IN_MBPS);
            if (bandwidthVolumeDetail != null && bandwidthVolumeDetail.getValue() != null) {
                bandwidthLimitInKbps = Long.parseLong(bandwidthVolumeDetail.getValue()) * 1024;
            }
            // Unlimited
            Long iopsLimit = Long.valueOf(0);
            // Check IOPS Limit parameter in volume details, else try MaxIOPS
            final VolumeDetailVO iopsVolumeDetail = volumeDetailsDao.findDetail(volume.getId(), Volume.IOPS_LIMIT);
            if (iopsVolumeDetail != null && iopsVolumeDetail.getValue() != null) {
                iopsLimit = Long.parseLong(iopsVolumeDetail.getValue());
            } else if (volume.getMaxIops() != null) {
                iopsLimit = volume.getMaxIops();
            }
            if (iopsLimit > 0 && iopsLimit < ScaleIOUtil.MINIMUM_ALLOWED_IOPS_LIMIT) {
                iopsLimit = ScaleIOUtil.MINIMUM_ALLOWED_IOPS_LIMIT;
            }
            final ScaleIOGatewayClient client = getScaleIOClient(dataStore.getId());
            final Sdc sdc = client.getConnectedSdcByIp(host.getPrivateIpAddress());
            if (sdc == null) {
                alertHostSdcDisconnection(host);
                throw new CloudRuntimeException("Unable to grant access to volume: " + dataObject.getId() + ", no Sdc connected with host ip: " + host.getPrivateIpAddress());
            }
            return client.mapVolumeToSdcWithLimits(ScaleIOUtil.getVolumePath(volume.getPath()), sdc.getId(), iopsLimit, bandwidthLimitInKbps);
        } else if (DataObjectType.TEMPLATE.equals(dataObject.getType())) {
            final VMTemplateStoragePoolVO templatePoolRef = vmTemplatePoolDao.findByPoolTemplate(dataStore.getId(), dataObject.getId(), null);
            LOGGER.debug("Granting access for PowerFlex template volume: " + templatePoolRef.getInstallPath());
            final ScaleIOGatewayClient client = getScaleIOClient(dataStore.getId());
            final Sdc sdc = client.getConnectedSdcByIp(host.getPrivateIpAddress());
            if (sdc == null) {
                alertHostSdcDisconnection(host);
                throw new CloudRuntimeException("Unable to grant access to template: " + dataObject.getId() + ", no Sdc connected with host ip: " + host.getPrivateIpAddress());
            }
            return client.mapVolumeToSdc(ScaleIOUtil.getVolumePath(templatePoolRef.getInstallPath()), sdc.getId());
        } else if (DataObjectType.SNAPSHOT.equals(dataObject.getType())) {
            SnapshotInfo snapshot = (SnapshotInfo) dataObject;
            LOGGER.debug("Granting access for PowerFlex volume snapshot: " + snapshot.getPath());
            final ScaleIOGatewayClient client = getScaleIOClient(dataStore.getId());
            final Sdc sdc = client.getConnectedSdcByIp(host.getPrivateIpAddress());
            if (sdc == null) {
                alertHostSdcDisconnection(host);
                throw new CloudRuntimeException("Unable to grant access to snapshot: " + dataObject.getId() + ", no Sdc connected with host ip: " + host.getPrivateIpAddress());
            }
            return client.mapVolumeToSdc(ScaleIOUtil.getVolumePath(snapshot.getPath()), sdc.getId());
        }
        return false;
    } catch (Exception e) {
        throw new CloudRuntimeException(e);
    }
}
Also used : VMTemplateStoragePoolVO(com.cloud.storage.VMTemplateStoragePoolVO) SnapshotInfo(org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo) Sdc(org.apache.cloudstack.storage.datastore.api.Sdc) VolumeVO(com.cloud.storage.VolumeVO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ScaleIOGatewayClient(org.apache.cloudstack.storage.datastore.client.ScaleIOGatewayClient) VolumeDetailVO(com.cloud.storage.VolumeDetailVO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Example 4 with Sdc

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

the class ScaleIOGatewayClientImpl method isSdcConnected.

@Override
public boolean isSdcConnected(String ipAddress) {
    Preconditions.checkArgument(StringUtils.isNotEmpty(ipAddress), "IP address cannot be null");
    List<Sdc> sdcs = listSdcs();
    if (sdcs != null) {
        for (Sdc sdc : sdcs) {
            if (ipAddress.equalsIgnoreCase(sdc.getSdcIp()) && MDM_CONNECTED_STATE.equalsIgnoreCase(sdc.getMdmConnectionState())) {
                return true;
            }
        }
    }
    return false;
}
Also used : Sdc(org.apache.cloudstack.storage.datastore.api.Sdc)

Aggregations

Sdc (org.apache.cloudstack.storage.datastore.api.Sdc)4 VMTemplateStoragePoolVO (com.cloud.storage.VMTemplateStoragePoolVO)2 VolumeVO (com.cloud.storage.VolumeVO)2 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 SnapshotInfo (org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo)2 ScaleIOGatewayClient (org.apache.cloudstack.storage.datastore.client.ScaleIOGatewayClient)2 VolumeDetailVO (com.cloud.storage.VolumeDetailVO)1 ArrayList (java.util.ArrayList)1