Search in sources :

Example 21 with ServiceErrorException

use of com.emc.vipr.client.exceptions.ServiceErrorException in project coprhd-controller by CoprHD.

the class ApiSystemTestUtil method createVolume.

public List<URI> createVolume(String name, String size, Integer count, URI vpool, URI varray, URI project, URI cg) {
    List<URI> volumes = new ArrayList<URI>();
    VolumeCreate createParam = new VolumeCreate();
    createParam.setName(name);
    createParam.setSize(size);
    ;
    createParam.setCount(count);
    createParam.setVpool(vpool);
    createParam.setVarray(varray);
    createParam.setProject(project);
    createParam.setConsistencyGroup(cg);
    try {
        Tasks<VolumeRestRep> tasks = client.blockVolumes().create(createParam);
        for (VolumeRestRep volumeRestRep : tasks.get()) {
            log.info(String.format("Volume %s (%s) created", volumeRestRep.getName(), volumeRestRep.getNativeId()));
            volumes.add(volumeRestRep.getId());
        }
        return volumes;
    } catch (ServiceErrorException ex) {
        log.error("Exception creating virtual volumes " + ex.getMessage(), ex);
        throw ex;
    }
}
Also used : ArrayList(java.util.ArrayList) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) UnManagedVolumeRestRep(com.emc.storageos.model.block.UnManagedVolumeRestRep) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) URI(java.net.URI) VolumeCreate(com.emc.storageos.model.block.VolumeCreate)

Example 22 with ServiceErrorException

use of com.emc.vipr.client.exceptions.ServiceErrorException in project coprhd-controller by CoprHD.

the class CustomConfigs method update.

@FlashException
public static void update(String id, String configType, String scopeType, String scopeValue, String value) {
    CustomConfigRestRep customConfig = CustomConfigUtils.getCustomConfig(uri(id));
    ScopeParam scope = customConfig.getScope();
    try {
        if (!scope.getType().equals(scopeType) || !scope.getValue().equals(scopeValue)) {
            CustomConfigUtils.deleteCustomConfig(uri(id));
            CustomConfigUtils.createCustomConfig(configType, scopeType, scopeValue, value);
        } else {
            CustomConfigUtils.updateCustomConfig(uri(id), value);
        }
    } catch (ServiceErrorException ex) {
        flash.error(MessagesUtils.get("CustomConfigs.error.update", value, MessagesUtils.get("CustomConfigs.configType." + configType)));
    }
}
Also used : CustomConfigRestRep(com.emc.storageos.model.customconfig.CustomConfigRestRep) ConfigTypeScopeParam(com.emc.storageos.model.customconfig.ConfigTypeScopeParam) ScopeParam(com.emc.storageos.model.customconfig.ScopeParam) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) FlashException(controllers.util.FlashException)

Example 23 with ServiceErrorException

use of com.emc.vipr.client.exceptions.ServiceErrorException in project coprhd-controller by CoprHD.

the class ComputeVirtualPools method saveTenantACLs.

/**
 * Saves tenant ACLs on the virtual compute pool.
 *
 * @param vpoolId
 *            the virtual compute pool ID.
 * @param tenants
 *            the tenant ACLs.
 * @param enableTenants
 *            the checked status for "Grant Access to Tenants".
 */
private static void saveTenantACLs(String vpoolId, List<String> tenants, Boolean enableTenants) {
    Set<String> tenantIds = Sets.newHashSet();
    if (isTrue(enableTenants) && tenants != null) {
        tenantIds.addAll(tenants);
    }
    ACLUpdateBuilder builder = new ACLUpdateBuilder(ComputeVirtualPoolUtils.getComputeACLs(vpoolId));
    builder.setTenants(tenantIds);
    try {
        ComputeVirtualPoolUtils.updateComputeACLs(vpoolId, builder.getACLUpdate());
    } catch (ViPRException e) {
        Logger.error(e, "Failed to update Compute Virtual Pool ACLs");
        String errorDesc = e.getMessage();
        if (e instanceof ServiceErrorException) {
            errorDesc = ((ServiceErrorException) e).getDetailedMessage();
        }
        flash.error(MessagesUtils.get("computeVirtualPool.updateComputeVirtualPoolACLs.failed", errorDesc));
    }
}
Also used : ViPRException(com.emc.vipr.client.exceptions.ViPRException) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) ACLUpdateBuilder(util.builders.ACLUpdateBuilder)

Example 24 with ServiceErrorException

use of com.emc.vipr.client.exceptions.ServiceErrorException in project coprhd-controller by CoprHD.

the class FileSnapshots method addSnapshotAcl.

