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);
}
}
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());
}
}
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());
}
}
}
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);
}
}
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);
}
}
}
Aggregations