Search in sources :

Example 71 with TenantOrg

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

the class VPlexDeviceController method promoteMirror.

/**
 * This method creates the virtual volume from the detached mirror device.
 *
 * @param vplexURI
 *            The vplex storage system URI
 * @param vplexMirrorURI
 *            The URI of the vplex mirror that needs to be promoted to the virtual volume
 * @param promoteVolumeURI
 *            The URI of the volume will be used as a promoted vplex volume
 * @param stepId
 *            The worflow stepId
 *
 * @throws WorkflowException
 *             When an error occurs updating the workflow step
 *             state.
 */
public void promoteMirror(URI vplexURI, URI vplexMirrorURI, URI promoteVolumeURI, String stepId) throws WorkflowException {
    try {
        WorkflowStepCompleter.stepExecuting(stepId);
        VPlexApiClient client = getVPlexAPIClient(_vplexApiFactory, vplexURI, _dbClient);
        VplexMirror vplexMirror = getDataObject(VplexMirror.class, vplexMirrorURI, _dbClient);
        Volume sourceVplexVolume = getDataObject(Volume.class, vplexMirror.getSource().getURI(), _dbClient);
        Volume promoteVolume = _dbClient.queryObject(Volume.class, promoteVolumeURI);
        // Find virtual volume that should have been created when we did detach mirror.
        // Virtual volume is created with the same name as the device name.
        VPlexVirtualVolumeInfo vvInfo = client.findVirtualVolume(vplexMirror.getDeviceLabel(), null);
        // Get the backend volume for this promoted VPLEX volume.
        StringSet assocVolumes = vplexMirror.getAssociatedVolumes();
        // Get the ViPR label for the promoted VPLEX volume.
        String promotedLabel = String.format("%s-%s", sourceVplexVolume.getLabel(), vplexMirror.getLabel());
        // Rename the vplex volume created using device detach mirror. If custom naming is enabled
        // generate the custom name, else the name follows the default naming convention and must
        // be renamed to append the "_vol" suffix.
        String newVolumeName = null;
        try {
            if (CustomVolumeNamingUtils.isCustomVolumeNamingEnabled(customConfigHandler, DiscoveredDataObject.Type.vplex.name())) {
                String customConfigName = CustomConfigConstants.CUSTOM_VOLUME_NAME;
                Project project = _dbClient.queryObject(Project.class, promoteVolume.getProject().getURI());
                TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, promoteVolume.getTenant().getURI());
                DataSource customNameDataSource = CustomVolumeNamingUtils.getCustomConfigDataSource(project, tenant, promotedLabel, vvInfo.getWwn(), null, dataSourceFactory, customConfigName, _dbClient);
                if (customNameDataSource != null) {
                    newVolumeName = CustomVolumeNamingUtils.getCustomName(customConfigHandler, customConfigName, customNameDataSource, DiscoveredDataObject.Type.vplex.name());
                }
                // Rename the vplex volume created using device detach mirror,
                vvInfo = CustomVolumeNamingUtils.renameVolumeOnVPlex(vvInfo, newVolumeName, client);
                promotedLabel = newVolumeName;
            } else {
                // Build the name for volume so as to rename the vplex volume that is created
                // with the same name as the device name to follow the name pattern _vol
                // as the suffix for the vplex volumes
                StringBuilder volumeNameBuilder = new StringBuilder();
                volumeNameBuilder.append(vplexMirror.getDeviceLabel());
                volumeNameBuilder.append(VPlexApiConstants.VIRTUAL_VOLUME_SUFFIX);
                newVolumeName = volumeNameBuilder.toString();
                // Rename the vplex volume created using device detach mirror,
                vvInfo = CustomVolumeNamingUtils.renameVolumeOnVPlex(vvInfo, newVolumeName, client);
            }
        } catch (Exception e) {
            _log.warn(String.format("Error renaming promoted VPLEX volume %s", promoteVolumeURI), e);
        }
        _log.info(String.format("Renamed promoted virtual volume: %s path: %s", vvInfo.getName(), vvInfo.getPath()));
        // Fill in the details for the promoted vplex volume
        promoteVolume.setLabel(promotedLabel);
        promoteVolume.setNativeId(vvInfo.getPath());
        promoteVolume.setNativeGuid(vvInfo.getPath());
        promoteVolume.setDeviceLabel(vvInfo.getName());
        promoteVolume.setThinlyProvisioned(vvInfo.isThinEnabled());
        promoteVolume.setWWN(vvInfo.getWwn());
        // For Vplex virtual volumes set allocated capacity to 0 (cop-18608)
        promoteVolume.setAllocatedCapacity(0L);
        promoteVolume.setCapacity(vplexMirror.getCapacity());
        promoteVolume.setProvisionedCapacity(vplexMirror.getProvisionedCapacity());
        promoteVolume.setVirtualPool(vplexMirror.getVirtualPool());
        promoteVolume.setVirtualArray(vplexMirror.getVirtualArray());
        promoteVolume.setStorageController(vplexMirror.getStorageController());
        promoteVolume.setSystemType(DiscoveredDataObject.Type.vplex.name());
        promoteVolume.setPool(NullColumnValueGetter.getNullURI());
        promoteVolume.setAssociatedVolumes(new StringSet(assocVolumes));
        promoteVolume.setThinlyProvisioned(vplexMirror.getThinlyProvisioned());
        promoteVolume.setThinVolumePreAllocationSize(vplexMirror.getThinPreAllocationSize());
        // VPLEX volumes created by VIPR have syncActive set to true hence setting same value for promoted vplex
        // volumes
        promoteVolume.setSyncActive(true);
        // Also, we update the name portion of the project and tenant URIs
        // to reflect the new name. This is necessary because the API
        // to search for volumes by project, extracts the name portion of the
        // project URI to get the volume name.
        NamedURI namedURI = promoteVolume.getProject();
        namedURI.setName(promotedLabel);
        promoteVolume.setProject(namedURI);
        namedURI = promoteVolume.getTenant();
        namedURI.setName(promotedLabel);
        promoteVolume.setTenant(namedURI);
        // Remove mirror from the source VPLEX volume
        sourceVplexVolume.getMirrors().remove(vplexMirror.getId().toString());
        _dbClient.updateObject(sourceVplexVolume);
        // Delete the mirror object
        _dbClient.removeObject(vplexMirror);
        // Persist changes for the newly promoted volume
        _dbClient.updateObject(promoteVolume);
        WorkflowStepCompleter.stepSucceded(stepId);
    } catch (VPlexApiException vae) {
        _log.error("Exception promoting mirror volume: " + vae.getMessage(), vae);
        WorkflowStepCompleter.stepFailed(stepId, vae);
    } catch (Exception ex) {
        _log.error("Exception promoting mirror volume: " + ex.getMessage(), ex);
        ServiceError serviceError = VPlexApiException.errors.promoteMirrorFailed(ex);
        WorkflowStepCompleter.stepFailed(stepId, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) NamedURI(com.emc.storageos.db.client.model.NamedURI) VPlexVirtualVolumeInfo(com.emc.storageos.vplex.api.VPlexVirtualVolumeInfo) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) DataSource(com.emc.storageos.customconfigcontroller.DataSource) Project(com.emc.storageos.db.client.model.Project) Volume(com.emc.storageos.db.client.model.Volume) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) VPlexApiClient(com.emc.storageos.vplex.api.VPlexApiClient) StringSet(com.emc.storageos.db.client.model.StringSet) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) VplexMirror(com.emc.storageos.db.client.model.VplexMirror)

