Search in sources :

Example 16 with ServiceCodeException

use of com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException in project coprhd-controller by CoprHD.

the class SmisCommandHelper method getSettingsDefineStateForSource.

/**
 * Retrieve the Clar_SettingsDefineState_RG_SAFS instance represented by the given
 * Clar_SynchronizationAspectForSourceGroup instance ID
 *
 * @param storageSystem
 *            - StorageArray reference, will be used to lookup SMI-S connection
 * @param synchAspectinstanceID
 *            - Clar_SynchronizationAspectForSourceGroup instance ID to look for
 * @return
 * @throws Exception
 *             - If it is not able to find the given id
 */
public CIMObjectPath getSettingsDefineStateForSource(StorageSystem storageSystem, String synchAspectinstanceID) throws Exception {
    boolean isVmax = (storageSystem.getSystemType().equals(DiscoveredDataObject.Type.vmax.name()));
    String className = (isVmax) ? SYMM_SETTINGS_DEFINE_STATE_SV_SAFS : CLAR_SETTINGS_DEFINE_STATE_SV_SAFS;
    CloseableIterator<CIMInstance> instances = getInstances(storageSystem, ROOT_EMC_NAMESPACE, className, true, false, false, new String[] { CP_INSTANCE_ID });
    try {
        while (instances.hasNext()) {
            CIMInstance instance = instances.next();
            CIMObjectPath settingsPath = instance.getObjectPath();
            CIMObjectPath syncPath = (CIMObjectPath) settingsPath.getKey(CP_SETTING_DATA).getValue();
            String instanceID = (String) syncPath.getKey(CP_INSTANCE_ID).getValue();
            if (instanceID.equals(synchAspectinstanceID)) {
                return settingsPath;
            }
        }
    } finally {
        closeCIMIterator(instances);
    }
    throw new ServiceCodeException(ServiceCode.CONTROLLER_ERROR, "Unable to find instance of Clar_SettingsDefineState_SV_SAFS with " + "Clar_SynchronizationAspectForSource={0}", new Object[] { synchAspectinstanceID });
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) ServiceCodeException(com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException) CIMInstance(javax.cim.CIMInstance)

Example 17 with ServiceCodeException

use of com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException in project coprhd-controller by CoprHD.

the class SmisCommandHelper method getSettingsDefineStateForSourceGroup.

/**
 * Retrieve the Clar_SettingsDefineState_RG_SAFS instance represented by the given
 * Clar_SynchronizationAspectForSourceGroup instance ID
 *
 * @param storageSystem
 *            - StorageArray reference, will be used to lookup SMI-S connection
 * @param synchAspectinstanceID
 *            - Clar_SynchronizationAspectForSourceGroup instance ID to look for
 * @return
 * @throws Exception
 *             - If it is not able to find the given id
 */
public CIMObjectPath getSettingsDefineStateForSourceGroup(StorageSystem storageSystem, String synchAspectinstanceID) throws Exception {
    CloseableIterator<CIMInstance> instances = getInstances(storageSystem, ROOT_EMC_NAMESPACE, CLAR_SETTINGS_DEFINE_STATE_RG_SAFS, true, false, false, new String[] { CP_INSTANCE_ID });
    try {
        while (instances.hasNext()) {
            CIMInstance instance = instances.next();
            CIMObjectPath settingsPath = instance.getObjectPath();
            CIMObjectPath syncPath = (CIMObjectPath) settingsPath.getKey(CP_SETTING_DATA).getValue();
            String instanceID = (String) syncPath.getKey(CP_INSTANCE_ID).getValue();
            if (instanceID.equals(synchAspectinstanceID)) {
                return settingsPath;
            }
        }
    } finally {
        closeCIMIterator(instances);
    }
    throw new ServiceCodeException(ServiceCode.CONTROLLER_ERROR, "Unable to find instance of Clar_SettingsDefineState_RG_SAFS with Clar_SynchronizationAspectForSourceGroup={0}", new Object[] { synchAspectinstanceID });
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) ServiceCodeException(com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException) CIMInstance(javax.cim.CIMInstance)

Example 18 with ServiceCodeException

use of com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException in project coprhd-controller by CoprHD.

the class VPlexBlockServiceApiImpl method upgradeToDistributed.

/**
 * Upgrade a local VPLEX volume to a distributed VPLEX volume.
 *
 * @param vplexURI -- VPLEX System URI
 * @param vplexVolume -- VPlex volume (existing).
 * @param vpool -- Requested vpool.
 * @param taskId
 * @throws InternalException
 */
