use of com.emc.storageos.plugins.metering.smis.SMIPluginException in project coprhd-controller by CoprHD.
the class HDSCommunicationInterface method getCIMClient.
/**
* Creates a new WEBClient for a given IP, based on AccessProfile
*
* @param accessProfile
* : AccessProfile for the providers
* @throws WBEMException
* : if WBEMException while creating the WBEMClient
* @throws SMIPluginException
* @return WBEMClient : initialized instance of WBEMClientCIMXML
*/
private WBEMClient getCIMClient(AccessProfile accessProfile) throws Exception {
String protocol = Boolean.valueOf(accessProfile.getSslEnable()) ? CimConstants.SECURE_PROTOCOL : CimConstants.DEFAULT_PROTOCOL;
CIMObjectPath path = CimObjectPathCreator.createInstance(protocol, accessProfile.getIpAddress(), Integer.toString(accessProfile.getPortNumber()), accessProfile.getInteropNamespace(), null, null);
try {
Subject subject = new Subject();
subject.getPrincipals().add(new UserPrincipal(accessProfile.getUserName()));
subject.getPrivateCredentials().add(new PasswordCredential(accessProfile.getPassword()));
wbemClient = WBEMClientFactory.getClient(CimConstants.CIM_CLIENT_PROTOCOL);
// Operations block by default, so a timeout must be set in case the
// CIM server becomes unreachable.
// Commenting out, as timeout had been moved to cimom.properties
// file
// _cimClient.setProperty(WBEMClientConstants.PROP_TIMEOUT,
// CimConstants.CIM_CLIENT_TIMEOUT);
wbemClient.initialize(path, subject, null);
} catch (Exception e) {
_logger.error("Could not establish connection for {}", accessProfile.getIpAddress(), e);
wbemClient.close();
throw e;
}
return wbemClient;
}
use of com.emc.storageos.plugins.metering.smis.SMIPluginException in project coprhd-controller by CoprHD.
the class RPInsertion method injectColumnsDetails.
@Override
public void injectColumnsDetails(Stat statObj, DbClient client) throws Exception {
ProtectionSystem protectionObj = client.queryObject(ProtectionSystem.class, statObj.getResourceId());
// Given a protection system, find a volume protected by this protection system,
// and then extract the project and vpool
Volume protectedVolume = null;
URIQueryResultList resultList = new URIQueryResultList();
client.queryByConstraint(ContainmentConstraint.Factory.getProtectionSystemVolumesConstraint(protectionObj.getId()), resultList);
for (Iterator<URI> volumeItr = resultList.iterator(); volumeItr.hasNext(); ) {
Volume volume = client.queryObject(Volume.class, volumeItr.next());
if (volume.getProtectionController().equals(protectionObj.getId())) {
protectedVolume = volume;
break;
}
}
if (protectedVolume != null) {
_logger.info("Found volume " + protectedVolume.getWWN() + " protected by this protection controller. Get the Cos/Project/Tenant.");
statObj.setProject(protectedVolume.getProject().getURI());
statObj.setVirtualPool(protectedVolume.getVirtualPool());
statObj.setTenant(protectedVolume.getTenant().getURI());
} else {
statObj.setProject(null);
statObj.setVirtualPool(null);
statObj.setTenant(null);
throw new SMIPluginException("Cassandra Database Insertion Error. Cannot identify Project/CoS/Tenant for ProtectionSystem", -1);
}
}
use of com.emc.storageos.plugins.metering.smis.SMIPluginException in project coprhd-controller by CoprHD.
the class ConnectionManagerUtils method disallowReaping.
public void disallowReaping(Object profile, Object client) throws BaseCollectionException {
AccessProfile accessProfile = (AccessProfile) profile;
DbClient dbClient = (DbClient) client;
try {
final CIMConnectionFactory connectionFactory = (CIMConnectionFactory) accessProfile.getCimConnectionFactory();
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
connectionFactory.setKeepAliveForConnection(storageSystem);
} catch (final IllegalStateException ex) {
log.error("Not able to get CIMOM Client instance for ip {} due to ", accessProfile.getIpAddress(), ex);
throw new SMIPluginException(SMIPluginException.ERRORCODE_NO_WBEMCLIENT, ex.fillInStackTrace(), ex.getMessage());
}
}
use of com.emc.storageos.plugins.metering.smis.SMIPluginException in project coprhd-controller by CoprHD.
the class FirmwareProcessor method processResult.
/**
* {@inheritDoc}
*/
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
try {
String serialNumber = null;
@SuppressWarnings("unchecked") final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
_dbClient = (DbClient) keyMap.get(Constants.dbClient);
coordinator = (CoordinatorClient) keyMap.get(Constants.COORDINATOR_CLIENT);
AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
String delimiter = Constants.PATH_DELIMITER_REGEX;
if (Type.ibmxiv.name().equals(profile.getSystemType())) {
delimiter = Pattern.quote(Constants.COLON);
}
if (it.hasNext()) {
// e.g., IBM XIV InstanceID, IBMTSDS:IBM.2810-7825363
CIMInstance firmwareInstance = it.next();
serialNumber = firmwareInstance.getPropertyValue(INSTANCEID).toString().split(delimiter)[1];
String nativeGuid = NativeGUIDGenerator.generateNativeGuid(profile.getSystemType(), serialNumber);
List<StorageSystem> systems = CustomQueryUtility.getActiveStorageSystemByNativeGuid(_dbClient, nativeGuid);
if (!systems.isEmpty()) {
StorageSystem system = systems.get(0);
checkFirmwareVersion(firmwareInstance, system);
}
} else {
String errMsg = String.format("No information obtained from Provider %s for Firmware version", profile.getIpAddress());
throw new SMIPluginException(errMsg, SMIPluginException.ERRORCODE_OPERATIONFAILED);
}
} catch (SMIPluginException e) {
throw e;
} catch (Exception e) {
String errMsg = String.format("An error occurred while verifying Firmware version: %s", e.getMessage());
throw new SMIPluginException(SMIPluginException.ERRORCODE_OPERATIONFAILED, e, errMsg);
}
}
use of com.emc.storageos.plugins.metering.smis.SMIPluginException in project coprhd-controller by CoprHD.
the class SoftwareIdentityProcessor method processResult.
/**
* {@inheritDoc}
*/
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
AccessProfile profile = null;
try {
_dbClient = (DbClient) keyMap.get(Constants.dbClient);
coordinator = (CoordinatorClient) keyMap.get(Constants.COORDINATOR_CLIENT);
profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
@SuppressWarnings("unchecked") final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
if (it.hasNext()) {
CIMInstance softwareInstance = it.next();
String providerId = profile.getIpAddress() + "-" + profile.getProviderPort();
List<StorageProvider> providers = CustomQueryUtility.getActiveStorageProvidersByProviderId(_dbClient, providerId);
if (!providers.isEmpty()) {
checkProviderVersion(softwareInstance, providers.get(0));
}
} else {
String errMsg = String.format("No information obtained from Provider %s for Provider version", profile.getIpAddress());
throw new SMIPluginException(errMsg, SMIPluginException.ERRORCODE_OPERATIONFAILED);
}
} catch (SMIPluginException e) {
throw e;
} catch (Exception e) {
String errMsg = String.format("An error occurred while verifying Provider version: %s", e.getMessage());
throw new SMIPluginException(SMIPluginException.ERRORCODE_OPERATIONFAILED, e, errMsg);
}
}
Aggregations