Search in sources :

Example 6 with LDEV

use of com.emc.storageos.hds.model.LDEV in project coprhd-controller by CoprHD.

the class HDSApiVolumeManager method modifyThinVolumeTieringPolicy.

public String modifyThinVolumeTieringPolicy(String systemObjectID, String luObjectID, String ldevObjectID, String tieringPolicyName, String model) {
    InputStream responseStream = null;
    String asyncTaskMessageId = null;
    Map<String, Object> attributeMap = new HashMap<String, Object>();
    Modify modifyOp = new Modify(HDSConstants.VIRTUALVOLUME);
    StorageArray array = new StorageArray(systemObjectID);
    LogicalUnit logicalUnit = new LogicalUnit();
    logicalUnit.setObjectID(luObjectID);
    LDEV ldev = new LDEV(ldevObjectID);
    ldev.setTierLevel(Integer.parseInt(tieringPolicyName));
    attributeMap.put(HDSConstants.STORAGEARRAY, array);
    attributeMap.put(HDSConstants.MODIFY, modifyOp);
    attributeMap.put(HDSConstants.MODEL, model);
    attributeMap.put(HDSConstants.LOGICALUNIT, logicalUnit);
    attributeMap.put(HDSConstants.LDEV, ldev);
    String modifyThinVolumeTieringPolicyPayload = InputXMLGenerationClient.getInputXMLString(HDSConstants.MODIFY_THIN_VOLUME_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
    URI endpointURI = hdsApiClient.getBaseURI();
    log.info("Modify Volume TieringPolicy payload:{}", modifyThinVolumeTieringPolicyPayload);
    ClientResponse response = hdsApiClient.post(endpointURI, modifyThinVolumeTieringPolicyPayload);
    if (HttpStatus.SC_OK == response.getStatus()) {
        responseStream = response.getEntityInputStream();
        JavaResult result = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
        EchoCommand command = result.getBean(EchoCommand.class);
        log.info("command Status :{} MessageId :{}", command.getStatus(), command.getMessageID());
        if (HDSConstants.PROCESSING_STR.equalsIgnoreCase(command.getStatus()) || HDSConstants.COMPLETED_STR.equalsIgnoreCase(command.getStatus())) {
            asyncTaskMessageId = command.getMessageID();
        } else if (HDSConstants.FAILED_STR.equalsIgnoreCase(command.getStatus())) {
            Error error = result.getBean(Error.class);
            log.error("Modify Volume TieringPolicy failed status messageID: {}", command.getMessageID());
            log.error("Modify Volume TieringPolicy failed with error code: {} with message: {}", error.getCode(), error.getDescription());
            throw HDSException.exceptions.notAbleToCreateVolume(error.getCode(), error.getDescription());
        }
    } else {
        log.error("Modify Volume TieringPolicy failed with invalid response code {}", response.getStatus());
        throw HDSException.exceptions.invalidResponseFromHDS(String.format("Modify Volume TieringPolicy failed due to invalid response %1$s from server for system %2$s", response.getStatus(), systemObjectID));
    }
    return asyncTaskMessageId;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) HashMap(java.util.HashMap) InputStream(java.io.InputStream) LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) Error(com.emc.storageos.hds.model.Error) Modify(com.emc.storageos.hds.model.Modify) LDEV(com.emc.storageos.hds.model.LDEV) URI(java.net.URI) JavaResult(org.milyn.payload.JavaResult) EchoCommand(com.emc.storageos.hds.model.EchoCommand) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 7 with LDEV

use of com.emc.storageos.hds.model.LDEV in project coprhd-controller by CoprHD.

the class HDSMetaVolumeOperations method expandVolumeAsMetaVolume.

