Search in sources :

Example 66 with DbClient

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);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) Volume(com.emc.storageos.db.client.model.Volume) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)

Example 67 with DbClient

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);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) Network(com.emc.storageos.db.client.model.Network) ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet) URI(java.net.URI) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)

Example 68 with DbClient

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;
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) ExecutionWindowHelper(com.emc.storageos.db.client.util.ExecutionWindowHelper) DbClient(com.emc.storageos.db.client.DbClient) NamedURI(com.emc.storageos.db.client.model.NamedURI) ExecutionWindow(com.emc.storageos.db.client.model.uimodels.ExecutionWindow) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 69 with DbClient

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);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) StoragePool(com.emc.storageos.db.client.model.StoragePool) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 70 with DbClient

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);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

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