Search in sources :

Example 1 with VPlexResourceInfo

use of com.emc.storageos.vplex.api.VPlexResourceInfo in project coprhd-controller by CoprHD.

the class VplexVolumeValidator method validateVolume.

/**
 * Validates an individual volume.
 *
 * @param virtualVolume the Volume to validate
 * @param delete boolean indicating if this validation is part of a delete operation
 * @param remediate boolean indicating whether or not remediation should be attempted
 * @param checks variable list of ValCks
 */
public void validateVolume(Volume virtualVolume, boolean delete, boolean remediate, ValCk... checks) {
    List<ValCk> checkList = Arrays.asList(checks);
    String volumeId = String.format("%s (%s)(%s)", virtualVolume.getLabel(), virtualVolume.getNativeGuid(), virtualVolume.getId());
    log.info("Initiating Vplex Volume validation: " + volumeId);
    VPlexVirtualVolumeInfo vvinfo = null;
    try {
        vvinfo = client.findVirtualVolume(virtualVolume.getDeviceLabel(), virtualVolume.getNativeId());
    } catch (VPlexApiException ex) {
        log.info(ex.getMessage());
    }
    if (vvinfo == null) {
        try {
            // Didn't find the virtual volume. Look at the storage volume, and from that determine
            // the deviceName. Then lookup the Device or DistributedDevice and check to see if
            // the device has been reassigned to a different virtual volume.
            Volume storageVolume = VPlexUtil.getVPLEXBackendVolume(virtualVolume, true, getDbClient(), false);
            if (storageVolume != null) {
                StorageSystem system = getDbClient().queryObject(StorageSystem.class, storageVolume.getStorageController());
                // Look up the corresponding device name to our Storage Volume
                VolumeInfo volumeInfo = new VolumeInfo(system.getNativeGuid(), system.getSystemType(), storageVolume.getWWN().toUpperCase().replaceAll(":", ""), storageVolume.getNativeId(), storageVolume.getThinlyProvisioned().booleanValue(), VPlexControllerUtils.getVolumeITLs(storageVolume));
                String deviceName = client.getDeviceForStorageVolume(volumeInfo);
                log.info("device name is " + deviceName);
                if (deviceName == null) {
                    if (!delete) {
                        // We didn't find a device name for the storage volume. Error if not deleting.
                        getValidatorLogger().logDiff(volumeId, "Vplex device-name", system.getSerialNumber() + "-" + storageVolume.getNativeId(), ValidatorLogger.NO_MATCHING_ENTRY);
                        return;
                    }
                }
                if (null != deviceName && !deviceName.trim().matches(VPlexApiConstants.STORAGE_VOLUME_NOT_IN_USE)) {
                    String volumeType = VPlexApiConstants.LOCAL_VIRTUAL_VOLUME;
                    if (virtualVolume.getAssociatedVolumes() != null && virtualVolume.getAssociatedVolumes().size() > 1) {
                        volumeType = VPlexApiConstants.DISTRIBUTED_VIRTUAL_VOLUME;
                    }
                    VPlexResourceInfo resourceInfo = client.getDeviceStructure(deviceName, volumeType);
                    if (resourceInfo instanceof VPlexDeviceInfo) {
                        // local device
                        VPlexDeviceInfo localDeviceInfo = (VPlexDeviceInfo) resourceInfo;
                        String virtualVolumeName = localDeviceInfo.getVirtualVolume();
                        if (virtualVolumeName != null && !virtualVolumeName.equals(virtualVolume.getDeviceLabel())) {
                            getValidatorLogger().logDiff(volumeId, "virtual-volume name changed", virtualVolume.getDeviceLabel(), virtualVolumeName);
                        }
                    } else if (resourceInfo instanceof VPlexDistributedDeviceInfo) {
                        VPlexDistributedDeviceInfo distDeviceInfo = (VPlexDistributedDeviceInfo) resourceInfo;
                        String virtualVolumeName = distDeviceInfo.getVirtualVolume();
                        if (virtualVolumeName != null && !virtualVolumeName.equals(virtualVolume.getDeviceLabel())) {
                            getValidatorLogger().logDiff(volumeId, "virtual-volume name changed", virtualVolume.getDeviceLabel(), virtualVolumeName);
                        }
                    }
                }
            }
        } catch (VPlexApiException ex) {
            log.error("Unable to determine if VPLEX device reused: " + volumeId, ex);
            if (getValidatorConfig().isValidationEnabled()) {
                throw ex;
            }
        }
        if (!delete) {
            // If we didn't log an error above indicating that the volume was reused,
            // and we are not deleting, it is still an error.
            // If we are deleting we won't error if it's just not there.
            getValidatorLogger().logDiff(volumeId, "virtual-volume", virtualVolume.getDeviceLabel(), ValidatorLogger.NO_MATCHING_ENTRY);
        }
        log.info("Vplex Validation complete (no vvinfo found); " + volumeId);
        return;
    }
    if (checkList.contains(ValCk.ID)) {
        if (!virtualVolume.getDeviceLabel().equals(vvinfo.getName())) {
            getValidatorLogger().logDiff(volumeId, "native-id", virtualVolume.getNativeId(), vvinfo.getName());
        }
        if (!NullColumnValueGetter.isNullValue(virtualVolume.getWWN()) && vvinfo.getWwn() != null && !virtualVolume.getWWN().equalsIgnoreCase(vvinfo.getWwn())) {
            getValidatorLogger().logDiff(volumeId, "wwn", virtualVolume.getWWN(), vvinfo.getWwn());
        }
        if (virtualVolume.getAssociatedVolumes() != null && !virtualVolume.getAssociatedVolumes().isEmpty()) {
            String locality = virtualVolume.getAssociatedVolumes().size() > 1 ? VPlexApiConstants.DISTRIBUTED_VIRTUAL_VOLUME : VPlexApiConstants.LOCAL_VIRTUAL_VOLUME;
            if (!locality.equalsIgnoreCase(vvinfo.getLocality())) {
                getValidatorLogger().logDiff(volumeId, "locality", locality, vvinfo.getLocality());
            }
        }
    }
    if (checkList.contains(ValCk.VPLEX) && !virtualVolume.isIngestedVolumeWithoutBackend(getDbClient())) {
        try {
            String drillDownInfo = client.getDrillDownInfoForDevice(vvinfo.getSupportingDevice());
            VPlexDrillDownParser parser = new VPlexDrillDownParser(drillDownInfo);
            VPlexDrillDownParser.Node root = parser.parse();
            boolean distributed = (root.getType() == VPlexDrillDownParser.NodeType.DIST) ? true : false;
            if (distributed) {
                List<VPlexDrillDownParser.Node> svols = root.getNodesOfType(NodeType.SVOL);
                boolean hasMirror = svols.size() > 2;
                String clusterName = VPlexControllerUtils.getVPlexClusterName(getDbClient(), virtualVolume);
                for (VPlexDrillDownParser.Node child : root.getChildren()) {
                    if (child.getArg2().equals(clusterName)) {
                        validateStorageVolumes(virtualVolume, volumeId, root.getArg1(), true, child.getArg2(), hasMirror);
                    }
                }
            } else {
                List<VPlexDrillDownParser.Node> svols = root.getNodesOfType(NodeType.SVOL);
                boolean hasMirror = svols.size() > 1;
                validateStorageVolumes(virtualVolume, volumeId, root.getArg1(), false, root.getArg2(), hasMirror);
            }
        } catch (Exception ex) {
            getValidatorLogger().logDiff(volumeId, "exception trying to validate storage volumes", virtualVolume.getDeviceLabel(), "N/A");
        }
    }
    log.info("Vplex Validation complete; " + volumeId);
}
Also used : ValCk(com.emc.storageos.volumecontroller.impl.validators.ValCk) VPlexDistributedDeviceInfo(com.emc.storageos.vplex.api.VPlexDistributedDeviceInfo) VPlexVirtualVolumeInfo(com.emc.storageos.vplex.api.VPlexVirtualVolumeInfo) VPlexStorageVolumeInfo(com.emc.storageos.vplex.api.VPlexStorageVolumeInfo) VolumeInfo(com.emc.storageos.vplex.api.clientdata.VolumeInfo) VPlexDrillDownParser(com.emc.storageos.util.VPlexDrillDownParser) VPlexVirtualVolumeInfo(com.emc.storageos.vplex.api.VPlexVirtualVolumeInfo) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) Volume(com.emc.storageos.db.client.model.Volume) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) VPlexDeviceInfo(com.emc.storageos.vplex.api.VPlexDeviceInfo) VPlexResourceInfo(com.emc.storageos.vplex.api.VPlexResourceInfo) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 2 with VPlexResourceInfo

