Search in sources :

Example 61 with DbClient

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

Example 62 with DbClient

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);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) Volume(com.emc.storageos.db.client.model.Volume) URI(java.net.URI)

Example 63 with DbClient

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

Example 64 with DbClient

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);
        }
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) Initiator(com.emc.storageos.db.client.model.Initiator) URI(java.net.URI)

Example 65 with DbClient

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);
        }
    }
}
Also used : IpInterface(com.emc.storageos.db.client.model.IpInterface) DbClient(com.emc.storageos.db.client.DbClient) URI(java.net.URI)

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