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);
}
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());
}
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());
}
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());
}
}
}
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);
}
}
}
}
}
Aggregations