/**
 * This method called when user Adds an access control entry from UI.
 *
 * @param aclURL
 *            URL of the snapshot share.
 * @param shareACL
 *            This contains the form data from UI.
 */
public static void addSnapshotAcl(String aclURL, SnapshotShareACLForm shareACL, String formAccessControlList) {
    String snapshotId = null;
    String shareName = null;
    if (StringUtils.isNotBlank(aclURL)) {
        String[] parts = aclURL.split("/");
        if (parts.length == 7) {
            snapshotId = parts[3];
            shareName = parts[5];
        }
    }
    if (formAccessControlList == null || "".equals(formAccessControlList)) {
        flash.error(MessagesUtils.get("resources.filesystem.share.acl.invalid.settings"), null);
        listSnapshotAcl(snapshotId, shareName);
    }
    SnapshotCifsShareACLUpdateParams input = createSnapshotCifsShareAclParams(formAccessControlList);
    ViPRCoreClient client = BourneUtil.getViprClient();
    try {
        client.fileSnapshots().updateShareACL(uri(snapshotId), shareName, input);
    } catch (ServiceErrorException e) {
        flash.error(e.getMessage(), null);
        listSnapshotAcl(snapshotId, shareName);
    }
    flash.success(MessagesUtils.get("resources.filesystem.share.acl.added"));
    listSnapshotAcl(snapshotId, shareName);
}
Also used : SnapshotCifsShareACLUpdateParams(com.emc.storageos.model.file.SnapshotCifsShareACLUpdateParams) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException)

Example 25 with ServiceErrorException

use of com.emc.vipr.client.exceptions.ServiceErrorException in project coprhd-controller by CoprHD.

the class FileSystems method addShareAcl.

/**
 * This method called when user Adds an access control entry from UI.
 *
 * @param aclURL
 *            URL of the file system share.
 * @param shareACL
 *            This contains the form data from UI.
 */
public static void addShareAcl(String aclURL, ShareACLForm shareACL, String formAccessControlList) {
    String fileSystem = null;
    String shareName = null;
    if (StringUtils.isNotBlank(aclURL)) {
        String[] parts = aclURL.split("/");
        if (parts.length == 7) {
            fileSystem = parts[3];
            shareName = parts[5];
        }
    }
    if (formAccessControlList == null || "".equals(formAccessControlList)) {
        flash.error(MessagesUtils.get("resources.filesystem.share.acl.invalid.name"), null);
        listAcl(fileSystem, shareName);
    }
    FileCifsShareACLUpdateParams input = createCifsShareAclParams(formAccessControlList);
    ViPRCoreClient client = BourneUtil.getViprClient();
    try {
        client.fileSystems().updateShareACL(uri(fileSystem), shareName, input);
    } catch (ServiceErrorException e) {
        flash.error(e.getMessage(), null);
        listAcl(fileSystem, shareName);
    }
    flash.success(MessagesUtils.get(ADDED));
    listAcl(fileSystem, shareName);
}
Also used : FileCifsShareACLUpdateParams(com.emc.storageos.model.file.FileCifsShareACLUpdateParams) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException)

Aggregations

ServiceErrorException (com.emc.vipr.client.exceptions.ServiceErrorException)26 Test (org.junit.Test)7 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)5 ArrayList (java.util.ArrayList)5 UnManagedVolumeRestRep (com.emc.storageos.model.block.UnManagedVolumeRestRep)4 URI (java.net.URI)4 ViPRException (com.emc.vipr.client.exceptions.ViPRException)3 VolumeCreate (com.emc.storageos.model.block.VolumeCreate)2 ServiceErrorRestRep (com.emc.storageos.model.errorhandling.ServiceErrorRestRep)2 TenantUpdateParam (com.emc.storageos.model.tenant.TenantUpdateParam)2 UserMappingChanges (com.emc.storageos.model.tenant.UserMappingChanges)2 UserMappingParam (com.emc.storageos.model.tenant.UserMappingParam)2 ViPRClientHelper (com.emc.storageos.usermanagement.util.ViPRClientHelper)2 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)2 ViPRSystemClient (com.emc.vipr.client.ViPRSystemClient)2 FlashException (controllers.util.FlashException)2 ACLUpdateBuilder (util.builders.ACLUpdateBuilder)2 ExecutionException (com.emc.sa.engine.ExecutionException)1 CreateBlockVolumeHelper (com.emc.sa.service.vipr.block.CreateBlockVolumeHelper)1 DeactivateBlockExport (com.emc.sa.service.vipr.block.tasks.DeactivateBlockExport)1