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 });
}
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 });
}
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);
}
}
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);
}
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);
}
Aggregations