Example 72 with TenantOrg

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

the class BlockObjectMultipleConsistencyGroupsMigrationTest method prepareProjectData.

/**
 * Prepares and persists the Project/Tenant data.
 *
 * @throws Exception
 */
private void prepareProjectData() throws Exception {
    TenantOrg tenantOrg = new TenantOrg();
    URI tenantOrgURI = URIUtil.createId(TenantOrg.class);
    tenantOrg.setId(tenantOrgURI);
    _dbClient.createObject(tenantOrg);
    Project proj = new Project();
    projectURI = URIUtil.createId(Project.class);
    String projectLabel = "project";
    proj.setId(projectURI);
    proj.setLabel(projectLabel);
    proj.setTenantOrg(new NamedURI(tenantOrgURI, projectLabel));
    _dbClient.createObject(proj);
}
Also used : Project(com.emc.storageos.db.client.model.Project) NamedURI(com.emc.storageos.db.client.model.NamedURI) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 73 with TenantOrg

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

the class RecoverPointConsistencyGroupMigrationTest method prepareRPConsistencyGroupData.

/**
 * Prepares the data for RP volume tests.
 *
 * @throws Exception When an error occurs preparing the RP volume data.
 */
private void prepareRPConsistencyGroupData() throws Exception {
    log.info("Preparing RecoverPoint consistency group data for RecoverPointConsistencyGroupMigration");
    TenantOrg tenantOrg = new TenantOrg();
    URI tenantOrgURI = URIUtil.createId(TenantOrg.class);
    tenantOrg.setId(tenantOrgURI);
    _dbClient.createObject(tenantOrg);
    Project proj = new Project();
    URI projectURI = URIUtil.createId(Project.class);
    String projectLabel = "project";
    proj.setId(projectURI);
    proj.setLabel(projectLabel);
    proj.setTenantOrg(new NamedURI(tenantOrgURI, projectLabel));
    _dbClient.createObject(proj);
    // Create CG 1 volumes
    ProtectionSet cg1ps = createProtectionSetData("cg1", projectURI);
    List<Volume> cg1Volumes = createRpVolumes("cg1volume1", 1, cg1ps);
    cg1Volumes.addAll(createRpVolumes("cg1volume2", 1, cg1ps));
    addVolumesToProtectionSet(cg1ps.getId(), cg1Volumes);
    createBlockSnapshotData("cg1Snap", cg1Volumes);
    // Create CG 2 volumes
    ProtectionSet cg2ps = createProtectionSetData("cg2", projectURI);
    List<Volume> cg2Volumes = createRpVolumes("cg2volume1", 2, cg2ps);
    cg2Volumes.addAll(createRpVolumes("cg2volume2", 2, cg2ps));
    addVolumesToProtectionSet(cg2ps.getId(), cg2Volumes);
    createBlockSnapshotData("cg2Snap", cg2Volumes);
    // Create CG 3 volumes
    ProtectionSet cg3ps = createProtectionSetData("cg3", projectURI);
    List<Volume> cg3Volumes = createRpVolumes("cg3volume1", 3, cg3ps);
    addVolumesToProtectionSet(cg3ps.getId(), cg3Volumes);
    createBlockSnapshotData("cg3Snap", cg3Volumes);
    // Verify the rp volume data exists in the database.
    for (URI volumeURI : rpTestVolumeURIs) {
        Volume volume = _dbClient.queryObject(Volume.class, volumeURI);
        Assert.assertNotNull(String.format("RecoverPoint test volume %s not found", volumeURI), volume);
    }
}
Also used : Project(com.emc.storageos.db.client.model.Project) NamedURI(com.emc.storageos.db.client.model.NamedURI) Volume(com.emc.storageos.db.client.model.Volume) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 74 with TenantOrg

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