private void upgradeToDistributed(URI vplexURI, Volume vplexVolume, VirtualPool vpool, String transferSpeed, String taskId) throws InternalException {
    try {
        VirtualArray neighborhood = _dbClient.queryObject(VirtualArray.class, vplexVolume.getVirtualArray());
        Set<URI> vplexes = new HashSet<URI>();
        vplexes.add(vplexURI);
        if (null == vplexVolume.getAssociatedVolumes() || vplexVolume.getAssociatedVolumes().isEmpty()) {
            s_logger.error("VPLEX volume {} has no backend volumes.", vplexVolume.forDisplay());
            throw InternalServerErrorException.internalServerErrors.noAssociatedVolumesForVPLEXVolume(vplexVolume.forDisplay());
        }
        Iterator<String> assocIter = vplexVolume.getAssociatedVolumes().iterator();
        URI existingVolumeURI = new URI(assocIter.next());
        Volume existingVolume = _dbClient.queryObject(Volume.class, existingVolumeURI);
        if (existingVolume == null || existingVolume.getInactive() == true) {
            throw new ServiceCodeException(ServiceCode.UNFORSEEN_ERROR, "Existing volume inactive", new Object[] {});
        }
        VirtualPoolCapabilityValuesWrapper cosCapabilities = new VirtualPoolCapabilityValuesWrapper();
        cosCapabilities.put(VirtualPoolCapabilityValuesWrapper.SIZE, getVolumeCapacity(existingVolume));
        cosCapabilities.put(VirtualPoolCapabilityValuesWrapper.RESOURCE_COUNT, new Integer(1));
        cosCapabilities.put(VirtualPoolCapabilityValuesWrapper.THIN_PROVISIONING, existingVolume.getThinlyProvisioned());
        // Get a recommendation.
        // Then create the volume.
        List<VolumeDescriptor> descriptors = new ArrayList<VolumeDescriptor>();
        Volume createVolume = null;
        // Determine if the user requested a specific HA VirtualArray and an associated HA VirtualPool.
        VirtualArray requestedHaVarray = null;
        VirtualPool requestedHaVirtualPool = vpool;
        if (vpool.getHaVarrayVpoolMap() != null && !vpool.getHaVarrayVpoolMap().isEmpty()) {
            for (String haNH : vpool.getHaVarrayVpoolMap().keySet()) {
                if (haNH.equals(NullColumnValueGetter.getNullURI().toString())) {
                    continue;
                }
                requestedHaVarray = _dbClient.queryObject(VirtualArray.class, new URI(haNH));
                String haVirtualPool = vpool.getHaVarrayVpoolMap().get(haNH);
                if (haVirtualPool.equals(NullColumnValueGetter.getNullURI().toString())) {
                    continue;
                }
                requestedHaVirtualPool = _dbClient.queryObject(VirtualPool.class, new URI(haVirtualPool));
                break;
            }
        }
        // Get the recommendations and pick one.
        List<Recommendation> recommendations = getBlockScheduler().scheduleStorageForImport(neighborhood, vplexes, requestedHaVarray, requestedHaVirtualPool, cosCapabilities);
        if (recommendations.isEmpty()) {
            throw APIException.badRequests.noStorageFoundForVolumeMigration(requestedHaVirtualPool.getLabel(), requestedHaVarray.getLabel(), existingVolume.getId());
        }
        Recommendation recommendation = recommendations.get(0);
        VPlexRecommendation vplexRecommendation = (VPlexRecommendation) recommendation;
        if (false == vplexURI.equals(vplexRecommendation.getVPlexStorageSystem())) {
            APIException.badRequests.vplexPlacementError(vplexVolume.getId());
        }
        StorageSystem vplexSystem = _dbClient.queryObject(StorageSystem.class, vplexURI);
        Project vplexProject = getVplexProject(vplexSystem, _dbClient, _tenantsService);
        // Prepare the created volume.
        VirtualArray haVirtualArray = _dbClient.queryObject(VirtualArray.class, vplexRecommendation.getVirtualArray());
        createVolume = prepareVolumeForRequest(getVolumeCapacity(existingVolume), vplexProject, haVirtualArray, requestedHaVirtualPool, vplexRecommendation.getSourceStorageSystem(), vplexRecommendation.getSourceStoragePool(), vplexVolume.getLabel() + "-1", ResourceOperationTypeEnum.CREATE_BLOCK_VOLUME, taskId, _dbClient);
        createVolume.addInternalFlags(Flag.INTERNAL_OBJECT);
        _dbClient.updateObject(createVolume);
        VolumeDescriptor desc = new VolumeDescriptor(VolumeDescriptor.Type.BLOCK_DATA, createVolume.getStorageController(), createVolume.getId(), createVolume.getPool(), cosCapabilities);
        descriptors.add(desc);
        // Add a descriptor for the VPlex Virtual Volume.
        desc = new VolumeDescriptor(VolumeDescriptor.Type.VPLEX_VIRT_VOLUME, vplexVolume.getStorageController(), vplexVolume.getId(), vplexVolume.getPool(), cosCapabilities);
        descriptors.add(desc);
        // Now send the command to the controller.
        try {
            s_logger.info("Calling VPlex controller.");
            VPlexController controller = getController();
            controller.importVolume(vplexURI, descriptors, null, null, vpool.getId(), null, transferSpeed, Boolean.TRUE, taskId);
        // controller.importVolume(vplexURI, vpool.getId(),
        // null, null, /* no need to pass System Project/Tenant */
        // null, /* no import volume */
        // createVolume.getId(), vplexVolume.getId(), taskId);
        } catch (InternalException ex) {
            s_logger.error("ControllerException on upgradeToDistributed", ex);
            String errMsg = String.format("ControllerException: %s", ex.getMessage());
            Operation statusUpdate = new Operation(Operation.Status.error.name(), errMsg);
            _dbClient.updateTaskOpStatus(Volume.class, vplexVolume.getId(), taskId, statusUpdate);
            throw ex;
        }
    } catch (URISyntaxException ex) {
        s_logger.debug("URISyntaxException", ex);
    }
}
Also used : VirtualPoolCapabilityValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) VPlexRecommendation(com.emc.storageos.volumecontroller.VPlexRecommendation) VPlexController(com.emc.storageos.vplexcontroller.VPlexController) ServiceCodeException(com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) Operation(com.emc.storageos.db.client.model.Operation) URISyntaxException(java.net.URISyntaxException) FCTN_STRING_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) FCTN_VPLEX_MIRROR_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_VPLEX_MIRROR_TO_URI) SRDFCopyRecommendation(com.emc.storageos.volumecontroller.SRDFCopyRecommendation) VolumeRecommendation(com.emc.storageos.api.service.impl.placement.VolumeRecommendation) VPlexRecommendation(com.emc.storageos.volumecontroller.VPlexRecommendation) Recommendation(com.emc.storageos.volumecontroller.Recommendation) SRDFRecommendation(com.emc.storageos.volumecontroller.SRDFRecommendation) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) Project(com.emc.storageos.db.client.model.Project) Volume(com.emc.storageos.db.client.model.Volume) HashSet(java.util.HashSet) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 19 with ServiceCodeException

