use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.
the class VdcControllerTest method testAddToSingleVdc.
/**
* Adding vdc2 to vdc1
*/
// Test hanging in IDE and "gradlew test"
@Test
public void testAddToSingleVdc() throws Exception {
dbClient.buildInitData(1);
// Treat as Geo strategy options already set to remove Cassandra, preventing calling to
// remote JMX
dbClient.getGeoStrategyOptions().put("vdc2", "abc");
VirtualDataCenter vdc1 = dbClient.vdcList.get(0);
VirtualDataCenter newVdc = newVdcForAdding("vdc2");
// dbClient.vdcList.add(newVdc);
log.info("Testing connect vdc2 {} to vdc1 {}", newVdc.getShortId(), vdc1.getId());
Properties vdcInfo = GeoServiceHelper.getVDCInfo(newVdc);
String reqId = "taskid-0000";
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("vdc2")) {
newVDCId = id;
break;
}
}
Assert.assertNotNull(newVDCId);
VirtualDataCenter vdc = dbClient.queryObject(VirtualDataCenter.class, newVDCId);
Assert.assertNotNull(vdc);
Assert.assertTrue(vdc.getShortId().equals("vdc2"));
Assert.assertNotNull(vdc.getHostCount());
Assert.assertNotNull(vdc.getHostIPv4AddressesMap());
Assert.assertTrue(vdc.getHostIPv4AddressesMap().size() == 1);
Assert.assertTrue(clientManager.client.countForSyncCall == 1);
}
use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.
the class VdcControllerTest method testAddVdcPrecheckFailure.
// Test hanging in IDE and "gradlew test"
@Test
public void testAddVdcPrecheckFailure() throws Exception {
// create a mock db with 2 existing vdc
dbClient.buildInitData(2);
VirtualDataCenter vdc1 = dbClient.vdcList.get(0);
vdc1.setConnectionStatus(VirtualDataCenter.ConnectionStatus.CONNECTING);
VirtualDataCenter newVdc = newVdcForAdding("vdc2");
log.info("Testing connect vdc2 {} to vdc1 {}", newVdc.getShortId(), vdc1.getId());
// Start execute vdc connect
try {
Properties vdcInfo = GeoServiceHelper.getVDCInfo(newVdc);
String reqId = "taskid-0003";
addTask(reqId, vdc1.getId());
// Start execute vdc connect
vdcController.connectVdc(vdc1, reqId, Arrays.asList(new Object[] { vdcInfo }));
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 testRemoveVdcPreCheck.
/**
* Remove vdc2 from vdc1
*/
// Test hanging in IDE and "gradlew test"
@Test
public void testRemoveVdcPreCheck() 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());
// create a geo object referencing a geo visible object in vdc2
TestGeoObject obj = new TestGeoObject();
obj.setId(URIUtil.createId(TestGeoObject.class));
String varrayId = URIUtil.createId(VirtualArray.class).toString();
varrayId = varrayId.replace("vdc1", "vdc2");
obj.setVarray(new URI(varrayId));
dbClient.testGeoList.add(obj);
// Start execute vdc remove
try {
String reqId = "remove-taskid-0002";
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 VdcConfigService method updateBlackListForReconnectedVdc.
private void updateBlackListForReconnectedVdc() {
List<URI> vdcIds = dbClient.queryByType(VirtualDataCenter.class, true);
dbClient.clearBlackList();
log.info("After clear, get current black list {}", dbClient.getBlacklist());
for (URI vdcId : vdcIds) {
VirtualDataCenter vdc = dbClient.queryObject(VirtualDataCenter.class, vdcId);
if (vdc.getConnectionStatus() == VirtualDataCenter.ConnectionStatus.DISCONNECTED) {
log.info("Add vdc {} with status {} to blacklist", vdc.getId(), vdc.getConnectionStatus());
dbClient.addVdcNodesToBlacklist(vdc);
}
}
}
use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.
the class VdcConfigService method reconnectVdc.
private void reconnectVdc(String vdcId) throws Exception {
URI id = new URI(vdcId);
VirtualDataCenter vdc = dbClient.queryObject(VirtualDataCenter.class, id);
vdc.setConnectionStatus(VirtualDataCenter.ConnectionStatus.CONNECTED);
dbClient.updateAndReindexObject(vdc);
dbClient.removeVdcNodesFromBlacklist(vdc);
}
Aggregations