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);
}
}
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);
}
}
}
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);
}
}
}
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;
}
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);
}
Aggregations