Search in sources :

Example 6 with MigrationCallbackException

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

the class ExportMaskExistingInitiatorsMigration method process.

@Override
public void process() throws MigrationCallbackException {
    logger.info("Started migration for exportmask existingInitiator into userCreatedInitiator");
    try {
        DbClient dbClient = getDbClient();
        int totalExportMaskObjectCount = 0;
        int exportMaskUpdatedCount = 0;
        Map<URI, String> systemTypeMap = new HashMap<>();
        StorageSystem system = null;
        List<URI> exportMaskUris = dbClient.queryByType(ExportMask.class, true);
        Iterator<ExportMask> exportMaskIterator = dbClient.queryIterativeObjects(ExportMask.class, exportMaskUris, true);
        while (exportMaskIterator.hasNext()) {
            totalExportMaskObjectCount++;
            ExportMask exportMask = exportMaskIterator.next();
            if (exportMask != null && !NullColumnValueGetter.isNullURI(exportMask.getStorageDevice())) {
                logger.info("Processing mask {}", exportMask.forDisplay());
                URI systemUri = exportMask.getStorageDevice();
                String systemType = systemTypeMap.get(systemUri);
                if (systemType == null) {
                    system = dbClient.queryObject(StorageSystem.class, systemUri);
                    if (system != null) {
                        systemTypeMap.put(systemUri, system.getSystemType());
                        systemType = system.getSystemType();
                    }
                }
                if (systemType != null && (Type.vmax.toString().equalsIgnoreCase(systemType) || (Type.vplex.toString().equalsIgnoreCase(systemType)))) {
                    logger.info("Processing existing initiators for export mask {} on {} storage {}", exportMask.getId(), systemType, systemUri);
                    boolean updateObject = false;
                    List<String> initiatorsToProcess = new ArrayList<String>();
                    if (exportMask.getExistingInitiators() != null && !exportMask.getExistingInitiators().isEmpty()) {
                        initiatorsToProcess.addAll(exportMask.getExistingInitiators());
                        for (String portName : initiatorsToProcess) {
                            Initiator existingInitiator = getInitiator(Initiator.toPortNetworkId(portName), dbClient);
                            if (existingInitiator != null && !checkIfDifferentResource(exportMask, existingInitiator)) {
                                exportMask.addInitiator(existingInitiator);
                                exportMask.addToUserCreatedInitiators(existingInitiator);
                                exportMask.removeFromExistingInitiators(existingInitiator);
                                logger.info("Initiator {} is being moved from existing to userCreated for the Mask {}", portName, exportMask.forDisplay());
                                updateObject = true;
                            }
                        }
                    }
                    if (updateObject) {
                        logger.info("Processed existing initiators for export mask {} on {} storage {} and updated the Mask Object", exportMask.getId(), systemType, systemUri);
                        dbClient.updateObject(exportMask);
                        exportMaskUpdatedCount++;
                    }
                } else if (systemType == null) {
                    logger.error("could not determine storage system type for exportMask {}", exportMask.forDisplay());
                }
            }
        }
        logger.info("Updated Existing information on {} of {} Export Mask Objects on VMAX Storage", exportMaskUpdatedCount, totalExportMaskObjectCount);
    } catch (Exception e) {
        logger.error("Fail to migrate ExportMask existingInitiator migration into userCreatedInitiator", e);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) HashMap(java.util.HashMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) URI(java.net.URI) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException) Initiator(com.emc.storageos.db.client.model.Initiator) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 7 with MigrationCallbackException

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

the class FileReplicationPolicyUpdateTargetPoolMigration method process.

