use of javax.wbem.client.WBEMClient in project coprhd-controller by CoprHD.
the class VmaxExportOperations method refreshExportMask.
@Override
public ExportMask refreshExportMask(StorageSystem storage, ExportMask mask) throws DeviceControllerException {
long startTime = System.currentTimeMillis();
try {
CIMInstance instance = _helper.getSymmLunMaskingView(storage, mask);
if (instance != null) {
StringBuilder builder = new StringBuilder();
WBEMClient client = _helper.getConnection(storage).getCimClient();
String name = CIMPropertyFactory.getPropertyValue(instance, SmisConstants.CP_ELEMENT_NAME);
// Get volumes and initiators for the masking instance
Map<String, Integer> discoveredVolumes = _helper.getVolumesFromLunMaskingInstance(client, instance);
List<String> discoveredPorts = _helper.getInitiatorsFromLunMaskingInstance(client, instance);
Set existingInitiators = (mask.getExistingInitiators() != null) ? mask.getExistingInitiators() : Collections.emptySet();
Set existingVolumes = (mask.getExistingVolumes() != null) ? mask.getExistingVolumes().keySet() : Collections.emptySet();
builder.append(String.format("%nXM existing objects: %s I{%s} V:{%s}%n", name, Joiner.on(',').join(existingInitiators), Joiner.on(',').join(existingVolumes)));
builder.append(String.format("XM discovered: %s I:{%s} V:{%s}%n", name, Joiner.on(',').join(discoveredPorts), Joiner.on(',').join(discoveredVolumes.keySet())));
List<String> initiatorsToAddToExisting = new ArrayList<String>();
List<Initiator> initiatorsToAddToUserAddedAndInitiatorList = new ArrayList<Initiator>();
/**
* For the newly discovered initiators, if they are ViPR discovered ports and belong to same resource
* add them to user added and initiators list, otherwise add to existing list.
*/
for (String port : discoveredPorts) {
String normalizedPort = Initiator.normalizePort(port);
if (!mask.hasExistingInitiator(normalizedPort) && !mask.hasUserInitiator(normalizedPort)) {
Initiator existingInitiator = ExportUtils.getInitiator(Initiator.toPortNetworkId(port), _dbClient);
// Don't add additional initiator to initiators list if it belongs to different host/cluster
if (existingInitiator != null && !ExportMaskUtils.checkIfDifferentResource(mask, existingInitiator)) {
_log.info("Initiator {}->{} belonging to same compute, adding to userAdded and initiator list.", normalizedPort, existingInitiator.getId());
initiatorsToAddToUserAddedAndInitiatorList.add(existingInitiator);
} else {
initiatorsToAddToExisting.add(normalizedPort);
}
}
}
/**
* Get the existing initiators from the mask and remove the non-discovered ports because
* they are not discovered and are stale.
*
* If the mask has existing initiators but if they are discovered and belongs to same compute resource, then the
* initiators has to get added to user Added and initiators list, and removed from existing list.
*/
List<String> initiatorsToRemoveFromExistingList = new ArrayList<String>();
if (mask.getExistingInitiators() != null && !mask.getExistingInitiators().isEmpty()) {
for (String existingInitiatorStr : mask.getExistingInitiators()) {
if (!discoveredPorts.contains(existingInitiatorStr)) {
initiatorsToRemoveFromExistingList.add(existingInitiatorStr);
} else {
Initiator existingInitiator = ExportUtils.getInitiator(Initiator.toPortNetworkId(existingInitiatorStr), _dbClient);
if (existingInitiator != null && !ExportMaskUtils.checkIfDifferentResource(mask, existingInitiator)) {
_log.info("Initiator {}->{} belonging to same compute, removing from existing," + " and adding to userAdded and initiator list", existingInitiatorStr, existingInitiator.getId());
initiatorsToAddToUserAddedAndInitiatorList.add(existingInitiator);
initiatorsToRemoveFromExistingList.add(existingInitiatorStr);
}
}
}
}
/**
* Get all the initiators from the mask and remove all the ViPR discovered ports.
* The remaining list has to be removed from user Added and initiator list, because they are not available in ViPR
* but has to be moved to existing list.
*/
List<URI> initiatorsToRemoveFromUserAddedAndInitiatorList = new ArrayList<URI>();
if (mask.getInitiators() != null && !mask.getInitiators().isEmpty()) {
initiatorsToRemoveFromUserAddedAndInitiatorList.addAll(transform(mask.getInitiators(), CommonTransformerFunctions.FCTN_STRING_TO_URI));
for (String port : discoveredPorts) {
String normalizedPort = Initiator.normalizePort(port);
Initiator initiatorDiscoveredInViPR = ExportUtils.getInitiator(Initiator.toPortNetworkId(port), _dbClient);
if (initiatorDiscoveredInViPR != null) {
initiatorsToRemoveFromUserAddedAndInitiatorList.remove(initiatorDiscoveredInViPR.getId());
} else if (!mask.hasExistingInitiator(normalizedPort)) {
_log.info("Initiator {} not found in database, removing from user Added and initiator list," + " and adding to existing list.", port);
initiatorsToAddToExisting.add(normalizedPort);
}
}
}
boolean removeInitiators = !initiatorsToRemoveFromExistingList.isEmpty() || !initiatorsToRemoveFromUserAddedAndInitiatorList.isEmpty();
boolean addInitiators = !initiatorsToAddToUserAddedAndInitiatorList.isEmpty() || !initiatorsToAddToExisting.isEmpty();
// Check the volumes and update the lists as necessary
Map<String, Integer> volumesToAdd = ExportMaskUtils.diffAndFindNewVolumes(mask, discoveredVolumes);
boolean addVolumes = !volumesToAdd.isEmpty();
boolean removeVolumes = false;
List<String> volumesToRemove = new ArrayList<String>();
// if the volume is in export mask's user added volumes and also in the existing volumes, remove from existing volumes
for (String wwn : discoveredVolumes.keySet()) {
if (mask.hasExistingVolume(wwn)) {
URIQueryResultList volumeList = new URIQueryResultList();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVolumeWwnConstraint(wwn), volumeList);
if (volumeList.iterator().hasNext()) {
URI volumeURI = volumeList.iterator().next();
if (mask.hasUserCreatedVolume(volumeURI)) {
builder.append(String.format("\texisting volumes contain wwn %s, but it is also in the " + "export mask's user added volumes, so removing from existing volumes", wwn));
volumesToRemove.add(wwn);
}
}
}
}
if (mask.getExistingVolumes() != null && !mask.getExistingVolumes().isEmpty()) {
volumesToRemove.addAll(mask.getExistingVolumes().keySet());
volumesToRemove.removeAll(discoveredVolumes.keySet());
removeVolumes = !volumesToRemove.isEmpty();
}
// Update user added volume's HLU information in ExportMask and ExportGroup
ExportMaskUtils.updateHLUsInExportMask(mask, discoveredVolumes, _dbClient);
// Grab the storage ports that have been allocated for this
// existing mask and update them.
List<String> storagePorts = _helper.getStoragePortsFromLunMaskingInstance(client, instance);
List<String> storagePortURIs = ExportUtils.storagePortNamesToURIs(_dbClient, storagePorts);
// Check the storagePorts and update the lists as necessary
boolean addStoragePorts = false;
List<String> storagePortsToAdd = new ArrayList<>();
if (mask.getStoragePorts() == null) {
mask.setStoragePorts(new ArrayList<String>());
}
for (String portID : storagePortURIs) {
if (!mask.getStoragePorts().contains(portID)) {
storagePortsToAdd.add(portID);
addStoragePorts = true;
}
}
boolean removeStoragePorts = false;
List<String> storagePortsToRemove = new ArrayList<String>();
if (mask.getStoragePorts() != null && !mask.getStoragePorts().isEmpty()) {
storagePortsToRemove.addAll(mask.getStoragePorts());
storagePortsToRemove.removeAll(storagePortURIs);
removeStoragePorts = !storagePortsToRemove.isEmpty();
}
builder.append(String.format("XM refresh: %s existing initiators; add:{%s} remove:{%s}%n", name, Joiner.on(',').join(initiatorsToAddToExisting), Joiner.on(',').join(initiatorsToRemoveFromExistingList)));
builder.append(String.format("XM refresh: %s user added and initiator list; add:{%s} remove:{%s}%n", name, Joiner.on(',').join(initiatorsToAddToUserAddedAndInitiatorList), Joiner.on(',').join(initiatorsToRemoveFromUserAddedAndInitiatorList)));
builder.append(String.format("XM refresh: %s volumes; add:{%s} remove:{%s}%n", name, Joiner.on(',').join(volumesToAdd.keySet()), Joiner.on(',').join(volumesToRemove)));
builder.append(String.format("XM refresh: %s ports; add:{%s} remove:{%s}%n", name, Joiner.on(',').join(storagePortsToAdd), Joiner.on(',').join(storagePortsToRemove)));
// Any changes indicated, then update the mask and persist it
if (addInitiators || removeInitiators || addVolumes || removeVolumes || addStoragePorts || removeStoragePorts) {
mask.removeFromExistingInitiators(initiatorsToRemoveFromExistingList);
if (!initiatorsToRemoveFromUserAddedAndInitiatorList.isEmpty()) {
mask.removeInitiatorURIs(initiatorsToRemoveFromUserAddedAndInitiatorList);
mask.removeFromUserAddedInitiatorsByURI(initiatorsToRemoveFromUserAddedAndInitiatorList);
}
// https://coprhd.atlassian.net/browse/COP-17224 - For those cases where InitiatorGroups are shared
// by
// MaskingViews, if CoprHD processes one ExportMask by updating it with new initiators, then it
// could
// affect another ExportMasks. Consider that this refreshExportMask is against that other
// ExportMask.
// We shouldn't read the initiators that we find as 'existing' (that is created outside of CoprHD),
// instead we should consider them userAdded for this ExportMask, as well.
List<Initiator> userAddedInitiators = ExportMaskUtils.findIfInitiatorsAreUserAddedInAnotherMask(mask, initiatorsToAddToUserAddedAndInitiatorList, _dbClient);
mask.addToUserCreatedInitiators(userAddedInitiators);
builder.append(String.format("XM refresh: %s user added initiators; add:{%s} remove:{%s}%n", name, Joiner.on(',').join(userAddedInitiators), Joiner.on(',').join(initiatorsToRemoveFromUserAddedAndInitiatorList)));
mask.addInitiators(initiatorsToAddToUserAddedAndInitiatorList);
mask.addToUserCreatedInitiators(initiatorsToAddToUserAddedAndInitiatorList);
mask.addToExistingInitiatorsIfAbsent(initiatorsToAddToExisting);
mask.removeFromExistingInitiators(initiatorsToRemoveFromExistingList);
mask.removeFromExistingVolumes(volumesToRemove);
mask.addToExistingVolumesIfAbsent(volumesToAdd);
mask.getStoragePorts().addAll(storagePortsToAdd);
mask.getStoragePorts().removeAll(storagePortsToRemove);
URI pgURI = mask.getPortGroup();
if (!NullColumnValueGetter.isNullURI(pgURI) && (!storagePortsToAdd.isEmpty() || !storagePortsToRemove.isEmpty())) {
StoragePortGroup portGroup = _dbClient.queryObject(StoragePortGroup.class, pgURI);
portGroup.getStoragePorts().addAll(storagePortsToAdd);
portGroup.getStoragePorts().removeAll(storagePortsToRemove);
_dbClient.updateObject(portGroup);
}
ExportMaskUtils.sanitizeExportMaskContainers(_dbClient, mask);
builder.append("XM refresh: There are changes to mask, " + "updating it...\n");
_dbClient.updateObject(mask);
} else {
builder.append("XM refresh: There are no changes to the mask\n");
}
_networkDeviceController.refreshZoningMap(mask, transform(initiatorsToRemoveFromUserAddedAndInitiatorList, CommonTransformerFunctions.FCTN_URI_TO_STRING), Collections.EMPTY_LIST, (addInitiators || removeInitiators), true);
_log.info(builder.toString());
}
} catch (Exception e) {
boolean throwException = true;
if (e instanceof WBEMException) {
WBEMException we = (WBEMException) e;
// Only throw exception if code is not CIM_ERROR_NOT_FOUND
throwException = (we.getID() != WBEMException.CIM_ERR_NOT_FOUND);
}
if (throwException) {
String msg = "Error when attempting to query LUN masking information: " + e.getMessage();
_log.error(MessageFormat.format("Encountered an SMIS error when attempting to refresh existing exports: {0}", msg), e);
throw SmisException.exceptions.refreshExistingMaskFailure(msg, e);
}
} finally {
long totalTime = System.currentTimeMillis() - startTime;
_log.info(String.format("refreshExportMask took %f seconds", (double) totalTime / (double) 1000));
}
return mask;
}
use of javax.wbem.client.WBEMClient in project coprhd-controller by CoprHD.
the class VmaxExportOperations method createOrSelectStorageGroup.
private CIMObjectPath createOrSelectStorageGroup(StorageSystem storage, URI exportMaskURI, Collection<Initiator> initiators, VolumeURIHLU[] volumeURIHLUs, String parentGroupName, Map<StorageGroupPolicyLimitsParam, CIMObjectPath> newlyCreatedChildVolumeGroups, TaskCompleter taskCompleter) throws Exception {
List<CIMObjectPath> childVolumeGroupsToBeAddedToParentGroup = new ArrayList<CIMObjectPath>();
String groupName = null;
CIMObjectPath groupPath = null;
ExportMask mask = _dbClient.queryObject(ExportMask.class, exportMaskURI);
// group volumes based on policy
ListMultimap<StorageGroupPolicyLimitsParam, VolumeURIHLU> policyToVolumeGroup = ArrayListMultimap.create();
WBEMClient client = _helper.getConnection(storage).getCimClient();
/**
* Group Volumes by Fast Policy and Host IO limit attributes
*
* policyToVolumeGroupEntry - this will essentially have multiple Groups
* E.g Group 1--> Fast Policy (FP1)+ FEBandwidth (100)
* Group 2--> Fast Policy (FP2)+ IOPS (100)
* Group 3--> FEBandwidth (100) + IOPS (100) ..
*
* For each Group {
* 1. Create a Storage Group.
* 2. Associate Fast Policy, bandwidth and IOPs ,based on the Group key.
*
* On failure ,remove the storage group, disassociate the added properties.
* }
*/
for (VolumeURIHLU volumeUriHLU : volumeURIHLUs) {
StorageGroupPolicyLimitsParam sgPolicyLimitsParam = null;
URI boUri = volumeUriHLU.getVolumeURI();
BlockObject bo = BlockObject.fetch(_dbClient, boUri);
boolean fastAssociatedAlready = false;
// Export fast volumes to 2 different nodes.
if (_helper.isFastPolicy(volumeUriHLU.getAutoTierPolicyName())) {
fastAssociatedAlready = _helper.checkVolumeAssociatedWithAnySGWithPolicy(bo.getNativeId(), storage, volumeUriHLU.getAutoTierPolicyName());
}
// should not be created with a FAST policy assigned.
if (fastAssociatedAlready || isRPJournalVolume(bo)) {
_log.info("Forcing policy name to NONE to prevent volume from using FAST policy.");
volumeUriHLU.setAutoTierPolicyName(Constants.NONE);
sgPolicyLimitsParam = new StorageGroupPolicyLimitsParam(Constants.NONE, volumeUriHLU.getHostIOLimitBandwidth(), volumeUriHLU.getHostIOLimitIOPs(), storage);
} else {
sgPolicyLimitsParam = new StorageGroupPolicyLimitsParam(volumeUriHLU, storage);
}
policyToVolumeGroup.put(sgPolicyLimitsParam, volumeUriHLU);
}
_log.info("{} Groups generated based on grouping volumes by fast policy", policyToVolumeGroup.size());
/**
* Grouped Volumes based on Fast Policy
*/
for (Entry<StorageGroupPolicyLimitsParam, Collection<VolumeURIHLU>> policyToVolumeGroupEntry : policyToVolumeGroup.asMap().entrySet()) {
List<CIMObjectPath> childVolumeGroupsToBeAdded = new ArrayList<CIMObjectPath>();
StorageGroupPolicyLimitsParam storageGroupPolicyLimitsParam = policyToVolumeGroupEntry.getKey();
ListMultimap<String, VolumeURIHLU> expectedVolumeHluMap = ControllerUtils.getVolumeNativeGuids(policyToVolumeGroupEntry.getValue(), _dbClient);
Map<String, Set<String>> existingGroupPaths;
// in case of non-fast always create a new Storage Group
if (!_helper.isFastPolicy(storageGroupPolicyLimitsParam.getAutoTierPolicyName())) {
_log.info("Non-FAST create a new Storage Group");
VolumeURIHLU[] volumeURIHLU = new VolumeURIHLU[policyToVolumeGroupEntry.getValue().size()];
volumeURIHLU = policyToVolumeGroupEntry.getValue().toArray(volumeURIHLU);
groupName = generateStorageGroupName(storage, mask, initiators, storageGroupPolicyLimitsParam);
_log.debug("Group Name Created {}", groupName);
groupPath = createVolumeGroup(storage, groupName, volumeURIHLU, taskCompleter, true);
_log.info("Volume Group {} created on Array", groupPath);
} else // in case of fast enabled, try to find any existing groups which can be reused.
{
/**
* Find any existing Storage Groups can be reused, in
* case of Fast Enabled volumes
*/
_log.info("Running Storage Group Selection Process");
existingGroupPaths = _helper.findAnyStorageGroupsCanBeReUsed(storage, expectedVolumeHluMap, storageGroupPolicyLimitsParam);
if (existingGroupPaths.size() > 0) {
_log.info("Existing Storage Groups Found :" + Joiner.on("\t").join(existingGroupPaths.keySet()));
} else {
_log.info("No existing Storage Groups Found for policy: " + storageGroupPolicyLimitsParam.toString());
}
if (existingGroupPaths.size() > 0) {
childVolumeGroupsToBeAdded.addAll(_helper.constructMaskingGroupPathsFromNames(existingGroupPaths.keySet(), storage));
}
Set<String> volumesInExistingStorageGroups = _helper.constructVolumeNativeGuids(existingGroupPaths.values());
_log.debug("Volumes part of existing reusable Storage Groups {}", Joiner.on("\t").join(volumesInExistingStorageGroups));
// Storage Group needs to be created for those volumes,
// which doesn't fit into
// existing groups.
Set<String> diff = Sets.difference(expectedVolumeHluMap.asMap().keySet(), volumesInExistingStorageGroups);
_log.debug("Remaining Volumes, for which new Storage Group needs to be created", Joiner.on("\t").join(diff));
// need to construct a new group for remaining volumes.
if (!diff.isEmpty()) {
VolumeURIHLU[] volumeURIHLU = ControllerUtils.constructVolumeUriHLUs(diff, expectedVolumeHluMap);
groupName = generateStorageGroupName(storage, mask, initiators, storageGroupPolicyLimitsParam);
_log.debug("Group Name Created :", groupName);
groupPath = createVolumeGroup(storage, groupName, volumeURIHLU, taskCompleter, true);
_log.info("Volume Group {} created on Array {}", groupName, storage.getSerialNumber());
}
}
if (null != groupPath) {
/**
* used later in deleting created groups on failure
*/
newlyCreatedChildVolumeGroups.put(storageGroupPolicyLimitsParam, groupPath);
childVolumeGroupsToBeAdded.add(groupPath);
}
/**
* check whether Storage Group is associated with Fast
* Policy, if not associate
*/
if (_helper.isFastPolicy(storageGroupPolicyLimitsParam.getAutoTierPolicyName())) {
for (CIMObjectPath path : childVolumeGroupsToBeAdded) {
// volumes).
if (!_helper.checkVolumeAssociatedWithPhantomSG(path, storage, storageGroupPolicyLimitsParam.getAutoTierPolicyName()) && !_helper.checkVolumeGroupAssociatedWithPolicy(storage, path, storageGroupPolicyLimitsParam.getAutoTierPolicyName())) {
_log.debug("Adding Volume Group {} to Fast Policy {}", path, storageGroupPolicyLimitsParam.getAutoTierPolicyName());
addVolumeGroupToAutoTieringPolicy(storage, storageGroupPolicyLimitsParam.getAutoTierPolicyName(), path, taskCompleter);
}
}
}
childVolumeGroupsToBeAddedToParentGroup.addAll(childVolumeGroupsToBeAdded);
}
// Avoid duplicate names for the Cascaded VolumeGroup
parentGroupName = _helper.generateGroupName(_helper.getExistingStorageGroupsFromArray(storage), parentGroupName);
CIMObjectPath cascadedGroupPath = createCascadedVolumeGroup(storage, parentGroupName, childVolumeGroupsToBeAddedToParentGroup, taskCompleter);
// for proper roll back , that is volume removal, if exception is thrown during update
for (Entry<StorageGroupPolicyLimitsParam, CIMObjectPath> createdChildVolumeGroupEntry : newlyCreatedChildVolumeGroups.entrySet()) {
CIMObjectPath childGroupPath = createdChildVolumeGroupEntry.getValue();
StorageGroupPolicyLimitsParam storageGroupPolicyLimitsParam = createdChildVolumeGroupEntry.getKey();
if (storageGroupPolicyLimitsParam.isHostIOLimitBandwidthSet()) {
_helper.updateHostIOLimitBandwidth(client, childGroupPath, storageGroupPolicyLimitsParam.getHostIOLimitBandwidth());
}
if (storageGroupPolicyLimitsParam.isHostIOLimitIOPsSet()) {
_helper.updateHostIOLimitIOPs(client, childGroupPath, storageGroupPolicyLimitsParam.getHostIOLimitIOPs());
}
}
return cascadedGroupPath;
}
use of javax.wbem.client.WBEMClient in project coprhd-controller by CoprHD.
the class VmaxExportOperations method findHLUsForInitiators.
@Override
public Set<Integer> findHLUsForInitiators(StorageSystem storage, List<String> initiatorNames, boolean mustHaveAllPorts) {
long startTime = System.currentTimeMillis();
Set<Integer> usedHLUs = new HashSet<Integer>();
CloseableIterator<CIMInstance> maskInstanceItr = null;
try {
// Get a mapping of the initiator port names to their CIMObjectPaths on the provider
WBEMClient client = _helper.getConnection(storage).getCimClient();
HashMap<String, CIMObjectPath> initiatorPathsMap = _cimPath.getInitiatorToInitiatorPath(storage, initiatorNames);
List<String> maskNames = new ArrayList<String>();
if (ExportUtils.isValidationEnabled()) {
findIfAnyIGHasConsistentLunFlagNotSet(storage, initiatorPathsMap.values());
}
// Iterate through each initiator port name ...
for (String initiatorName : initiatorPathsMap.keySet()) {
CIMObjectPath initiatorPath = initiatorPathsMap.get(initiatorName);
// Find out if there is a MaskingView associated with the initiator...
maskInstanceItr = _helper.getAssociatorInstances(storage, initiatorPath, null, SmisConstants.SYMM_LUN_MASKING_VIEW, null, null, SmisConstants.PS_LUN_MASKING_CNTRL_NAME_AND_ROLE);
while (maskInstanceItr.hasNext()) {
// Found a MaskingView...
CIMInstance instance = maskInstanceItr.next();
String systemName = CIMPropertyFactory.getPropertyValue(instance, SmisConstants.CP_SYSTEM_NAME);
if (!systemName.contains(storage.getSerialNumber())) {
// SMISProvider pointed to by 'storage' system.
continue;
}
String name = CIMPropertyFactory.getPropertyValue(instance, SmisConstants.CP_ELEMENT_NAME);
if (!maskNames.contains(name)) {
_log.info("Found matching mask {}", name);
maskNames.add(name);
// Find all the initiators associated with the MaskingView
List<String> initiatorPorts = _helper.getInitiatorsFromLunMaskingInstance(client, instance);
// Get volumes for the MaskingView
Map<String, Integer> volumeWWNs = _helper.getVolumesFromLunMaskingInstance(client, instance);
// add HLUs to set
usedHLUs.addAll(volumeWWNs.values());
_log.info(String.format("%nXM:%s I:{%s} V:{%s} HLU:{%s}%n", name, Joiner.on(',').join(initiatorPorts), Joiner.on(',').join(volumeWWNs.keySet()), volumeWWNs.values()));
}
}
}
_log.info(String.format("HLUs found for Initiators { %s }: %s", Joiner.on(',').join(initiatorNames), usedHLUs));
} catch (Exception e) {
String errMsg = "Encountered an SMIS error when attempting to query used HLUs for initiators: " + e.getMessage();
_log.error(errMsg, e);
throw SmisException.exceptions.hluRetrievalFailed(errMsg, e);
} finally {
if (maskInstanceItr != null) {
maskInstanceItr.close();
}
long totalTime = System.currentTimeMillis() - startTime;
_log.info(String.format("find used HLUs for Initiators took %f seconds", (double) totalTime / (double) 1000));
}
return usedHLUs;
}
use of javax.wbem.client.WBEMClient in project coprhd-controller by CoprHD.
the class SmisCommandHelper method setRecoverPointTagInternal.
/**
* Method will add or remove the EMCRecoverPointEnabled flag from the device masking group for
* VMAX.
*
* @param deviceGroupPath
* [in] - CIMObjectPath referencing the volume
*/
private boolean setRecoverPointTagInternal(StorageSystem storage, List<CIMObjectPath> volumeMemberList, boolean tag) throws Exception {
boolean tagSet = false;
try {
_log.info("Attempting to {} RecoverPoint tag on Volume: {}", tag ? "enable" : "disable", Joiner.on(",").join(volumeMemberList));
CimConnection connection = _cimConnection.getConnection(storage);
WBEMClient client = connection.getCimClient();
if (storage.getUsingSmis80()) {
CIMObjectPath configSvcPath = _cimPath.getConfigSvcPath(storage);
CIMArgument[] inArgs = getRecoverPointInputArguments(storage, volumeMemberList, tag);
CIMArgument[] outArgs = new CIMArgument[5];
SmisJob job = null;
invokeMethodSynchronously(storage, configSvcPath, EMC_SETUNSET_RECOVERPOINT, inArgs, outArgs, job);
} else {
for (CIMObjectPath volumeMember : volumeMemberList) {
CIMInstance toUpdate = new CIMInstance(volumeMember, new CIMProperty[] { _cimProperty.bool(EMC_RECOVERPOINT_ENABLED, tag) });
_log.debug("Params: " + toUpdate.toString());
client.modifyInstance(toUpdate, CP_EMC_RECOVERPOINT_ENABLED);
}
}
_log.info(String.format("RecoverPoint tag has been successfully %s Volume", tag ? "applied to" : "removed from"));
tagSet = true;
} catch (WBEMException e) {
if (e.getMessage().contains("is already set to the requested state")) {
_log.info("Found the volume was already in the proper RecoverPoint tag state");
tagSet = true;
} else {
_log.error(String.format("Encountered an error while trying to %s the RecoverPoint tag", tag ? "enable" : "disable"), e);
}
}
return tagSet;
}
use of javax.wbem.client.WBEMClient in project coprhd-controller by CoprHD.
the class CimSubscriptionManager method getInstance.
/**
* Gets the named instance from the CIMOM.
*
* @param className The CIM class name.
* @param name The CIM Name property value.
*
* @return The CIM instance or null
*
* @throws javax.wbem.WBEMException
*/
private CIMInstance getInstance(String className, String name) throws WBEMException {
CIMInstance instance = null;
WBEMClient cimClient = _connection.getCimClient();
String interopNS = _connection.getInteropNamespace();
CIMObjectPath path = CimObjectPathCreator.createInstance(className, interopNS);
CloseableIterator<CIMInstance> instanceIter = null;
CIMProperty<?> property;
try {
instanceIter = cimClient.enumerateInstances(path, true, true, false, null);
while (instanceIter.hasNext()) {
instance = instanceIter.next();
property = instance.getProperty(CimConstants.NAME_KEY);
if (property.getValue().toString().equals(name)) {
s_logger.debug("Found: {}", instance.getObjectPath());
break;
}
instance = null;
}
} finally {
if (instanceIter != null) {
instanceIter.close();
}
}
return instance;
}
Aggregations