use of com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException in project coprhd-controller by CoprHD.

the class ServiceCodeExceptionTest method invalidACL.

@Test
public void invalidACL() {
    final String acl = "ace";
    final ServiceCodeException exception = new ServiceCodeException(API_PARAMETER_INVALID, "invalid acl: {0}", new Object[] { acl });
    assertApiBadParameters("invalid acl: " + acl, exception);
}
Also used : ServiceCodeException(com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException) Test(org.junit.Test) BaseServiceCodeExceptionTest(com.emc.storageos.svcs.errorhandling.mappers.BaseServiceCodeExceptionTest)

Example 20 with ServiceCodeException

use of com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException in project coprhd-controller by CoprHD.

the class ServiceCodeExceptionTest method rootNoDelete.

@Test
public void rootNoDelete() {
    final ServiceCodeException exception = new ServiceCodeException(API_PARAMETER_INVALID, "Root tenant can not be deleted", null);
    assertApiBadParameters("Root tenant can not be deleted", exception);
}
Also used : ServiceCodeException(com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException) Test(org.junit.Test) BaseServiceCodeExceptionTest(com.emc.storageos.svcs.errorhandling.mappers.BaseServiceCodeExceptionTest)

Aggregations

ServiceCodeException (com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException)37 BaseServiceCodeExceptionTest (com.emc.storageos.svcs.errorhandling.mappers.BaseServiceCodeExceptionTest)27 Test (org.junit.Test)27 URI (java.net.URI)10 Operation (com.emc.storageos.db.client.model.Operation)5 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)5 ArrayList (java.util.ArrayList)5 DataObject (com.emc.storageos.db.client.model.DataObject)4 Volume (com.emc.storageos.db.client.model.Volume)4 BlockObject (com.emc.storageos.db.client.model.BlockObject)3 DiscoveredDataObject (com.emc.storageos.db.client.model.DiscoveredDataObject)3 NamedURI (com.emc.storageos.db.client.model.NamedURI)3 MapVolume (com.emc.storageos.api.mapper.functions.MapVolume)2 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)2 StringMap (com.emc.storageos.db.client.model.StringMap)2 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)2 NullColumnValueGetter.isNullURI (com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI)2 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)2 HashMap (java.util.HashMap)2 List (java.util.List)2