Search in sources :

Example 1 with ConsistencyGroupResult

use of com.emc.storageos.hp3par.command.ConsistencyGroupResult in project coprhd-controller by CoprHD.

the class HP3PARStorageDriver method getStorageObject.

/*
	 * objectid is nothing but the native id of the storage object. For
	 * consistency group it would be the native id of consistency group, which
	 * on the HP3PAR array is nothing but the name of the volume set.
	 */
@Override
public <T extends StorageObject> T getStorageObject(String storageSystemId, String objectId, Class<T> type) {
    // TODO Auto-generated method stub
    _log.info("3PARDriver: getStorageObject enter ");
    try {
        HP3PARApi hp3parApi = hp3parUtil.getHP3PARDeviceFromNativeId(storageSystemId, this.driverRegistry);
        ConsistencyGroupResult cgResult = null;
        if (VolumeConsistencyGroup.class.getSimpleName().equals(type.getSimpleName())) {
            cgResult = hp3parApi.getVVsetDetails(objectId);
            VolumeConsistencyGroup cg = new VolumeConsistencyGroup();
            cg.setStorageSystemId(storageSystemId);
            cg.setNativeId(cgResult.getName());
            cg.setDeviceLabel(objectId);
            _log.info("3PARDriver: getStorageObject leaving ");
            return (T) cg;
        } else if (StoragePool.class.getSimpleName().equals(type.getSimpleName())) {
            CPGMember cpgResult = null;
            cpgResult = hp3parApi.getCPGDetails(objectId);
            StoragePool sp = new StoragePool();
            String cpgName = cpgResult.getName();
            sp.setNativeId(cpgName);
            CPGSpaceCommandResult cpgSpaceResult = hp3parApi.getCPGSpaceDetails(cpgName);
            // CPG common space is space available to the CPG from the common pool
            Long cpgCommonSpace = cpgSpaceResult.getUsableFreeMiB().longValue();
            // CPG allocated capacity is what is currently allocated to the CPG
            Long cpgAllocatedCapacity = cpgResult.getUsrUsage().getTotalMiB().longValue() + cpgResult.getSAUsage().getTotalMiB().longValue() + cpgResult.getSDUsage().getTotalMiB().longValue();
            // CPG used capacity is what is currently used within the CPG
            Long cpgUsedCapacity = cpgResult.getUsrUsage().getUsedMiB().longValue() + cpgResult.getSAUsage().getUsedMiB().longValue() + cpgResult.getSDUsage().getUsedMiB().longValue();
            // CPG Free capacity is what is currently free within the CPG
            Long cpgFreeCapacity = cpgAllocatedCapacity - cpgUsedCapacity;
            // CPG total potentially usable capacity is the sum of these two
            // Here we are assuming that the CPG can potentially use all of the common capacity
            // Although in practice this is shared with all CPGs of the same type
            Long cpgTotalCapacity = cpgAllocatedCapacity + cpgCommonSpace;
            // We add the common space to the free capacity because it can also be used by the CPG
            cpgFreeCapacity += cpgCommonSpace;
            sp.setTotalCapacity(cpgTotalCapacity * HP3PARConstants.KILO_BYTE);
            sp.setFreeCapacity(cpgFreeCapacity * HP3PARConstants.KILO_BYTE);
            VolumesCommandResult volumesOfCpg = hp3parApi.getVolumesofCPG(cpgName);
            Long cpgSubscribedCapacity = (long) 0;
            Iterator<VolumeDetailsCommandResult> volIter = volumesOfCpg.getMembers().iterator();
            while (volIter.hasNext()) {
                cpgSubscribedCapacity += volIter.next().getSizeMiB();
            }
            sp.setSubscribedCapacity(cpgSubscribedCapacity * HP3PARConstants.KILO_BYTE);
            _log.info("3PARDriver: For CPG {}:", cpgName);
            _log.info("Number of volumes in CPG = {}", volumesOfCpg.getTotal());
            _log.info("Total Capacity = {} MB, Subscribed Capacity = {} MB, Free Capacity = {} MB", cpgTotalCapacity, cpgSubscribedCapacity, cpgFreeCapacity);
            // Note that subscribed capacity need not be equal to (total - free capacity) for thin pools
            _log.info("3PARDriver: StoragePool getStorageObject leaving ");
            return (T) sp;
        }
    } catch (Exception e) {
        String msg = String.format("3PARDriver: Unable to get Stroage Object for id %s; Error: %s.\n", objectId, e.getMessage());
        _log.error(msg);
        e.printStackTrace();
        _log.error(CompleteError.getStackTrace(e));
        return (T) null;
    }
    return null;
}
Also used : VolumeConsistencyGroup(com.emc.storageos.storagedriver.model.VolumeConsistencyGroup) ConsistencyGroupResult(com.emc.storageos.hp3par.command.ConsistencyGroupResult) StoragePool(com.emc.storageos.storagedriver.model.StoragePool) Iterator(java.util.Iterator) CPGMember(com.emc.storageos.hp3par.command.CPGMember) CPGSpaceCommandResult(com.emc.storageos.hp3par.command.CPGSpaceCommandResult) VolumesCommandResult(com.emc.storageos.hp3par.command.VolumesCommandResult)