@Override
public void expandVolumeAsMetaVolume(StorageSystem storageSystem, StoragePool storagePool, Volume metaHead, List<String> newMetaMembers, String metaType, MetaVolumeTaskCompleter metaVolumeTaskCompleter) throws Exception {
    HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword());
    String systemObjectID = HDSUtils.getSystemObjectID(storageSystem);
    LogicalUnit metaHeadVolume = hdsApiClient.getLogicalUnitInfo(systemObjectID, HDSUtils.getLogicalUnitObjectId(metaHead.getNativeId(), storageSystem));
    String metaHeadLdevId = null;
    List<String> metaMembersLdevObjectIds = new ArrayList<String>();
    // Step 1: Get LDEV id's of the meta members and format them
    if (null != newMetaMembers && !newMetaMembers.isEmpty()) {
        for (String metaMember : newMetaMembers) {
            if (null != metaMember) {
                String asyncTaskMessageId = hdsApiClient.formatLogicalUnit(systemObjectID, metaMember);
                if (asyncTaskMessageId == null) {
                    throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the expand volume call");
                }
                HDSJob formatLUJob = new HDSJob(asyncTaskMessageId, storageSystem.getId(), metaVolumeTaskCompleter.getVolumeTaskCompleter(), "formatLogicalUnit");
                invokeMethodSynchronously(hdsApiFactory, asyncTaskMessageId, formatLUJob);
            }
            LogicalUnit metaMemberVolume = hdsApiClient.getLogicalUnitInfo(systemObjectID, metaMember);
            if (null != metaMemberVolume && !metaMemberVolume.getLdevList().isEmpty()) {
                for (LDEV ldev : metaMemberVolume.getLdevList()) {
                    // Format the logical unit. This is synchronous operation
                    // should wait it the operation completes.
                    metaMembersLdevObjectIds.add(ldev.getObjectID());
                }
            }
        }
    }
    log.info("New Meta member LDEV ids: {}", metaMembersLdevObjectIds);
    // Step 2: Get LDEV id of the meta volume head.
    if (null != metaHeadVolume && null != metaHeadVolume.getLdevList()) {
        for (LDEV ldev : metaHeadVolume.getLdevList()) {
            // will be created during expansion of volume.
            if (getLDEVID(ldev.getObjectID()).equalsIgnoreCase(metaHead.getNativeId())) {
                metaHeadLdevId = ldev.getObjectID();
                break;
            }
        }
    }
    // Step 3: Create LUSE Volume using metaHead LDEV & meta
    // members LDEV Ids.
    LogicalUnit logicalUnit = hdsApiClient.createLUSEVolume(systemObjectID, metaHeadLdevId, metaMembersLdevObjectIds);
    if (null != logicalUnit) {
        long capacityInBytes = Long.valueOf(logicalUnit.getCapacityInKB()) * 1024L;
        metaHead.setProvisionedCapacity(capacityInBytes);
        metaHead.setAllocatedCapacity(capacityInBytes);
        dbClient.persistObject(metaHead);
    }
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) HDSJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob) LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) ArrayList(java.util.ArrayList) LDEV(com.emc.storageos.hds.model.LDEV)

Example 8 with LDEV

use of com.emc.storageos.hds.model.LDEV in project coprhd-controller by CoprHD.

the class HDSAbstractCreateVolumeJob method changeVolumeName.

/**
 * Method will modify the name of a given volume to a generate name.
 *
 * @param dbClient [in] - Client instance for reading/writing from/to DB
 * @param client [in] - HDSApiClient used for reading/writing from/to HiCommand DM.
 * @param volume [in] - Volume object
 */
protected void changeVolumeName(DbClient dbClient, HDSApiClient client, Volume volume, String name) {
    try {
        _log.info(String.format("Attempting to add volume label %s to %s", name, volume.getWWN()));
        StorageSystem system = dbClient.queryObject(StorageSystem.class, volume.getStorageController());
        String systemObjectId = HDSUtils.getSystemObjectID(system);
        LogicalUnit logicalUnit = client.getLogicalUnitInfo(systemObjectId, HDSUtils.getLogicalUnitObjectId(volume.getNativeId(), system));
        if (null != logicalUnit && null != logicalUnit.getLdevList() && !logicalUnit.getLdevList().isEmpty()) {
            Iterator<LDEV> ldevItr = logicalUnit.getLdevList().iterator();
            if (ldevItr.hasNext()) {
                LDEV ldev = ldevItr.next();
                ObjectLabel objectLabel = client.addVolumeLabel(ldev.getObjectID(), name);
                volume.setDeviceLabel(objectLabel.getLabel());
                dbClient.persistObject(volume);
            }
        } else {
            _log.info("No LDEV's found on volume: {}", volume.getWWN());
        }
        _log.info(String.format("Volume label has been added to volume %s", volume.getWWN()));
    } catch (DatabaseException e) {
        _log.error("Encountered an error while trying to set the volume name", e);
    } catch (Exception e) {
        _log.error("Encountered an error while trying to set the volume name", e);
    }
}
Also used : ObjectLabel(com.emc.storageos.hds.model.ObjectLabel) LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) LDEV(com.emc.storageos.hds.model.LDEV) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) IOException(java.io.IOException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 9 with LDEV

use of com.emc.storageos.hds.model.LDEV in project coprhd-controller by CoprHD.

the class HDSBlockCreateSnapshotJob method changeSnapshotName.

/**
 * Method will modify the name of a given volume to a generate name.
 *
 * @param dbClient [in] - Client instance for reading/writing from/to DB
 * @param client [in] - HDSApiClient used for reading/writing from/to HiCommand DM.
 * @param snapshotObj [in] - Volume object
 */
private void changeSnapshotName(DbClient dbClient, HDSApiClient client, BlockSnapshot snapshotObj) {
    try {
        Volume source = dbClient.queryObject(Volume.class, snapshotObj.getParent());
        // Get the tenant name from the volume
        TenantOrg tenant = dbClient.queryObject(TenantOrg.class, source.getTenant().getURI());
        String tenantName = tenant.getLabel();
        // that was successfully created
        if (_nameGeneratorRef.get() == null) {
            _nameGeneratorRef.compareAndSet(null, (NameGenerator) ControllerServiceImpl.getBean("defaultNameGenerator"));
        }
        String generatedName = _nameGeneratorRef.get().generate(tenantName, snapshotObj.getLabel(), snapshotObj.getId().toString(), '-', HDSConstants.MAX_VOLUME_NAME_LENGTH);
        log.info(String.format("Attempting to add snapshot label %s to %s", generatedName, snapshotObj.getNativeId()));
        StorageSystem system = dbClient.queryObject(StorageSystem.class, snapshotObj.getStorageController());
        String systemObjectId = HDSUtils.getSystemObjectID(system);
        LogicalUnit logicalUnit = client.getLogicalUnitInfo(systemObjectId, HDSUtils.getLogicalUnitObjectId(snapshotObj.getNativeId(), system));
        if (null != logicalUnit && null != logicalUnit.getLdevList() && !logicalUnit.getLdevList().isEmpty()) {
            Iterator<LDEV> ldevItr = logicalUnit.getLdevList().iterator();
            if (ldevItr.hasNext()) {
                LDEV ldev = ldevItr.next();
                ObjectLabel objectLabel = client.addVolumeLabel(ldev.getObjectID(), generatedName);
                snapshotObj.setDeviceLabel(objectLabel.getLabel());
                dbClient.persistObject(snapshotObj);
            }
        } else {
            log.info("No LDEV's found on volume: {}", snapshotObj.getNativeId());
        }
        log.info(String.format("snapshot label has been added to snapshot %s", snapshotObj.getNativeId()));
    } catch (Exception e) {
        log.error("Encountered an error while trying to set the snapshot name", e);
    }
}
Also used : ObjectLabel(com.emc.storageos.hds.model.ObjectLabel) Volume(com.emc.storageos.db.client.model.Volume) LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) LDEV(com.emc.storageos.hds.model.LDEV) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 10 with LDEV

