Search in sources :

Example 81 with DatabaseException

use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.

the class XIVSmisStorageDevice method doCreateSnapshot.

@Override
public void doCreateSnapshot(final StorageSystem storage, final List<URI> snapshotList, final Boolean createInactive, Boolean readOnly, final TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        List<BlockSnapshot> snapshots = _dbClient.queryObject(BlockSnapshot.class, snapshotList);
        if (ControllerUtils.checkSnapshotsInConsistencyGroup(snapshots, _dbClient, taskCompleter)) {
            _snapshotOperations.createGroupSnapshots(storage, snapshotList, createInactive, readOnly, taskCompleter);
        } else {
            URI snapshot = snapshots.get(0).getId();
            _snapshotOperations.createSingleVolumeSnapshot(storage, snapshot, createInactive, readOnly, taskCompleter);
        }
    } catch (DatabaseException e) {
        String message = String.format("IO exception when trying to create snapshot(s) on array %s", storage.getSerialNumber());
        _log.error(message, e);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("doCreateSnapshot", e.getMessage());
        taskCompleter.error(_dbClient, error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 82 with DatabaseException

use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.

the class XIVSmisStorageDevice method doCreateVolumes.

/*
     * (non-Javadoc)
     * 
     * @see
     * com.emc.storageos.volumecontroller.BlockStorageDevice#doCreateVolumes
     * (com.emc.storageos.db.client.model.StorageSystem,
     * com.emc.storageos.db.client.model.StoragePool, java.lang.String,
     * java.util.List, com.emc.storageos.volumecontroller.impl.utils.
     * VirtualPoolCapabilityValuesWrapper,
     * com.emc.storageos.volumecontroller.TaskCompleter)
     */
@Override
public void doCreateVolumes(final StorageSystem storageSystem, final StoragePool storagePool, final String opId, final List<Volume> volumes, final VirtualPoolCapabilityValuesWrapper capabilities, final TaskCompleter taskCompleter) throws DeviceControllerException {
    Set<URI> volumeURIs = new HashSet<URI>(0);
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Create Volume Start - Array:%s, Pool:%s", storageSystem.getLabel(), storagePool.getNativeId()));
    Volume firstVolume = volumes.get(0);
    Long capacity = firstVolume.getCapacity();
    boolean isThinlyProvisioned = firstVolume.getThinlyProvisioned();
    String tenantName = "";
    try {
        TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, firstVolume.getTenant().getURI());
        tenantName = tenant.getLabel();
    } catch (DatabaseException e) {
        _log.error("Error lookup TenantOrg object", e);
    }
    List<String> labels = new ArrayList<String>(volumes.size());
    for (Volume volume : volumes) {
        String label = volume.getLabel();
        logMsgBuilder.append("\nVolume: ").append(label);
        labels.add(_nameGenerator.generate(tenantName, label, volume.getId().toString(), '-', SmisConstants.MAX_VOLUME_NAME_LENGTH));
    }
    _log.info(logMsgBuilder.toString());
    try {
        CIMObjectPath configSvcPath = _cimPath.getConfigSvcPath(storageSystem);
        CIMArgument[] inArgs = _helper.getCreateVolumesInputArguments(storageSystem, storagePool, labels, capacity, volumes.size(), isThinlyProvisioned);
        CIMArgument[] outArgs = new CIMArgument[5];
        _helper.invokeMethod(storageSystem, configSvcPath, SmisConstants.CREATE_OR_MODIFY_ELEMENTS_FROM_STORAGE_POOL, inArgs, outArgs);
        volumeURIs = _smisStorageDevicePostProcessor.processVolumeCreation(storageSystem, storagePool.getId(), volumes, outArgs);
        if (!volumeURIs.isEmpty()) {
            // see SmisAbstractCreateVolumeJob.addVolumeToConsistencyGroup
            // All the volumes will be in the same consistency group
            final URI consistencyGroupId = firstVolume.getConsistencyGroup();
            if (consistencyGroupId != null) {
                addVolumesToCG(storageSystem, consistencyGroupId, new ArrayList<URI>(volumeURIs));
            }
        }
        taskCompleter.ready(_dbClient);
    } catch (final InternalException e) {
        _log.error("Problem in doCreateVolumes: ", e);
        taskCompleter.error(_dbClient, e);
    } catch (WBEMException e) {
        _log.error("Problem making SMI-S call: ", e);
        ServiceError serviceError = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
        taskCompleter.error(_dbClient, serviceError);
    } catch (Exception e) {
        _log.error("Problem in doCreateVolumes: ", e);
        ServiceError serviceError = DeviceControllerErrors.smis.methodFailed("doCreateVolumes", e.getMessage());
        taskCompleter.error(_dbClient, serviceError);
    }
    List<Volume> volumesToSave = new ArrayList<Volume>();
    for (URI id : taskCompleter.getIds()) {
        if (!volumeURIs.contains(id)) {
            logMsgBuilder.append("\n");
            logMsgBuilder.append(String.format("Task %s failed to create volume: %s", opId, id.toString()));
            Volume volume = _dbClient.queryObject(Volume.class, id);
            volume.setInactive(true);
            volumesToSave.add(volume);
        }
    }
    if (!volumesToSave.isEmpty()) {
        _dbClient.persistObject(volumesToSave);
    }
    logMsgBuilder = new StringBuilder(String.format("Create Volumes End - Array:%s, Pool:%s", storageSystem.getLabel(), storagePool.getNativeId()));
    for (Volume volume : volumes) {
        logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
    }
    _log.info(logMsgBuilder.toString());
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ArrayList(java.util.ArrayList) CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException) URI(java.net.URI) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) Volume(com.emc.storageos.db.client.model.Volume) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) HashSet(java.util.HashSet) CIMArgument(javax.cim.CIMArgument)