Example 2 with ConsistencyGroupResult

use of com.emc.storageos.hp3par.command.ConsistencyGroupResult in project coprhd-controller by CoprHD.

the class HP3PARApi method getVVsetDetails.

/**
 * Get Consistency Group details
 *
 * @param displayName
 * @return
 * @throws Exception
 */
public ConsistencyGroupResult getVVsetDetails(String displayName) throws Exception {
    _log.info("3PARDriver: getVVsetDetails enter");
    ClientResponse clientResp = null;
    final String path = MessageFormat.format(URI_CG_DETAILS, displayName);
    try {
        clientResp = get(path);
        if (clientResp == null) {
            _log.error("3PARDriver: getVVsetDetails There is no response from 3PAR");
            throw new HP3PARException("There is no response from 3PAR");
        } else if (clientResp.getStatus() != 200) {
            String errResp = getResponseDetails(clientResp);
            _log.error("3PARDriver: getVVsetDetails There is error response from 3PAR = {}", errResp);
            throw new HP3PARException(errResp);
        } else {
            String responseString = clientResp.getEntity(String.class);
            _log.info("3PARDriver: getVVsetDetails 3PAR response is {}", responseString);
            ConsistencyGroupResult cgResult = new Gson().fromJson(sanitize(responseString), ConsistencyGroupResult.class);
            return cgResult;
        }
    } catch (Exception e) {
        throw e;
    } finally {
        if (clientResp != null) {
            clientResp.close();
        }
        _log.info("3PARDriver: getVVsetDetails leave");
    }
// end try/catch/finally
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) ConsistencyGroupResult(com.emc.storageos.hp3par.command.ConsistencyGroupResult) Gson(com.google.gson.Gson)

Example 3 with ConsistencyGroupResult

use of com.emc.storageos.hp3par.command.ConsistencyGroupResult in project coprhd-controller by CoprHD.

the class HP3PARIngestHelper method generateVolumeSetToVolumeMap.

/*
	 * Returns: Hashmap of volume to volumesets mapping The key of this hashmap
	 * will be the name of the volume The value of the hasmap returned will be
	 * an array list of volume sets that the volume belongs to. Example:
	 * {volume1: [volumeset5] , volume2:[volumeset1, volumeset2]}
	 */
