Search in sources :

Example 91 with DbClient

use of com.emc.storageos.db.client.DbClient in project coprhd-controller by CoprHD.

the class StoragePortHADomainPopulater method process.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.db.client.upgrade.BaseCustomMigrationCallback#process()
     */
@Override
public void process() throws MigrationCallbackException {
    log.info("START - StoragePortHADomainPopulater migration call back");
    DbClient dbClient = getDbClient();
    List<URI> storagePortURIs = dbClient.queryByType(StoragePort.class, false);
    Iterator<StoragePort> storagePortsIter = dbClient.queryIterativeObjects(StoragePort.class, storagePortURIs);
    Map<URI, StorageSystem> uriVsSystem = new HashMap<>();
    List<StoragePort> modifiedPorts = new ArrayList<>();
    while (storagePortsIter.hasNext()) {
        StoragePort storagePort = storagePortsIter.next();
        URI deviceURI = storagePort.getStorageDevice();
        StorageSystem system = null;
        if (uriVsSystem.containsKey(deviceURI)) {
            system = uriVsSystem.get(deviceURI);
        } else {
            system = dbClient.queryObject(StorageSystem.class, deviceURI);
            if (null != system) {
                uriVsSystem.put(deviceURI, system);
            } else {
                log.warn("No storage system found for the port - {} , it will be skipped from" + "migration, storageHADomain will continue to remain empty", storagePort.getId().toString());
                continue;
            }
        }
        if (storagePort.getStorageHADomain() == null && DiscoveredDataObject.Type.openstack.name().equalsIgnoreCase((system.getSystemType()))) {
            StorageHADomain haDomain = createStorageAdapter(system, dbClient);
            log.info("Populating the storageHADomian for the port - {} ", storagePort.getId().toString());
            storagePort.setStorageHADomain(haDomain.getId());
            modifiedPorts.add(storagePort);
        }
    }
    // Persist the change
    if (!modifiedPorts.isEmpty()) {
        dbClient.persistObject(modifiedPorts);
    }
    log.info("END - StoragePortHADomainPopulater migration call back");
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) HashMap(java.util.HashMap) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 92 with DbClient

use of com.emc.storageos.db.client.DbClient in project coprhd-controller by CoprHD.

the class VDCRoleMigrationCallback method process.

@Override
public void process() throws MigrationCallbackException {
    _log.info("VDC Role Migration Started ...");
    DbClient dbClient = getDbClient();
    TenantOrg rootTenant = findRootTenant(dbClient);
    StringSetMap tenantRoles = rootTenant.getRoleAssignments();
    if (tenantRoles == null) {
        _log.info("No Role Assignments in original Root Tenant. Skip moving.");
        return;
    }
    VirtualDataCenter vdc = VdcUtil.getLocalVdc();
    if (vdc == null) {
        throw new IllegalStateException("the CF of Local VDC is not found.");
    }
    // only copy VDC role assignments
    copyRoleAssignments(tenantRoles, vdc);
    removeRoleFromRootTenant(vdc, rootTenant);
    dbClient.persistObject(vdc);
    dbClient.persistObject(rootTenant);
    _log.info("VDC Role Migration Done.");
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) DbClient(com.emc.storageos.db.client.DbClient) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter)

Example 93 with DbClient

use of com.emc.storageos.db.client.DbClient in project coprhd-controller by CoprHD.

the class VPlexVolumeProtocolMigration method process.

@Override
public void process() throws MigrationCallbackException {
    DbClient dbClient = getDbClient();
    List<URI> volumeURIs = dbClient.queryByType(Volume.class, false);
    Iterator<Volume> volumesIter = dbClient.queryIterativeObjects(Volume.class, volumeURIs);
    while (volumesIter.hasNext()) {
        Volume volume = volumesIter.next();
        URI systemURI = volume.getStorageController();
        if (!NullColumnValueGetter.isNullURI(systemURI)) {
            StorageSystem system = dbClient.queryObject(StorageSystem.class, systemURI);
            if ((system != null) && (DiscoveredDataObject.Type.vplex.name().equals(system.getSystemType()))) {
                // This is a VPLEX volume. If not already set,
                // set the protocols to FC.
                StringSet protocols = volume.getProtocol();
                if (protocols == null) {
                    protocols = new StringSet();
                    protocols.add(StorageProtocol.Block.FC.name());
                    volume.setProtocol(protocols);
                    dbClient.persistObject(volume);
                }
            }
        }
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) Volume(com.emc.storageos.db.client.model.Volume) StringSet(com.emc.storageos.db.client.model.StringSet) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 94 with DbClient

use of com.emc.storageos.db.client.DbClient in project coprhd-controller by CoprHD.

the class VcenterTenantsSharingMigration method process.

@Override
public void process() throws MigrationCallbackException {
    DbClient dbClient = getDbClient();
    List<URI> vcenterURIs = dbClient.queryByType(Vcenter.class, false);
    Iterator<Vcenter> vcentersIter = dbClient.queryIterativeObjects(Vcenter.class, vcenterURIs);
    _log.info("Migrating vCenter tenant to acls - start");
    while (vcentersIter.hasNext()) {
        Vcenter vcenter = vcentersIter.next();
        URI tenantURI = vcenter.getTenant();
        if (!NullColumnValueGetter.isNullURI(tenantURI)) {
            _log.info("Migrating the tenant {} of the vCenter {}", vcenter.getTenant(), vcenter.getLabel());
            vcenter.setCascadeTenancy(Boolean.TRUE);
            vcenter.addAcl(tenantURI);
            vcenter.setTenant(NullColumnValueGetter.getNullURI());
            dbClient.persistObject(vcenter);
        }
    }
    _log.info("Migrating vCenter tenant to acls - end");
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) URI(java.net.URI)

Example 95 with DbClient

use of com.emc.storageos.db.client.DbClient in project coprhd-controller by CoprHD.

the class VirtualPoolDedupCapableMigration method process.

@Override
public void process() throws MigrationCallbackException {
    logger.info("Virtual pool DedupCapable migration START");
    DbClient dbClient = getDbClient();
    try {
        List<URI> virtualPoolURIs = dbClient.queryByType(VirtualPool.class, true);
        Iterator<VirtualPool> virtualPools = dbClient.queryIterativeObjects(VirtualPool.class, virtualPoolURIs, true);
        List<VirtualPool> modifiedVpools = new ArrayList<VirtualPool>();
        while (virtualPools.hasNext()) {
            VirtualPool virtualPool = virtualPools.next();
            if (VirtualPool.Type.block.name().equals(virtualPool.getType()) && virtualPool.getDedupCapable() == null) {
                virtualPool.setDedupCapable(false);
                modifiedVpools.add(virtualPool);
                logger.info("Updating VirtualPool (id={}) with DedupCapable set to default value 'false' ", virtualPool.getId().toString());
            }
        }
        if (!modifiedVpools.isEmpty()) {
            dbClient.updateObject(modifiedVpools);
        }
    } catch (Exception ex) {
        logger.error("Exception occured while migrating DedupCapable for Virtual pools");
        logger.error(ex.getMessage(), ex);
    }
    logger.info("Virtual pool DedupCapable migration END");
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)

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