Example 83 with DatabaseException

use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.

the class SmisStorageDevice method doCreateSnapshot.

@Override
public void doCreateSnapshot(final StorageSystem storage, final List<URI> snapshotList, final Boolean createInactive, final Boolean readOnly, final TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        List<BlockSnapshot> snapshots = _dbClient.queryObject(BlockSnapshot.class, snapshotList);
        if (ControllerUtils.checkSnapshotsInConsistencyGroup(snapshots, _dbClient, taskCompleter)) {
            _snapshotOperations.createGroupSnapshots(storage, snapshotList, createInactive, readOnly, taskCompleter);
        } else {
            URI snapshot = snapshots.get(0).getId();
            _snapshotOperations.createSingleVolumeSnapshot(storage, snapshot, createInactive, readOnly, taskCompleter);
        }
    } catch (DatabaseException e) {
        String message = String.format("IO exception when trying to create snapshot(s) on array %s", storage.getSerialNumber());
        _log.error(message, e);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("doCreateSnapshot", e.getMessage());
        taskCompleter.error(_dbClient, error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 84 with DatabaseException

use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.

the class VNXUnityCreateFileSystemQuotaDirectoryJob method updateQuota.

/**
 * update quota
 *
 * @param fsId
 *            fileShare uri in vipr
 * @param dbClient
 *            DbClient
 * @param logMsgBuilder
 *            string builder for logging
 * @param vnxeApiClient
 *            VNXeApiClient
 */
private void updateQuota(QuotaDirectory quotaObj, DbClient dbClient, StringBuilder logMsgBuilder, VNXeApiClient vnxeApiClient) {
    VNXUnityTreeQuota vnxUnityQuota = null;
    try {
        FileShare fs = dbClient.queryObject(FileShare.class, quotaObj.getParent().getURI());
        vnxUnityQuota = vnxeApiClient.getQuotaByName(fs.getNativeId(), quotaObj.getName());
        if (vnxUnityQuota != null) {
            quotaObj.setInactive(false);
            quotaObj.setCreationTime(Calendar.getInstance());
            quotaObj.setNativeId(vnxUnityQuota.getId());
            String path = "/" + quotaObj.getName();
            quotaObj.setPath(path);
            try {
                quotaObj.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(dbClient, quotaObj, quotaObj.getParent().getName()));
            } catch (IOException e) {
                logMsgBuilder.append("/n");
                logMsgBuilder.append("Exception while setting quota's nativeGuid");
                logMsgBuilder.append(e.getMessage());
            }
            logMsgBuilder.append("/n");
            logMsgBuilder.append(String.format("Create file system quota directory successfully for NativeId: %s, URI: %s", quotaObj.getNativeId(), getTaskCompleter().getId()));
            dbClient.updateObject(quotaObj);
        } else {
            logMsgBuilder.append("Could not get newly created quota directory in the Unity, using the quota name: ");
            logMsgBuilder.append(quotaObj.getName());
        }
    } catch (DatabaseException e) {
        logMsgBuilder.append("/n");
        logMsgBuilder.append("Exception while querying associated fs from the db:");
        logMsgBuilder.append(e.getMessage());
    }
}
Also used : IOException(java.io.IOException) VNXUnityTreeQuota(com.emc.storageos.vnxe.models.VNXUnityTreeQuota) FileShare(com.emc.storageos.db.client.model.FileShare) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 85 with DatabaseException

use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.

the class ControllerUtils method convertToRecordableBourneEvent.

/**
 * Create a new instance of RecordableBourneEvent with the given resource
 * and properties.
 *
 * @param resource
 *            - Type of Resource - File or Volume
 * @param type
 *            - Event Type Enum
 * @param description
 *            - Description of event if available
 * @param extensions
 *            - Extensions mapped with Event Model Extensions
 * @param eventServiceSource
 *            - URI of the Project
 * @param dbClient
 *            - DBClient reference
 * @param evtServiceType
 *            - Service Type
 * @param recordType
 *            - Type of Indication
 * @return RecordableBourneEvent
 */
public static RecordableBourneEvent convertToRecordableBourneEvent(DataObject resource, String type, String description, String extensions, DbClient dbClient, String evtServiceType, String recordType, String eventServiceSource) {
    URI cos = null;
    URI id = null;
    String nativeGuid = null;
    URI projectURI = null;
    URI tenantURI = null;
    RecordableBourneEvent event = null;
    if (resource != null) {
        if (resource instanceof Volume) {
            Volume volume = (Volume) resource;
            cos = volume.getVirtualPool();
            id = volume.getId();
            nativeGuid = volume.getNativeGuid();
            projectURI = volume.getProject().getURI();
            tenantURI = volume.getTenant().getURI();
        } else if (resource instanceof FileShare) {
            FileShare fs = (FileShare) resource;
            cos = fs.getVirtualPool();
            id = fs.getId();
            nativeGuid = fs.getNativeGuid();
            projectURI = (fs.getProject() != null) ? fs.getProject().getURI() : null;
            tenantURI = (fs.getTenant() != null) ? fs.getTenant().getURI() : null;
        } else if (resource instanceof VplexMirror) {
            VplexMirror vplexMirror = (VplexMirror) resource;
            cos = vplexMirror.getVirtualPool();
            id = vplexMirror.getId();
            projectURI = vplexMirror.getProject().getURI();
            tenantURI = vplexMirror.getTenant().getURI();
        } else if (resource instanceof BlockSnapshot) {
            BlockSnapshot snapshot = (BlockSnapshot) resource;
            try {
                if (!NullColumnValueGetter.isNullNamedURI(snapshot.getParent())) {
                    Volume volume = dbClient.queryObject(Volume.class, snapshot.getParent());
                    cos = volume.getVirtualPool();
                    tenantURI = (volume.getTenant() != null) ? volume.getTenant().getURI() : null;
                }
                id = snapshot.getId();
                nativeGuid = snapshot.getNativeGuid();
                projectURI = snapshot.getProject().getURI();
            } catch (DatabaseException e) {
                s_logger.error("Exception caught", e);
            }
        } else if (resource instanceof BlockSnapshotSession) {
            BlockSnapshotSession session = (BlockSnapshotSession) resource;
            try {
                id = session.getId();
                projectURI = session.getProject().getURI();
            } catch (DatabaseException e) {
                s_logger.error("Exception caught", e);
            }
        } else if (resource instanceof ExportGroup) {
            ExportGroup exportGroup = (ExportGroup) resource;
            try {
                id = exportGroup.getId();
                projectURI = exportGroup.getProject().getURI();
                tenantURI = (exportGroup.getTenant() != null) ? exportGroup.getTenant().getURI() : null;
            } catch (Exception e) {
                s_logger.error("Exception caught", e);
            }
        } else if (resource instanceof FCZoneReference) {
            FCZoneReference zone = (FCZoneReference) resource;
            try {
                id = zone.getId();
            } catch (Exception e) {
                s_logger.error("Exception caught", e);
            }
        } else if (resource instanceof Network) {
            Network tz = (Network) resource;
            id = tz.getId();
            nativeGuid = tz.getNativeGuid();
        } else if (resource instanceof BlockConsistencyGroup) {
            BlockConsistencyGroup consistencyGroup = (BlockConsistencyGroup) resource;
            try {
                id = consistencyGroup.getId();
                projectURI = consistencyGroup.getProject().getURI();
                tenantURI = (consistencyGroup.getTenant() != null) ? consistencyGroup.getTenant().getURI() : null;
            } catch (Exception e) {
                s_logger.error("Exception caught", e);
            }
        } else if (resource instanceof StoragePool) {
            StoragePool sp = (StoragePool) resource;
            id = sp.getId();
            nativeGuid = sp.getNativeGuid();
        } else {
            s_logger.info("Error getting vpool,id,NativeGuid for event. Unexpected resource type {}.", resource.getClass().getName());
        }
        // TODO fix the bogus tenant, user ID once we have AuthZ working
        if (tenantURI == null && projectURI != null) {
            tenantURI = ControllerUtils.getProjectTenantOrgURI(dbClient, projectURI);
        }
        event = new RecordableBourneEvent(type, tenantURI, // user ID TODO when AAA
        URI.create("ViPR-User"), // fixed
        projectURI, cos, evtServiceType, id, description, System.currentTimeMillis(), extensions, nativeGuid, recordType, eventServiceSource, "", "");
    }
    return event;
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) RecordableBourneEvent(com.emc.storageos.volumecontroller.impl.monitoring.RecordableBourneEvent) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) FCZoneReference(com.emc.storageos.db.client.model.FCZoneReference) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) ExportGroup(com.emc.storageos.db.client.model.ExportGroup) Volume(com.emc.storageos.db.client.model.Volume) Network(com.emc.storageos.db.client.model.Network) VplexMirror(com.emc.storageos.db.client.model.VplexMirror) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Aggregations

DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)109 URI (java.net.URI)71 ArrayList (java.util.ArrayList)29 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)22 IOException (java.io.IOException)21 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)20 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)19 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)18 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)17 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)16 NamedURI (com.emc.storageos.db.client.model.NamedURI)14 ControllerException (com.emc.storageos.volumecontroller.ControllerException)13 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)12 HashMap (java.util.HashMap)12 HashSet (java.util.HashSet)12 List (java.util.List)12 StoragePool (com.emc.storageos.db.client.model.StoragePool)11 StoragePort (com.emc.storageos.db.client.model.StoragePort)11 Volume (com.emc.storageos.db.client.model.Volume)11 WBEMException (javax.wbem.WBEMException)11