Search in sources :

Example 1 with VPlexApiFactory

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

the class VPlexControllerUtils method getDistributedDevicePathToClusterMap.

/**
 * Returns a Map of distributed device component context
 * paths from the VPLEX API to VPLEX cluster names.
 *
 * @param vplexUri the VPLEX to query
 * @param dbClient a reference to the database client
 * @return a Map of distributed device component context
 *         paths from the VPLEX API to VPLEX cluster names
 *
 * @throws VPlexApiException
 */
public static Map<String, String> getDistributedDevicePathToClusterMap(URI vplexUri, DbClient dbClient) throws VPlexApiException {
    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);
    }
    Map<String, String> distributedDevicePathToClusterMap = Collections.emptyMap();
    if (null != client) {
        distributedDevicePathToClusterMap = client.getDistributedDevicePathToClusterMap();
    }
    return distributedDevicePathToClusterMap;
}
Also used : VPlexApiClient(com.emc.storageos.vplex.api.VPlexApiClient) URISyntaxException(java.net.URISyntaxException) VPlexApiFactory(com.emc.storageos.vplex.api.VPlexApiFactory)

Example 2 with VPlexApiFactory

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

the class VPlexControllerUtils method validateSupportingDeviceStructure.

/**
 * Validates that the underlying structure of the given device name
 * satisfies the constraints for compatibility with ViPR.  Used for
 * validating unmanaged VPLEX volumes before ingestion.
 *
 * @param deviceName the device to validate
 * @param vplexUri the VPLEX to query
 * @param dbClient a reference to the database client
 * @throws VPlexApiException if the device structure is incompatible with ViPR
 */
public static void validateSupportingDeviceStructure(String deviceName, URI vplexUri, DbClient dbClient) throws VPlexApiException {
    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) {
        String drillDownResponse = client.getDrillDownInfoForDevice(deviceName);
        if (!VPlexUtil.isDeviceStructureValid(deviceName, drillDownResponse)) {
            throw VPlexApiException.exceptions.deviceStructureIsIncompatibleForIngestion(drillDownResponse);
        }
    } else {
        throw VPlexApiException.exceptions.failedToExecuteDrillDownCommand(deviceName, "cannot load vplex api client");
    }
}
Also used : VPlexApiClient(com.emc.storageos.vplex.api.VPlexApiClient) URISyntaxException(java.net.URISyntaxException) VPlexApiFactory(com.emc.storageos.vplex.api.VPlexApiFactory)

Example 3 with VPlexApiFactory

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

the class VPlexControllerUtils method getStorageVolumeInfoForDevice.

/**
 * Returns a Map of lowest-level storage-volume resource's WWN to its VPlexStorageVolumeInfo
 * object for a given device name, virtual volume type, and cluster name. If
 * hasMirror is true, this indicates the top-level device is composed of a
 * RAID-1 mirror, so there's an extra layers of components to traverse in finding
 * the lowest-level storage-volume resources.
 *
 * @param deviceName the name of the top-level device to look at
 * @param virtualVolumeType the type of virtual volume (local or distributed)
 * @param clusterName the cluster name
 * @param hasMirror indicates if the top-level device is a RAID-1 mirror
 * @param vplexUri the URI of the VPLEX system
 * @param dbClient a reference to the database client
 *
 * @return a map of WWNs to VPlexStorageVolumeInfo objects
 * @throws VPlexApiException
 */
public static Map<String, VPlexStorageVolumeInfo> getStorageVolumeInfoForDevice(String deviceName, String virtualVolumeType, String clusterName, boolean hasMirror, URI vplexUri, DbClient dbClient) throws VPlexApiException {
    Map<String, VPlexStorageVolumeInfo> storageVolumeInfo = 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) {
        storageVolumeInfo = client.getStorageVolumeInfoForDevice(deviceName, virtualVolumeType, clusterName, hasMirror);
    }
    log.info("Backend storage volume wwns for {} are {}", deviceName, storageVolumeInfo);
    return storageVolumeInfo;
}
Also used : VPlexStorageVolumeInfo(com.emc.storageos.vplex.api.VPlexStorageVolumeInfo) VPlexApiClient(com.emc.storageos.vplex.api.VPlexApiClient) URISyntaxException(java.net.URISyntaxException) VPlexApiFactory(com.emc.storageos.vplex.api.VPlexApiFactory)

Example 4 with VPlexApiFactory

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

the class VPlexMigrationJob method getVPlexAPIClient.

/**
 * Get the HTTP client for making requests to the VPlex at the
 * endpoint specified in the passed profile.
 *
 * @param jobContext The job context
 * @param vplexSystem The VPlex storage system
 *
 * @return A reference to the VPlex API HTTP client.
 * @throws URISyntaxException
 */
