use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.
the class CinderCommunicationInterface method scan.
/**
* Process the cinder.conf file and deduce storage systems from it
*/
@Override
public void scan(AccessProfile accessProfile) throws BaseCollectionException {
_logger.info("Scanning started for provider: {}", accessProfile.getSystemId());
StorageProvider storageProvider = _dbClient.queryObject(StorageProvider.class, accessProfile.getSystemId());
String username = storageProvider.getUserName();
String password = storageProvider.getPassword();
String hostName = storageProvider.getIPAddress();
// map to hold cinder end point info
StringMap providerKeys = storageProvider.getKeys();
if (providerKeys == null) {
providerKeys = new StringMap();
}
updateKeyInProvider(providerKeys, CinderConstants.KEY_CINDER_HOST_NAME, hostName);
Integer portNumber = storageProvider.getPortNumber();
ArrayList<Section> sections = new ArrayList<Section>();
String volume_driver = "";
String auth_strategy = "unknown";
ChannelSftp sftp = null;
Session session = null;
try {
JSch jsch = new JSch();
session = jsch.getSession(username, hostName, portNumber);
session.setPassword(password);
Hashtable<String, String> config = new Hashtable<String, String>();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.connect(timeout);
_logger.debug("Session Connected...");
Channel channel = session.openChannel("sftp");
sftp = (ChannelSftp) channel;
InputStream ins;
sftp.connect(connectTimeout);
if (sftp.isConnected()) {
_logger.debug("SFTP Connected");
ins = sftp.get(CONFFILE);
BufferedReader b = new BufferedReader(new InputStreamReader(ins));
int next_section_index = 0;
String section_title = "";
Boolean auth_section = false;
while (!sftp.isEOF()) {
String line = b.readLine();
if (line == null) {
_logger.debug("End of buffer -- break");
break;
}
if (isComment(line)) {
// skip comments
continue;
}
if (isSection(line)) {
// start new section
section_title = line.substring(line.indexOf('[') + 1, line.indexOf(']'));
Section section = new Section();
section.index = next_section_index;
section.title = section_title;
sections.add(section);
next_section_index++;
_logger.debug("Section {}: Title: {}", section.index, section.title);
auth_section = section_title.startsWith(auth_strategy);
continue;
}
if (!line.contains("=")) {
// not a value-parameter pair
continue;
}
// Now process each line
String[] splits = line.split("=");
if (splits.length == 2) {
String parameter = splits[0].trim();
String value = splits[1].trim();
if (auth_section) {
if (parameter.equalsIgnoreCase("admin_user") || parameter.equalsIgnoreCase("username")) {
updateKeyInProvider(providerKeys, CinderConstants.KEY_CINDER_REST_USER, value);
_logger.debug("REST user name = {}", value);
} else if (parameter.equalsIgnoreCase("admin_password") || parameter.equalsIgnoreCase("password")) {
updateKeyInProvider(providerKeys, CinderConstants.KEY_CINDER_REST_PASSWORD, value);
_logger.debug("REST password = {}", value);
} else if (parameter.equalsIgnoreCase("admin_tenant_name") || parameter.equalsIgnoreCase("project_name")) {
updateKeyInProvider(providerKeys, CinderConstants.KEY_CINDER_TENANT_NAME, value);
_logger.debug("Tenant name = {}", value);
} else if (parameter.equalsIgnoreCase("auth_uri")) {
updateKeyInProvider(providerKeys, CinderConstants.KEY_CINDER_REST_URI_BASE, value);
_logger.info("REST uri = {}", value);
}
} else {
// this is a storage section
_logger.debug("Storage section: parameter = {}, value = {}", parameter, value);
if (parameter.equalsIgnoreCase("auth_strategy")) {
auth_strategy = value.trim();
_logger.info("Auth strategy = {}", auth_strategy);
} else if (parameter.equalsIgnoreCase("volume_driver")) {
volume_driver = value.trim();
sections.get(next_section_index - 1).volume_driver = volume_driver;
_logger.debug("Volume driver = {}", volume_driver);
} else if (parameter.equalsIgnoreCase("volume_backend_name")) {
String volume_backend_name = value.trim();
_logger.debug("Volume backend_name = {}", volume_backend_name);
sections.get(next_section_index - 1).volume_backend_name = volume_backend_name;
}
}
}
/* if splits.length */
}
/* while not EOF */
b.close();
}
/* if sftp is connected */
storageProvider.setConnectionStatus(ConnectionStatus.CONNECTED.name());
}/* try */
catch (Exception e) {
// exceptionOccured = true;
storageProvider.setConnectionStatus(ConnectionStatus.NOTCONNECTED.name());
_logger.error("Exception occurred while scanning provider {}", accessProfile.getSystemId(), e);
} finally {
fillStorageSystemCache(accessProfile, sections);
if (storageProvider.getKeys() == null) {
/* first time scan */
storageProvider.setKeys(providerKeys);
}
_dbClient.persistObject(storageProvider);
if (sftp != null) {
sftp.disconnect();
}
if (session != null) {
session.disconnect();
}
}
_logger.info("Scanning ended for provider: {}", accessProfile.getSystemId());
}
use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.
the class DataDomainCommunicationInterface method discover.
@Override
public void discover(AccessProfile accessProfile) throws BaseCollectionException {
DataDomainClient ddClient = getDataDomainClient(accessProfile);
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
URI providerId = storageSystem.getActiveProviderURI();
StorageProvider provider = _dbClient.queryObject(StorageProvider.class, providerId);
if (storageSystem == null || storageSystem.getInactive()) {
return;
}
if ((null != accessProfile.getnamespace()) && (accessProfile.getnamespace().equals(StorageSystem.Discovery_Namespaces.UNMANAGED_FILESYSTEMS.toString()))) {
discoverUnManagedFileSystems(ddClient, storageSystem);
discoverUnManagedNewExports(ddClient, storageSystem);
discoverUnManagedCifsShares(ddClient, storageSystem);
} else {
discoverAll(ddClient, storageSystem);
}
}
use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.
the class DataDomainCommunicationInterface method scan.
@Override
public void scan(AccessProfile accessProfile) throws DataDomainApiException {
DataDomainClient ddClient = getDataDomainClient(accessProfile);
StorageProvider provider = _dbClient.queryObject(StorageProvider.class, accessProfile.getSystemId());
DDMCInfoDetail ddmcInfo = new DDMCInfoDetail();
try {
ddmcInfo = ddClient.getManagementSystemInfo();
} catch (DataDomainApiException dex) {
provider.setConnectionStatus(ConnectionStatus.NOTCONNECTED.toString());
String op = "DDMC info retrieval";
String sys = provider.getLabel() + "(" + provider.getIPAddress() + ")";
throw DataDomainApiException.exceptions.opFailedProviderUnreachable(op, sys);
}
if (!validDdmcVersion(accessProfile, provider, ddmcInfo)) {
String version = null;
String minimumSupportedVersion = null;
Map<String, String> props = accessProfile.getProps();
if (props != null) {
version = props.get(CURRENT_VERSION);
minimumSupportedVersion = props.get(MINIMUM_VERSION);
}
throw DataDomainApiException.exceptions.scanFailedIncompatibleDdmc(version, minimumSupportedVersion);
}
Map<String, StorageSystemViewObject> cache = accessProfile.getCache();
DDSystemList systemList = ddClient.getManagedSystemList();
for (DDSystemInfo system : systemList.getSystemInfo()) {
DDSystem ddSystem = ddClient.getDDSystem(system.getId());
StorageSystemViewObject view = new StorageSystemViewObject();
view.addprovider(accessProfile.getSystemId().toString());
view.setDeviceType(accessProfile.getSystemType());
view.setProperty(StorageSystemViewObject.SERIAL_NUMBER, ddSystem.serialNo);
view.setProperty(StorageSystemViewObject.MODEL, ddSystem.model);
view.setProperty(StorageSystemViewObject.STORAGE_NAME, ddSystem.name);
view.setProperty(StorageSystemViewObject.VERSION, ddSystem.version);
cache.put(system.getId(), view);
}
}
use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.
the class ExternalDeviceUtils method refreshProviderConnections.
/**
* Refresh connections to driver managed providers.
*
* @param dbClient db client
* @return list of connected providers
*/
public static List<URI> refreshProviderConnections(DbClient dbClient) {
List<StorageProvider> externalProviders = new ArrayList<>();
List<URI> externalProvidersUris = new ArrayList<>();
try {
// get providers managed by drivers
driverManager = getDriverManager();
Collection<String> externalDeviceProviderTypes = driverManager.getStorageProvidersMap().values();
_log.info("Processing external provider types: {}", externalDeviceProviderTypes);
for (String providerType : externalDeviceProviderTypes) {
externalProviders.addAll(CustomQueryUtility.getActiveStorageProvidersByInterfaceType(dbClient, providerType));
}
} catch (Exception e) {
_log.error("Failed to refresh connections for external providers.", e);
return externalProvidersUris;
}
for (StorageProvider storageProvider : externalProviders) {
try {
// Make sure external provider is connected
String providerIpAddress = storageProvider.getIPAddress();
Integer providerPortNumber = storageProvider.getPortNumber();
if (getExternalDevice().validateStorageProviderConnection(providerIpAddress, providerPortNumber)) {
storageProvider.setConnectionStatus(StorageProvider.ConnectionStatus.CONNECTED.name());
externalProvidersUris.add(storageProvider.getId());
_log.info("Storage Provider {}/{}:{} is reachable", storageProvider.getLabel(), providerIpAddress, providerPortNumber);
} else {
storageProvider.setConnectionStatus(StorageProvider.ConnectionStatus.NOTCONNECTED.name());
_log.error("Storage Provider {}/{}:{} is not reachable", storageProvider.getLabel(), providerIpAddress, providerPortNumber);
}
} catch (Exception e) {
storageProvider.setConnectionStatus(StorageProvider.ConnectionStatus.NOTCONNECTED.name());
_log.error("Storage Provider {}/{}:{} is not reachable", storageProvider.getLabel(), storageProvider.getIPAddress(), storageProvider.getPortNumber(), e);
} finally {
dbClient.updateObject(storageProvider);
}
}
return externalProvidersUris;
}
use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.
the class XtremIOProvUtils method getXtremIOVersion.
/**
* Gets the XtrmeIO model.
*
* @param dbClient
* the db client
* @param system
* the system
* @return the XtrmeIO model
*/
public static String getXtremIOVersion(DbClient dbClient, StorageSystem system) {
String version = system.getFirmwareVersion();
// get model info from storage provider as it will have the latest model updated after scan process
if (!NullColumnValueGetter.isNullURI(system.getActiveProviderURI())) {
StorageProvider provider = dbClient.queryObject(StorageProvider.class, system.getActiveProviderURI());
version = provider.getVersionString();
}
return version;
}
Aggregations