use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.
the class XIVSmisStorageDevice method doFindHostHLUs.
/**
* {@inheritDoc}
*/
@Override
public Map<URI, List<Integer>> doFindHostHLUs(StorageSystem storage, Collection<URI> initiatorURIs) throws DeviceControllerException {
Map<URI, List<Integer>> initiatorToHLUMap = new HashMap<URI, List<Integer>>();
for (URI initiatorURI : initiatorURIs) {
List<Integer> initiatorHLUs = new ArrayList<Integer>();
initiatorToHLUMap.put(initiatorURI, initiatorHLUs);
Initiator initiator = _dbClient.queryObject(Initiator.class, initiatorURI);
final String normalizedPortName = Initiator.normalizePort(initiator.getInitiatorPort());
CloseableIterator<CIMInstance> scsiPCInstances = null;
CloseableIterator<CIMInstance> pcforseunitInstances = null;
try {
String query = String.format("Select * From %s Where ElementName=\"%s\"", IBMSmisConstants.CP_STORAGE_HARDWARE_ID, normalizedPortName);
CIMObjectPath pcHwdIDPath = CimObjectPathCreator.createInstance(IBMSmisConstants.CP_STORAGE_HARDWARE_ID, Constants.IBM_NAMESPACE, null);
List<CIMInstance> hwidInstances = _helper.executeQuery(storage, pcHwdIDPath, query, "WQL");
if (null != hwidInstances && !hwidInstances.isEmpty()) {
CIMObjectPath hwidObjectPath = hwidInstances.get(0).getObjectPath();
scsiPCInstances = _helper.getAssociatorInstances(storage, hwidObjectPath, null, IBMSmisConstants.CP_SCSI_PROTOCOL_CONTROLLER, IBMSmisConstants.CP_COLLECTION, IBMSmisConstants.CP_MEMBER, SmisConstants.PS_ELEMENT_NAME);
while (null != scsiPCInstances && scsiPCInstances.hasNext()) {
CIMInstance scsiPCInstance = scsiPCInstances.next();
CIMObjectPath scsiPCObjectPath = scsiPCInstance.getObjectPath();
pcforseunitInstances = _helper.getReferenceInstances(storage, scsiPCObjectPath, IBMSmisConstants.CP_PROTOCOLCONTROLLER_FOR_SEUNIT, null, new String[] { IBMSmisConstants.DEVICE_NUMBER });
while (null != pcforseunitInstances && pcforseunitInstances.hasNext()) {
CIMInstance instance = pcforseunitInstances.next();
final String deviceNumber = CIMPropertyFactory.getPropertyValue(instance, IBMSmisConstants.DEVICE_NUMBER);
if (null != deviceNumber && !deviceNumber.isEmpty()) {
initiatorHLUs.add(Integer.parseInt(deviceNumber));
}
}
_log.info("HLU list for Initiator Port {} : {}", normalizedPortName, initiatorHLUs);
}
}
} catch (WBEMException e) {
DeviceControllerException.exceptions.smis.hluRetrievalFailed("Error occured during retrieval of HLUs for a Host", e);
} finally {
if (scsiPCInstances != null) {
scsiPCInstances.close();
}
if (pcforseunitInstances != null) {
pcforseunitInstances.close();
}
}
}
return initiatorToHLUMap;
}
use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.
the class XIVSmisStorageDevice method doExpandVolume.
/*
* (non-Javadoc)
*
* @see com.emc.storageos.volumecontroller.BlockStorageDevice#doExpandVolume
* (com.emc.storageos.db.client.model.StorageSystem,
* com.emc.storageos.db.client.model.StoragePool,
* com.emc.storageos.db.client.model.Volume, java.lang.Long,
* com.emc.storageos.volumecontroller.TaskCompleter)
*/
@Override
public void doExpandVolume(final StorageSystem storageSystem, final StoragePool pool, final Volume volume, final Long size, final TaskCompleter taskCompleter) throws DeviceControllerException {
_log.info(String.format("Expand Volume Start - Array: %s, Pool: %s, Volume: %s, New size: %d", storageSystem.getLabel(), pool.getNativeId(), volume.getLabel(), size));
try {
CIMObjectPath configSvcPath = _cimPath.getConfigSvcPath(storageSystem);
CIMArgument[] inArgs = _helper.getExpandVolumeInputArguments(storageSystem, volume, size);
CIMArgument[] outArgs = new CIMArgument[5];
_helper.invokeMethod(storageSystem, configSvcPath, SmisConstants.CREATE_OR_MODIFY_ELEMENT_FROM_STORAGE_POOL, inArgs, outArgs);
_smisStorageDevicePostProcessor.processVolumeExpansion(storageSystem, pool.getId(), volume.getId(), outArgs);
taskCompleter.ready(_dbClient);
} catch (WBEMException e) {
_log.error("Problem making SMI-S call: ", e);
ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
taskCompleter.error(_dbClient, error);
} catch (Exception e) {
_log.error("Problem in doExpandVolume: ", e);
ServiceError error = DeviceControllerErrors.smis.methodFailed("doExpandVolume", e.getMessage());
taskCompleter.error(_dbClient, error);
}
_log.info(String.format("Expand Volume End - Array: %s, Pool: %s, Volume: %s", storageSystem.getLabel(), pool.getNativeId(), volume.getLabel()));
}
use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.
the class XIVSmisStorageDevicePostProcessor method processVolume.
/*
* (non-Javadoc) Processes a newly created volume.
*
* @param volumePath The CIM object path for the volume.
*
* @param nativeID The native volume identifier.
*
* @param volumeId The Bourne volume id.
*
* @param client The CIM client.
*
* @param logMsgBuilder Holds a log message.
*
* @param creationTime Holds the date-time for the volume creation
*
* @throws java.io.IOException When an error occurs querying the database.
*
* @throws DatabaseException
*/
private void processVolume(CIMObjectPath volumePath, String nativeID, Volume volume, WBEMClient client, StringBuilder logMsgBuilder, Calendar creationTime) throws DatabaseException {
CIMInstance volumeInstance = null;
try {
volume.setCreationTime(creationTime);
volume.setNativeId(nativeID);
volume.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(_dbClient, volume));
volumeInstance = client.getInstance(volumePath, true, false, null);
if (volumeInstance != null) {
String wwn = CIMPropertyFactory.getPropertyValue(volumeInstance, IBMSmisConstants.CP_NAME);
volume.setAlternateName(wwn);
volume.setWWN(wwn.toUpperCase());
String elementName = CIMPropertyFactory.getPropertyValue(volumeInstance, IBMSmisConstants.CP_ELEMENT_NAME);
// should have already been set outside controller, just to make
// sure there is no mismatch
volume.setLabel(elementName);
volume.setDeviceLabel(elementName);
volume.setProvisionedCapacity(getProvisionedCapacityInformation(volumeInstance));
volume.setAllocatedCapacity(getAllocatedCapacityInformation(client, volumeInstance));
volume.setInactive(false);
} else {
volume.setInactive(true);
}
} catch (IOException e) {
_log.error("Caught an exception while trying to update volume attributes", e);
} catch (WBEMException e) {
_log.error("Caught an exception while trying to update volume attributes", e);
}
if (logMsgBuilder.length() != 0) {
logMsgBuilder.append("\n");
}
logMsgBuilder.append(String.format("Created volume successfully .. NativeId: %s", nativeID));
}
use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.
the class XIVSnapshotOperations method restoreSingleVolumeSnapshot.
/**
* Implementation for restoring of a single volume snapshot restore. That
* is, this volume is independent of other volumes and a snapshot was taken
* previously, and now we want to restore that snap to the original volume.
*
* @param storage
* [required] - StorageSystem object representing the array
* @param volume
* [required] - Volume URI for the volume to be restored
* @param snapshot
* [required] - BlockSnapshot URI representing the previously
* created snap for the volume
* @param taskCompleter
* - TaskCompleter object used for the updating operation status.
*/
@Override
public void restoreSingleVolumeSnapshot(StorageSystem storage, URI volume, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
BlockSnapshot from = _dbClient.queryObject(BlockSnapshot.class, snapshot);
Volume to = _dbClient.queryObject(Volume.class, volume);
CIMObjectPath syncObjectPath = _cimPath.getSyncObject(storage, from);
if (_helper.checkExists(storage, syncObjectPath, false, false) != null) {
_log.info("Volume {} is not thinly provisioned, will attempt restore", to.getLabel());
_helper.callModifyReplica(storage, _helper.getRestoreFromSnapshotInputArguments(syncObjectPath));
taskCompleter.ready(_dbClient);
} else {
ServiceError error = DeviceControllerErrors.smis.unableToFindSynchPath(storage.getLabel());
taskCompleter.error(_dbClient, error);
}
} catch (WBEMException e) {
String message = String.format("Error encountered when trying to restore from snapshot %s on array %s", snapshot.toString(), storage.getLabel());
_log.error(message, e);
ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
taskCompleter.error(_dbClient, error);
} catch (Exception e) {
String message = String.format("Generic exception when trying to restore from snapshot %s on array %s", snapshot.toString(), storage.getLabel());
_log.error(message, e);
ServiceError error = DeviceControllerErrors.smis.methodFailed("restoreSingleVolumeSnapshot", e.getMessage());
taskCompleter.error(_dbClient, error);
}
}
use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.
the class AbstractExportMaskValidator method getHardwareResources.
private Set<String> getHardwareResources() {
Set<String> hardware = Sets.newHashSet();
CloseableIterator<CIMInstance> associatedResources = null;
try {
CIMObjectPath maskingViewPath = getMaskingView();
String[] prop = new String[] { getAssociatorProperty() };
associatedResources = getHelper().getAssociatorInstances(storage, maskingViewPath, null, getAssociatorClass(), null, null, prop);
while (associatedResources.hasNext()) {
CIMInstance cimInstance = associatedResources.next();
String assocProperty = CIMPropertyFactory.getPropertyValue(cimInstance, getAssociatorProperty());
hardware.add(assocProperty);
}
} catch (WBEMException wbeme) {
log.error("SMI-S failure", wbeme);
} finally {
if (associatedResources != null) {
try {
associatedResources.close();
} catch (Exception e) {
// ignore
}
}
}
Function<? super String, String> hardwareTransformer = getHardwareTransformer();
Collection<String> result = hardware;
if (hardwareTransformer != null) {
result = transform(hardware, getHardwareTransformer());
}
return Sets.newHashSet(result);
}
Aggregations