use of com.emc.storageos.db.client.DbClient 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.db.client.DbClient in project coprhd-controller by CoprHD.
the class FullCopyVolumeReplicaStateMigration method initializeVolumeFields.
/**
* For all full copy volume, set replicaState as DETACHED
*/
private void initializeVolumeFields() {
log.info("Updating full copy volume replica state.");
DbClient dbClient = this.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.info("Examining Volume (id={}) for upgrade", volume.getId().toString());
if (!NullColumnValueGetter.isNullURI(volume.getAssociatedSourceVolume())) {
volume.setReplicaState(ReplicationState.DETACHED.name());
}
dbClient.persistObject(volume);
}
}
use of com.emc.storageos.db.client.DbClient 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.db.client.DbClient in project coprhd-controller by CoprHD.
the class HostInterfaceLabelMigration method processInitiators.
private void processInitiators() {
DbClient dbClient = getDbClient();
List<URI> uris = dbClient.queryByType(Initiator.class, false);
Iterator<Initiator> objects = dbClient.queryIterativeObjects(Initiator.class, uris);
while (objects.hasNext()) {
Initiator initiator = objects.next();
if (initiator.getLabel() == null || initiator.getLabel().isEmpty()) {
log.info("Setting label of " + initiator.getId() + " to " + initiator.getInitiatorPort());
initiator.setLabel(initiator.getInitiatorPort());
dbClient.persistObject(initiator);
}
}
}
use of com.emc.storageos.db.client.DbClient in project coprhd-controller by CoprHD.
the class HostInterfaceLabelMigration method processIpInterfaces.
private void processIpInterfaces() {
DbClient dbClient = getDbClient();
List<URI> uris = dbClient.queryByType(IpInterface.class, false);
Iterator<IpInterface> objects = dbClient.queryIterativeObjects(IpInterface.class, uris);
while (objects.hasNext()) {
IpInterface ipinterface = objects.next();
if (ipinterface.getLabel() == null || ipinterface.getLabel().isEmpty()) {
log.info("Setting label of " + ipinterface.getId() + " to " + ipinterface.getIpAddress());
ipinterface.setLabel(ipinterface.getIpAddress());
dbClient.persistObject(ipinterface);
}
}
}
Aggregations