Search in sources :

Example 76 with TenantOrg

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

the class DbClientTest method createTenants.

private List<TenantOrg> createTenants(int count, String label, String indexKey) {
    List<TenantOrg> tenants = new ArrayList<>(count);
    for (int i = 0; i < count; i++) {
        TenantOrg t = new TenantOrg();
        t.setId(URIUtil.createId(TenantOrg.class));
        t.setLabel(label);
        t.setRoleAssignments(new StringSetMap());
        t.addRole(indexKey, "role1");
        t.addRole(indexKey, "role2");
        _dbClient.createObject(t);
        tenants.add(t);
    }
    return tenants;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) ArrayList(java.util.ArrayList) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentPrefixConstraint(com.emc.storageos.db.client.constraint.ContainmentPrefixConstraint) AggregatedConstraint(com.emc.storageos.db.client.constraint.AggregatedConstraint) ContainmentPermissionsConstraint(com.emc.storageos.db.client.constraint.ContainmentPermissionsConstraint) Constraint(com.emc.storageos.db.client.constraint.Constraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint)

Example 77 with TenantOrg

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

the class DbClientTest method testContainmentPaginateConstraint.

@Test
public void testContainmentPaginateConstraint() throws Exception {
    TenantOrg tenant = new TenantOrg();
    tenant.setId(URIUtil.createId(TenantOrg.class));
    _dbClient.createObject(tenant);
    int objCount = 10;
    List<Project> projects = createProjects(objCount, tenant);
    Constraint constraint = ContainmentConstraint.Factory.getTenantOrgProjectConstraint(tenant.getId());
    queryInPaginate(constraint, URIQueryResultList.class, objCount, pageSize);
}
Also used : Project(com.emc.storageos.db.client.model.Project) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentPrefixConstraint(com.emc.storageos.db.client.constraint.ContainmentPrefixConstraint) AggregatedConstraint(com.emc.storageos.db.client.constraint.AggregatedConstraint) ContainmentPermissionsConstraint(com.emc.storageos.db.client.constraint.ContainmentPermissionsConstraint) Constraint(com.emc.storageos.db.client.constraint.Constraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentPrefixConstraint(com.emc.storageos.db.client.constraint.ContainmentPrefixConstraint) AggregatedConstraint(com.emc.storageos.db.client.constraint.AggregatedConstraint) ContainmentPermissionsConstraint(com.emc.storageos.db.client.constraint.ContainmentPermissionsConstraint) Constraint(com.emc.storageos.db.client.constraint.Constraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) Test(org.junit.Test)

Example 78 with TenantOrg

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

the class DbClientTest method testContainmentPermissionsPaginateConstraint.

@Test
public void testContainmentPermissionsPaginateConstraint() throws Exception {
    int objCount = 10;
    String indexKey = "indexKey1";
    List<TenantOrg> tenants = createTenants(objCount, "test tenant", indexKey);
    Constraint constraint = ContainmentPermissionsConstraint.Factory.getTenantsWithPermissionsConstraint(indexKey);
    queryInPaginate(constraint, URIQueryResultList.class, objCount, 3, 5);
}
Also used : PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentPrefixConstraint(com.emc.storageos.db.client.constraint.ContainmentPrefixConstraint) AggregatedConstraint(com.emc.storageos.db.client.constraint.AggregatedConstraint) ContainmentPermissionsConstraint(com.emc.storageos.db.client.constraint.ContainmentPermissionsConstraint) Constraint(com.emc.storageos.db.client.constraint.Constraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentPrefixConstraint(com.emc.storageos.db.client.constraint.ContainmentPrefixConstraint) AggregatedConstraint(com.emc.storageos.db.client.constraint.AggregatedConstraint) ContainmentPermissionsConstraint(com.emc.storageos.db.client.constraint.ContainmentPermissionsConstraint) Constraint(com.emc.storageos.db.client.constraint.Constraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) Test(org.junit.Test)

Example 79 with TenantOrg

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

the class CinderStorageDevice 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(StorageSystem storageSystem, StoragePool storagePool, String opId, List<Volume> volumes, VirtualPoolCapabilityValuesWrapper capabilities, TaskCompleter taskCompleter) throws DeviceControllerException {
    String label = null;
    Long capacity = null;
    boolean opCreationFailed = false;
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Create Volume Start - Array:%s, Pool:%s", storageSystem.getSerialNumber(), storagePool.getNativeGuid()));
    for (Volume volume : volumes) {
        logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
        String tenantName = "";
        try {
            TenantOrg tenant = dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
            tenantName = tenant.getLabel();
        } catch (DatabaseException e) {
            log.error("Error lookup TenantOrg object", e);
        }
        label = nameGenerator.generate(tenantName, volume.getLabel(), volume.getId().toString(), CinderConstants.CHAR_HYPHEN, SmisConstants.MAX_VOLUME_NAME_LENGTH);
        if (capacity == null) {
            capacity = volume.getCapacity();
        }
    }
    log.info(logMsgBuilder.toString());
    try {
        CinderEndPointInfo ep = CinderUtils.getCinderEndPoint(storageSystem.getActiveProviderURI(), dbClient);
        log.info("Getting the cinder APi for the provider with id {}", storageSystem.getActiveProviderURI());
        CinderApi cinderApi = cinderApiFactory.getApi(storageSystem.getActiveProviderURI(), ep);
        String volumeId = null;
        Map<String, URI> volumeIds = new HashMap<String, URI>();
        if (volumes.size() == 1) {
            volumeId = cinderApi.createVolume(label, CinderUtils.convertToGB(capacity), storagePool.getNativeId());
            volumeIds.put(volumeId, volumes.get(0).getId());
            log.debug("Creating volume with the id {} on Openstack cinder node", volumeId);
        } else {
            log.debug("Starting to create {} volumes", volumes.size());
            for (int volumeIndex = 0; volumeIndex < volumes.size(); volumeIndex++) {
                volumeId = cinderApi.createVolume(label + CinderConstants.HYPHEN + (volumeIndex + 1), CinderUtils.convertToGB(capacity), storagePool.getNativeId());
                volumeIds.put(volumeId, volumes.get(volumeIndex).getId());
                log.debug("Creating volume with the id {} on Openstack cinder node", volumeId);
            }
        }
        if (!volumeIds.isEmpty()) {
            CinderJob createVolumeJob = (volumes.size() > 1) ? new CinderMultiVolumeCreateJob(volumeId, label, volumes.get(0).getStorageController(), CinderConstants.ComponentType.volume.name(), ep, taskCompleter, storagePool.getId(), volumeIds) : new CinderSingleVolumeCreateJob(volumeId, label, volumes.get(0).getStorageController(), CinderConstants.ComponentType.volume.name(), ep, taskCompleter, storagePool.getId(), volumeIds);
            ControllerServiceImpl.enqueueJob(new QueueJob(createVolumeJob));
        }
    } catch (final InternalException e) {
        log.error("Problem in doCreateVolumes: ", e);
        opCreationFailed = true;
        taskCompleter.error(dbClient, e);
    } catch (final Exception e) {
        log.error("Problem in doCreateVolumes: ", e);
        opCreationFailed = true;
        ServiceError serviceError = DeviceControllerErrors.cinder.operationFailed("doCreateVolumes", e.getMessage());
        taskCompleter.error(dbClient, serviceError);
    }
    if (opCreationFailed) {
        for (Volume vol : volumes) {
            vol.setInactive(true);
            dbClient.persistObject(vol);
        }
    }
    logMsgBuilder = new StringBuilder(String.format("Create Volumes End - Array:%s, Pool:%s", storageSystem.getSerialNumber(), storagePool.getNativeGuid()));
    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) HashMap(java.util.HashMap) CinderApi(com.emc.storageos.cinder.api.CinderApi) CinderSingleVolumeCreateJob(com.emc.storageos.volumecontroller.impl.cinder.job.CinderSingleVolumeCreateJob) URI(java.net.URI) CinderJob(com.emc.storageos.volumecontroller.impl.cinder.job.CinderJob) CinderException(com.emc.storageos.cinder.errorhandling.CinderException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) Volume(com.emc.storageos.db.client.model.Volume) CinderEndPointInfo(com.emc.storageos.cinder.CinderEndPointInfo) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) CinderMultiVolumeCreateJob(com.emc.storageos.volumecontroller.impl.cinder.job.CinderMultiVolumeCreateJob) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob)

