use of com.emc.storageos.db.client.model.OpStatusMap in project coprhd-controller by CoprHD.
the class DbClientImpl method createTaskOpStatus.
@Override
public Operation createTaskOpStatus(Class<? extends DataObject> clazz, URI id, String opId, Operation newOperation) {
tracer.newTracer("write");
if (newOperation == null) {
throw new IllegalArgumentException("missing required parameter: Operation");
}
try {
if (newOperation.getDescription() == null) {
throw new IllegalArgumentException("missing required parameter: description");
}
DataObject doobj = clazz.newInstance();
doobj.setId(id);
doobj.setOpStatus(new OpStatusMap());
Operation op = new Operation();
op.setStartTime(Calendar.getInstance());
String message = newOperation.getMessage();
String description = newOperation.getDescription();
String name = newOperation.getName();
if (newOperation.getStatus().equals(Operation.Status.ready.name())) {
op.ready();
op.setEndTime(Calendar.getInstance());
}
if (message != null) {
op.setMessage(message);
}
if (description != null) {
op.setDescription(description);
}
if (name != null) {
op.setName(name);
}
List<String> associatedResources = newOperation.getAssociatedResourcesField();
if (associatedResources != null) {
String associatedResourcesStr = Joiner.on(',').join(associatedResources);
op.setAssociatedResourcesField(associatedResourcesStr);
}
doobj.getOpStatus().put(opId, op);
persistObject(doobj);
newOperation.addTask(id, op.getTask(id));
return op;
} catch (InstantiationException e) {
throw new IllegalStateException(e);
} catch (IllegalAccessException e) {
throw new IllegalStateException(e);
}
}
use of com.emc.storageos.db.client.model.OpStatusMap in project coprhd-controller by CoprHD.
the class ExportService method initTaskStatus.
private Operation initTaskStatus(ExportGroup exportGroup, String task, Operation.Status status, ResourceOperationTypeEnum opType) {
if (exportGroup.getOpStatus() == null) {
exportGroup.setOpStatus(new OpStatusMap());
}
Operation op = new Operation();
op.setResourceType(opType);
if (status == Operation.Status.ready) {
op.ready();
}
_dbClient.createTaskOpStatus(ExportGroup.class, exportGroup.getId(), task, op);
return op;
}
use of com.emc.storageos.db.client.model.OpStatusMap in project coprhd-controller by CoprHD.
the class BlockSnapshotService method prepareVPLEXBackendVolumeFromSnapshot.
/**
* Creates a Volume instance to represent the snapshot target volume represented
* by the passed BlockSnapshot instance.
*
* @param snapshot A reference to a BlockSnapshot instance.
* @param sourceVolume A reference to the snapshot source Volume.
*
* @return A new INTERNAL Volume instance representing the snapshot target volume.
*/
private Volume prepareVPLEXBackendVolumeFromSnapshot(BlockSnapshot snapshot, Volume sourceVolume) {
// Create a new Volume instance and populate its fields with the
// target volume information in the passed snapshot. Note that
// not all fields need be populated. This is an INTERNAL volume
// and the operations on the VPLEX volume created on top of it
// will be limited. We set the fields that accurately reflect
// the volume and are necessary to allow it to be used as a
// backend volume for a VPLEX volume and to allow that VPLEX
// volume to subsequently be exported to hosts/clusters.
Volume volume = new Volume();
volume.setId(URIUtil.createId(Volume.class));
volume.setLabel(snapshot.getLabel());
volume.setWWN(snapshot.getWWN());
volume.setNativeId(snapshot.getNativeId());
volume.setNativeGuid(snapshot.getNativeGuid());
volume.setAlternateName(snapshot.getAlternateName());
volume.setDeviceLabel(snapshot.getDeviceLabel());
volume.setProvisionedCapacity(snapshot.getProvisionedCapacity());
volume.setAllocatedCapacity(snapshot.getAllocatedCapacity());
volume.setVirtualArray(snapshot.getVirtualArray());
volume.setProject(snapshot.getProject());
volume.setStorageController(snapshot.getStorageController());
volume.setSystemType(snapshot.getSystemType());
StringSet protocols = new StringSet();
protocols.addAll(snapshot.getProtocol());
volume.setProtocol(protocols);
volume.addInternalFlags(DataObject.Flag.INTERNAL_OBJECT);
volume.setOpStatus(new OpStatusMap());
// Some of the volume parameters must come from the source volume
// of the passed block snapshot including the Tenant.
volume.setTenant(sourceVolume.getTenant());
// The snapshot does not contain the user requested capacity.
volume.setCapacity(sourceVolume.getCapacity());
// The snapshot target should be thin if the source volume was
// thinly provisioned. This will control be used to control whether
// or not thin rebuilds occur when the volume we create is
// distributed.
volume.setThinlyProvisioned(sourceVolume.getThinlyProvisioned());
// The source side backend volume for a VPLEX volume always
// has the same virtual pool as the VPLEX volume, and we will
// use the source volume virtual pool for the VPLEX volume.
volume.setVirtualPool(sourceVolume.getVirtualPool());
// Set auto tier policy from the source volume. This comes
// into play in vmax3 export operations.
volume.setAutoTieringPolicyUri(sourceVolume.getAutoTieringPolicyUri());
// The pool is not currently set as the BlockSnapshot does not
// keep the storage pool for the target volume. This did not
// cause issues for the allowed operations (export/unexport/delete)
// for the VPLEX volume built on the snapshot. We could alternatively
// try and set the storage pool in the block snapshot instance so
// we have the actual storage pool.
// volume.setPool(TBD);
// Create the instance in the database.
_dbClient.createObject(volume);
return volume;
}
use of com.emc.storageos.db.client.model.OpStatusMap in project coprhd-controller by CoprHD.
the class BucketService method prepareBucket.
/**
* Allocate, initialize and persist state of the Bucket being created.
*
* @param param
* @param project
* @param tenantOrg
* @param neighborhood
* @param vpool
* @param flags
* @param placement
* @return
*/
private Bucket prepareBucket(BucketParam param, Project project, TenantOrg tenantOrg, VirtualArray neighborhood, VirtualPool vpool, DataObject.Flag[] flags, BucketRecommendation placement) {
_log.debug("Preparing Bucket creation for Param : {}", param);
StoragePool pool = null;
Bucket bucket = new Bucket();
bucket.setId(URIUtil.createId(Bucket.class));
bucket.setLabel(param.getLabel().replaceAll(SPECIAL_CHAR_REGEX, ""));
bucket.setHardQuota(SizeUtil.translateSize(param.getHardQuota()));
bucket.setSoftQuota(SizeUtil.translateSize(param.getSoftQuota()));
bucket.setRetention(Integer.valueOf(param.getRetention()));
bucket.setOwner(param.getOwner());
bucket.setNamespace(tenantOrg.getNamespace());
bucket.setVirtualPool(param.getVpool());
if (project != null) {
bucket.setProject(new NamedURI(project.getId(), bucket.getLabel()));
}
bucket.setTenant(new NamedURI(tenantOrg.getId(), param.getLabel()));
bucket.setVirtualArray(neighborhood.getId());
if (null != placement.getSourceStoragePool()) {
pool = _dbClient.queryObject(StoragePool.class, placement.getSourceStoragePool());
if (null != pool) {
bucket.setProtocol(new StringSet());
bucket.getProtocol().addAll(VirtualPoolUtil.getMatchingProtocols(vpool.getProtocols(), pool.getProtocols()));
}
}
bucket.setStorageDevice(placement.getSourceStorageSystem());
bucket.setPool(placement.getSourceStoragePool());
bucket.setOpStatus(new OpStatusMap());
// Bucket name to be used at Storage System
String bucketName = project.getLabel() + UNDER_SCORE + param.getLabel();
bucket.setName(bucketName.replaceAll(SPECIAL_CHAR_REGEX, ""));
// Update Bucket path
StringBuilder bucketPath = new StringBuilder();
bucketPath.append(tenantOrg.getNamespace()).append(SLASH).append(project.getLabel()).append(SLASH).append(param.getLabel());
bucket.setPath(bucketPath.toString());
if (flags != null) {
bucket.addInternalFlags(flags);
}
_dbClient.createObject(bucket);
return bucket;
}
use of com.emc.storageos.db.client.model.OpStatusMap in project coprhd-controller by CoprHD.
the class RPDeviceController method initTaskStatus.
private void initTaskStatus(ExportGroup exportGroup, String task, Operation.Status status, String message) {
if (exportGroup.getOpStatus() == null) {
exportGroup.setOpStatus(new OpStatusMap());
}
final Operation op = new Operation();
if (status == Operation.Status.ready) {
op.ready();
}
exportGroup.getOpStatus().put(task, op);
}
Aggregations