Search in sources :

Example 66 with NamedURI

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

the class DbClientImpl method serializeTasks.

private void serializeTasks(DataObject dataObject, RowMutator mutator, List<URI> objectsToCleanup) {
    OpStatusMap statusMap = dataObject.getOpStatus();
    if (statusMap == null || statusMap.getChangedKeySet() == null || statusMap.getChangedKeySet().isEmpty()) {
        return;
    }
    Set<String> addedSet = statusMap.getChangedKeySet();
    if (addedSet != null) {
        DataObjectType taskDoType = TypeMap.getDoType(Task.class);
        Iterator<String> it = statusMap.getChangedKeySet().iterator();
        while (it.hasNext()) {
            String requestId = it.next();
            Operation operation = statusMap.get(requestId);
            Task task = TaskUtils.findTaskForRequestId(this, dataObject.getId(), requestId);
            if (task == null) {
                // Task doesn't currently exist for this id, so create it
                task = new Task();
                task.setId(URIUtil.createId(Task.class));
                task.setRequestId(requestId);
                task.setInactive(false);
                task.setServiceCode(operation.getServiceCode());
                task.setLabel(operation.getName());
                task.setStatus(operation.getStatus());
                task.setDescription(operation.getDescription());
                Integer progress = operation.getProgress();
                task.setProgress(progress != null ? progress : 0);
                task.setMessage(operation.getMessage());
                task.setAssociatedResources(operation.rawAssociatedResources());
                task.setCreationTime(Calendar.getInstance());
                task.setInactive(false);
                task.setStartTime(operation.getStartTime());
                task.setEndTime(getEndTime(operation));
                // Often dummy objects are used that just contain an ID, for some things we need access to the entire object
                DataObject loadedObject = dataObject;
                if (StringUtils.isBlank(dataObject.getLabel())) {
                    loadedObject = this.queryObject(URIUtil.getModelClass(dataObject.getId()), dataObject.getId());
                }
                if (loadedObject == null) {
                    throw new RuntimeException("Task created on a resource which doesn't exist " + dataObject.getId());
                }
                task.setResource(new NamedURI(loadedObject.getId(), loadedObject.getLabel()));
                URI tenantId = getTenantURI(loadedObject);
                if (tenantId == null) {
                    task.setTenant(TenantOrg.SYSTEM_TENANT);
                } else {
                    task.setTenant(tenantId);
                }
                _log.info("Created task {}, {}", task.getId() + " (" + task.getRequestId() + ")", task.getLabel());
            } else {
                // Task exists so update it
                task.setServiceCode(operation.getServiceCode());
                task.setStatus(operation.getStatus());
                task.setMessage(operation.getMessage());
                // Some code isn't updating progress to 100 when completed, so fix this here
                if (Objects.equal(task.getStatus(), "pending") || Objects.equal(task.getStatus(), "suspended_no_error") || Objects.equal(task.getStatus(), "suspended_error")) {
                    task.setProgress(operation.getProgress());
                } else {
                    task.setProgress(COMPLETED_PROGRESS);
                }
                task.setStartTime(operation.getStartTime());
                task.setEndTime(getEndTime(operation));
                task.setAssociatedResources(operation.rawAssociatedResources());
                if (!Objects.equal(task.getStatus(), "pending")) {
                    _log.info("Completed task {}, {}", task.getId() + " (" + task.getRequestId() + ")", task.getStatus());
                }
            }
            if (taskDoType.serialize(mutator, task)) {
                objectsToCleanup.add(task.getId());
            }
            operation.addTask(dataObject.getId(), task);
        }
    }
}
Also used : Task(com.emc.storageos.db.client.model.Task) PropertyListDataObject(com.emc.storageos.db.client.model.PropertyListDataObject) DataObject(com.emc.storageos.db.client.model.DataObject) NamedURI(com.emc.storageos.db.client.model.NamedURI) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) Operation(com.emc.storageos.db.client.model.Operation) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 67 with NamedURI

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

the class DbConsistencyCheckerHelper method getIndexColumns.

public static Object[] getIndexColumns(ColumnField field, Column<CompositeColumnName> column, String rowKey) {
    Object[] indexColumns = null;
    DbIndex dbIndex = field.getIndex();
    if (dbIndex instanceof AggregateDbIndex) {
        // Not support this index type yet.
        return indexColumns;
    }
    if (dbIndex instanceof NamedRelationDbIndex) {
        indexColumns = new String[4];
        indexColumns[0] = field.getDataObjectType().getSimpleName();
        NamedURI namedURI = NamedURI.fromString(column.getStringValue());
        String name = namedURI.getName();
        indexColumns[1] = name.toLowerCase();
        indexColumns[2] = name;
        indexColumns[3] = rowKey;
    } else if (dbIndex instanceof PrefixDbIndex) {
        indexColumns = new String[4];
        indexColumns[0] = field.getDataObjectType().getSimpleName();
        indexColumns[1] = column.getStringValue().toLowerCase();
        indexColumns[2] = column.getStringValue();
        indexColumns[3] = rowKey;
    } else if (dbIndex instanceof ScopedLabelDbIndex) {
        indexColumns = new String[4];
        indexColumns[0] = field.getDataObjectType().getSimpleName();
        ScopedLabel label = ScopedLabel.fromString(column.getStringValue());
        indexColumns[1] = label.getLabel().toLowerCase();
        indexColumns[2] = label.getLabel();
        indexColumns[3] = rowKey;
    } else if (dbIndex instanceof DecommissionedDbIndex) {
        indexColumns = new String[2];
        Boolean val = column.getBooleanValue();
        indexColumns[0] = val.toString();
        indexColumns[1] = rowKey;
    } else if (dbIndex instanceof ClassNameTimeSeriesDBIndex || dbIndex instanceof TimeSeriesDbIndex) {
        indexColumns = new Object[3];
        indexColumns[0] = field.getDataObjectType().getSimpleName();
        indexColumns[1] = TimeUUIDUtils.getMicrosTimeFromUUID(column.getName().getTimeUUID());
        indexColumns[2] = rowKey;
    } else {
        // For AltIdDbIndex, RelationDbIndex, PermissionsDbIndex
        indexColumns = new String[2];
        indexColumns[0] = field.getDataObjectType().getSimpleName();
        indexColumns[1] = rowKey;
    }
    return indexColumns;
}
Also used : NamedURI(com.emc.storageos.db.client.model.NamedURI) ScopedLabel(com.emc.storageos.db.client.model.ScopedLabel) DataObject(com.emc.storageos.db.client.model.DataObject)

