Search in sources :

Example 86 with VirtualArray

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()));
}
Also used : Project(com.emc.storageos.db.client.model.Project) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) DbClient(com.emc.storageos.db.client.DbClient) VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) ArrayList(java.util.ArrayList) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare) Test(org.junit.Test)

Example 87 with VirtualArray

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;
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) ArrayList(java.util.ArrayList) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentPrefixConstraint(com.emc.storageos.db.client.constraint.ContainmentPrefixConstraint) AggregatedConstraint(com.emc.storageos.db.client.constraint.AggregatedConstraint) ContainmentPermissionsConstraint(com.emc.storageos.db.client.constraint.ContainmentPermissionsConstraint) Constraint(com.emc.storageos.db.client.constraint.Constraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint)

Example 88 with VirtualArray

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);
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentPrefixConstraint(com.emc.storageos.db.client.constraint.ContainmentPrefixConstraint) AggregatedConstraint(com.emc.storageos.db.client.constraint.AggregatedConstraint) ContainmentPermissionsConstraint(com.emc.storageos.db.client.constraint.ContainmentPermissionsConstraint) Constraint(com.emc.storageos.db.client.constraint.Constraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentPrefixConstraint(com.emc.storageos.db.client.constraint.ContainmentPrefixConstraint) AggregatedConstraint(com.emc.storageos.db.client.constraint.AggregatedConstraint) ContainmentPermissionsConstraint(com.emc.storageos.db.client.constraint.ContainmentPermissionsConstraint) Constraint(com.emc.storageos.db.client.constraint.Constraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) Test(org.junit.Test)

Example 89 with VirtualArray

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);
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentPrefixConstraint(com.emc.storageos.db.client.constraint.ContainmentPrefixConstraint) AggregatedConstraint(com.emc.storageos.db.client.constraint.AggregatedConstraint) ContainmentPermissionsConstraint(com.emc.storageos.db.client.constraint.ContainmentPermissionsConstraint) Constraint(com.emc.storageos.db.client.constraint.Constraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) Test(org.junit.Test)

Example 90 with VirtualArray

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();
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) StoragePool(com.emc.storageos.db.client.model.StoragePool) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

VirtualArray (com.emc.storageos.db.client.model.VirtualArray)183 URI (java.net.URI)91 ArrayList (java.util.ArrayList)91 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)84 Project (com.emc.storageos.db.client.model.Project)53 NamedURI (com.emc.storageos.db.client.model.NamedURI)52 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)52 StringSet (com.emc.storageos.db.client.model.StringSet)50 Volume (com.emc.storageos.db.client.model.Volume)46 VirtualPoolCapabilityValuesWrapper (com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper)44 List (java.util.List)44 StoragePool (com.emc.storageos.db.client.model.StoragePool)43 HashMap (java.util.HashMap)38 StringMap (com.emc.storageos.db.client.model.StringMap)37 Recommendation (com.emc.storageos.volumecontroller.Recommendation)37 RPRecommendation (com.emc.storageos.volumecontroller.RPRecommendation)31 RPProtectionRecommendation (com.emc.storageos.volumecontroller.RPProtectionRecommendation)30 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)29 Network (com.emc.storageos.db.client.model.Network)27 VPlexRecommendation (com.emc.storageos.volumecontroller.VPlexRecommendation)27