use of com.emc.storageos.db.client.DbClient 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);
}
}
use of com.emc.storageos.db.client.DbClient in project coprhd-controller by CoprHD.
the class NetworkConnectedVirtualArraysMigration method process.
/**
* Add assigned virtual arrays to connected virtual arrays.
* Starting 2.0, connected virtual arrays includes assigned,
* connected via port-virtualArray associations, and connected
* via routed networks
*/
@Override
public void process() throws MigrationCallbackException {
DbClient dbClient = getDbClient();
try {
List<URI> networkUris = dbClient.queryByType(Network.class, true);
Iterator<Network> networks = dbClient.queryIterativeObjects(Network.class, networkUris);
List<Network> updated = new ArrayList<Network>();
while (networks.hasNext()) {
Network network = networks.next();
log.info("Updating connected virtual arrays for network {}", network.getLabel());
if (network.getAssignedVirtualArrays() != null) {
if (network.getConnectedVirtualArrays() != null) {
for (String assignedVarrayUri : network.getAssignedVirtualArrays()) {
log.info("Adding virtual array {} to connected virtual arrays", assignedVarrayUri);
network.getConnectedVirtualArrays().add(assignedVarrayUri);
}
} else {
log.info("Setting connected virtual arrays to {}", network.getAssignedVirtualArrays());
network.setConnectedVirtualArrays(new StringSet(network.getAssignedVirtualArrays()));
}
updated.add(network);
}
}
dbClient.updateAndReindexObject(updated);
} catch (Exception e) {
log.error("Exception occured while updating Network connectedVirtualArrays");
log.error(e.getMessage(), e);
}
}
use of com.emc.storageos.db.client.DbClient in project coprhd-controller by CoprHD.
the class OrderScheduleTimeCallback method process.
@Override
public void process() throws MigrationCallbackException {
log.info("Handle Order schedule time ...");
DbClient dbClient = getDbClient();
List<URI> orders = dbClient.queryByType(Order.class, true);
for (URI uri : orders) {
Order order = dbClient.queryObject(Order.class, uri);
if (order == null)
continue;
if (order.getScheduledEventId() == null) {
if (order.getExecutionWindowId() == null || order.getExecutionWindowId().getURI().equals(ExecutionWindow.NEXT)) {
Calendar scheduleTime = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
scheduleTime.setTime(order.getLastUpdated());
order.setExecutionWindowId(new NamedURI(ExecutionWindow.NEXT, "NEXT"));
order.setScheduledTime(scheduleTime);
} else {
// For original orders, set schedule time to
// either 1) the next execution window starting time
// or 2) the current time if it is in current execution window
ExecutionWindow executionWindow = dbClient.queryObject(ExecutionWindow.class, order.getExecutionWindowId().getURI());
if (executionWindow == null)
continue;
ExecutionWindowHelper helper = new ExecutionWindowHelper(executionWindow);
order.setScheduledTime(helper.getScheduledTime());
}
dbClient.updateObject(order);
}
}
return;
}
use of com.emc.storageos.db.client.DbClient in project coprhd-controller by CoprHD.
the class PoolsCompatibilityStatusMigration method process.
@Override
public void process() throws MigrationCallbackException {
DbClient dbClient = getDbClient();
List<URI> storageSystemURIs = dbClient.queryByType(StorageSystem.class, true);
Iterator<StorageSystem> storageSystemObjs = dbClient.queryIterativeObjects(StorageSystem.class, storageSystemURIs);
while (storageSystemObjs.hasNext()) {
StorageSystem storageSystem = storageSystemObjs.next();
URIQueryResultList storagePoolURIs = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePoolConstraint(storageSystem.getId()), storagePoolURIs);
Iterator<StoragePool> storagePoolObjs = dbClient.queryIterativeObjects(StoragePool.class, storagePoolURIs);
List<StoragePool> pools = new ArrayList<StoragePool>();
while (storagePoolObjs.hasNext()) {
StoragePool pool = storagePoolObjs.next();
if (pool.getInactive()) {
continue;
}
log.info("Setting compatibility status of " + pool.getId() + " to " + storageSystem.getCompatibilityStatus());
pool.setCompatibilityStatus(storageSystem.getCompatibilityStatus());
pools.add(pool);
}
dbClient.persistObject(pools);
}
}
use of com.emc.storageos.db.client.DbClient in project coprhd-controller by CoprHD.
the class PortsCompatibilityStatusMigration method process.
@Override
public void process() throws MigrationCallbackException {
DbClient dbClient = getDbClient();
List<URI> storageSystemURIs = dbClient.queryByType(StorageSystem.class, true);
Iterator<StorageSystem> storageSystemObjs = dbClient.queryIterativeObjects(StorageSystem.class, storageSystemURIs);
while (storageSystemObjs.hasNext()) {
StorageSystem storageSystem = storageSystemObjs.next();
URIQueryResultList storagePortURIs = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePortConstraint(storageSystem.getId()), storagePortURIs);
Iterator<StoragePort> storagePortObjs = dbClient.queryIterativeObjects(StoragePort.class, storagePortURIs);
List<StoragePort> ports = new ArrayList<StoragePort>();
while (storagePortObjs.hasNext()) {
StoragePort port = storagePortObjs.next();
if (port.getInactive()) {
continue;
}
log.info("Setting compatibility status of " + port.getId() + " to " + storageSystem.getCompatibilityStatus());
port.setCompatibilityStatus(storageSystem.getCompatibilityStatus());
ports.add(port);
}
dbClient.persistObject(ports);
}
}
Aggregations