Search in sources :

Example 11 with VolumeDetailsCommandResult

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

the class HP3PARStorageDriver method discoverStoragePools.

/**
 * Get storage pool information and its capabilities
 */
@Override
public DriverTask discoverStoragePools(StorageSystem storageSystem, List<StoragePool> storagePools) {
    // For this 3PAR system
    _log.info("3PARDriver: discoverStoragePools information for storage system {}, nativeId {} - start", storageSystem.getIpAddress(), storageSystem.getNativeId());
    DriverTask task = createDriverTask(HP3PARConstants.TASK_TYPE_DISCOVER_STORAGE_POOLS);
    DeduplicationCapabilityDefinition dedupCapabilityDefinition = new DeduplicationCapabilityDefinition();
    try {
        // get Api client
        HP3PARApi hp3parApi = hp3parUtil.getHP3PARDeviceFromNativeId(storageSystem.getNativeId(), this.driverRegistry);
        // get storage pool details
        CPGCommandResult cpgResult = hp3parApi.getAllCPGDetails();
        // for each ViPR Storage pool = 3PAR CPG
        for (CPGMember currMember : cpgResult.getMembers()) {
            StoragePool pool = new StoragePool();
            String cpgName = currMember.getName();
            pool.setPoolName(cpgName);
            pool.setStorageSystemId(storageSystem.getNativeId());
            Set<Protocols> supportedProtocols = new HashSet<>();
            supportedProtocols.add(Protocols.iSCSI);
            supportedProtocols.add(Protocols.FC);
            pool.setProtocols(supportedProtocols);
            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 = currMember.getUsrUsage().getTotalMiB().longValue() + currMember.getSAUsage().getTotalMiB().longValue() + currMember.getSDUsage().getTotalMiB().longValue();
            // CPG used capacity is what is currently used within the CPG
            Long cpgUsedCapacity = currMember.getUsrUsage().getUsedMiB().longValue() + currMember.getSAUsage().getUsedMiB().longValue() + currMember.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;
            pool.setTotalCapacity(cpgTotalCapacity * HP3PARConstants.KILO_BYTE);
            pool.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();
            }
            pool.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
            pool.setOperationalStatus(currMember.getState() == 1 ? PoolOperationalStatus.READY : PoolOperationalStatus.NOTREADY);
            Set<RaidLevels> supportedRaidLevels = new HashSet<>();
            switch(currMember.getSDGrowth().getLDLayout().getRAIDType()) {
                case 1:
                    supportedRaidLevels.add(RaidLevels.RAID0);
                    break;
                case 2:
                    supportedRaidLevels.add(RaidLevels.RAID1);
                    break;
                case 3:
                    supportedRaidLevels.add(RaidLevels.RAID5);
                    break;
                case 4:
                    supportedRaidLevels.add(RaidLevels.RAID6);
                    break;
            }
            pool.setSupportedRaidLevels(supportedRaidLevels);
            if (currMember.getSDGrowth().getLDLayout().getDiskPatterns() == null) {
                _log.warn("3PARDriver: Neglecting storage pool {} as there is no disk associated with it", currMember.getName());
                continue;
            }
            Set<SupportedDriveTypes> supportedDriveTypes = new HashSet<>();
            for (int j = 0; j < currMember.getSDGrowth().getLDLayout().getDiskPatterns().size(); j++) {
                switch(currMember.getSDGrowth().getLDLayout().getDiskPatterns().get(j).getDiskType()) {
                    case 1:
                        supportedDriveTypes.add(SupportedDriveTypes.FC);
                        break;
                    case 2:
                        supportedDriveTypes.add(SupportedDriveTypes.NL_SAS);
                        break;
                    case 3:
                        supportedDriveTypes.add(SupportedDriveTypes.SSD);
                        break;
                }
            }
            pool.setSupportedDriveTypes(supportedDriveTypes);
            pool.setMaximumThinVolumeSize(16 * HP3PARConstants.MEGA_BYTE);
            pool.setMinimumThinVolumeSize(256 * HP3PARConstants.KILO_BYTE);
            pool.setMaximumThickVolumeSize(16 * HP3PARConstants.MEGA_BYTE);
            pool.setMinimumThickVolumeSize(256 * HP3PARConstants.KILO_BYTE);
            pool.setSupportedResourceType(SupportedResourceType.THIN_AND_THICK);
            pool.setPoolServiceType(PoolServiceType.block);
            // Storage object properties
            // SB SDK is not sending pool name in volume creation
            pool.setNativeId(currMember.getName());
            pool.setDeviceLabel(currMember.getName());
            pool.setDisplayName(currMember.getName());
            storageSystem.setAccessStatus(AccessStatus.READ_WRITE);
            // SDK requires initialization
            List<CapabilityInstance> capabilities = new ArrayList<>();
            // setting appropriate capability for dedup supported pool
            if (currMember.isDedupCapable()) {
                Boolean dedupEnabled = true;
                Map<String, List<String>> props = new HashMap<>();
                props.put(DeduplicationCapabilityDefinition.PROPERTY_NAME.ENABLED.name(), Arrays.asList(dedupEnabled.toString()));
                CapabilityInstance capabilityInstance = new CapabilityInstance(dedupCapabilityDefinition.getId(), dedupCapabilityDefinition.getId(), props);
                capabilities.add(capabilityInstance);
            }
            pool.setCapabilities(capabilities);
            _log.info("3PARDriver: added storage pool {}, native id {}", pool.getPoolName(), pool.getNativeId());
            storagePools.add(pool);
        }
        // for each storage pool
        task.setStatus(DriverTask.TaskStatus.READY);
        _log.info("3PARDriver: discoverStoragePools information for storage system {}, nativeId {} - end", storageSystem.getIpAddress(), storageSystem.getNativeId());
    } catch (Exception e) {
        String msg = String.format("3PARDriver: Unable to discover the storage pool information for storage system %s native id %s; Error: %s.\n", storageSystem.getSystemName(), storageSystem.getNativeId(), e);
        _log.error(msg);
        _log.error(CompleteError.getStackTrace(e));
        task.setMessage(msg);
        task.setStatus(DriverTask.TaskStatus.FAILED);
        e.printStackTrace();
    }
    return task;
}
Also used : Protocols(com.emc.storageos.storagedriver.model.StoragePool.Protocols) StoragePool(com.emc.storageos.storagedriver.model.StoragePool) HashMap(java.util.HashMap) DeduplicationCapabilityDefinition(com.emc.storageos.storagedriver.storagecapabilities.DeduplicationCapabilityDefinition) ArrayList(java.util.ArrayList) VolumeDetailsCommandResult(com.emc.storageos.hp3par.command.VolumeDetailsCommandResult) RaidLevels(com.emc.storageos.storagedriver.model.StoragePool.RaidLevels) VolumesCommandResult(com.emc.storageos.hp3par.command.VolumesCommandResult) DriverTask(com.emc.storageos.storagedriver.DriverTask) CapabilityInstance(com.emc.storageos.storagedriver.storagecapabilities.CapabilityInstance) List(java.util.List) ArrayList(java.util.ArrayList) SupportedDriveTypes(com.emc.storageos.storagedriver.model.StoragePool.SupportedDriveTypes) MutableBoolean(org.apache.commons.lang.mutable.MutableBoolean) CPGSpaceCommandResult(com.emc.storageos.hp3par.command.CPGSpaceCommandResult) HashSet(java.util.HashSet) CPGCommandResult(com.emc.storageos.hp3par.command.CPGCommandResult) CPGMember(com.emc.storageos.hp3par.command.CPGMember)

