Search in sources :

Example 81 with DataObject

use of com.emc.storageos.db.client.model.DataObject in project coprhd-controller by CoprHD.

the class QueryService method queryObject.

@GET
@Path(GeoServiceClient.GEO_VISIBLE + "{name}/object/{id}")
@Produces({ MediaType.APPLICATION_OCTET_STREAM })
public Response queryObject(@PathParam("name") String className, @PathParam("id") URI id) throws DatabaseException {
    ArgValidator.checkFieldNotNull(className, "name");
    ArgValidator.checkUri(id);
    try {
        Class clazz = Class.forName(className);
        DataObject obj = dbClient.queryObject(clazz, id);
        return Response.ok(getStreamingOutput(obj), MediaType.APPLICATION_OCTET_STREAM).build();
    } catch (ClassNotFoundException e) {
        log.error("e=", e);
        throw APIException.badRequests.invalidParameter("name", className);
    }
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject)

Example 82 with DataObject

use of com.emc.storageos.db.client.model.DataObject in project coprhd-controller by CoprHD.

the class VdcConfigHelper method resetStaleLocalObjects.

public void resetStaleLocalObjects() {
    Class[] resetClasses = new Class[] { Token.class, StorageOSUserDAO.class, PasswordHistory.class, CustomConfig.class, TenantOrg.class };
    for (Class clazz : resetClasses) {
        List<URI> idList = dbClient.queryByType(clazz, true);
        log.info("Reset data object {}", clazz);
        for (URI key : idList) {
            DataObject obj = dbClient.queryObject((Class<? extends DataObject>) clazz, key);
            dbClient.removeObject(obj);
            log.info("Remove {}", key);
        }
    }
}
Also used : CustomConfig(com.emc.storageos.db.client.model.CustomConfig) StorageOSUserDAO(com.emc.storageos.db.client.model.StorageOSUserDAO) DataObject(com.emc.storageos.db.client.model.DataObject) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) Token(com.emc.storageos.db.client.model.Token) PasswordHistory(com.emc.storageos.db.client.model.PasswordHistory) URI(java.net.URI)

Example 83 with DataObject

use of com.emc.storageos.db.client.model.DataObject in project coprhd-controller by CoprHD.

the class ExportMaskUtils method sanitizeExportMaskContainers.

/**
 * Routine will examine the ExportMask and determine if any of its initiators or volumes no
 * longer exist in the database or are marked as inactive. If so, they will get removed
 * from the list.
 *
 * @param dbClient [in] - DbClient object
 * @param exportMask [in] - ExportMask object to check and sanitize
 */
public static void sanitizeExportMaskContainers(DbClient dbClient, ExportMask exportMask) {
    if (exportMask != null) {
        List<URI> initiatorURIs = StringSetUtil.stringSetToUriList(exportMask.getInitiators());
        List<URI> initiatorsToRemove = new ArrayList<>();
        for (URI initiatorURI : initiatorURIs) {
            DataObject initiator = dbClient.queryObject(initiatorURI);
            if (initiator == null || initiator.getInactive()) {
                initiatorsToRemove.add(initiatorURI);
            }
        }
        if (!initiatorsToRemove.isEmpty()) {
            _log.info(String.format("sanitizeExportMaskContainers - Removing non-existent/inactive Initiators from ExportMask %s (%s): %s", exportMask.getMaskName(), exportMask.getId(), CommonTransformerFunctions.collectionToString(initiatorsToRemove)));
            exportMask.removeInitiatorURIs(initiatorsToRemove);
            exportMask.removeFromUserAddedInitiatorsByURI(initiatorsToRemove);
        }
        Map<URI, Integer> volumeMap = StringMapUtil.stringMapToVolumeMap(exportMask.getVolumes());
        List<URI> volumesToRemove = new ArrayList<>();
        for (URI volumeURI : volumeMap.keySet()) {
            DataObject volume = dbClient.queryObject(volumeURI);
            if (volume == null || volume.getInactive()) {
                volumesToRemove.add(volumeURI);
            }
        }
        if (!volumesToRemove.isEmpty()) {
            _log.info(String.format("sanitizeExportMaskContainers - Removing non-existent/inactive BlockObjects from ExportMask %s (%s): %s", exportMask.getMaskName(), exportMask.getId(), CommonTransformerFunctions.collectionToString(volumesToRemove)));
            exportMask.removeVolumes(volumesToRemove);
            exportMask.removeFromUserAddedVolumesByURI(volumesToRemove);
        }
        List<URI> storagePorts = StringSetUtil.stringSetToUriList(exportMask.getStoragePorts());
        List<URI> storagePortsToRemove = new ArrayList<>();
        for (URI storagePortURI : storagePorts) {
            DataObject storagePort = dbClient.queryObject(storagePortURI);
            if (storagePort == null || storagePort.getInactive()) {
                storagePortsToRemove.add(storagePortURI);
            }
        }
        if (!storagePortsToRemove.isEmpty()) {
            _log.info(String.format("sanitizeExportMaskContainers - Removing non-existent/inactive StoragePorts from ExportMask %s (%s): %s", exportMask.getMaskName(), exportMask.getId(), CommonTransformerFunctions.collectionToString(storagePortsToRemove)));
            exportMask.removeTargets(storagePortsToRemove);
        }
    }
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) ArrayList(java.util.ArrayList) URI(java.net.URI)