Example 80 with TenantOrg

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

the class HDSProtectionOperations method createSecondaryVolumeForMirror.

/**
 * Creates secondary volume for ShadowImage pair operations.
 *
 * @param storageSystem
 * @param sourceVolume
 * @param mirror
 * @throws Exception
 */
public void createSecondaryVolumeForMirror(StorageSystem storageSystem, URI sourceVolume, BlockMirror mirror) throws Exception {
    log.info("SecondaryVolume for mirror creation operation started");
    String taskId = UUID.randomUUID().toString();
    TaskCompleter taskCompleter = new BlockMirrorCreateCompleter(mirror.getId(), taskId);
    String asyncTaskMessageId = null;
    HDSApiClient hdsApiClient = HDSUtils.getHDSApiClient(hdsApiFactory, storageSystem);
    String systemObjectID = HDSUtils.getSystemObjectID(storageSystem);
    StoragePool targetPool = dbClient.queryObject(StoragePool.class, mirror.getPool());
    Volume source = dbClient.queryObject(Volume.class, sourceVolume);
    TenantOrg tenant = dbClient.queryObject(TenantOrg.class, source.getTenant().getURI());
    String tenantName = tenant.getLabel();
    String targetLabelToUse = nameGenerator.generate(tenantName, mirror.getLabel(), mirror.getId().toString(), '-', HDSConstants.MAX_VOLUME_NAME_LENGTH);
    if (mirror.getThinlyProvisioned()) {
        asyncTaskMessageId = hdsApiClient.createThinVolumes(systemObjectID, targetPool.getNativeId(), mirror.getCapacity(), 1, targetLabelToUse, HDSConstants.QUICK_FORMAT_TYPE, storageSystem.getModel());
    } else {
        String poolObjectID = HDSUtils.getPoolObjectID(targetPool);
        asyncTaskMessageId = hdsApiClient.createThickVolumes(systemObjectID, poolObjectID, mirror.getCapacity(), 1, targetLabelToUse, null, storageSystem.getModel(), null);
    }
    if (asyncTaskMessageId != null) {
        HDSJob createHDSJob = new HDSBlockCreateMirrorJob(asyncTaskMessageId, mirror.getStorageController(), targetPool.getId(), taskCompleter);
        hdsCommandHelper.waitForAsyncHDSJob(createHDSJob);
    } else {
        throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the create volume call");
    }
    log.info("SecondaryVolume for mirror creation operation completed successfully");
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) StoragePool(com.emc.storageos.db.client.model.StoragePool) HDSJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob) Volume(com.emc.storageos.db.client.model.Volume) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) BlockMirrorCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockMirrorCreateCompleter) HDSBlockCreateMirrorJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSBlockCreateMirrorJob)

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