Search in sources :

Example 46 with DataObject

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

the class RecordableDeviceEvent method getProjectId.

/**
 * {@inheritDoc}
 */
@Override
public URI getProjectId() {
    URI projectId = null;
    DataObject resource = getResource();
    if (resource != null) {
        if (resource instanceof Volume) {
            Volume volume = (Volume) resource;
            projectId = volume.getProject().getURI();
        } else if (resource instanceof FileShare) {
            FileShare fs = (FileShare) resource;
            projectId = fs.getProject().getURI();
        } else if (resource instanceof BlockSnapshot) {
            BlockSnapshot bs = (BlockSnapshot) resource;
            projectId = bs.getProject().getURI();
        } else {
            s_logger.info("Error getting projectId for event. Unexpected resource type {}.", resource.getClass().getName());
        }
    }
    return projectId;
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) Volume(com.emc.storageos.db.client.model.Volume) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare)

Example 47 with DataObject

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

the class RecordableDeviceEvent method getResourceId.

/**
 * {@inheritDoc}
 */
@Override
public URI getResourceId() {
    URI resourceId = null;
    DataObject resource = getResource();
    if (resource != null) {
        resourceId = resource.getId();
    }
    return resourceId;
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) URI(java.net.URI)

Example 48 with DataObject

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

the class RecordableDeviceEvent method getVirtualPool.

/**
 * {@inheritDoc}
 */
@Override
public URI getVirtualPool() {
    URI vpool = null;
    DataObject resource = getResource();
    if (resource != null) {
        if (resource instanceof Volume) {
            Volume volume = (Volume) resource;
            vpool = volume.getVirtualPool();
        } else if (resource instanceof BlockSnapshot) {
            BlockSnapshot bs = (BlockSnapshot) resource;
            Volume volume = _dbClient.queryObject(Volume.class, bs.getParent().getURI());
            if (volume != null) {
                vpool = volume.getVirtualPool();
            }
        } else if (resource instanceof FileShare) {
            FileShare fs = (FileShare) resource;
            vpool = fs.getVirtualPool();
        } else {
            s_logger.info("Error getting vpool for event. Unexpected resource type {}.", resource.getClass().getName());
        }
    }
    return vpool;
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) Volume(com.emc.storageos.db.client.model.Volume) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare)

Example 49 with DataObject

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

the class ExternalDeviceCommunicationInterface method createOrUpdateAutoTierPolicies.

/**
 * Creates and/or updates the auto tiering policies in the controller database after
 * processing the discovered storage pools and the auto tiering policies that they support.
 *
 * @param system A reference to the storage system.
 * @param autoTieringPolicyPoolMap A map of the storage pools for each policy keyed by policy id.
 * @param autoTieringPolicyPropertiesMap A map of the auto tiering policy properties keyed by policy id.
 */
private void createOrUpdateAutoTierPolicies(com.emc.storageos.db.client.model.StorageSystem system, Map<String, List<com.emc.storageos.db.client.model.StoragePool>> autoTieringPolicyPoolMap, Map<String, Map<String, List<String>>> autoTieringPolicyPropertiesMap) {
    List<DataObject> objectsToCreate = new ArrayList<>();
    List<DataObject> objectsToUpdate = new ArrayList<>();
    for (Entry<String, List<com.emc.storageos.db.client.model.StoragePool>> policyEntry : autoTieringPolicyPoolMap.entrySet()) {
        String policyId = policyEntry.getKey();
        String nativeGuid = NativeGUIDGenerator.generateAutoTierPolicyNativeGuid(system.getNativeGuid(), policyId, NativeGUIDGenerator.AUTO_TIERING_POLICY);
        AutoTieringPolicy autoTieringPolicy = checkAutoTieringPolicyExistsInDB(nativeGuid);
        if (autoTieringPolicy == null) {
            autoTieringPolicy = new AutoTieringPolicy();
            autoTieringPolicy.setId(URIUtil.createId(AutoTieringPolicy.class));
            autoTieringPolicy.setPolicyName(policyId);
            autoTieringPolicy.setStorageSystem(system.getId());
            autoTieringPolicy.setNativeGuid(nativeGuid);
            autoTieringPolicy.setLabel(policyId);
            autoTieringPolicy.setSystemType(system.getSystemType());
            autoTieringPolicy.setPolicyEnabled(Boolean.TRUE);
            Map<String, List<String>> policyProperties = autoTieringPolicyPropertiesMap.get(policyId);
            List<String> provTypeValueList = policyProperties.get(AutoTieringPolicyCapabilityDefinition.PROPERTY_NAME.PROVISIONING_TYPE.name());
            if (!provTypeValueList.isEmpty()) {
                autoTieringPolicy.setProvisioningType(provTypeValueList.get(0));
            }
            objectsToCreate.add(autoTieringPolicy);
            _log.info(String.format("Creating new auto tiering policy %s, supported by storage pools %s", policyId, policyEntry.getValue()));
        } else {
            objectsToUpdate.add(autoTieringPolicy);
            _log.info(String.format("Updating existing auto tiering policy %s, supported by storage pools %s", policyId, policyEntry.getValue()));
        }
        // Set the storage pools for this policy. Since the pools have enabled auto
        // tiering policies, also, make sure auto tiering is enabled on each pool.
        StringSet poolIds = new StringSet();
        for (com.emc.storageos.db.client.model.StoragePool pool : policyEntry.getValue()) {
            poolIds.add(pool.getId().toString());
            // Note that the pool in the db will be updated by the caller.
            pool.setAutoTieringEnabled(true);
        }
        autoTieringPolicy.setPools(poolIds);
        // sure the system has auto tiering enabled.
        if (!system.getAutoTieringEnabled()) {
            system.setAutoTieringEnabled(true);
            _dbClient.updateObject(system);
        }
    }
    // Now any auto tier policies in the database for the passed system that are
    // not represented by the passed policy map need to be marked disabled.
    disableRemovedAutoTieringPolicies(autoTieringPolicyPoolMap.keySet(), system.getId());
    // Lastly create and update objects in the database.
    _dbClient.createObject(objectsToCreate);
    _dbClient.updateObject(objectsToUpdate);
}
Also used : ArrayList(java.util.ArrayList) AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 50 with DataObject

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

