Search in sources :

Example 56 with DbClient

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

the class CustomMigrationCallbackExample method validateHostLabelLength.

private void validateHostLabelLength() throws MigrationCallbackException {
    try {
        DbClient dbClient = this.getDbClient();
        List<URI> hostIds = dbClient.queryByType(Host.class, true);
        Iterator<Host> hosts = dbClient.queryIterativeObjects(Host.class, hostIds, true);
        while (hosts.hasNext()) {
            Host host = hosts.next();
            if (host.getLabel() != null && host.getLabel().length() < MIN_LABEL_LENGTH) {
                String errorMsg = String.format("%s failed: invalid label length %s(%s)", this.getName(), Host.class.getSimpleName(), host.getId().toString());
                throw new MigrationCallbackException(errorMsg, new IllegalStateException());
            }
        }
    } 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) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException) Host(com.emc.storageos.db.client.model.Host) URI(java.net.URI) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)

Example 57 with DbClient

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

the class DataObjectInactiveFieldScrubber method updateInactiveField.

/**
 * Update the missed setting of "inactive field" for all data object
 */
private <T extends DataObject> void updateInactiveField(Class<T> clazz, List<URI> keyList) {
    DbClient dbClient = getDbClient();
    log.info("update inactive field for class: {}", clazz.getSimpleName());
    T object;
    for (URI key : keyList) {
        try {
            object = clazz.newInstance();
            object.setId(key);
            object.setInactive(false);
        } catch (Exception e) {
            log.error("create new object of class({}) failed. e=", clazz.getSimpleName(), e);
            throw new IllegalStateException(e);
        }
        dbClient.updateAndReindexObject(object);
        log.info("Update the inactive field of object(cf={}, id={}) to false", object.getClass().getName(), object.getId());
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) InternalDbClient(com.emc.storageos.db.client.upgrade.InternalDbClient) URI(java.net.URI) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)

Example 58 with DbClient

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

the class DataObjectInternalFlagsInitializer method updateInternalVolumes.

/**
 * Update volumes that need to have the INTERNAL_OBJECT flag set.
 */
private void updateInternalVolumes() {
    DbClient dbClient = getDbClient();
    List<URI> volumeURIs = dbClient.queryByType(Volume.class, false);
    Iterator<Volume> volumes = dbClient.queryIterativeObjects(Volume.class, volumeURIs);
    while (volumes.hasNext()) {
        Volume volume = volumes.next();
        log.debug("Examining volume (id={}) for upgrade", volume.getId().toString());
        // Check if the volume has associated volumes. If so,
        // this is a VPLEX volume, and we must mark these
        // associated backend volumes as internal.
        StringSet associatedVolumeIds = volume.getAssociatedVolumes();
        if ((associatedVolumeIds != null) && (!associatedVolumeIds.isEmpty())) {
            log.info("Backend volumes for VPLEX volume (id={}) must be upgraded", volume.getId().toString());
            handleVPlexAssociatedVolumes(associatedVolumeIds);
            continue;
        }
        // RP Journal volume and should be marked as internal.
        if (volume.getPersonality() != null && volume.getPersonality().equals(Volume.PersonalityTypes.METADATA.toString())) {
            log.info("RecoverPoint Journal volume (id={}) must be upgraded", volume.getId().toString());
            volume.addInternalFlags(Flag.INTERNAL_OBJECT);
            volume.addInternalFlags(Flag.SUPPORTS_FORCE);
            dbClient.persistObject(volume);
            log.info("Marked RecoverPoint Journal volume (id={}) as internal object that supports force", volume.getId().toString());
        }
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) Volume(com.emc.storageos.db.client.model.Volume) StringSet(com.emc.storageos.db.client.model.StringSet) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 59 with DbClient

use of com.emc.storageos.db.client.DbClient 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 60 with DbClient

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

the class FCZoneReferenceMigration method initializeField.

/**
 * For all FC Zone Reference objects
 */
private void initializeField() {
    log.info("Updating FC Zone reference label object to be more searchable");
    DbClient dbClient = this.getDbClient();
    List<URI> fcZoneRefs = dbClient.queryByType(FCZoneReference.class, false);
    Iterator<FCZoneReference> refs = dbClient.queryIterativeObjects(FCZoneReference.class, fcZoneRefs);
    while (refs.hasNext()) {
        FCZoneReference ref = refs.next();
        log.info("Examining block ref (id={}) for upgrade", ref.getId().toString());
        String label = ref.getLabel();
        // Criteria to switch over the label that is that it does not contain a second underscore
        if (label == null || !label.matches(".*_.*_.*")) {
            log.info("Resetting label:", label);
            ref.setLabel(FCZoneReference.makeLabel(label, ref.getVolumeUri().toString()));
            dbClient.updateObject(ref);
        }
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) URI(java.net.URI) FCZoneReference(com.emc.storageos.db.client.model.FCZoneReference)

Aggregations

DbClient (com.emc.storageos.db.client.DbClient)253 URI (java.net.URI)155 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)73 Volume (com.emc.storageos.db.client.model.Volume)67 ArrayList (java.util.ArrayList)58 Test (org.junit.Test)42 FileShare (com.emc.storageos.db.client.model.FileShare)34 NamedURI (com.emc.storageos.db.client.model.NamedURI)31 CIMObjectPath (javax.cim.CIMObjectPath)31 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)29 WBEMClient (javax.wbem.client.WBEMClient)29 StringSet (com.emc.storageos.db.client.model.StringSet)28 CIMConnectionFactory (com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory)28 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)26 MigrationCallbackException (com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)25 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)22 InternalDbClient (com.emc.storageos.db.client.upgrade.InternalDbClient)22 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)21 CIMInstance (javax.cim.CIMInstance)21 BlockObject (com.emc.storageos.db.client.model.BlockObject)20