Search in sources :

Example 16 with StorageProvider

use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.

the class CinderUtils method getStorageAdapter.

/**
 * Creates StorageHADomain for storage port.
 *
 * Cinder API does not provide the information about the storage adapter.
 * Consider it as a dummy storageHADomain for cinder based systems. If the storageHADomain
 * is not populated then the port will not be considered for multipath participatipation. While
 * creating a virtual pool with multiple paths, it gets discarded if storageHADomain is not found.
 *
 * @param storageSystem
 * @param dbClient
 * @return
 */
public static StorageHADomain getStorageAdapter(StorageSystem storageSystem, DbClient dbClient) {
    String cinderHostName = "";
    URI providerUri = storageSystem.getActiveProviderURI();
    StorageProvider provider = dbClient.queryObject(StorageProvider.class, providerUri);
    if (null != provider && null != provider.getKeys()) {
        cinderHostName = provider.getKeyValue(CinderConstants.KEY_CINDER_HOST_NAME);
    }
    String adapterNativeGUID = NativeGUIDGenerator.generateNativeGuid(storageSystem, cinderHostName, NativeGUIDGenerator.ADAPTER);
    StorageHADomain adapter = new StorageHADomain();
    adapter.setStorageDeviceURI(storageSystem.getId());
    adapter.setId(URIUtil.createId(StorageHADomain.class));
    adapter.setAdapterName(cinderHostName);
    adapter.setLabel(cinderHostName);
    adapter.setNativeGuid(adapterNativeGUID);
    adapter.setNumberofPorts("1");
    adapter.setAdapterType(StorageHADomain.HADomainType.FRONTEND.name());
    adapter.setInactive(false);
    dbClient.createObject(adapter);
    return adapter;
}
Also used : StorageProvider(com.emc.storageos.db.client.model.StorageProvider) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) URI(java.net.URI)

Example 17 with StorageProvider

use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.

the class CinderUtils method getCinderEndPoint.

/**
 * Gets the cinder endpoint info to access the endpoint
 *
 * @param storageProviderURi
 * @return
 */
public static CinderEndPointInfo getCinderEndPoint(URI storageProviderURi, DbClient dbClient) {
    StorageProvider provider = dbClient.queryObject(StorageProvider.class, storageProviderURi);
    // Get the persisted end point info
    StringMap endPointKeys = provider.getKeys();
    String hostName = endPointKeys.get(CinderConstants.KEY_CINDER_HOST_NAME);
    String password = endPointKeys.get(CinderConstants.KEY_CINDER_REST_PASSWORD);
    String userName = endPointKeys.get(CinderConstants.KEY_CINDER_REST_USER);
    String tenantName = endPointKeys.get(CinderConstants.KEY_CINDER_TENANT_NAME);
    String tenantId = endPointKeys.get(CinderConstants.KEY_CINDER_TENANT_ID);
    String baseUri = endPointKeys.get(CinderConstants.KEY_CINDER_REST_URI_BASE);
    String token = endPointKeys.get(CinderConstants.KEY_CINDER_REST_TOKEN);
    CinderEndPointInfo ep = new CinderEndPointInfo(hostName, userName, password, tenantName);
    if (baseUri.startsWith(CinderConstants.HTTP_URL)) {
        ep.setCinderBaseUriHttp(baseUri);
    } else {
        ep.setCinderBaseUriHttps(baseUri);
    }
    ep.setCinderToken(token);
    ep.setCinderTenantId(tenantId);
    return ep;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) CinderEndPointInfo(com.emc.storageos.cinder.CinderEndPointInfo) StorageProvider(com.emc.storageos.db.client.model.StorageProvider)

Example 18 with StorageProvider

use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.

the class CinderUtils method refreshCinderConnections.

/**
 * Refresh cinder connections.
 *
 * @param cinderProviderList the cinder provider list
 * @param dbClient the db client
 * @return the list
 */
public static List<URI> refreshCinderConnections(final List<StorageProvider> cinderProviderList, DbClient dbClient) {
    List<URI> activeProviders = new ArrayList<URI>();
    for (StorageProvider storageProvider : cinderProviderList) {
        try {
            // Makes sure Cinder Provider is reachable
            checkProviderConnection(storageProvider);
            storageProvider.setConnectionStatus(ConnectionStatus.CONNECTED.name());
            activeProviders.add(storageProvider.getId());
            _log.info("Storage Provider {} is reachable", storageProvider.getIPAddress());
        } catch (Exception e) {
            storageProvider.setConnectionStatus(ConnectionStatus.NOTCONNECTED.name());
            _log.error("Storage Provider {} is not reachable", storageProvider.getIPAddress());
        } finally {
            dbClient.persistObject(storageProvider);
        }
    }
    return activeProviders;
}
Also used : ArrayList(java.util.ArrayList) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URI(java.net.URI) SftpException(com.jcraft.jsch.SftpException) IOException(java.io.IOException) JSchException(com.jcraft.jsch.JSchException)

Example 19 with StorageProvider

use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.

the class ExternalBlockStorageDevice method validateStorageProviderConnection.