use of com.emc.storageos.vplex.api.VPlexResourceInfo in project coprhd-controller by CoprHD.

the class VplexBackendIngestionContext method getMirrorMap.

/**
 * Creates a Map of cluster name to sorted Map of slot numbers to VPlexDeviceInfos
 * for use in describing the layout of VPLEX native mirrors.
 *
 * @return a Map of cluster id to sorted Map of slot numbers to VPlexDeviceInfos
 */
private Map<String, Map<String, VPlexDeviceInfo>> getMirrorMap() {
    if (null != mirrorMap) {
        return mirrorMap;
    }
    // the mirror map is a mapping of:
    // 
    // cluster id (e.g., cluster-1 and cluster-2) to:
    // a sorted map of device slot-number to:
    // the VPlexDeviceInfo in that slot
    // sort of like: Map<ClusterName, Map<SlotNumber, VPlexDeviceInfo>>
    // 
    // if distributed, it assumes only one mirror set
    // can be present on each side of the vplex
    _logger.info("assembling mirror map");
    mirrorMap = new HashMap<String, Map<String, VPlexDeviceInfo>>();
    VPlexResourceInfo device = getTopLevelDevice();
    if (isLocal() && (device instanceof VPlexDeviceInfo)) {
        VPlexDeviceInfo localDevice = ((VPlexDeviceInfo) device);
        if (VPlexApiConstants.ARG_GEOMETRY_RAID1.equals(((VPlexDeviceInfo) device).getGeometry())) {
            mirrorMap.put(localDevice.getCluster(), mapDevices(localDevice));
        }
    } else {
        for (VPlexDeviceInfo localDevice : ((VPlexDistributedDeviceInfo) device).getLocalDeviceInfo()) {
            if (VPlexApiConstants.ARG_GEOMETRY_RAID1.equals(((VPlexDistributedDeviceInfo) device).getGeometry())) {
                mirrorMap.put(localDevice.getCluster(), mapDevices(localDevice));
            }
        }
    }
    _logger.info("mirror map is: " + mirrorMap);
    return mirrorMap;
}
Also used : VPlexDistributedDeviceInfo(com.emc.storageos.vplex.api.VPlexDistributedDeviceInfo) VPlexDeviceInfo(com.emc.storageos.vplex.api.VPlexDeviceInfo) HashMap(java.util.HashMap) Map(java.util.Map) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) TreeMap(java.util.TreeMap) StringMap(com.emc.storageos.db.client.model.StringMap) VPlexResourceInfo(com.emc.storageos.vplex.api.VPlexResourceInfo)