use of com.emc.storageos.hds.model.LDEV in project coprhd-controller by CoprHD.

the class HDSModifyVolumeJob method updateStatus.

/**
 * Called to update the job status when the volume expand job completes.
 *
 * @param jobContext
 *            The job context.
 */
@Override
public void updateStatus(JobContext jobContext) throws Exception {
    LogicalUnit logicalUnit = null;
    try {
        if (_status == JobStatus.IN_PROGRESS) {
            return;
        }
        DbClient dbClient = jobContext.getDbClient();
        String opId = getTaskCompleter().getOpId();
        StringBuilder logMsgBuilder = new StringBuilder(String.format("Updating status of job %s to %s, task: %s", this.getJobName(), _status.name(), opId));
        if (_status == JobStatus.SUCCESS) {
            logicalUnit = (LogicalUnit) _javaResult.getBean("logicalunit");
            if (null != logicalUnit.getLdevList() && !logicalUnit.getLdevList().isEmpty()) {
                Iterator<LDEV> ldevListItr = logicalUnit.getLdevList().iterator();
                if (ldevListItr.hasNext()) {
                    LDEV ldev = ldevListItr.next();
                    if (null != ldev && -1 != ldev.getTierLevel()) {
                        logMsgBuilder.append(String.format("Task %s is successful to update volume %s tieringPolicy: %s", opId, logicalUnit.getObjectID(), ldev.getTierLevel()));
                    }
                }
            }
        } else if (_status == JobStatus.FAILED && VOLUME_MODIFY_JOB.equalsIgnoreCase(getJobName())) {
            URI id = getTaskCompleter().getId();
            logMsgBuilder.append(String.format("Task %s failed to update volume tieringPolicy: %s", opId, id.toString()));
            Volume volume = dbClient.queryObject(Volume.class, id);
            volume.setInactive(true);
            dbClient.persistObject(volume);
        }
        log.info(logMsgBuilder.toString());
    } catch (Exception e) {
        log.error("Caught an exception while trying to updating tieringPolicy of the volume", e);
        setErrorStatus("Encountered an internal error during tieringPolicy updation of volume: " + e.getMessage());
    } finally {
        super.updateStatus(jobContext);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) Volume(com.emc.storageos.db.client.model.Volume) LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) LDEV(com.emc.storageos.hds.model.LDEV) URI(java.net.URI)

Aggregations

LDEV (com.emc.storageos.hds.model.LDEV)10 LogicalUnit (com.emc.storageos.hds.model.LogicalUnit)7 Volume (com.emc.storageos.db.client.model.Volume)4 HDSApiClient (com.emc.storageos.hds.api.HDSApiClient)3 ObjectLabel (com.emc.storageos.hds.model.ObjectLabel)3 HDSJob (com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob)3 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)2 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)2 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 HDSException (com.emc.storageos.hds.HDSException)2 StorageArray (com.emc.storageos.hds.model.StorageArray)2 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)2 HDSModifyVolumeJob (com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSModifyVolumeJob)2 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)2 URI (java.net.URI)2 HashMap (java.util.HashMap)2 DbClient (com.emc.storageos.db.client.DbClient)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)1 Add (com.emc.storageos.hds.model.Add)1