@Override
public void process() throws MigrationCallbackException {
    logger.info("File replication policy to update it's target pool in topology migration START");
    DbClient dbClient = getDbClient();
    try {
        List<URI> virtualPoolURIs = dbClient.queryByType(VirtualPool.class, true);
        Iterator<VirtualPool> virtualPools = dbClient.queryIterativeObjects(VirtualPool.class, virtualPoolURIs, true);
        List<FileReplicationTopology> replPolicyTopologies = new ArrayList<FileReplicationTopology>();
        Map<String, FilePolicy> replicationPolicies = getRemoteReplicationPolicies();
        if (replicationPolicies.isEmpty()) {
            logger.info("No remote replication policies found in system... ");
            return;
        }
        // Update the target vpool in topology for that policy
        while (virtualPools.hasNext()) {
            VirtualPool virtualPool = virtualPools.next();
            if (VirtualPool.Type.file.name().equals(virtualPool.getType()) && virtualPool.getFileReplicationType() != null && FileReplicationType.REMOTE.name().equalsIgnoreCase(virtualPool.getFileReplicationType())) {
                logger.info("Getting replicaiton policies associated with vpool {} ", virtualPool.getLabel());
                // Get the existing replication policy
                // which was created with vpool name followed by _Replication_Policy
                String polName = virtualPool.getLabel() + "_Replication_Policy";
                FilePolicy replPolicy = replicationPolicies.get(polName);
                if (replPolicy != null) {
                    // Get the replication topologies for the policy!!
                    List<FileReplicationTopology> policyTopologies = queryDBReplicationTopologies(replPolicy);
                    if (policyTopologies != null && !policyTopologies.isEmpty()) {
                        // Get the target vpool from the vpool!
                        String targetVarray = null;
                        String targetVPool = null;
                        Map<URI, VpoolRemoteCopyProtectionSettings> remoteSettings = virtualPool.getFileRemoteProtectionSettings(virtualPool, dbClient);
                        if (remoteSettings != null && !remoteSettings.isEmpty()) {
                            // till now CoprHD supports only single target!!
                            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;
                                }
                            }
                        }
                        for (FileReplicationTopology topology : policyTopologies) {
                            if (virtualPool.getVirtualArrays().contains(topology.getSourceVArray().toASCIIString()) && topology.getTargetVArrays().contains(targetVarray)) {
                                if (targetVarray != null && targetVPool != null) {
                                    topology.setTargetVAVPool(targetVarray + SEPARATOR + targetVPool);
                                    replPolicyTopologies.add(topology);
                                }
                            }
                        }
                    }
                } else {
                    logger.info("No remote replication policy with name {} ", polName);
                }
            }
        }
        // Udate DB
        if (!replPolicyTopologies.isEmpty()) {
            logger.info("Modified {} topologies ", replPolicyTopologies.size());
            dbClient.updateObject(replPolicyTopologies);
        }
    } catch (Exception ex) {
        logger.error("Exception occured while migrating file replication policy topology ");
        logger.error(ex.getMessage(), ex);
    }
    logger.info("File replication policy to update it's target pool in topology 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) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException) HashMap(java.util.HashMap) Map(java.util.Map) FileReplicationTopology(com.emc.storageos.db.client.model.FileReplicationTopology)

Example 8 with MigrationCallbackException

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

the class GeoDbMigrationCallback method process.

@Override
public void process() throws MigrationCallbackException {
    if (cfClass == null || annotation == null) {
        // this callback has not been set up; skip it.
        throw DatabaseException.fatals.failedDuringUpgrade("Unexpected state: callback not setup", null);
    }
    if (!annotation.annotationType().equals(DbKeyspace.class)) {
        throw DatabaseException.fatals.failedDuringUpgrade("Unexpected annotation: only support" + " @DbKeyspace", null);
    }
    String cfName = cfClass.getCanonicalName();
    if (!DataObject.class.isAssignableFrom(cfClass)) {
        throw DatabaseException.fatals.failedDuringUpgrade("Unexpected CF type: " + cfName, null);
    }
    // No need to do anything if the DbKeyspace is set to LOCAL
    DbKeyspace keyspace = (DbKeyspace) cfClass.getAnnotation(annotation.annotationType());
    if (keyspace.value().equals(DbKeyspace.Keyspaces.LOCAL)) {
        log.info("No need to do anything for CF {}", cfName);
        return;
    }
    log.info("Copying db records for class: {} from local db into geodb", cfName);
    try {
        getInternalDbClient().migrateToGeoDb(cfClass);
    } catch (Exception e) {
        log.error("GeoDbMigrationCallback migration failed", e);
        throw DatabaseException.fatals.failedDuringUpgrade("db schema migration error: failed" + "to migrate CF " + cfName + " into geodb", e);
    }
    log.info("migrate on global resource {} finished", cfClass.getSimpleName());
}
Also used : DbKeyspace(com.emc.storageos.db.client.model.DbKeyspace) DataObject(com.emc.storageos.db.client.model.DataObject) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 9 with MigrationCallbackException

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

the class HDSStorageSystemSerialNumberMigration method process.

/**
 * Process the HDS storagesystems and update their serialNumber from ARRAY.R700.94677 to 94677.
 */
@Override
public void process() throws MigrationCallbackException {
    DbClient dbClient = getDbClient();
    try {
        List<URI> storageSystemURIList = dbClient.queryByType(StorageSystem.class, true);
        List<StorageSystem> storageSystemsList = dbClient.queryObject(StorageSystem.class, storageSystemURIList);
        Iterator<StorageSystem> systemItr = storageSystemsList.iterator();
        List<StorageSystem> systemsToUpdate = new ArrayList<StorageSystem>();
        while (systemItr.hasNext()) {
            StorageSystem storageSystem = systemItr.next();
            // perform storagesystem upgrade only fro HDS storagesystems.
            if (DiscoveredDataObject.Type.hds.name().equalsIgnoreCase(storageSystem.getSystemType())) {
                String serialNumber = storageSystem.getSerialNumber();
                if (serialNumber.contains(ARRAY)) {
                    String[] dotSeperatedStrings = serialNumber.split(DOT_OPERATOR);
                    String serialNumberToUpdate = dotSeperatedStrings[dotSeperatedStrings.length - 1];
                    storageSystem.setSerialNumber(serialNumberToUpdate);
                    systemsToUpdate.add(storageSystem);
                }
            }
        }
        // persist all systems here.
        dbClient.persistObject(systemsToUpdate);
    } catch (Exception e) {
        log.error("Exception occured while updating hds storagesystem serialnumber");
        log.error(e.getMessage(), e);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) ArrayList(java.util.ArrayList) URI(java.net.URI) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 10 with MigrationCallbackException

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

the class MetroPointVolumeInternalSiteNameMigration method updateVolumeInternalSiteName.

/**
 * Update the MetroPoint Volume objects to ensure the source VPlex volume uses the
 * internalSiteName of the source side backing Volume. The correct source side backing
 * volume can be found by matching up the RP copy name on the volumes.
 */
private void updateVolumeInternalSiteName() throws MigrationCallbackException {
    log.info("Migrating MetroPoint Volume internalSiteName fields.");
    try {
        DbClient dbClient = getDbClient();
        List<URI> volumeURIs = dbClient.queryByType(Volume.class, true);
        Iterator<Volume> volumes = dbClient.queryIterativeObjects(Volume.class, volumeURIs);
        List<String> updatedVolumes = new ArrayList<String>();
        List<String> invalidVolumes = new ArrayList<String>();
        while (volumes.hasNext()) {
            Volume volume = volumes.next();
            if (PersonalityTypes.SOURCE.name().equals(volume.getPersonality()) && (NullColumnValueGetter.isNullNamedURI(volume.getProtectionSet()) || NullColumnValueGetter.isNullURI(volume.getConsistencyGroup()))) {
                invalidVolumes.add(volume.getId().toString());
                continue;
            }
            if (volume != null && NullColumnValueGetter.isNotNullValue(volume.getRpCopyName()) && PersonalityTypes.SOURCE.name().equals(volume.getPersonality()) && volume.getAssociatedVolumes() != null && volume.getAssociatedVolumes().size() == 2 && !NullColumnValueGetter.isNullURI(volume.getVirtualPool())) {
                // Get the volume's virtual pool and use that to determine if this is a MetroPoint volume
                VirtualPool vpool = dbClient.queryObject(VirtualPool.class, volume.getVirtualPool());
                if (vpool != null && VirtualPool.vPoolSpecifiesMetroPoint(vpool)) {
                    // This is a MetroPoint VPlex source volume, so update it.
                    if (updateVolume(volume)) {
                        updatedVolumes.add(volume.getId().toString());
                    }
                }
            }
        }
        log.info(String.format("MetroPointVolumeInternalSiteNameMigration has updated %d MetroPoint source volumes: %s", updatedVolumes.size(), updatedVolumes.toString()));
        log.info(String.format("MetroPointVolumeInternalSiteNameMigration has found %d invalid volumes.  These volumes have an invalid protection set or consistency group reference: %s", invalidVolumes.size(), invalidVolumes.toString()));
    } 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) Volume(com.emc.storageos.db.client.model.Volume) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)

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