Search in sources :

Example 46 with TenantOrg

use of com.emc.storageos.db.client.model.TenantOrg in project coprhd-controller by CoprHD.

the class XIVSnapshotOperations method createSingleVolumeSnapshot.

/**
 * Should implement creation of a single volume snapshot. That is a volume
 * that is not in any consistency group.
 *
 * @param storage
 *            [required] - StorageSystem object representing the array
 * @param snapshot
 *            [required] - BlockSnapshot URI representing the previously
 *            created snap for the volume
 * @param taskCompleter
 *            - TaskCompleter object used for the updating operation status.
 */
@SuppressWarnings("rawtypes")
@Override
public void createSingleVolumeSnapshot(StorageSystem storage, URI snapshot, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("createSingleVolumeSnapshot operation START");
    try {
        BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
        Volume volume = _dbClient.queryObject(Volume.class, snapshotObj.getParent());
        TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
        String tenantName = tenant.getLabel();
        String snapLabelToUse = _nameGenerator.generate(tenantName, snapshotObj.getLabel(), snapshot.toString(), '-', IBMSmisConstants.MAX_SNAPSHOT_NAME_LENGTH);
        CIMArgument[] inArgs = _helper.getCreateElementReplicaSnapInputArguments(storage, volume, createInactive, snapLabelToUse);
        CIMArgument[] outArgs = new CIMArgument[5];
        _helper.callReplicationSvc(storage, IBMSmisConstants.CREATE_ELEMENT_REPLICA, inArgs, outArgs);
        _smisStorageDevicePostProcessor.processSnapshotCreation(storage, snapshot, !createInactive, outArgs, (BlockSnapshotCreateCompleter) taskCompleter);
    } catch (Exception e) {
        _log.info("Problem making SMI-S call: ", e);
        ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
        taskCompleter.error(_dbClient, error);
        setInactive(snapshot, true);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) WBEMException(javax.wbem.WBEMException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CIMArgument(javax.cim.CIMArgument)

Example 47 with TenantOrg

use of com.emc.storageos.db.client.model.TenantOrg in project coprhd-controller by CoprHD.

the class XIVSnapshotOperations method createGroupSnapshots.

/**
 * Should implement create of a snapshot from a source volume that is part
 * of a consistency group.
 *
 * @param storage
 *            [required] - StorageSystem object representing the array
 * @param taskCompleter
 *            - TaskCompleter object used for the updating operation status.
 * @param snapshot
 *            [required] - BlockSnapshot URI representing the previously
 *            created snap for the volume
 * @throws DeviceControllerException
 */
@SuppressWarnings("rawtypes")
@Override
public void createGroupSnapshots(StorageSystem storage, List<URI> snapshotList, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        URI snapshot = snapshotList.get(0);
        BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
        Volume volume = _dbClient.queryObject(Volume.class, snapshotObj.getParent());
        TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
        String tenantName = tenant.getLabel();
        String snapLabelToUse = _nameGenerator.generate(tenantName, snapshotObj.getSnapsetLabel(), snapshot.toString(), '-', IBMSmisConstants.MAX_SNAPSHOT_NAME_LENGTH);
        // check if the snapshot group name is used on array, return if the name is used to avoid unnecessary CIM call
        // snapshot group name has to be unique on array
        CIMObjectPath sgPath = _cimPath.getSnapshotGroupPath(storage, snapLabelToUse);
        if (sgPath != null) {
            _log.error("Failed to create group snapshots: " + IBMSmisConstants.DUPLICATED_SG_NAME_ERROR);
            ServiceError error = DeviceControllerErrors.smis.methodFailed("createGroupSnapshots", IBMSmisConstants.DUPLICATED_SG_NAME_ERROR);
            taskCompleter.error(_dbClient, error);
            setInactive(snapshotList, true);
            return;
        }
        String groupName = _helper.getConsistencyGroupName(snapshotObj, storage);
        CIMObjectPath cgPath = _cimPath.getConsistencyGroupPath(storage, groupName);
        CIMArgument[] inArgs = _helper.getCreateGroupReplicaInputArguments(storage, cgPath, createInactive, snapLabelToUse);
        CIMArgument[] outArgs = new CIMArgument[5];
        _helper.callReplicationSvc(storage, IBMSmisConstants.CREATE_GROUP_REPLICA, inArgs, outArgs);
        _smisStorageDevicePostProcessor.processCGSnapshotCreation(storage, snapshotList, !createInactive, snapLabelToUse, (BlockSnapshotCreateCompleter) taskCompleter);
    } catch (Exception e) {
        _log.info("Problem making SMI-S call: ", e);
        ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
        taskCompleter.error(_dbClient, error);
        setInactive(snapshotList, true);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) CIMObjectPath(javax.cim.CIMObjectPath) URI(java.net.URI) WBEMException(javax.wbem.WBEMException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CIMArgument(javax.cim.CIMArgument)

Example 48 with TenantOrg

use of com.emc.storageos.db.client.model.TenantOrg in project coprhd-controller by CoprHD.

the class VNXeSnapshotOperation method createSingleVolumeSnapshot.

@Override
public void createSingleVolumeSnapshot(StorageSystem storage, URI snapshot, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
        Volume volume = _dbClient.queryObject(Volume.class, snapshotObj.getParent());
        TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
        String tenantName = tenant.getLabel();
        String snapLabelToUse = _nameGenerator.generate(tenantName, snapshotObj.getLabel(), snapshot.toString(), '-', SmisConstants.MAX_SNAPSHOT_NAME_LENGTH);
        VNXeApiClient apiClient = getVnxeClient(storage);
        VNXeCommandJob job = apiClient.createLunSnap(volume.getNativeId(), snapLabelToUse);
        if (job != null) {
            ControllerServiceImpl.enqueueJob(new QueueJob(new VNXeBlockSnapshotCreateJob(job.getId(), storage.getId(), !createInactive, taskCompleter)));
        }
    } catch (VNXeException e) {
        _log.error("Create volume snapshot got the exception", e);
        taskCompleter.error(_dbClient, e);
    } catch (Exception ex) {
        _log.error("Create volume snapshot got the exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateVolumeSnapshot", ex.getMessage());
        taskCompleter.error(_dbClient, error);
    }
}
Also used : VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeException(com.emc.storageos.vnxe.VNXeException) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) VNXeBlockSnapshotCreateJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeBlockSnapshotCreateJob) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) VNXeException(com.emc.storageos.vnxe.VNXeException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 49 with TenantOrg

use of com.emc.storageos.db.client.model.TenantOrg in project coprhd-controller by CoprHD.

the class VNXeStorageDevice method doCreateVolumes.

@Override
public void doCreateVolumes(StorageSystem storage, StoragePool storagePool, String opId, List<Volume> volumes, VirtualPoolCapabilityValuesWrapper capabilities, TaskCompleter taskCompleter) throws DeviceControllerException {
    _logger.info("creating volumes, array: {}, pool : {}", storage.getSerialNumber(), storagePool.getNativeId());
    VNXeApiClient apiClient = getVnxeClient(storage);
    List<String> jobs = new ArrayList<String>();
    boolean opFailed = false;
    try {
        boolean isCG = false;
        Volume vol = volumes.get(0);
        if (vol.getConsistencyGroup() != null) {
            isCG = true;
        }
        List<String> volNames = new ArrayList<String>();
        String autoTierPolicyName = null;
        InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_022);
        for (Volume volume : volumes) {
            String tenantName = "";
            try {
                TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
                tenantName = tenant.getLabel();
            } catch (DatabaseException e) {
                _logger.error("Error lookup TenantOrb object", e);
            }
            String label = nameGenerator.generate(tenantName, volume.getLabel(), volume.getId().toString(), '-', VNXeConstants.MAX_NAME_LENGTH);
            autoTierPolicyName = ControllerUtils.getAutoTieringPolicyName(volume.getId(), _dbClient);
            if (autoTierPolicyName.equals(Constants.NONE)) {
                autoTierPolicyName = null;
            }
            volume.setNativeGuid(label);
            _dbClient.persistObject(volume);
            if (!isCG) {
                VNXeCommandJob job = apiClient.createLun(label, storagePool.getNativeId(), volume.getCapacity(), volume.getThinlyProvisioned(), autoTierPolicyName);
                jobs.add(job.getId());
            } else {
                volNames.add(label);
            }
        }
        if (isCG) {
            URI cg = vol.getConsistencyGroup();
            BlockConsistencyGroup cgObj = _dbClient.queryObject(BlockConsistencyGroup.class, cg);
            String cgId = cgObj.getCgNameOnStorageSystem(storage.getId());
            VNXeCommandJob job = apiClient.createLunsInLunGroup(volNames, storagePool.getNativeId(), vol.getCapacity(), vol.getThinlyProvisioned(), autoTierPolicyName, cgId);
            jobs.add(job.getId());
        }
        VNXeCreateVolumesJob createVolumesJob = new VNXeCreateVolumesJob(jobs, storage.getId(), taskCompleter, storagePool.getId(), isCG);
        ControllerServiceImpl.enqueueJob(new QueueJob(createVolumesJob));
        InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_023);
    } catch (VNXeException e) {
        _logger.error("Create volumes got the exception", e);
        opFailed = true;
        taskCompleter.error(_dbClient, e);
    } catch (Exception ex) {
        _logger.error("Create volumes got the exception", ex);
        opFailed = true;
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateVolumes", ex.getMessage());
        taskCompleter.error(_dbClient, error);
    }
    if (opFailed) {
        for (Volume vol : volumes) {
            vol.setInactive(true);
            _dbClient.persistObject(vol);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) ArrayList(java.util.ArrayList) VNXeCreateVolumesJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeCreateVolumesJob) URI(java.net.URI) VNXeException(com.emc.storageos.vnxe.VNXeException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) Volume(com.emc.storageos.db.client.model.Volume) VNXeException(com.emc.storageos.vnxe.VNXeException) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob)