the class VolumeAccessStateLinkStatusMigrationTest method prepareVolumeData.

/**
 * Prepares the data for RP volume tests.
 *
 * @throws Exception When an error occurs preparing the RP volume data.
 */
private void prepareVolumeData() throws Exception {
    log.info("Preparing Volumes for VolumeAccessStateLinkStatusMigration");
    TenantOrg tenantOrg = new TenantOrg();
    URI tenantOrgURI = URIUtil.createId(TenantOrg.class);
    tenantOrg.setId(tenantOrgURI);
    _dbClient.createObject(tenantOrg);
    volumeAccessStateLinkStatusURIs = new ArrayList<URI>();
    Project proj = new Project();
    URI projectURI = URIUtil.createId(Project.class);
    String projectLabel = "project";
    proj.setId(projectURI);
    proj.setLabel(projectLabel);
    proj.setTenantOrg(new NamedURI(tenantOrgURI, projectLabel));
    _dbClient.createObject(proj);
    // Create RP source volume
    Volume sourceVolume = new Volume();
    URI sourceVolumeURI = URIUtil.createId(Volume.class);
    volumeAccessStateLinkStatusURIs.add(sourceVolumeURI);
    sourceVolume.setId(sourceVolumeURI);
    sourceVolume.setLabel("SOURCE");
    sourceVolume.setPersonality(Volume.PersonalityTypes.SOURCE.toString());
    sourceVolume.setRpCopyName("COPY");
    _dbClient.createObject(sourceVolume);
    // Create RP target volume
    Volume targetVolume = new Volume();
    URI targetVolumeURI = URIUtil.createId(Volume.class);
    volumeAccessStateLinkStatusURIs.add(targetVolumeURI);
    targetVolume.setId(targetVolumeURI);
    targetVolume.setLabel("TARGET");
    targetVolume.setPersonality(Volume.PersonalityTypes.TARGET.toString());
    targetVolume.setRpCopyName("COPY");
    _dbClient.createObject(targetVolume);
    // Create RP journal volume
    Volume journalVolume = new Volume();
    URI journalVolumeURI = URIUtil.createId(Volume.class);
    volumeAccessStateLinkStatusURIs.add(journalVolumeURI);
    journalVolume.setId(journalVolumeURI);
    journalVolume.setLabel("METADATA");
    journalVolume.setPersonality(Volume.PersonalityTypes.METADATA.toString());
    journalVolume.setRpCopyName("COPY");
    _dbClient.createObject(journalVolume);
    // Create SRDF source volume
    Volume srdfSourceVolume = new Volume();
    URI srdfSourceVolumeURI = URIUtil.createId(Volume.class);
    volumeAccessStateLinkStatusURIs.add(srdfSourceVolumeURI);
    srdfSourceVolume.setId(srdfSourceVolumeURI);
    srdfSourceVolume.setLabel("SOURCE");
    srdfSourceVolume.setPersonality(Volume.PersonalityTypes.SOURCE.toString());
    srdfSourceVolume.setSrdfParent(new NamedURI(sourceVolume.getId(), "source-srdf"));
    _dbClient.createObject(srdfSourceVolume);
    // Create SRDF target volume
    Volume srdfTargetVolume = new Volume();
    URI srdfTargetVolumeURI = URIUtil.createId(Volume.class);
    volumeAccessStateLinkStatusURIs.add(srdfTargetVolumeURI);
    srdfTargetVolume.setId(srdfTargetVolumeURI);
    srdfTargetVolume.setLabel("TARGET");
    srdfTargetVolume.setPersonality(Volume.PersonalityTypes.TARGET.toString());
    srdfTargetVolume.setSrdfParent(new NamedURI(targetVolume.getId(), "target-srdf"));
    _dbClient.createObject(srdfTargetVolume);
    // Create a "normal" volume
    Volume volume = new Volume();
    URI volumeURI = URIUtil.createId(Volume.class);
    volumeAccessStateLinkStatusURIs.add(volumeURI);
    volume.setId(volumeURI);
    volume.setLabel("NORMAL");
    _dbClient.createObject(volume);
}
Also used : Project(com.emc.storageos.db.client.model.Project) NamedURI(com.emc.storageos.db.client.model.NamedURI) Volume(com.emc.storageos.db.client.model.Volume) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 75 with TenantOrg

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

the class DbClientTest method testStringSetMap.

@Test
public void testStringSetMap() throws Exception {
    _logger.info("Starting StringSetMap test");
    DbClient dbClient = _dbClient;
    TenantOrg tenant = new TenantOrg();
    tenant.setId(URIUtil.createId(TenantOrg.class));
    StringSetMap sMap = new StringSetMap();
    tenant.setUserMappings(sMap);
    StringSet set = new StringSet();
    set.add("test1");
    sMap.put("key1", set);
    sMap.get("key1").add("test2");
    sMap.get("key1").remove("test1");
    dbClient.persistObject(tenant);
    // record pending
    tenant = dbClient.queryObject(TenantOrg.class, tenant.getId());
    sMap = tenant.getUserMappings();
    set = sMap.get("key1");
    Assert.assertEquals(set.size(), 1);
    Assert.assertEquals(set.contains("test2"), true);
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) DbClient(com.emc.storageos.db.client.DbClient) InternalDbClient(com.emc.storageos.db.client.upgrade.InternalDbClient) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) StringSet(com.emc.storageos.db.client.model.StringSet) Test(org.junit.Test)

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