use of javax.cim.UnsignedInteger32 in project coprhd-controller by CoprHD.
the class ExportProcessor method processResult.
/*
* (non-Javadoc)
*
* @see com.emc.storageos.plugins.common.Processor#processResult(com.emc.storageos.plugins.common.domainmodel.Operation,
* java.lang.Object, java.util.Map)
*/
@SuppressWarnings("unchecked")
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
initialize(operation, resultObj, keyMap);
CloseableIterator<CIMInstance> it = null;
EnumerateResponse<CIMInstance> response = null;
List<Initiator> matchedInitiators = new ArrayList<Initiator>();
List<StoragePort> matchedPorts = new ArrayList<StoragePort>();
WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
StringSet knownIniSet = new StringSet();
StringSet knownNetworkIdSet = new StringSet();
StringSet knownPortSet = new StringSet();
StringSet knownVolumeSet = new StringSet();
try {
// set lun masking view CIM path
CIMObjectPath path = this.getObjectPathfromCIMArgument(_args, keyMap);
UnManagedExportMask mask = this.getUnManagedExportMask(path);
mask.setMaskingViewPath(path.toString());
_logger.info("looking at lun masking view: " + path.toString());
CIMInstance lunMaskingView = client.getInstance(path, false, false, null);
if (lunMaskingView != null) {
String maskName = CIMPropertyFactory.getPropertyValue(lunMaskingView, SmisConstants.CP_NAME);
if (maskName != null) {
mask.setMaskName(maskName);
}
_logger.info("set UnManagedExportMask maskName to " + mask.getMaskName());
} else {
_logger.info("lunMaskingView was null");
}
CIMProperty<String> deviceIdProperty = (CIMProperty<String>) path.getKey(SmisConstants.CP_DEVICE_ID);
if (deviceIdProperty != null) {
mask.setNativeId(deviceIdProperty.getValue());
}
_logger.info("set UnManagedExportMask nativeId to " + mask.getNativeId());
// set storage system id
URI systemId = (URI) keyMap.get(Constants.SYSTEMID);
mask.setStorageSystemUri(systemId);
response = (EnumerateResponse<CIMInstance>) resultObj;
processVolumesAndInitiatorsPaths(response.getResponses(), mask, matchedInitiators, matchedPorts, knownIniSet, knownNetworkIdSet, knownPortSet, knownVolumeSet);
while (!response.isEnd()) {
_logger.info("Processing next Chunk");
response = client.getInstancesWithPath(Constants.MASKING_PATH, response.getContext(), new UnsignedInteger32(BATCH_SIZE));
processVolumesAndInitiatorsPaths(response.getResponses(), mask, matchedInitiators, matchedPorts, knownIniSet, knownNetworkIdSet, knownPortSet, knownVolumeSet);
}
// CTRL - 8918 - always update the mask with new initiators and volumes.
mask.replaceNewWithOldResources(knownIniSet, knownNetworkIdSet, knownVolumeSet, knownPortSet);
// get zones and store them?
updateZoningMap(mask, matchedInitiators, matchedPorts);
updateVplexBackendVolumes(mask, matchedInitiators);
updateRecoverPointVolumes(mask, matchedInitiators);
} catch (Exception e) {
_logger.error("something failed", e);
} finally {
if (it != null) {
it.close();
}
wrapUp();
if (response != null) {
try {
client.closeEnumeration(Constants.MASKING_PATH, response.getContext());
} catch (Exception e) {
_logger.debug("Exception occurred while closing enumeration", e);
}
}
}
}
use of javax.cim.UnsignedInteger32 in project coprhd-controller by CoprHD.
the class VmaxMirrorOperations method detachGroupMirrors.
@Override
public void detachGroupMirrors(StorageSystem storage, List<URI> mirrorList, Boolean deleteGroup, TaskCompleter taskCompleter) throws DeviceControllerException {
_log.info("START detach group mirror operation");
if (!storage.getUsingSmis80()) {
throw DeviceControllerException.exceptions.blockDeviceOperationNotSupported();
}
try {
callEMCRefreshIfRequired(_dbClient, _helper, storage, mirrorList);
CIMObjectPath groupSynchronized = ReplicationUtils.getMirrorGroupSynchronizedPath(storage, mirrorList.get(0), _dbClient, _helper, _cimPath);
if (_helper.checkExists(storage, groupSynchronized, false, false) != null) {
CIMArgument[] detachCGMirrorInput = _helper.getDetachSynchronizationInputArguments(groupSynchronized);
// Invoke method to detach local mirrors
UnsignedInteger32 result = (UnsignedInteger32) _helper.callModifyReplica(storage, detachCGMirrorInput, new CIMArgument[5]);
if (JOB_COMPLETED_NO_ERROR.equals(result)) {
List<BlockMirror> mirrors = _dbClient.queryObject(BlockMirror.class, mirrorList);
if (deleteGroup) {
ReplicationUtils.deleteReplicationGroup(storage, mirrors.get(0).getReplicationGroupInstance(), _dbClient, _helper, _cimPath);
}
// Set mirrors replication group to null
for (BlockMirror mirror : mirrors) {
if (deleteGroup) {
mirror.setConsistencyGroup(NullColumnValueGetter.getNullURI());
mirror.setReplicationGroupInstance(NullColumnValueGetter.getNullStr());
}
mirror.setSyncState(NullColumnValueGetter.getNullStr());
}
_dbClient.persistObject(mirrors);
taskCompleter.ready(_dbClient);
} else {
String msg = String.format("SMI-S call returned unsuccessfully: %s", result);
taskCompleter.error(_dbClient, DeviceControllerException.errors.smis.jobFailed(msg));
}
} else {
_log.error("Unable to find group synchronized {}", groupSynchronized.toString());
BlockMirror mirror = _dbClient.queryObject(BlockMirror.class, mirrorList.get(0));
ServiceError error = DeviceControllerErrors.smis.unableToFindSynchPath(mirror.getReplicationGroupInstance());
taskCompleter.error(_dbClient, error);
}
} catch (Exception e) {
_log.error("Problem making SMI-S call: ", e);
ServiceError error = DeviceControllerException.errors.jobFailed(e);
taskCompleter.error(_dbClient, error);
}
}
use of javax.cim.UnsignedInteger32 in project coprhd-controller by CoprHD.
the class XIVSmisStorageDevicePostProcessor method processVolumeDeletion.
/**
* Update DB with SMI-S output, also set task completer status.
*/
public List<Volume> processVolumeDeletion(StorageSystem storageSystem, List<Volume> volumes, CIMArgument[] outArgs, MultiVolumeTaskCompleter multiVolumeTaskCompleter) throws Exception {
CimConnection connection = _cimConnection.getConnection(storageSystem);
WBEMClient client = connection.getCimClient();
List<Volume> volumesToProcess = new ArrayList<Volume>();
for (Volume vol : volumes) {
Volume volume = _dbClient.queryObject(Volume.class, vol.getId());
volumesToProcess.add(volume);
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, volume.getPool());
updateStoragePoolCapacity(client, storagePool);
}
StringBuilder logMsgBuilder = new StringBuilder();
UnsignedInteger32[] returnCoedes = (UnsignedInteger32[]) _cimPath.getFromOutputArgs(outArgs, IBMSmisConstants.CP_RETURN_CODES);
List<Volume> volumesToSave = new ArrayList<Volume>(returnCoedes.length);
for (int i = 0; i < returnCoedes.length; i++) {
Volume volume = volumesToProcess.get(i);
VolumeTaskCompleter deleteTaskCompleter = multiVolumeTaskCompleter.skipTaskCompleter(volume.getId());
if (returnCoedes[i].longValue() == 0L) {
volume.setInactive(true);
volume.setConsistencyGroup(NullColumnValueGetter.getNullURI());
_dbClient.updateAndReindexObject(volume);
deleteTaskCompleter.ready(_dbClient);
if (logMsgBuilder.length() != 0) {
logMsgBuilder.append("\n");
}
logMsgBuilder.append(String.format("Successfully deleted volume %s", volume.getId()));
} else {
// cannot delete volume
String errorMessage = String.format("Failed to delete volume: %s , nativeId: %s with return code: %s", volume.getId(), volume.getNativeId(), returnCoedes[i].toString());
ServiceError error = DeviceControllerErrors.smis.methodFailed("doDeleteVolume", errorMessage);
deleteTaskCompleter.error(_dbClient, error);
if (logMsgBuilder.length() != 0) {
logMsgBuilder.append("\n");
}
logMsgBuilder.append(errorMessage);
}
}
if (logMsgBuilder.length() > 0) {
_log.info(logMsgBuilder.toString());
}
return volumesToSave;
}
use of javax.cim.UnsignedInteger32 in project coprhd-controller by CoprHD.
the class XIVSmisStorageDevicePostProcessor method processVolumeExpansion.
/**
* Update DB with SMI-S output.
*/
public void processVolumeExpansion(StorageSystem storageSystem, URI storagePoolURI, URI volumeId, CIMArgument[] outArgs) throws Exception {
StringBuilder logMsgBuilder = new StringBuilder(String.format("Processing volume expansion - "));
CimConnection connection = _cimConnection.getConnection(storageSystem);
WBEMClient client = connection.getCimClient();
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolURI);
StringMap reservationMap = storagePool.getReservedCapacityMap();
reservationMap.remove(volumeId.toString());
updateStoragePoolCapacity(client, storagePool);
_dbClient.persistObject(storagePool);
Volume volume = _dbClient.queryObject(Volume.class, volumeId);
CIMObjectPath volumePath = (CIMObjectPath) _cimPath.getFromOutputArgs(outArgs, IBMSmisConstants.CP_THE_ELEMENT);
boolean isSuccess = false;
if (volumePath != null) {
CIMInstance volumeInstance = client.getInstance(volumePath, true, false, null);
if (volumeInstance != null) {
isSuccess = true;
volume.setProvisionedCapacity(getProvisionedCapacityInformation(volumeInstance));
volume.setAllocatedCapacity(getAllocatedCapacityInformation(client, volumeInstance));
_dbClient.persistObject(volume);
logMsgBuilder.append(String.format("%n Capacity: %s, Provisioned capacity: %s, Allocated Capacity: %s", volume.getCapacity(), volume.getProvisionedCapacity(), volume.getAllocatedCapacity()));
}
}
if (!isSuccess) {
UnsignedInteger32 returnCoede = (UnsignedInteger32) _cimPath.getFromOutputArgs(outArgs, IBMSmisConstants.CP_RETURN_CODE);
logMsgBuilder.append("\n");
logMsgBuilder.append(String.format("Failed to expand volume: %s with return code: %s", volume.getId(), returnCoede.toString()));
}
_log.info(logMsgBuilder.toString());
}
use of javax.cim.UnsignedInteger32 in project coprhd-controller by CoprHD.
the class SmisCommandHelper method callRefreshSystem.
/**
* FIXME
* This method is a temporary alternative to the one below and
* removes the initial waiting time (~3 minutes) before refreshing.
*
* The wait time is deemed unnecessary because the Provider will attempt
* to consolidate its sync requests.
*
* Still, there appears to be a requirement for waiting an arbitrary amount of
* time *after* the refresh call in order for subsequent associator calls to
* get correct data.
*
* @param storage
* @return
* @throws WBEMException
*/
public Object callRefreshSystem(StorageSystem storage) throws WBEMException {
Object result = null;
String lockKey = String.format("callRefreshSystem-%s", storage.getId().toString());
try {
if (_locker.acquireLock(lockKey, MAX_REFRESH_LOCK_WAIT_TIME)) {
CIMObjectPath seSystemRegistrationSvc = getRegistrationService(storage);
UnsignedInteger32[] syncType = new UnsignedInteger32[] { new UnsignedInteger32(REPLICATION_DATA_SYNC_TYPE), new UnsignedInteger32(DEVICES_SYNC_TYPE), new UnsignedInteger32(MASKING_SYNC_TYPE) };
CIMObjectPath[] systems = new CIMObjectPath[] { _cimPath.getStorageSystem(storage) };
CIMArgument[] refreshArgs = new CIMArgument[] { _cimArgument.uint32Array(CP_SYNC_TYPE, syncType), _cimArgument.referenceArray(CP_SYSTEMS, systems) };
CIMArgument[] outArgs = new CIMArgument[5];
result = invokeMethod(storage, seSystemRegistrationSvc, EMC_REFRESH_SYSTEM, refreshArgs, outArgs);
long currentMillis = Calendar.getInstance().getTimeInMillis();
storage.setLastRefresh(currentMillis);
_dbClient.updateObject(storage);
_log.info(String.format("Did EMCRefresh against StorageSystem %s. " + "Last refresh set to %d", storage.getNativeGuid(), currentMillis));
}
} finally {
_locker.releaseLock(lockKey);
}
return result;
}
Aggregations