Search in sources :

Example 31 with MigrationCallbackException

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

the class VirtualPoolFileReplicationPolicyMigration method process.

@Override
public void process() throws MigrationCallbackException {
    logger.info("File Virtual pool to file replication policy migration START");
    DbClient dbClient = getDbClient();
    try {
        List<URI> virtualPoolURIs = dbClient.queryByType(VirtualPool.class, true);
        Iterator<VirtualPool> virtualPools = dbClient.queryIterativeObjects(VirtualPool.class, virtualPoolURIs, true);
        List<VirtualPool> modifiedVpools = new ArrayList<VirtualPool>();
        List<FilePolicy> replPolicies = new ArrayList<FilePolicy>();
        // Establish relation from policy to FilePolicyResource
        while (virtualPools.hasNext()) {
            VirtualPool virtualPool = virtualPools.next();
            if (VirtualPool.Type.file.name().equals(virtualPool.getType()) && virtualPool.getFileReplicationType() != null && !FileReplicationType.NONE.name().equalsIgnoreCase(virtualPool.getFileReplicationType())) {
                logger.info("vpool {} has enabled with replication, Creating appropriate file policy.....", virtualPool.getLabel());
                // Create replication policy
                FilePolicy replPolicy = new FilePolicy();
                replPolicy.setId(URIUtil.createId(FilePolicy.class));
                replPolicy.setFilePolicyDescription("Policy created from virtual pool " + virtualPool.getLabel() + " while system upgrade");
                String polName = virtualPool.getLabel() + "_Replication_Policy";
                replPolicy.setLabel(polName);
                replPolicy.setFilePolicyName(polName);
                replPolicy.setLabel(polName);
                replPolicy.setFilePolicyType(FilePolicyType.file_replication.name());
                replPolicy.setFilePolicyVpool(virtualPool.getId());
                // Replication policy was created always at file system level!!
                replPolicy.setApplyAt(FilePolicyApplyLevel.file_system.name());
                if (virtualPool.getFileReplicationCopyMode().equals(VirtualPool.RPCopyMode.ASYNCHRONOUS.name())) {
                    replPolicy.setFileReplicationCopyMode(FilePolicy.FileReplicationCopyMode.ASYNC.name());
                } else {
                    replPolicy.setFileReplicationCopyMode(FilePolicy.FileReplicationCopyMode.SYNC.name());
                }
                replPolicy.setFileReplicationType(virtualPool.getFileReplicationType());
                replPolicy.setPriority(FilePolicyPriority.Normal.toString());
                // Set the policy schedule based on vPool RPO
                if (virtualPool.getFrRpoValue() != null && virtualPool.getFrRpoType() != null) {
                    replPolicy.setScheduleRepeat((long) virtualPool.getFrRpoValue());
                    replPolicy.setScheduleTime("00:00AM");
                    replPolicy.setScheduleFrequency(virtualPool.getFrRpoType().toLowerCase());
                    // Virtual pool was supporting only Minutes/Hours/Days for RPO type
                    // Day of the week and month is not applicable!!
                    replPolicy.setScheduleDayOfWeek(NullColumnValueGetter.getNullStr());
                    replPolicy.setScheduleDayOfMonth(0L);
                }
                // set topology reference to policy
                if (FileReplicationType.REMOTE.name().equalsIgnoreCase(virtualPool.getFileReplicationType())) {
                    logger.info("Creating replication topology for remote replication vpool {} .....", virtualPool.getLabel());
                    StringSet replicationTopologies = new StringSet();
                    StringSet targetVarrays = new StringSet();
                    String targetVarray = null;
                    String targetVPool = null;
                    Map<URI, VpoolRemoteCopyProtectionSettings> remoteSettings = virtualPool.getFileRemoteProtectionSettings(virtualPool, dbClient);
                    if (remoteSettings != null && !remoteSettings.isEmpty()) {
                        for (Map.Entry<URI, VpoolRemoteCopyProtectionSettings> entry : remoteSettings.entrySet()) {
                            if (entry != null) {
                                targetVarray = entry.getKey().toString();
                                if (entry.getValue() != null && entry.getValue().getVirtualPool() != null) {
                                    targetVPool = entry.getValue().getVirtualPool().toString();
                                }
                                break;
                            }
                        }
                        if (targetVarray != null) {
                            targetVarrays.add(targetVarray);
                        }
                    }
                    if (virtualPool.getVirtualArrays() != null && !virtualPool.getVirtualArrays().isEmpty()) {
                        for (String srcvArray : virtualPool.getVirtualArrays()) {
                            FileReplicationTopology dbReplTopology = new FileReplicationTopology();
                            dbReplTopology.setId(URIUtil.createId(FileReplicationTopology.class));
                            dbReplTopology.setPolicy(replPolicy.getId());
                            dbReplTopology.setSourceVArray(URI.create(srcvArray));
                            dbReplTopology.setTargetVArrays(targetVarrays);
                            if (targetVarray != null && targetVPool != null) {
                                dbReplTopology.setTargetVAVPool(targetVarray + SEPARATOR + targetVPool);
                            }
                            dbClient.createObject(dbReplTopology);
                            replicationTopologies.add(dbReplTopology.getId().toString());
                        }
                        replPolicy.setReplicationTopologies(replicationTopologies);
                        logger.info("Created {} replication topologies from vpool {}", replicationTopologies.size(), virtualPool.getLabel().toString());
                    }
                }
                // Fetch if there are any file system were provisioned with the vpool
                // if present, link them to replication policy!!
                URIQueryResultList resultList = new URIQueryResultList();
                dbClient.queryByConstraint(ContainmentConstraint.Factory.getVirtualPoolFileshareConstraint(virtualPool.getId()), resultList);
                for (Iterator<URI> fileShareItr = resultList.iterator(); fileShareItr.hasNext(); ) {
                    FileShare fs = dbClient.queryObject(FileShare.class, fileShareItr.next());
                    if (!fs.getInactive() && fs.getPersonality() != null && fs.getPersonality().equalsIgnoreCase(PersonalityTypes.SOURCE.name())) {
                        StorageSystem system = dbClient.queryObject(StorageSystem.class, fs.getStorageDevice());
                        updatePolicyStorageResouce(system, replPolicy, fs);
                        fs.addFilePolicy(replPolicy.getId());
                        dbClient.updateObject(fs);
                    }
                }
                replPolicies.add(replPolicy);
                virtualPool.setAllowFilePolicyAtFSLevel(true);
                virtualPool.setFileReplicationSupported(true);
                modifiedVpools.add(virtualPool);
            }
        }
        // Udate DB
        if (!replPolicies.isEmpty()) {
            logger.info("Created {} replication policies ", replPolicies.size());
            dbClient.createObject(replPolicies);
        }
        if (!modifiedVpools.isEmpty()) {
            logger.info("Modified {} vpools ", modifiedVpools.size());
            dbClient.updateObject(modifiedVpools);
        }
    } catch (Exception ex) {
        logger.error("Exception occured while migrating file replication policy for Virtual pools");
        logger.error(ex.getMessage(), ex);
    }
    logger.info("Virtual pool file replication policy migration END");
}
Also used : VpoolRemoteCopyProtectionSettings(com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings) DbClient(com.emc.storageos.db.client.DbClient) FilePolicy(com.emc.storageos.db.client.model.FilePolicy) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException) StringSet(com.emc.storageos.db.client.model.StringSet) Map(java.util.Map) FileReplicaPolicyTargetMap(com.emc.storageos.db.client.model.FileReplicaPolicyTargetMap) FileReplicationTopology(com.emc.storageos.db.client.model.FileReplicationTopology) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 32 with MigrationCallbackException

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