@Override
public boolean validateStorageProviderConnection(String ipAddress, Integer portNumber) {
    // call driver to validate provider connection
    boolean isConnectionValid = false;
    try {
        StringBuffer providerID = new StringBuffer(ipAddress).append(HDSConstants.HYPHEN_OPERATOR).append(portNumber);
        _log.info("Request to validate connection to provider, ID: {}", providerID);
        URIQueryResultList providerUriList = new URIQueryResultList();
        dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStorageProviderByProviderIDConstraint(providerID.toString()), providerUriList);
        if (providerUriList.iterator().hasNext()) {
            StorageProvider storageProvider = dbClient.queryObject(StorageProvider.class, providerUriList.iterator().next());
            isConnectionValid = validateStorageProviderConnection(storageProvider);
        } else {
            String msg = String.format("Cannot find provider with ID: %s ", providerID);
        }
    } catch (Exception ex) {
        _log.error("Problem in checking provider live connection with IP address and port: {}:{} due to: ", ipAddress, portNumber, ex);
    }
    return isConnectionValid;
}
Also used : StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) IOException(java.io.IOException)

Example 20 with StorageProvider

use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.

the class VPlexCommunicationInterface method getInitiatorHostName.

private String getInitiatorHostName(StorageSystem vplexStorageSystem) {
    // By default, we use the IP address of the active VPLEX management
    // server used for discovery for the host name for initiators
    // associated with the VPLEX.
    URI activeMgmntSvrURI = vplexStorageSystem.getActiveProviderURI();
    StorageProvider activeMgmntSvr = _dbClient.queryObject(StorageProvider.class, activeMgmntSvrURI);
    String hostName = activeMgmntSvr.getIPAddress();
    if (IPAddressUtil.isIPv4LiteralAddress(hostName) || IPAddressUtil.isIPv6LiteralAddress(hostName)) {
        // The VNX cannot deal with literal IP addresses in the hostName
        // field of an initiator. Make it something more reasonable.
        hostName = VPLEX_INITIATOR_HOSTNAME_PREFIX + hostName;
        s_logger.info("New host name is {}", hostName);
    }
    // The default is to use the IP of the active provider when no initiators
    // are found for this VPLEX system.
    String dfltHostName = hostName;
    // Check to see if there are any existing initiators with this host name.
    // If there are, then return this host name.
    List<Initiator> initiatorsWithHostName = CustomQueryUtility.queryActiveResourcesByAltId(_dbClient, Initiator.class, "hostname", hostName);
    if (!initiatorsWithHostName.isEmpty()) {
        return hostName;
    }
    // Otherwise, see if there are any initiators with a host name based
    // on any other providers for this vplex system. It could be that the
    // active management server has changed, and since that happened new
    // backend ports were added to the VPLEX. We want to make sure that all
    // initiators have the same host name. So it could be that previously
    // discovered backend ports have a host name based on the IP of a now
    // inactive management server.
    StringSet mgmntSvrIds = vplexStorageSystem.getProviders();
    for (String mgmntSvrId : mgmntSvrIds) {
        if (mgmntSvrId.equals(activeMgmntSvrURI.toString())) {
            continue;
        }
        StorageProvider mgmntSvr = _dbClient.queryObject(StorageProvider.class, URI.create(mgmntSvrId));
        hostName = mgmntSvr.getIPAddress();
        if (IPAddressUtil.isIPv4LiteralAddress(hostName) || IPAddressUtil.isIPv6LiteralAddress(hostName)) {
            hostName = VPLEX_INITIATOR_HOSTNAME_PREFIX + hostName;
            s_logger.info("New host name is {}", hostName);
        }
        // Check to see if there are any existing initiators with
        // this host name. If there are, then return this host name.
        initiatorsWithHostName = CustomQueryUtility.queryActiveResourcesByAltId(_dbClient, Initiator.class, "hostname", hostName);
        if (!initiatorsWithHostName.isEmpty()) {
            return hostName;
        }
    }
    // discovery of the VPLEX. Just use the default.
    return dfltHostName;
}
Also used : Initiator(com.emc.storageos.db.client.model.Initiator) StringSet(com.emc.storageos.db.client.model.StringSet) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URI(java.net.URI)

Aggregations

StorageProvider (com.emc.storageos.db.client.model.StorageProvider)97 URI (java.net.URI)44 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)26 ArrayList (java.util.ArrayList)24 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)23 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)19 Produces (javax.ws.rs.Produces)19 IOException (java.io.IOException)18 StringSet (com.emc.storageos.db.client.model.StringSet)17 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)15 Path (javax.ws.rs.Path)15 Consumes (javax.ws.rs.Consumes)11 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)10 MapStorageProvider (com.emc.storageos.api.mapper.functions.MapStorageProvider)8 StorageSystemViewObject (com.emc.storageos.plugins.StorageSystemViewObject)8 GET (javax.ws.rs.GET)8 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)7 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)7 AsyncTask (com.emc.storageos.volumecontroller.AsyncTask)7 BlockController (com.emc.storageos.volumecontroller.BlockController)7