Search in sources :

Example 46 with Network

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

the class NetworkConnectedVirtualArraysMigrationTest method prepareData.

@SuppressWarnings("deprecation")
@Override
protected void prepareData() throws Exception {
    Network networkAllNull;
    Network networkAssignedOnly;
    Network networkConnectedOnly;
    Network networkAssignedAndConnected;
    connectedVarray = new VirtualArray();
    connectedVarray.setId(URIUtil.createId(VirtualArray.class));
    connectedVarray.setLabel("connectedVarray");
    _dbClient.createObject(connectedVarray);
    assignedVarray = new VirtualArray();
    assignedVarray.setId(URIUtil.createId(VirtualArray.class));
    assignedVarray.setLabel("assignedVarray");
    _dbClient.createObject(assignedVarray);
    connectedAndassignedVarray = new VirtualArray();
    connectedAndassignedVarray.setId(URIUtil.createId(VirtualArray.class));
    connectedAndassignedVarray.setLabel("connectedAndassignedVarray");
    _dbClient.createObject(connectedAndassignedVarray);
    networkAllNull = new Network();
    networkAllNull.setId(URIUtil.createId(Network.class));
    networkAllNull.setLabel("networkAllNull");
    _dbClient.createObject(networkAllNull);
    networkAssignedOnly = new Network();
    networkAssignedOnly.setId(URIUtil.createId(Network.class));
    networkAssignedOnly.setLabel("networkAssignedOnly");
    networkAssignedOnly.addAssignedVirtualArrays(Collections.singletonList(assignedVarray.getId().toString()));
    _dbClient.createObject(networkAssignedOnly);
    networkConnectedOnly = new Network();
    networkConnectedOnly.setId(URIUtil.createId(Network.class));
    networkConnectedOnly.setLabel("networkConnectedOnly");
    networkConnectedOnly.addConnectedVirtualArrays(Collections.singletonList(connectedVarray.getId().toString()));
    _dbClient.createObject(networkConnectedOnly);
    networkAssignedAndConnected = new Network();
    networkAssignedAndConnected.setId(URIUtil.createId(Network.class));
    networkAssignedAndConnected.setLabel("networkAssignedAndConnected");
    networkAssignedAndConnected.addAssignedVirtualArrays(Collections.singletonList(assignedVarray.getId().toString()));
    networkAssignedAndConnected.addAssignedVirtualArrays(Collections.singletonList(connectedAndassignedVarray.getId().toString()));
    networkAssignedAndConnected.addConnectedVirtualArrays(Collections.singletonList(connectedVarray.getId().toString()));
    networkAssignedAndConnected.addConnectedVirtualArrays(Collections.singletonList(connectedAndassignedVarray.getId().toString()));
    _dbClient.createObject(networkAssignedAndConnected);
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) Network(com.emc.storageos.db.client.model.Network)

Example 47 with Network

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

the class NetworkVarrayIndexMigrationTest method prepareData.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.db.server.upgrade.DbSimpleMigrationTestBase#prepareData()
     */
@Override
protected void prepareData() throws Exception {
    DbClient dbClient = getDbClient();
    virtualArray1 = new VirtualArray();
    virtualArray1.setId(URIUtil.createId(VirtualArray.class));
    virtualArray1.setLabel("varray1");
    dbClient.createObject(virtualArray1);
    network = new Network();
    network.setId(URIUtil.createId(Network.class));
    network.setLabel("networkObj");
    StringSet varrayStrSet1 = new StringSet();
    varrayStrSet1.add(virtualArray1.getId().toString());
    network.setAssignedVirtualArrays(varrayStrSet1);
    virtualArray2 = new VirtualArray();
    virtualArray2.setId(URIUtil.createId(VirtualArray.class));
    virtualArray2.setLabel("varray2");
    dbClient.createObject(virtualArray2);
    StringSet varrayStrSet2 = new StringSet();
    varrayStrSet2.add(virtualArray1.getId().toString());
    varrayStrSet2.add(virtualArray2.getId().toString());
    network.setConnectedVirtualArrays(varrayStrSet2);
    dbClient.createObject(network);
    // prove that we've reproduced the problem
    List<Network> assignedNetworks = CustomQueryUtility.queryActiveResourcesByRelation(dbClient, virtualArray2.getId(), Network.class, "assignedVirtualArrays");
    // should be false once the index is fixed
    Assert.assertTrue(assignedNetworks.iterator().hasNext());
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) DbClient(com.emc.storageos.db.client.DbClient) Network(com.emc.storageos.db.client.model.Network) StringSet(com.emc.storageos.db.client.model.StringSet)

Example 48 with Network

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

the class NetworkVarrayIndexMigrationTest method verifyResults.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.db.server.upgrade.DbSimpleMigrationTestBase#verifyResults()
     */
@Override
protected void verifyResults() throws Exception {
    DbClient dbClient = getDbClient();
    List<Network> assignedNetworks = CustomQueryUtility.queryActiveResourcesByRelation(dbClient, virtualArray1.getId(), Network.class, "assignedVirtualArrays");
    Assert.assertTrue(assignedNetworks.iterator().hasNext());
    Assert.assertEquals(assignedNetworks.size(), 1);
    List<Network> connectedNetworks = CustomQueryUtility.queryActiveResourcesByRelation(dbClient, virtualArray2.getId(), Network.class, "connectedVirtualArrays");
    Assert.assertTrue(connectedNetworks.iterator().hasNext());
    Assert.assertEquals(connectedNetworks.size(), 1);
    connectedNetworks.clear();
    connectedNetworks = CustomQueryUtility.queryActiveResourcesByRelation(dbClient, virtualArray1.getId(), Network.class, "connectedVirtualArrays");
    Assert.assertTrue(connectedNetworks.iterator().hasNext());
    Assert.assertEquals(connectedNetworks.size(), 1);
    assignedNetworks.clear();
    assignedNetworks = CustomQueryUtility.queryActiveResourcesByRelation(dbClient, virtualArray2.getId(), Network.class, "assignedVirtualArrays");
    Assert.assertFalse(assignedNetworks.iterator().hasNext());
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) Network(com.emc.storageos.db.client.model.Network)

Example 49 with Network

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

the class NetworkAssignedVirtualArraysInitializer method process.

@SuppressWarnings("deprecation")
@Override
public void process() throws MigrationCallbackException {
    DbClient dbClient = getDbClient();
    List<URI> networkURIs = dbClient.queryByType(Network.class, false);
    Iterator<Network> networksIter = dbClient.queryIterativeObjects(Network.class, networkURIs);
    while (networksIter.hasNext()) {
        Network network = networksIter.next();
        String networkId = network.getId().toString();
        log.info("Examining Network (id={}) for upgrade", networkId);
        URI networkVArrayURI = network.getVirtualArray();
        if (!NullColumnValueGetter.isNullURI(networkVArrayURI)) {
            // Update the new field.
            network.setAssignedVirtualArrays(StringSetUtil.uriListToStringSet(Collections.singletonList(networkVArrayURI)));
            dbClient.updateAndReindexObject(network);
            log.info("Set assigned virtual arrays for network (id={}) to virtual array (id={})", networkId, networkVArrayURI.toString());
        }
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) Network(com.emc.storageos.db.client.model.Network) URI(java.net.URI)

Example 50 with Network

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

the class StoragePortConnectedVirtualArraysInitializer method process.

@SuppressWarnings("deprecation")
@Override
public void process() {
    DbClient dbClient = getDbClient();
    List<URI> storagePortURIs = dbClient.queryByType(StoragePort.class, false);
    Iterator<StoragePort> storagePortsIter = dbClient.queryIterativeObjects(StoragePort.class, storagePortURIs);
    while (storagePortsIter.hasNext()) {
        StoragePort storagePort = storagePortsIter.next();
        String storagePortId = storagePort.getId().toString();
        log.info("Examining StoragePort (id={}) for upgrade", storagePortId);
        URI networkURI = storagePort.getNetwork();
        if (!NullColumnValueGetter.isNullURI(networkURI)) {
            Network network = dbClient.queryObject(Network.class, networkURI);
            if (network != null) {
                URI varrayURI = network.getVirtualArray();
                if (!NullColumnValueGetter.isNullURI(varrayURI)) {
                    String varrayId = varrayURI.toString();
                    storagePort.addConnectedVirtualArray(varrayId);
                    dbClient.updateAndReindexObject(storagePort);
                    log.info("Set connected virtual array (id={}) for StoragePort (id={}) for upgrade", varrayId, storagePortId);
                }
            }
        }
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) Network(com.emc.storageos.db.client.model.Network) StoragePort(com.emc.storageos.db.client.model.StoragePort) URI(java.net.URI)

Aggregations

Network (com.emc.storageos.db.client.model.Network)88 URI (java.net.URI)42 ArrayList (java.util.ArrayList)38 StringSet (com.emc.storageos.db.client.model.StringSet)31 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)28 StoragePort (com.emc.storageos.db.client.model.StoragePort)25 StringMap (com.emc.storageos.db.client.model.StringMap)23 List (java.util.List)23 StoragePool (com.emc.storageos.db.client.model.StoragePool)22 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)22 Test (org.junit.Test)20 NamedURI (com.emc.storageos.db.client.model.NamedURI)19 Project (com.emc.storageos.db.client.model.Project)19 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)19 VirtualPoolCapabilityValuesWrapper (com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper)19 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)17 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)17 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)16 Produces (javax.ws.rs.Produces)16 RPProtectionRecommendation (com.emc.storageos.volumecontroller.RPProtectionRecommendation)15