the class VirtualPoolVNXAutoTierPolicyIdMigration method process.

/**
 * Process the BlockVirtualPools and update their AutoTieringPolicyId from .
 */
@Override
public void process() throws MigrationCallbackException {
    DbClient dbClient = getDbClient();
    try {
        List<URI> virtualPoolUris = dbClient.queryByType(VirtualPool.class, true);
        Iterator<VirtualPool> virtualPools = dbClient.queryIterativeObjects(VirtualPool.class, virtualPoolUris, true);
        while (virtualPools.hasNext()) {
            VirtualPool virtualPool = virtualPools.next();
            String autoTierPolicyName = virtualPool.getAutoTierPolicyName();
            // If there is a VNX FAST policy associated with the vpool, then change the format.
            if (null != autoTierPolicyName && !autoTierPolicyName.isEmpty() && autoTierPolicyName.contains(CLARIION_KEY)) {
                String[] autoTierPolicyArray = autoTierPolicyName.split(PLUS_OPERATOR);
                virtualPool.setAutoTierPolicyName(autoTierPolicyArray[3]);
                dbClient.persistObject(virtualPool);
                log.info("Updating VirtualPool (id={}) with  right VNX FAST Policy {}", virtualPool.getId().toString(), virtualPool.getAutoTierPolicyName());
            }
        }
    } catch (Exception e) {
        log.error("Exception occured while updating VirtualPool VNX AutoTieringPolicy");
        log.error(e.getMessage(), e);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)

Example 33 with MigrationCallbackException

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

the class VplexExportMaskInitiatorsAndVolumesMigration method process.

@Override
public void process() throws MigrationCallbackException {
    DbClient dbClient = getDbClient();
    try {
        List<URI> exportMaskUris = dbClient.queryByType(ExportMask.class, true);
        Iterator<ExportMask> exportMasks = dbClient.queryIterativeObjects(ExportMask.class, exportMaskUris, true);
        while (exportMasks.hasNext()) {
            ExportMask exportMask = exportMasks.next();
            try {
                URI storageSytsemURI = exportMask.getStorageDevice();
                StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, storageSytsemURI);
                // We only need to update VPlex ExportMask
                if ((storageSystem != null) && (DiscoveredDataObject.Type.vplex.name().equals(storageSystem.getSystemType()))) {
                    // Volumes list can be inconsistent only when its created by ViPR
                    if (exportMask.getCreatedBySystem()) {
                        log.info("Looking at export mask " + exportMask.getMaskName() + " Export Mask ID is :" + exportMask.getId() + "created by system is " + exportMask.getCreatedBySystem());
                        StringMap volumeMaps = exportMask.getVolumes();
                        if (volumeMaps != null && !volumeMaps.isEmpty()) {
                            Set<String> volumeIds = volumeMaps.keySet();
                            List<BlockObject> volumes = new ArrayList<BlockObject>();
                            for (String volumeId : volumeIds) {
                                BlockObject bo = BlockObject.fetch(dbClient, URI.create(volumeId));
                                if (bo != null) {
                                    if (bo.getWWN() == null) {
                                        log.info("Skipping volume " + bo.getId() + " " + bo.getLabel() + " as its wwn is null.");
                                        ;
                                    } else {
                                        volumes.add(bo);
                                    }
                                }
                            }
                            StringMap userAddedVolumesMap = exportMask.getUserAddedVolumes();
                            if (userAddedVolumesMap == null && !volumes.isEmpty()) {
                                // If there is nothing in the userAddedVolumesMap then add all the
                                // volumes from the EXportMask Volumes list
                                log.info("Adding volumes to the userCreatedVolumes " + volumes + "to the export mask " + exportMask.getMaskName() + " export mask ID is :" + exportMask.getId());
                                try {
                                    exportMask.addToUserCreatedVolumes(volumes);
                                } catch (Exception volEx) {
                                    log.error("Exception occured while adding volumes to the userCreatedVolumes");
                                    log.error(volEx.getMessage(), volEx);
                                }
                            } else {
                                // user added list
                                for (BlockObject volume : volumes) {
                                    if (volume.getWWN() != null && !volume.getWWN().isEmpty()) {
                                        if (userAddedVolumesMap.get(BlockObject.normalizeWWN(volume.getWWN())) == null) {
                                            log.info("Adding volume to the userCreatedVolumes " + volume + "to the export mask " + exportMask.getMaskName() + "exportmask ID is :" + exportMask.getId());
                                            try {
                                                exportMask.addToUserCreatedVolumes(volume);
                                            } catch (Exception volEx) {
                                                log.error("Exception occured while adding volume to the userCreatedVolumes");
                                                log.error(volEx.getMessage(), volEx);
                                            }
                                        }
                                    }
                                }
                            }
                            // Add all the initiators from the initiators list if any to the userAddedInitiators
                            populateExportMaskUserAddedInitiators(exportMask);
                            dbClient.persistObject(exportMask);
                        }
                    } else {
                        log.info("Looking at export mask " + exportMask.getMaskName() + " Export Mask ID is :" + exportMask.getId() + "created by system is " + exportMask.getCreatedBySystem());
                        // First add all the initiators from the initiators list if any to the userAddedInitiators
                        populateExportMaskUserAddedInitiators(exportMask);
                        // Add existing initiators to the initiators list if we can find Initiator object for those pwwn
                        if (exportMask.getExistingInitiators() != null && !exportMask.getExistingInitiators().isEmpty()) {
                            StringSet existingInitiators = exportMask.getExistingInitiators();
                            List<URI> existingInitiatorsURIs = new ArrayList<URI>();
                            for (String pwwn : existingInitiators) {
                                Initiator initiator = findInitiatorInDB(pwwn);
                                if (initiator != null) {
                                    existingInitiatorsURIs.add(initiator.getId());
                                }
                            }
                            if (exportMask.getInitiators() == null && !existingInitiatorsURIs.isEmpty()) {
                                log.info("Adding existingInitiators to the initiators " + existingInitiatorsURIs + "to the export mask " + exportMask.getMaskName() + "export mask ID is :" + exportMask.getId());
                                exportMask.setInitiators(StringSetUtil.uriListToStringSet(existingInitiatorsURIs));
                            } else {
                                for (URI uri : existingInitiatorsURIs) {
                                    log.info("Adding existingInitiator to the initiators " + uri + "to the export mask " + exportMask.getMaskName() + "export mask ID is :" + exportMask.getId());
                                    exportMask.getInitiators().add(uri.toString());
                                }
                            }
                        }
                        dbClient.persistObject(exportMask);
                    }
                }
            } catch (Exception emex) {
                log.error("Exception occured while migrating VPLEX ExportMask " + exportMask.getId() + " " + exportMask.getMaskName());
                log.error(emex.getMessage(), emex);
            }
        }
    } catch (Exception ex) {
        log.error("Exception occured while migrating VPLEX ExportMask ");
        log.error(ex.getMessage(), ex);
    }
    log.info("Done VplexExportMaskInitiatorsAndVolumesMigration.");
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) DbClient(com.emc.storageos.db.client.DbClient) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) URI(java.net.URI) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException) IOException(java.io.IOException) Initiator(com.emc.storageos.db.client.model.Initiator) StringSet(com.emc.storageos.db.client.model.StringSet) BlockObject(com.emc.storageos.db.client.model.BlockObject) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 34 with MigrationCallbackException

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

