use of com.emc.storageos.db.client.model.VirtualArray in project coprhd-controller by CoprHD.
the class VdcUtilTest method testVdcUtil.
@Test
public void testVdcUtil() {
VirtualDataCenter localVdc = null;
DbClient dbClient = getDbClient();
Iterator<URI> vdcs = dbClient.queryByType(VirtualDataCenter.class, true).iterator();
if (vdcs.hasNext()) {
localVdc = dbClient.queryObject(VirtualDataCenter.class, vdcs.next());
} else {
Assert.fail("no VDC found in database");
}
if (vdcs.hasNext()) {
Assert.fail("multiple VDC's found in database after initial bootstap");
}
Assert.assertEquals(localVdc.getId(), VdcUtil.getLocalVdc().getId());
Assert.assertEquals(localVdc.getShortId(), VdcUtil.getLocalShortVdcId());
Assert.assertEquals(localVdc.getId(), VdcUtil.getVdcUrn(localVdc.getShortId()));
VirtualDataCenter remoteVdc1 = new VirtualDataCenter();
remoteVdc1.setId(URIUtil.createId(VirtualDataCenter.class));
remoteVdc1.setLocal(Boolean.FALSE);
remoteVdc1.setShortId("vdc2");
VirtualDataCenter remoteVdc2 = new VirtualDataCenter();
remoteVdc2.setId(URIUtil.createId(VirtualDataCenter.class));
remoteVdc2.setLocal(Boolean.FALSE);
remoteVdc2.setShortId("vdc3");
List<VirtualDataCenter> vdcList = new ArrayList<VirtualDataCenter>();
vdcList.add(remoteVdc1);
vdcList.add(remoteVdc2);
dbClient.createObject(vdcList);
VdcUtil.invalidateVdcUrnCache();
Assert.assertEquals(localVdc.getId(), VdcUtil.getLocalVdc().getId());
Assert.assertEquals(localVdc.getShortId(), VdcUtil.getLocalShortVdcId());
Assert.assertEquals(localVdc.getId(), VdcUtil.getVdcUrn(localVdc.getShortId()));
Assert.assertEquals(remoteVdc1.getId(), VdcUtil.getVdcUrn(remoteVdc1.getShortId()));
Assert.assertEquals(remoteVdc2.getId(), VdcUtil.getVdcUrn(remoteVdc2.getShortId()));
VirtualArray va = new VirtualArray();
va.setId(URIUtil.createId(VirtualArray.class));
Assert.assertFalse(VdcUtil.isRemoteObject(va));
vdcList.clear();
remoteVdc1.setLocal(Boolean.TRUE);
localVdc.setLocal(Boolean.FALSE);
vdcList.add(remoteVdc1);
vdcList.add(localVdc);
dbClient.updateAndReindexObject(vdcList);
VdcUtil.invalidateVdcUrnCache();
Assert.assertTrue(VdcUtil.isRemoteObject(va));
URI globalId = URIUtil.createId(Project.class);
URI localId = URIUtil.createId(FileShare.class);
Assert.assertTrue(VdcUtil.getVdcId(Project.class, globalId).toString().equals(VdcUtil.getLocalShortVdcId()));
Assert.assertTrue(VdcUtil.getVdcId(FileShare.class, localId).toString().equals(VdcUtil.getLocalShortVdcId()));
}
use of com.emc.storageos.db.client.model.VirtualArray in project coprhd-controller by CoprHD.
the class DbClientTest method createVirtualArrays.
private List<VirtualArray> createVirtualArrays(int count, String labelPrefix) {
List<VirtualArray> varrays = new ArrayList<>(count);
for (int i = 0; i < count; i++) {
VirtualArray varray = new VirtualArray();
varray.setId(URIUtil.createId(VirtualArray.class));
varray.setLabel(labelPrefix + i);
_dbClient.createObject(varray);
varrays.add(varray);
}
return varrays;
}
use of com.emc.storageos.db.client.model.VirtualArray in project coprhd-controller by CoprHD.
the class DbClientTest method testPrefixPaginateConstraint.
@Test
public void testPrefixPaginateConstraint() throws Exception {
int objCount = 10;
List<VirtualArray> varrays = createVirtualArrays(10, "foo");
Constraint labelConstraint = PrefixConstraint.Factory.getLabelPrefixConstraint(VirtualArray.class, "foo");
queryInPaginate(labelConstraint, URIQueryResultList.class, objCount, pageSize);
}
use of com.emc.storageos.db.client.model.VirtualArray in project coprhd-controller by CoprHD.
the class DbClientTest method testDecommisionedConstraintWithPageinate.
@Test
public void testDecommisionedConstraintWithPageinate() throws Exception {
int objCount = 10;
List<VirtualArray> varrays = createVirtualArrays(10, "foo");
List<URI> ids = _dbClient.queryByType(VirtualArray.class, true);
int count = 0;
for (@SuppressWarnings("unused") URI ignore : ids) {
count++;
}
Assert.assertEquals(objCount, count);
testQueryByType(VirtualArray.class, true, objCount);
testQueryByType(VirtualArray.class, false, objCount);
// delete two virtual arrays
_dbClient.markForDeletion(varrays.get(0));
_dbClient.markForDeletion(varrays.get(1));
testQueryByType(VirtualArray.class, true, objCount - 2);
testQueryByType(VirtualArray.class, false, objCount);
}
use of com.emc.storageos.db.client.model.VirtualArray in project coprhd-controller by CoprHD.
the class RPRecommendation method toString.
/**
* Print the recommendation
*
* @param dbClient DBClient reference
* @param ps The protection system in question
* @param noOfTabs Number of tabs to use
* @return Recommendation string output
*/
public String toString(DbClient dbClient, ProtectionSystem ps, int... noOfTabs) {
StringBuffer buff = new StringBuffer();
final String TAB = "\t";
String printTabs = TAB;
if (noOfTabs.length > 0 && noOfTabs[0] > 0) {
for (int i = 0; i < noOfTabs[0]; i++) {
printTabs += TAB;
}
}
VirtualArray varray = dbClient.queryObject(VirtualArray.class, getVirtualArray());
VirtualPool vpool = getVirtualPool();
StoragePool storagePool = dbClient.queryObject(StoragePool.class, getSourceStoragePool());
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, getSourceStorageSystem());
buff.append(String.format("%n"));
buff.append(printTabs + String.format("Resource Count \t\t: %s %n", this.getResourceCount()));
String siteName = ((ps.getRpSiteNames() != null) ? ps.getRpSiteNames().get(this.getInternalSiteName()) : "");
String siteId = this.getInternalSiteName();
if (this.getInternalSiteName() == null) {
siteName = "(no RP protection specified)";
siteId = "";
}
buff.append(printTabs + String.format("Internal Site \t\t: %s %s %n", siteName, siteId));
buff.append(printTabs + String.format("RP Copy Name \t\t: %s %n", (this.getRpCopyName() == null ? "Not determined yet" : this.getRpCopyName())));
buff.append(printTabs + String.format("Virtual Array \t\t: %s %n", varray.getLabel()));
buff.append(printTabs + String.format("Virtual Pool \t\t: %s %n", vpool.getLabel()));
if (virtualVolumeRecommendation != null && virtualVolumeRecommendation.getVPlexStorageSystem() != null) {
StorageSystem vplexStorageSystem = dbClient.queryObject(StorageSystem.class, virtualVolumeRecommendation.getVPlexStorageSystem());
buff.append(printTabs + String.format("VPLEX Storage \t\t: %s %n", vplexStorageSystem.getLabel()));
}
buff.append(printTabs + String.format("Storage Pool \t\t: %s %n", storagePool.getLabel()));
buff.append(printTabs + String.format("Storage System \t\t: %s %n", storageSystem.getLabel()));
buff.append(printTabs + String.format("Resource Size \t\t: %s GB %n", SizeUtil.translateSize(this.getSize(), SizeUtil.SIZE_GB)));
buff.append(String.format("----------------------%n"));
if (this.getHaRecommendation() != null) {
buff.append(printTabs + String.format("High Availability Recommendation : %n"));
buff.append(getHaRecommendation().toString(dbClient, ps, 1));
if (this.getHaRecommendation().getTargetRecommendations() != null && !this.getHaRecommendation().getTargetRecommendations().isEmpty()) {
buff.append(printTabs + String.format("High Availability Target : %n"));
for (RPRecommendation haTargetRec : this.getHaRecommendation().getTargetRecommendations()) {
buff.append(String.format("%s", haTargetRec.toString(dbClient, ps, 1)));
}
}
}
return buff.toString();
}
Aggregations