private HashMap<String, ArrayList<String>> generateVolumeSetToVolumeMap(StorageSystem storageSystem, Registry registry) throws Exception {
    // get Api client
    HP3PARApi hp3parApi = hp3parUtil.getHP3PARDeviceFromNativeId(storageSystem.getNativeId(), registry);
    ConsistencyGroupsListResult objConsisGroupSets = hp3parApi.getVVsetsList();
    HashMap<String, ArrayList<String>> volumeToVolumeSetMap = new HashMap<String, ArrayList<String>>();
    _log.info("3PARDriver: objConsisGroupSets.getTotal() information is {}", objConsisGroupSets.getTotal());
    for (ConsistencyGroupResult objConsisGroupResult : objConsisGroupSets.getMembers()) {
        if (objConsisGroupResult.getSetmembers() != null) {
            for (Integer volIndex = 0; volIndex < objConsisGroupResult.getSetmembers().size(); volIndex++) {
                String vVolName = objConsisGroupResult.getSetmembers().get(volIndex);
                if (!volumeToVolumeSetMap.containsKey(vVolName)) {
                    ArrayList<String> volSetList = new ArrayList<String>();
                    volSetList.add(objConsisGroupResult.getName());
                    volumeToVolumeSetMap.put(vVolName, volSetList);
                } else {
                    volumeToVolumeSetMap.get(vVolName).add(objConsisGroupResult.getName());
                }
            }
        }
    }
    _log.info("3PARDriver: volumeToVolumeSetMap information is {}", volumeToVolumeSetMap.toString());
    return volumeToVolumeSetMap;
}
Also used : ConsistencyGroupResult(com.emc.storageos.hp3par.command.ConsistencyGroupResult) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ConsistencyGroupsListResult(com.emc.storageos.hp3par.command.ConsistencyGroupsListResult)

Example 4 with ConsistencyGroupResult

use of com.emc.storageos.hp3par.command.ConsistencyGroupResult in project coprhd-controller by CoprHD.

the class HP3PARCGHelper method createConsistencyGroup.

public DriverTask createConsistencyGroup(VolumeConsistencyGroup consistencyGroup, DriverTask task, Registry driverRegistry) {
    try {
        _log.info("3PARDriver: createConsistencyGroup for storage system  id {}, display name {} , native id {}, device lable id {} , cosistency group id {}  - start", consistencyGroup.getStorageSystemId(), consistencyGroup.getDisplayName(), consistencyGroup.getNativeId(), consistencyGroup.getDeviceLabel(), consistencyGroup.getConsistencyGroup());
        // get Api client
        HP3PARApi hp3parApi = hp3parUtil.getHP3PARDeviceFromNativeId(consistencyGroup.getStorageSystemId(), driverRegistry);
        ConsistencyGroupResult cgResult = null;
        // Create VV Set / Consistency Group
        hp3parApi.createVVset(consistencyGroup.getDisplayName());
        cgResult = hp3parApi.getVVsetDetails(consistencyGroup.getDisplayName());
        _log.info("3PARDriver: createConsistencyGroup getDetails " + cgResult.getDetails());
        consistencyGroup.setNativeId(consistencyGroup.getDisplayName());
        consistencyGroup.setDeviceLabel(consistencyGroup.getDisplayName());
        task.setStatus(DriverTask.TaskStatus.READY);
        _log.info("3PARDriver: createConsistencyGroup for storage system  id {}, display name {} , native id {}, device lable id {} , cosistency group id {}  - end", consistencyGroup.getStorageSystemId(), consistencyGroup.getDisplayName(), consistencyGroup.getNativeId(), consistencyGroup.getDeviceLabel(), consistencyGroup.getConsistencyGroup());
    } catch (Exception e) {
        String msg = String.format("3PARDriver: Unable to create consistency group name %s in storage system native id is %s; Error: %s.\n", consistencyGroup.getDisplayName(), consistencyGroup.getStorageSystemId(), e.getMessage());
        _log.error(msg);
        task.setMessage(msg);
        task.setStatus(DriverTask.TaskStatus.FAILED);
        e.printStackTrace();
    }
    return task;
}
Also used : ConsistencyGroupResult(com.emc.storageos.hp3par.command.ConsistencyGroupResult)

Aggregations

ConsistencyGroupResult (com.emc.storageos.hp3par.command.ConsistencyGroupResult)4 CPGMember (com.emc.storageos.hp3par.command.CPGMember)1 CPGSpaceCommandResult (com.emc.storageos.hp3par.command.CPGSpaceCommandResult)1 ConsistencyGroupsListResult (com.emc.storageos.hp3par.command.ConsistencyGroupsListResult)1 VolumesCommandResult (com.emc.storageos.hp3par.command.VolumesCommandResult)1 StoragePool (com.emc.storageos.storagedriver.model.StoragePool)1 VolumeConsistencyGroup (com.emc.storageos.storagedriver.model.VolumeConsistencyGroup)1 Gson (com.google.gson.Gson)1 ClientResponse (com.sun.jersey.api.client.ClientResponse)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1