Example 68 with NamedURI

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

the class BlockStorageDeviceTest method createVolumes.

private List<Volume> createVolumes() {
    List<Volume> volumes = new ArrayList<Volume>(NUM_OF_VOLUMES);
    for (int i = 0; i < NUM_OF_VOLUMES; i++) {
        Volume volume = new Volume();
        volume.setId(URIUtil.createId(Volume.class));
        volume.setInactive(false);
        volume.setLabel(LABEL_PREFIX + i);
        // which capacity to set?
        volume.setCapacity(17298180736L);
        volume.setStorageController(_storageSystem.getId());
        volume.setSystemType(_storageSystem.getSystemType());
        volume.setPool(_storagePool.getId());
        volume.setVirtualPool(URIUtil.createId(VirtualPool.class));
        volume.setProject(new NamedURI(_project.getId(), volume.getLabel()));
        volume.setTenant(new NamedURI(_project.getTenantOrg().getURI(), volume.getLabel()));
        volumes.add(volume);
    }
    _dbClient.createObject(volumes);
    return volumes;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) NamedURI(com.emc.storageos.db.client.model.NamedURI) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint)

Example 69 with NamedURI

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

the class BlockStorageDeviceTest method createSnapshots.

private List<BlockSnapshot> createSnapshots() {
    List<BlockSnapshot> snapshots = new ArrayList<BlockSnapshot>(NUM_OF_SNAPSHOTS);
    for (int i = 0; i < NUM_OF_SNAPSHOTS; i++) {
        BlockSnapshot snapshot = new BlockSnapshot();
        snapshot.setId(URIUtil.createId(BlockSnapshot.class));
        snapshot.setInactive(false);
        snapshot.setLabel(LABEL_PREFIX + "_snap_" + 1);
        snapshot.setStorageController(_storageSystem.getId());
        snapshot.setSystemType(_storageSystem.getSystemType());
        snapshot.setProject(new NamedURI(_project.getId(), snapshot.getLabel()));
        snapshot.setParent(new NamedURI(getVolumes(_storageSystem).get(0).getId(), snapshot.getLabel()));
        snapshot.setConsistencyGroup(getConsistencyGroup().getId());
        snapshots.add(snapshot);
    }
    _dbClient.createObject(snapshots);
    return snapshots;
}
Also used : NamedURI(com.emc.storageos.db.client.model.NamedURI) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) ArrayList(java.util.ArrayList) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint)

Example 70 with NamedURI

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

the class BlockStorageDeviceTest method getExportGroup.

private ExportGroup getExportGroup() {
    ExportGroup exportGroup = null;
    List<URI> objectURIs = _dbClient.queryByType(ExportGroup.class, true);
    Iterator<ExportGroup> iter = _dbClient.queryIterativeObjects(ExportGroup.class, objectURIs);
    while (iter.hasNext()) {
        exportGroup = iter.next();
        break;
    }
    if (exportGroup == null) {
        exportGroup = new ExportGroup();
        exportGroup.setId(URIUtil.createId(ExportGroup.class));
        exportGroup.setLabel("EMCViPR");
        exportGroup.setInactive(false);
        exportGroup.setProject(new NamedURI(_project.getId(), exportGroup.getLabel()));
        exportGroup.setTenant(new NamedURI(_project.getTenantOrg().getURI(), exportGroup.getLabel()));
        exportGroup.setVirtualArray(URIUtil.createId(VirtualArray.class));
        _dbClient.createObject(exportGroup);
    }
    List<ExportMask> masks = ExportMaskUtils.getExportMasks(_dbClient, exportGroup);
    if (masks.isEmpty()) {
        exportGroup.addExportMask(getExportMask().getId());
        _dbClient.updateObject(exportGroup);
    }
    return exportGroup;
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) NamedURI(com.emc.storageos.db.client.model.NamedURI) ExportMask(com.emc.storageos.db.client.model.ExportMask) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Aggregations

NamedURI (com.emc.storageos.db.client.model.NamedURI)196 URI (java.net.URI)98 Volume (com.emc.storageos.db.client.model.Volume)74 StringSet (com.emc.storageos.db.client.model.StringSet)65 Project (com.emc.storageos.db.client.model.Project)54 ArrayList (java.util.ArrayList)46 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)43 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)42 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)36 Test (org.junit.Test)32 StoragePool (com.emc.storageos.db.client.model.StoragePool)31 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)31 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)27 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)26 StringMap (com.emc.storageos.db.client.model.StringMap)26 List (java.util.List)23 OpStatusMap (com.emc.storageos.db.client.model.OpStatusMap)20 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)20 VirtualPoolCapabilityValuesWrapper (com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper)18 FileShare (com.emc.storageos.db.client.model.FileShare)17