Example 50 with TenantOrg

use of com.emc.storageos.db.client.model.TenantOrg in project coprhd-controller by CoprHD.

the class VNXeStorageDevice method doCreateConsistencyGroup.

@Override
public void doCreateConsistencyGroup(StorageSystem storage, URI consistencyGroup, String replicationGroupName, TaskCompleter taskCompleter) throws DeviceControllerException {
    _logger.info("creating consistency group, array: {}", storage.getSerialNumber());
    BlockConsistencyGroup consistencyGroupObj = _dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroup);
    VNXeApiClient apiClient = getVnxeClient(storage);
    String tenantName = "";
    try {
        TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, consistencyGroupObj.getTenant().getURI());
        tenantName = tenant.getLabel();
    } catch (DatabaseException e) {
        _logger.error("Error lookup TenantOrb object", e);
    }
    String label = nameGenerator.generate(tenantName, consistencyGroupObj.getLabel(), consistencyGroupObj.getId().toString(), '-', VNXeConstants.MAX_NAME_LENGTH);
    try {
        VNXeCommandResult result = apiClient.createLunGroup(label);
        if (result.getStorageResource() != null) {
            consistencyGroupObj.addSystemConsistencyGroup(storage.getId().toString(), result.getStorageResource().getId());
            consistencyGroupObj.addConsistencyGroupTypes(Types.LOCAL.name());
            if (NullColumnValueGetter.isNullURI(consistencyGroupObj.getStorageController())) {
                consistencyGroupObj.setStorageController(storage.getId());
            }
            _dbClient.persistObject(consistencyGroupObj);
            taskCompleter.ready(_dbClient);
        } else {
            _logger.error("No storage resource Id returned");
            consistencyGroupObj.setInactive(true);
            _dbClient.persistObject(consistencyGroupObj);
            ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateConsistencyGroup failed");
            taskCompleter.error(_dbClient, error);
        }
    } catch (Exception e) {
        _logger.error("Exception caught when createing consistency group ", e);
        consistencyGroupObj.setInactive(true);
        _dbClient.persistObject(consistencyGroupObj);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateConsistencyGroup", e.getMessage());
        taskCompleter.error(_dbClient, error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeCommandResult(com.emc.storageos.vnxe.models.VNXeCommandResult) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) VNXeException(com.emc.storageos.vnxe.VNXeException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Aggregations

TenantOrg (com.emc.storageos.db.client.model.TenantOrg)138 URI (java.net.URI)64 NamedURI (com.emc.storageos.db.client.model.NamedURI)57 Project (com.emc.storageos.db.client.model.Project)54 Volume (com.emc.storageos.db.client.model.Volume)41 ArrayList (java.util.ArrayList)40 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)37 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)34 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)33 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)29 StringSet (com.emc.storageos.db.client.model.StringSet)29 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)28 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)26 Produces (javax.ws.rs.Produces)26 StoragePool (com.emc.storageos.db.client.model.StoragePool)25 List (java.util.List)23 Test (org.junit.Test)23 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)22 StringMap (com.emc.storageos.db.client.model.StringMap)21 Consumes (javax.ws.rs.Consumes)21