Example 12 with VolumeDetailsCommandResult

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

the class HP3PARApi method restorePhysicalCopy.

public void restorePhysicalCopy(String name) throws Exception {
    _log.info("3PARDriver: restorePhysicalCopy enter");
    ClientResponse clientResp = null;
    Boolean offline = false;
    String intermediateSnapshot = name;
    // Offline restore is performed on intermediate snapshot
    String offlinePayload = "{\"action\":4, \"online\": " + offline + " }";
    try {
        VolumeDetailsCommandResult volResult = null;
        volResult = getVolumeDetails(name);
        if (volResult != null && volResult.getProvisioningType() != 3) {
            // get intermediate snapshot of clone/physical copy
            intermediateSnapshot = volResult.getCopyOf();
        }
        final String path = MessageFormat.format(URI_RESTORE_VOLUME_CLONE, intermediateSnapshot);
        // trying offline restore
        clientResp = put(path, offlinePayload);
        if (clientResp == null) {
            _log.error("3PARDriver: restorePhysicalCopy 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.info("3PARDriver: restorePhysicalCopy error {} ", errResp);
            throw new HP3PARException(errResp);
        } else {
            _log.info("3PARDriver: restorePhysicalCopy success");
        }
    } catch (Exception e) {
        _log.info("3PARDriver: restorePhysicalCopy exception info {} ", e.getMessage());
        throw e;
    } finally {
        if (clientResp != null) {
            clientResp.close();
        }
        _log.info("3PARDriver: restorePhysicalCopy leave");
    }
// end try/catch/finally
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) VolumeDetailsCommandResult(com.emc.storageos.hp3par.command.VolumeDetailsCommandResult)

Example 13 with VolumeDetailsCommandResult

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

the class HP3PARApi method getVolumeDetails.

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

Example 14 with VolumeDetailsCommandResult

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

the class HP3PARCGHelper method createConsistencyGroupClone.

/**
 * Creating physical copy for VVset or CG clone Rest API expects created
 * VVset with its corresponding volumes types for clone destination So,
 * There are many ways for implementation
 *
 * 1. Customer will provide the VVSet name which already exist in Array
 * with its corresponding similar volumes for cloning
 *
 * 2. Customer will not provide any existing and matching VV set with
 * corresponding volumes for CG clone
 *
 * 3. Customer will provide VVset name which is created but volumes are not
 * matching for clone creation.
 *
 * Create new VV Set / CG . Create new volumes similar to parent VVSet
 * volumes Use this newly created VV set for CG clone
 *
 * option 2 is implemented, need to handle negative / error cases of option
 * 3
 */
public DriverTask createConsistencyGroupClone(VolumeConsistencyGroup consistencyGroup, List<VolumeClone> clones, List<CapabilityInstance> capabilities, DriverTask task, Registry driverRegistry) {
    _log.info("3PARDriver: createConsistencyGroupClone for storage system  id {}, Base CG name {} , Base CG native id {} - start", consistencyGroup.getStorageSystemId(), consistencyGroup.getDisplayName(), consistencyGroup.getNativeId());
    String VVsetNameForClone = consistencyGroup.getDisplayName();
    VolumeDetailsCommandResult volResult = null;
    HashMap<String, VolumeClone> clonesMap = new HashMap<String, VolumeClone>();
    try {
        Boolean saveSnapshot = true;
        // get Api client
        HP3PARApi hp3parApi = hp3parUtil.getHP3PARDeviceFromNativeId(consistencyGroup.getStorageSystemId(), driverRegistry);
        // get Vipr generated clone name
        for (VolumeClone clone : clones) {
            // native id = null ,
            _log.info("3PARDriver: createConsistencyGroupClone generated clone parent id {}, display name {} ", clone.getParentId(), clone.getDisplayName());
            String generatedCloneName = clone.getDisplayName();
            VVsetNameForClone = generatedCloneName.substring(0, generatedCloneName.lastIndexOf("-"));
            _log.info("3PARDriver: createConsistencyGroupClone CG name {} to be used in cloning ", VVsetNameForClone);
            clonesMap.put(clone.getParentId(), clone);
        }
        _log.info("3PARDriver: createConsistencyGroupClone  clonesMap {}", clonesMap.toString());
        // Create vvset clone
        VVSetVolumeClone[] result = hp3parApi.createVVsetPhysicalCopy(consistencyGroup.getNativeId(), VVsetNameForClone, clones, saveSnapshot);
        _log.info("3PARDriver: createConsistencyGroupClone outPut of CG clone result  {} ", result.toString());
        for (VVSetVolumeClone cloneCreated : result) {
            VolumeClone clone = clonesMap.get(cloneCreated.getParent());
            _log.info("createConsistencyGroupClone cloneCreated {} and local clone obj nativeid = {} , parent id = {}", cloneCreated.getValues(), clone.getNativeId(), clone.getParentId());
            volResult = hp3parApi.getVolumeDetails(cloneCreated.getChild());
            _log.info("createConsistencyGroupClone cloneCreated All values {} ", volResult.getAllValues());
            clone.setWwn(volResult.getWwn());
            clone.setNativeId(volResult.getId());
            clone.setDeviceLabel(volResult.getName());
            // snap.setAccessStatus(volResult.getAccessStatus());
            clone.setDisplayName(volResult.getName());
            clone.setReplicationState(VolumeClone.ReplicationState.SYNCHRONIZED);
            clone.setProvisionedCapacity(clone.getRequestedCapacity());
            // Allocated capacity is the sum of user, snapshot and admin reserved space
            Long allocatedCapacity = volResult.getUserSpace().getReservedMiB();
            allocatedCapacity += volResult.getSnapshotSpace().getReservedMiB();
            allocatedCapacity += volResult.getAdminSpace().getReservedMiB();
            clone.setAllocatedCapacity(allocatedCapacity * HP3PARConstants.MEGA_BYTE);
        }
        task.setStatus(DriverTask.TaskStatus.READY);
        _log.info("createConsistencyGroupClone for storage system native id {}, CG display Name {}, CG native id {} - end", consistencyGroup.getStorageSystemId(), consistencyGroup.getDisplayName(), consistencyGroup.getNativeId());
    } catch (Exception e) {
        String msg = String.format("3PARDriver: createConsistencyGroupClone Unable to create vv set snap name %s and its native id %s whose storage system  id is %s; Error: %s.\n", VVsetNameForClone, consistencyGroup.getNativeId(), consistencyGroup.getStorageSystemId(), e.getMessage());
        _log.error(msg);
        task.setMessage(msg);
        task.setStatus(DriverTask.TaskStatus.PARTIALLY_FAILED);
        e.printStackTrace();
    }
    return task;
}
Also used : HashMap(java.util.HashMap) VVSetVolumeClone(com.emc.storageos.hp3par.command.VVSetCloneList.VVSetVolumeClone) VolumeDetailsCommandResult(com.emc.storageos.hp3par.command.VolumeDetailsCommandResult) VolumeClone(com.emc.storageos.storagedriver.model.VolumeClone) VVSetVolumeClone(com.emc.storageos.hp3par.command.VVSetCloneList.VVSetVolumeClone)

Aggregations

VolumeDetailsCommandResult (com.emc.storageos.hp3par.command.VolumeDetailsCommandResult)14 VolumeClone (com.emc.storageos.storagedriver.model.VolumeClone)4 ClientResponse (com.sun.jersey.api.client.ClientResponse)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 VirtualLunsList (com.emc.storageos.hp3par.command.VirtualLunsList)3 VolumeSnapshot (com.emc.storageos.storagedriver.model.VolumeSnapshot)3 HashMap (java.util.HashMap)3 VVSetVolumeClone (com.emc.storageos.hp3par.command.VVSetCloneList.VVSetVolumeClone)2 VolumesCommandResult (com.emc.storageos.hp3par.command.VolumesCommandResult)2 StorageVolume (com.emc.storageos.storagedriver.model.StorageVolume)2 CapabilityInstance (com.emc.storageos.storagedriver.storagecapabilities.CapabilityInstance)2 Gson (com.google.gson.Gson)2 CPGCommandResult (com.emc.storageos.hp3par.command.CPGCommandResult)1 CPGMember (com.emc.storageos.hp3par.command.CPGMember)1 CPGSpaceCommandResult (com.emc.storageos.hp3par.command.CPGSpaceCommandResult)1 DriverTask (com.emc.storageos.storagedriver.DriverTask)1 StoragePool (com.emc.storageos.storagedriver.model.StoragePool)1 Protocols (com.emc.storageos.storagedriver.model.StoragePool.Protocols)1 RaidLevels (com.emc.storageos.storagedriver.model.StoragePool.RaidLevels)1