use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.
the class VdcControllerTest method testAddToMultipleVdc.
/**
* Adding vdc4 to a connected vdc1/2/3
*/
// Test hanging in IDE and "gradlew test"
@Test
public void testAddToMultipleVdc() throws Exception {
// create a mockdb with 3 existing vdc
dbClient.buildInitData(3);
// Treat as Geo strategy options already set to remove Cassandra, preventing calling to
// remote JMX
dbClient.getGeoStrategyOptions().put("vdc4", "abc");
VirtualDataCenter vdc1 = dbClient.vdcList.get(0);
VirtualDataCenter newVdc = newVdcForAdding("vdc4");
// dbClient.vdcList.add(newVdc);
log.info("Testing connect new vdc {} to 3 existing vdc {}", newVdc.getShortId(), vdc1.getId());
Properties vdcInfo = GeoServiceHelper.getVDCInfo(newVdc);
String reqId = "taskid-0001";
addTask(reqId, vdc1.getId());
// Start execute vdc connect
vdcController.connectVdc(vdc1, reqId, Arrays.asList(new Object[] { vdcInfo }));
// Verify result
URI newVDCId = null;
Iterator<URI> vdcIter = dbClient.queryByType(VirtualDataCenter.class, true).iterator();
while (vdcIter.hasNext()) {
URI id = vdcIter.next();
String vdcId = URIUtil.parseVdcIdFromURI(id.toASCIIString());
if (vdcId.equals("vdc4")) {
newVDCId = id;
break;
}
}
Assert.assertNotNull(newVDCId);
VirtualDataCenter vdc = dbClient.queryObject(VirtualDataCenter.class, newVDCId);
Assert.assertNotNull(vdc);
Assert.assertTrue(vdc.getShortId().equals("vdc4"));
Assert.assertNotNull(vdc.getHostCount());
Assert.assertNotNull(vdc.getHostIPv4AddressesMap());
Assert.assertTrue(clientManager.client.countForSyncCall == 3);
}
use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.
the class VdcControllerTest method testRemoveVdcInUsePreCheck.
/**
* Remove vdc2 from vdc1
*/
// Test hanging in IDE and "gradlew test"
@Test
public void testRemoveVdcInUsePreCheck() throws Exception {
// create a mock db with 2 existing vdc
dbClient.buildInitData(2);
VirtualDataCenter vdc1 = dbClient.vdcList.get(0);
VirtualDataCenter vdc2 = dbClient.vdcList.get(1);
log.info("Testing precheck for removing vdc2 {} from vdc1 {}", vdc2.getId(), vdc1.getId());
VirtualDataCenterInUse vdcInUse = new VirtualDataCenterInUse();
vdcInUse.setId(vdc2.getId());
vdcInUse.setInUse(true);
dbClient.createObject(vdcInUse);
// Start execute vdc remove
try {
String reqId = "remove-taskid-0003";
addTask(reqId, vdc2.getId());
vdcController.removeVdc(vdc2, reqId, null);
Assert.assertTrue("Precheck should throw an exception", false);
} catch (Exception ex) {
log.error("precheck error ", ex);
Assert.assertTrue(ex instanceof FatalGeoException);
}
}
use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.
the class VdcControllerTest method testRemoveVdcFromThreeSiteGeo.
/**
* Remove vdc3 from vdc1/vdc2
*/
// Test hanging in IDE and "gradlew test"
@Test
public void testRemoveVdcFromThreeSiteGeo() throws Exception {
// create a mock db with 3 existing vdc
dbClient.buildInitData(3);
VirtualDataCenter vdc1 = dbClient.vdcList.get(0);
VirtualDataCenter vdc2 = dbClient.vdcList.get(1);
VirtualDataCenter vdc3 = dbClient.vdcList.get(1);
log.info("Testing remove vdc3 {} ", vdc3.getId());
// Start execute vdc remove
vdc3.setConnectionStatus(VirtualDataCenter.ConnectionStatus.REMOVING);
dbClient.updateAndReindexObject(vdc3);
String reqId = "remove-taskid-0003";
addTask(reqId, vdc3.getId());
vdcController.removeVdc(vdc3, reqId, null);
// Verify result
Assert.assertTrue(dbClient.vdcList.size() == 2);
VirtualDataCenter vdc = dbClient.queryObject(VirtualDataCenter.class, vdc1.getId());
Assert.assertNotNull(vdc);
Assert.assertTrue(vdc.getShortId().equals("vdc1"));
Assert.assertNotNull(vdc.getHostCount());
Assert.assertNotNull(vdc.getHostIPv4AddressesMap());
Assert.assertTrue(clientManager.client.countForSyncCall == 2);
// vdc3 should be removed from local db
vdc = dbClient.queryObject(VirtualDataCenter.class, vdc3.getId());
Assert.assertNull(vdc);
}
use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.
the class VdcUtil method buildUrnMap.
private static void buildUrnMap() {
if (rebuildVdcIdMap) {
// When running unit test, prevents NPEs when creating URIs
if (dbClient == null) {
return;
}
synchronized (vdcIdMap) {
if (rebuildVdcIdMap) {
log.info("Rebuilding the vdcIdMap from the database");
List<URI> vdcIds = dbClient.queryByType(VirtualDataCenter.class, true);
Iterator<VirtualDataCenter> vdcIter = dbClient.queryIterativeObjects(VirtualDataCenter.class, vdcIds);
localVdc = null;
vdcIdMap.clear();
while (vdcIter.hasNext()) {
VirtualDataCenter vdc = vdcIter.next();
vdcIdMap.put(vdc.getShortId(), vdc.getId());
if (Boolean.TRUE.equals(vdc.getLocal())) {
localVdc = vdc;
}
}
if (!vdcIdMap.isEmpty()) {
rebuildVdcIdMap = false;
}
}
}
}
}
use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.
the class SchemaUtil method insertMyVdcInfo.
/**
* Insert vdc info of current site
*/
private void insertMyVdcInfo(DbClient dbClient) throws UnknownHostException {
if (!getCfMap().containsKey(TypeMap.getDoType(VirtualDataCenter.class).getCF().getName())) {
_log.error("Unable to find VirtualDataCenter CF in current keyspace");
return;
}
VirtualDataCenter localVdc = queryLocalVdc(dbClient);
if (localVdc != null) {
return;
}
_log.info("insert vdc info of current site...");
VirtualDataCenter vdc = new VirtualDataCenter();
vdc.setId(URIUtil.createVirtualDataCenterId(_vdcShortId));
vdc.setShortId(_vdcShortId);
vdc.setLabel(_vdcShortId);
vdc.setConnectionStatus(VirtualDataCenter.ConnectionStatus.ISOLATED);
vdc.setRepStatus(VirtualDataCenter.GeoReplicationStatus.REP_NONE);
// timestamp
vdc.setVersion(new Date().getTime());
vdc.setApiEndpoint(_vdcEndpoint);
vdc.setLocal(true);
dbClient.createObject(vdc);
}
Aggregations