the class VplexVolumeAllocatedCapacityMigration method process.

@Override
public void process() throws MigrationCallbackException {
    DbClient dbClient = getDbClient();
    try {
        List<URI> volumeUris = dbClient.queryByType(Volume.class, true);
        Iterator<Volume> volumes = dbClient.queryIterativeObjects(Volume.class, volumeUris, true);
        while (volumes.hasNext()) {
            Volume volume = volumes.next();
            URI storageURI = volume.getStorageController();
            if (!NullColumnValueGetter.isNullURI(storageURI)) {
                StorageSystem storage = dbClient.queryObject(StorageSystem.class, storageURI);
                if (DiscoveredDataObject.Type.vplex.name().equals(storage.getSystemType())) {
                    Long allocatedCapacity = volume.getAllocatedCapacity();
                    // For Vplex virtual volumes set allocated capacity to 0 (cop-18608)
                    if (allocatedCapacity != null && allocatedCapacity != 0) {
                        log.info("migrating allocated capacity from {} to 0 on VPLEX volume {}", allocatedCapacity, volume.getLabel());
                        volume.setAllocatedCapacity(0L);
                        dbClient.persistObject(volume);
                    }
                }
            }
        }
    } catch (Exception ex) {
        log.error("Exception occured while migrating VPLEX Volume Allocated Capacities.");
        log.error(ex.getMessage(), ex);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) Volume(com.emc.storageos.db.client.model.Volume) URI(java.net.URI) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 35 with MigrationCallbackException

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

the class XtremioBlockSnapshotDeviceLabelMigration method process.

/**
 * Get all the BlockSnapshots associated with XtremIO storage systems and if the deviceLabel is not set, set it to the label of the
 * snapshots.
 */
@Override
public void process() throws MigrationCallbackException {
    log.info("Started execution of XtremioBlockSnapshotDeviceLabelMigration migration callback.");
    try {
        DbClient dbClient = getDbClient();
        List<URI> storageSystemURIList = dbClient.queryByType(StorageSystem.class, true);
        Iterator<StorageSystem> storageSystems = dbClient.queryIterativeObjects(StorageSystem.class, storageSystemURIList);
        while (storageSystems.hasNext()) {
            StorageSystem storageSystem = storageSystems.next();
            if (DiscoveredDataObject.Type.xtremio.name().equalsIgnoreCase(storageSystem.getSystemType())) {
                URIQueryResultList snapshotURIs = new URIQueryResultList();
                dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceSnapshotConstraint(storageSystem.getId()), snapshotURIs);
                Iterator<BlockSnapshot> xioSnapshots = dbClient.queryIterativeObjects(BlockSnapshot.class, snapshotURIs);
                List<BlockSnapshot> updatedSnaps = new ArrayList<BlockSnapshot>();
                while (xioSnapshots.hasNext()) {
                    BlockSnapshot xioSnapshot = xioSnapshots.next();
                    if (!xioSnapshot.getInactive() && NullColumnValueGetter.isNullValue(xioSnapshot.getDeviceLabel())) {
                        String label = xioSnapshot.getLabel();
                        log.info(String.format("Setting deviceLabel of snapshot %s : %s to %s", label, xioSnapshot.getNativeGuid(), label));
                        xioSnapshot.setDeviceLabel(label);
                        updatedSnaps.add(xioSnapshot);
                    }
                }
                dbClient.updateObject(updatedSnaps);
            }
        }
        log.info("Completed executing XtremioBlockSnapshotDeviceLabelMigration migration callback.");
    } catch (Exception e) {
        String errorMsg = String.format("%s encounter unexpected error %s", this.getName(), e.getMessage());
        throw new MigrationCallbackException(errorMsg, e);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

MigrationCallbackException (com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)36 URI (java.net.URI)25 DbClient (com.emc.storageos.db.client.DbClient)24 ArrayList (java.util.ArrayList)18 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)11 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)9 StringSet (com.emc.storageos.db.client.model.StringSet)6 FileShare (com.emc.storageos.db.client.model.FileShare)4 HashMap (java.util.HashMap)4 DbClientImpl (com.emc.storageos.db.client.impl.DbClientImpl)3 FilePolicy (com.emc.storageos.db.client.model.FilePolicy)3 Volume (com.emc.storageos.db.client.model.Volume)3 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)3 Configuration (com.emc.storageos.coordinator.common.Configuration)2 FatalCoordinatorException (com.emc.storageos.coordinator.exceptions.FatalCoordinatorException)2 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)2 ExportMask (com.emc.storageos.db.client.model.ExportMask)2 FileReplicationTopology (com.emc.storageos.db.client.model.FileReplicationTopology)2 Initiator (com.emc.storageos.db.client.model.Initiator)2