Example 3 with VPlexResourceInfo

use of com.emc.storageos.vplex.api.VPlexResourceInfo in project coprhd-controller by CoprHD.

the class VPlexControllerUtils method getDeviceInfo.

/**
 * Returns a VPlexResourceInfo object for the given device name based
 * on its virtual volume type (local or distributed).
 *
 * @param deviceName the name of the device
 * @param virtualVolumeType the type of virtual volume (local or distributed)
 * @param vplexUri the URI of the VPLEX system
 * @param dbClient a reference to the database client
 *
 * @return a VPlexResourceInfo object for the device name
 * @throws VPlexApiException
 */
public static VPlexResourceInfo getDeviceInfo(String deviceName, String virtualVolumeType, URI vplexUri, DbClient dbClient) throws VPlexApiException {
    VPlexResourceInfo device = null;
    VPlexApiClient client = null;
    try {
        VPlexApiFactory vplexApiFactory = VPlexApiFactory.getInstance();
        client = VPlexControllerUtils.getVPlexAPIClient(vplexApiFactory, vplexUri, dbClient);
    } catch (URISyntaxException e) {
        log.error("cannot load vplex api client", e);
    }
    if (null != client) {
        device = client.getDeviceStructure(deviceName, virtualVolumeType);
    }
    return device;
}
Also used : VPlexApiClient(com.emc.storageos.vplex.api.VPlexApiClient) URISyntaxException(java.net.URISyntaxException) VPlexResourceInfo(com.emc.storageos.vplex.api.VPlexResourceInfo) VPlexApiFactory(com.emc.storageos.vplex.api.VPlexApiFactory)

Aggregations

VPlexResourceInfo (com.emc.storageos.vplex.api.VPlexResourceInfo)3 VPlexDeviceInfo (com.emc.storageos.vplex.api.VPlexDeviceInfo)2 VPlexDistributedDeviceInfo (com.emc.storageos.vplex.api.VPlexDistributedDeviceInfo)2 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 StringMap (com.emc.storageos.db.client.model.StringMap)1 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)1 Volume (com.emc.storageos.db.client.model.Volume)1 VPlexDrillDownParser (com.emc.storageos.util.VPlexDrillDownParser)1 ValCk (com.emc.storageos.volumecontroller.impl.validators.ValCk)1 VPlexApiClient (com.emc.storageos.vplex.api.VPlexApiClient)1 VPlexApiException (com.emc.storageos.vplex.api.VPlexApiException)1 VPlexApiFactory (com.emc.storageos.vplex.api.VPlexApiFactory)1 VPlexStorageVolumeInfo (com.emc.storageos.vplex.api.VPlexStorageVolumeInfo)1 VPlexVirtualVolumeInfo (com.emc.storageos.vplex.api.VPlexVirtualVolumeInfo)1 VolumeInfo (com.emc.storageos.vplex.api.clientdata.VolumeInfo)1 URISyntaxException (java.net.URISyntaxException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1