the class TaskMapper method toTask.

public static TaskResourceRep toTask(Task task) {
    TaskResourceRep taskResourceRep = new TaskResourceRep();
    mapDataObjectFields(task, taskResourceRep);
    taskResourceRep.setId(task.getId());
    taskResourceRep.setResource(toNamedRelatedResource(task.getResource()));
    // Check to see if there are any associated resources
    List<NamedRelatedResourceRep> associatedRefs = Lists.newArrayList();
    for (URI assocId : task.getAssociatedResourcesList()) {
        DataObject associatedObject = getConfig().getDbClient().queryObject(assocId);
        if (associatedObject != null) {
            associatedRefs.add(toNamedRelatedResource(associatedObject));
        } else {
            log.warn(String.format("For task %s could not find associated object %s", task.getId(), assocId));
        }
    }
    taskResourceRep.setAssociatedResources(associatedRefs);
    if (!StringUtils.isBlank(task.getRequestId())) {
        taskResourceRep.setOpId(task.getRequestId());
    }
    if (task.getWorkflow() != null) {
        taskResourceRep.setWorkflow(toRelatedResource(ResourceTypeEnum.WORKFLOW, task.getWorkflow()));
    }
    if (!task.getTenant().equals(TenantOrg.SYSTEM_TENANT)) {
        taskResourceRep.setTenant(DbObjectMapper.toRelatedResource(ResourceTypeEnum.TENANT, task.getTenant()));
    }
    // Operation
    taskResourceRep.setState(task.getStatus());
    if (task.getServiceCode() != null) {
        taskResourceRep.setServiceError(toServiceErrorRestRep(toServiceCode(task.getServiceCode()), task.getMessage()));
    } else {
        taskResourceRep.setMessage(task.getMessage());
        if (!task.getWarningMessages().isEmpty()) {
            taskResourceRep.setWarningMessages(new ArrayList<String>(task.getWarningMessages()));
        }
    }
    taskResourceRep.setDescription(task.getDescription());
    // COP-23486
    // 
    // This is a workaround to migration post-commit delete source volumes. We would like to be able to
    // mark this Task as one that cannot be rolled back, however at the time there is no framework to
    // detect the state of not being able to rollback, so we will catch this specific situation from the
    // message so we can "flip the flag" of allowable operations by the UI.
    taskResourceRep.setAllowedOperations(Task.AllowedOperations.none_specified.name());
    if (task.getWorkflow() != null) {
        Workflow wf = configInstance.getDbClient().queryObject(Workflow.class, task.getWorkflow());
        if (wf != null && NullColumnValueGetter.isNotNullValue(wf.getCompletionMessage()) && wf.getCompletionMessage().contains("post-migration delete of original source backing volumes")) {
            taskResourceRep.setAllowedOperations(Task.AllowedOperations.retry_only.name());
        }
    }
    taskResourceRep.setStartTime(task.getStartTime());
    taskResourceRep.setEndTime(task.getEndTime());
    taskResourceRep.setProgress(task.getProgress() != null ? task.getProgress() : 0);
    taskResourceRep.setQueuedStartTime(task.getQueuedStartTime());
    taskResourceRep.setQueueName(task.getQueueName());
    return taskResourceRep;
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Workflow(com.emc.storageos.db.client.model.Workflow) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) URI(java.net.URI)

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