Example 84 with DataObject

use of com.emc.storageos.db.client.model.DataObject in project coprhd-controller by CoprHD.

the class BaseAssetOptionsProvider method createOptions.

protected List<AssetOption> createOptions(Collection<? extends DataObject> values) {
    List<AssetOption> options = Lists.newArrayList();
    for (DataObject value : values) {
        options.add(createOption(value));
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) DataObject(com.emc.storageos.db.client.model.DataObject)

Example 85 with DataObject

use of com.emc.storageos.db.client.model.DataObject in project coprhd-controller by CoprHD.

the class BlockSnapshotSessionMigrationTest method prepareGroupSnapshotData.

/**
 * Prepares group snapshot test data.
 */
private void prepareGroupSnapshotData() {
    // A list of database object instances to be created.
    ArrayList<DataObject> newObjectsToBeCreated = new ArrayList<DataObject>();
    // Create some group BlockSnapshot instances on a storage system
    // that supports snapshot sessions. VMAX3 is the only storage
    // system for which we currently support snapshot sessions. We
    // set up the system so that the method on StorageSystem
    // "checkIfVmax3" returns true.
    StorageSystem system = new StorageSystem();
    URI systemURI = URIUtil.createId(StorageSystem.class);
    system.setId(systemURI);
    system.setSystemType(DiscoveredDataObject.Type.vmax.name());
    system.setFirmwareVersion(VMAX3_SYSTEM_FW_VERSION);
    newObjectsToBeCreated.add(system);
    BlockConsistencyGroup cg = new BlockConsistencyGroup();
    URI cgURI = URIUtil.createId(BlockConsistencyGroup.class);
    cg.setId(cgURI);
    newObjectsToBeCreated.add(cg);
    URI projectURI = URIUtil.createId(Project.class);
    for (int i = 0; i < GRP_SETTINGS_INSTANCE_COUNT; i++) {
        for (int j = 0; j < SNAPVX_SNAPSHOT_COUNT; j++) {
            BlockSnapshot snapshot = new BlockSnapshot();
            URI snapshotURI = URIUtil.createId(BlockSnapshot.class);
            snapshot.setId(snapshotURI);
            snapshot.setLabel(BASE_GRP_SNAPVX_SNAPSHOT_NAME + i + j);
            snapshot.setSnapsetLabel(BASE_GRP_SNAPVX_SNAPSHOT_NAME + i);
            snapshot.setProject(new NamedURI(projectURI, PROJECT_NAME));
            URI parentURI = URIUtil.createId(Volume.class);
            snapshot.setParent(new NamedURI(parentURI, GRP_PARENT_NAME + i + j));
            snapshot.setConsistencyGroup(cgURI);
            snapshot.setSettingsInstance(BASE_GRP_SETTINGS_INSTANCE + i);
            snapshot.setStorageController(systemURI);
            newObjectsToBeCreated.add(snapshot);
        }
    }
    // Create the database objects.
    _dbClient.createObject(newObjectsToBeCreated);
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) NamedURI(com.emc.storageos.db.client.model.NamedURI) ArrayList(java.util.ArrayList) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Aggregations

DataObject (com.emc.storageos.db.client.model.DataObject)154 URI (java.net.URI)62 ArrayList (java.util.ArrayList)53 DiscoveredDataObject (com.emc.storageos.db.client.model.DiscoveredDataObject)44 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)30 Volume (com.emc.storageos.db.client.model.Volume)26 NamedURI (com.emc.storageos.db.client.model.NamedURI)24 StringSet (com.emc.storageos.db.client.model.StringSet)23 HashMap (java.util.HashMap)22 BlockObject (com.emc.storageos.db.client.model.BlockObject)17 HashSet (java.util.HashSet)17 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)16 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)14 Operation (com.emc.storageos.db.client.model.Operation)13 List (java.util.List)10 Set (java.util.Set)10 BlockSnapshotSession (com.emc.storageos.db.client.model.BlockSnapshotSession)9 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)9 InvocationTargetException (java.lang.reflect.InvocationTargetException)9 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)8