private VPlexApiClient getVPlexAPIClient(JobContext jobContext, StorageSystem vplexSystem) throws URISyntaxException {
    // Create the URI to access the VPlex Management Station based
    // on the IP and port for the passed VPlex system.
    URI vplexEndpointURI = new URI("https", null, vplexSystem.getIpAddress(), vplexSystem.getPortNumber(), "/", null, null);
    s_logger.debug("VPlex base URI is {}", vplexEndpointURI.toString());
    VPlexApiFactory vplexApiFactory = jobContext.getVPlexApiFactory();
    s_logger.debug("Got VPlex API factory");
    VPlexApiClient client = vplexApiFactory.getClient(vplexEndpointURI, vplexSystem.getUsername(), vplexSystem.getPassword());
    s_logger.debug("Got VPlex API client");
    return client;
}
Also used : VPlexApiClient(com.emc.storageos.vplex.api.VPlexApiClient) URI(java.net.URI) VPlexApiFactory(com.emc.storageos.vplex.api.VPlexApiFactory)

Example 5 with VPlexApiFactory

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

the class VPlexDeviceController method migrationSupportedForVolume.

/**
 * Determines if the controller can support migration for the passed VPLEX volume.
 *
 * @param volume
 *            A reference to a VPLEX volume.
 * @param varrayURI
 *            A reference to a varray or null.
 *
 * @return true if migration is supported, false otherwise.
 */
public static boolean migrationSupportedForVolume(Volume volume, URI varrayURI, DbClient dbClient) {
    boolean supported = true;
    // Migration is supported for all volumes that were not ingested.
    if (volume.isIngestedVolumeWithoutBackend(dbClient)) {
        VirtualPool vpool = dbClient.queryObject(VirtualPool.class, volume.getVirtualPool());
        // Migration is supported for all local volumes.
        if (VirtualPool.HighAvailabilityType.vplex_distributed.name().equals(vpool.getHighAvailability())) {
            StorageSystem vplexSystem = dbClient.queryObject(StorageSystem.class, volume.getStorageController());
            try {
                VPlexApiFactory apiFactory = VPlexApiFactory.getInstance();
                VPlexApiClient client = getVPlexAPIClient(apiFactory, vplexSystem, dbClient);
                VPlexVirtualVolumeInfo vvInfo = client.getVirtualVolumeStructure(volume.getDeviceLabel());
                VPlexDistributedDeviceInfo ddInfo = (VPlexDistributedDeviceInfo) vvInfo.getSupportingDeviceInfo();
                List<VPlexDeviceInfo> localDeviceInfoList = ddInfo.getLocalDeviceInfo();
                for (VPlexDeviceInfo localDeviceInfo : localDeviceInfoList) {
                    _log.info("localDeviceInfo: {}, {}", localDeviceInfo.getName(), localDeviceInfo.getCluster());
                    // the passed varray.
                    if (varrayURI != null) {
                        _log.info("varrayURI:{}", varrayURI);
                        String varrayCluster = ConnectivityUtil.getVplexClusterForVarray(varrayURI, vplexSystem.getId(), dbClient);
                        _log.info("varrayCluster:{}", varrayCluster);
                        if (!localDeviceInfo.getCluster().contains(varrayCluster)) {
                            continue;
                        }
                    }
                    // For distributed volumes, the local device must be built
                    // on a single extent.
                    _log.info("Local device: {}", localDeviceInfo.getName());
                    _log.info("Extent count: {}", localDeviceInfo.getExtentInfo().size());
                    if (localDeviceInfo.getExtentInfo().size() != 1) {
                        supported = false;
                        break;
                    }
                }
            } catch (VPlexApiException vae) {
                _log.error("Exception checking if migration supported for volume:", vae);
                throw vae;
            } catch (Exception ex) {
                _log.error("Exception checking if migration supported for volume", ex);
                throw VPlexApiException.exceptions.failedGettingMigrationSupportedForVolume(vplexSystem.getId().toString(), volume.getLabel());
            }
        }
    }
    return supported;
}
Also used : VPlexDistributedDeviceInfo(com.emc.storageos.vplex.api.VPlexDistributedDeviceInfo) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) VPlexApiClient(com.emc.storageos.vplex.api.VPlexApiClient) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) VPlexDeviceInfo(com.emc.storageos.vplex.api.VPlexDeviceInfo) VPlexVirtualVolumeInfo(com.emc.storageos.vplex.api.VPlexVirtualVolumeInfo) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) VPlexApiFactory(com.emc.storageos.vplex.api.VPlexApiFactory)

Aggregations

VPlexApiClient (com.emc.storageos.vplex.api.VPlexApiClient)8 VPlexApiFactory (com.emc.storageos.vplex.api.VPlexApiFactory)8 URISyntaxException (java.net.URISyntaxException)6 URI (java.net.URI)2 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)1 ControllerException (com.emc.storageos.volumecontroller.ControllerException)1 VPlexApiException (com.emc.storageos.vplex.api.VPlexApiException)1 VPlexDeviceInfo (com.emc.storageos.vplex.api.VPlexDeviceInfo)1 VPlexDistributedDeviceInfo (com.emc.storageos.vplex.api.VPlexDistributedDeviceInfo)1 VPlexResourceInfo (com.emc.storageos.vplex.api.VPlexResourceInfo)1 VPlexStorageVolumeInfo (com.emc.storageos.vplex.api.VPlexStorageVolumeInfo)1 VPlexVirtualVolumeInfo (com.emc.storageos.vplex.api.VPlexVirtualVolumeInfo)1 WorkflowException (com.emc.storageos.workflow.WorkflowException)1 IOException (java.io.IOException)1