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