use of com.emc.storageos.cimadapter.connections.cim.CimConnection in project coprhd-controller by CoprHD.
the class XIVSmisCommandHelper method validateStorageProviderConnection.
/*
* Validate connection
*/
public boolean validateStorageProviderConnection(String ipAddress, Integer portNumber) {
boolean isConnectionValid = false;
try {
CimConnection connection = _cimConnection.getConnection(ipAddress, portNumber.toString());
isConnectionValid = (connection != null && _cimConnection.checkConnectionliveness(connection));
} catch (IllegalStateException ise) {
_log.error(ise.getMessage());
}
return isConnectionValid;
}
use of com.emc.storageos.cimadapter.connections.cim.CimConnection in project coprhd-controller by CoprHD.
the class XIVSmisCommandHelper method getInstance.
/*
* Return CIM instance of the given object path.
*/
public CIMInstance getInstance(StorageSystem storage, CIMObjectPath objectPath, boolean propagated, boolean includeClassOrigin, String[] propertyList) throws Exception {
CimConnection connection = _cimConnection.getConnection(storage);
WBEMClient client = connection.getCimClient();
// CTRL-9069 workaround CIM_BAD_REQUEST error
CIMInstance instance = null;
int retryCount = 0;
while (true) {
try {
_log.info("Calling getInstance, attempt {}", retryCount);
instance = client.getInstance(objectPath, propagated, includeClassOrigin, propertyList);
} catch (WBEMException e) {
if (CIM_BAD_REQUEST.equals(e.getMessage())) {
if (retryCount < CIM_MAX_RETRY_COUNT) {
_log.warn("Encountered 'request-not-well-formed' error. Retry...");
retryCount++;
try {
Thread.sleep(CIM_RETRY_WAIT_INTERVAL);
} catch (InterruptedException ie) {
_log.warn("Thread: " + Thread.currentThread().getName() + " interrupted.");
throw e;
}
continue;
}
_log.warn("Exhausted {} retries", CIM_MAX_RETRY_COUNT);
}
// other WBEMException, or reach the max retry count
throw e;
}
// no exception
break;
}
return instance;
}
use of com.emc.storageos.cimadapter.connections.cim.CimConnection in project coprhd-controller by CoprHD.
the class XIVSmisStorageDevicePostProcessor method processVolumeCreation.
/*
* (non-Javadoc) Update DB with volume creation output from SMI-S.
*
* @see
* com.emc.storageos.volumecontroller.impl.smis.job.SmisAbstractCreateVolumeJob
* #updateStatus
*/
public Set<URI> processVolumeCreation(StorageSystem storageSystem, URI storagePoolURI, List<Volume> volumes, CIMArgument[] outArgs) throws Exception {
Set<URI> volumeURIs = new HashSet<URI>(volumes.size());
StringBuilder logMsgBuilder = new StringBuilder(String.format("Processing volume creation"));
CimConnection connection = _cimConnection.getConnection(storageSystem);
WBEMClient client = connection.getCimClient();
Calendar now = Calendar.getInstance();
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolURI);
updateStoragePoolCapacity(client, storagePool);
StringMap reservationMap = storagePool.getReservedCapacityMap();
for (Volume volume : volumes) {
reservationMap.remove(volume.getId().toString());
}
_dbClient.persistObject(storagePool);
CIMObjectPath[] elements = (CIMObjectPath[]) _cimPath.getFromOutputArgs(outArgs, IBMSmisConstants.CP_THE_ELEMENTS);
UnsignedInteger32[] returnCoedes = (UnsignedInteger32[]) _cimPath.getFromOutputArgs(outArgs, IBMSmisConstants.CP_RETURN_CODES);
List<Volume> volumesToSave = new ArrayList<Volume>(elements.length);
if (elements != null && returnCoedes != null) {
for (int i = 0; i < elements.length; i++) {
URI volumeId = volumes.get(i).getId();
Volume volume = _dbClient.queryObject(Volume.class, volumeId);
volumesToSave.add(volume);
volumeURIs.add(volumeId);
boolean isSuccess = false;
CIMObjectPath volumePath = elements[i];
if (volumePath != null) {
CIMProperty<String> deviceID = (CIMProperty<String>) volumePath.getKey(IBMSmisConstants.CP_DEVICE_ID);
if (deviceID != null) {
String nativeID = deviceID.getValue();
if ((nativeID != null) && (nativeID.length() != 0)) {
isSuccess = true;
volume.setPool(storagePoolURI);
processVolume(volumePath, nativeID, volume, client, logMsgBuilder, now);
}
}
}
if (!isSuccess) {
logMsgBuilder.append("\n");
logMsgBuilder.append(String.format("Failed to create volume: %s with return code: %s", volumeId, returnCoedes[i].toString()));
volume.setInactive(true);
}
}
}
if (!volumesToSave.isEmpty()) {
_dbClient.persistObject(volumesToSave);
}
_log.info(logMsgBuilder.toString());
return volumeURIs;
}
use of com.emc.storageos.cimadapter.connections.cim.CimConnection in project coprhd-controller by CoprHD.
the class XIVSmisStorageDevicePostProcessor method processCloneCreation.
@SuppressWarnings("rawtypes")
public void processCloneCreation(StorageSystem storageSystem, URI volumeURI, CIMArgument[] outArgs, CloneCreateCompleter taskCompleter) throws Exception {
StringBuilder logMsgBuilder = new StringBuilder(String.format("Processing clone creation - "));
CimConnection connection = _cimConnection.getConnection(storageSystem);
WBEMClient client = connection.getCimClient();
Volume cloneVolume = _dbClient.queryObject(Volume.class, volumeURI);
URI poolURI = cloneVolume.getPool();
StoragePool pool = _dbClient.queryObject(StoragePool.class, poolURI);
updateStoragePoolCapacity(client, pool);
StringMap reservationMap = pool.getReservedCapacityMap();
// remove from reservation map
reservationMap.remove(cloneVolume.getId().toString());
_dbClient.persistObject(pool);
CIMObjectPath cloneVolumePath = (CIMObjectPath) _cimPath.getFromOutputArgs(outArgs, IBMSmisConstants.CP_TARGET_ELEMENT);
if (cloneVolumePath != null) {
// Get the sync volume native device id
CIMInstance syncVolume = client.getInstance(cloneVolumePath, false, false, null);
String deviceID = cloneVolumePath.getKey(IBMSmisConstants.CP_DEVICE_ID).getValue().toString();
String elementName = CIMPropertyFactory.getPropertyValue(syncVolume, IBMSmisConstants.CP_ELEMENT_NAME);
String wwn = CIMPropertyFactory.getPropertyValue(syncVolume, IBMSmisConstants.CP_NAME);
cloneVolume.setNativeId(deviceID);
cloneVolume.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(_dbClient, cloneVolume));
cloneVolume.setLabel(elementName);
cloneVolume.setDeviceLabel(elementName);
cloneVolume.setInactive(false);
cloneVolume.setCreationTime(Calendar.getInstance());
cloneVolume.setWWN(wwn.toUpperCase());
cloneVolume.setAlternateName(wwn);
cloneVolume.setProvisionedCapacity(getProvisionedCapacityInformation(syncVolume));
cloneVolume.setAllocatedCapacity(getAllocatedCapacityInformation(client, syncVolume));
logMsgBuilder.append(String.format("For sync volume path %1$s, going to set blocksnapshot %2$s nativeId to %3$s.", cloneVolumePath.toString(), cloneVolume.getId().toString(), deviceID));
_dbClient.persistObject(cloneVolume);
taskCompleter.ready(_dbClient);
} else {
cloneVolume.setInactive(true);
_dbClient.persistObject(cloneVolume);
ServiceError error = DeviceControllerErrors.smis.unableToFindSynchPath(volumeURI.toString());
logMsgBuilder.append(error.getMessage());
_log.error(logMsgBuilder.toString());
throw new Exception(error.getMessage());
}
_log.info(logMsgBuilder.toString());
}
use of com.emc.storageos.cimadapter.connections.cim.CimConnection in project coprhd-controller by CoprHD.
the class CIMConnectionFactory method deleteStaleSubscriptions.
/**
* Deletes stale subscriptions
*
* @param smisProviderURI {@link String} SMIS Provider's URI for delete stale subscription
* @return boolean success flag. True means delete stale subscription for the given smisProvider is success, else returns false
*/
public boolean deleteStaleSubscriptions(String smisProviderURI) {
_log.debug("Entering {}", Thread.currentThread().getStackTrace()[1].getMethodName());
boolean isSuccess = false;
try {
_log.debug("smisProviderURI :{}", smisProviderURI);
CimConnection cimConnection = getSMISProviderConnection(smisProviderURI);
if (null != cimConnection) {
_connectionManager.deleteStaleSubscriptions(cimConnection);
isSuccess = true;
}
} catch (Exception e) {
_log.error("Delete stale subscription for the SMIS provider {} is failed", smisProviderURI);
_log.error(e.getMessage(), e);
// throw e;
}
_log.debug("Exiting {}", Thread.currentThread().getStackTrace()[1].getMethodName());
return isSuccess;
}
Aggregations