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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations