use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.
the class VmaxSnapshotOperations method isTargetOrGroupCopyMode.
/**
* Determines if the target or target group represented by the passed synchronization object path
* is linked to the snapshot session in "copy" mode.
*
* @param system A reference to the storage system.
* @param syncObjPath The synchronization object path.
*
* @return true if the target is linked in "copy" mode, false otherwise.
*
* @throws Exception When an exception occurs getting the CIM_StorageSynchronized instance representing the linked target
*/
private boolean isTargetOrGroupCopyMode(StorageSystem system, CIMObjectPath syncObjPath) throws Exception {
boolean isCopyMode = false;
String[] props = new String[] { SmisConstants.CP_SYNC_TYPE };
CIMInstance syncObj = _helper.getInstance(system, syncObjPath, false, false, props);
String syncType = syncObj.getProperty(SmisConstants.CP_SYNC_TYPE).getValue().toString();
if (String.valueOf(SYNC_TYPE.CLONE.getValue()).equals(syncType)) {
isCopyMode = true;
}
return isCopyMode;
}
use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.
the class VmaxSnapshotOperations method createSingleVolumeSnapshot.
/**
* Should implement creation of a single volume snapshot. That is a volume that
* is not in any consistency group.
*
* @param storage [required] - StorageSystem object representing the array
* @param snapshot [required] - BlockSnapshot URI representing the previously created
* snap for the volume
* @param createInactive - whether the snapshot needs to to be created with sync_active=true/false
* @param readOnly - Indicates if the snapshot should be read only.
* @param taskCompleter - TaskCompleter object used for the updating operation status.
*/
@Override
public void createSingleVolumeSnapshot(StorageSystem storage, URI snapshot, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
// List of target device ids
List<String> targetDeviceIds = null;
try {
BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
_log.info("createSingleVolumeSnapshot operation START");
Volume volume = _dbClient.queryObject(Volume.class, snapshotObj.getParent());
// Need to terminate an restore sessions, so that we can
// restore from the same snapshot multiple times
terminateAnyRestoreSessionsForVolume(storage, volume, taskCompleter);
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
String tenantName = tenant.getLabel();
String snapLabelToUse = _nameGenerator.generate(tenantName, snapshotObj.getLabel(), snapshot.toString(), '-', storage.getUsingSmis80() ? SmisConstants.MAX_SMI80_SNAPSHOT_NAME_LENGTH : SmisConstants.MAX_SNAPSHOT_NAME_LENGTH);
CIMObjectPath replicationSvcPath = _cimPath.getControllerReplicationSvcPath(storage);
CIMArgument[] inArgs = null;
CIMArgument[] outArgs = new CIMArgument[5];
if (storage.checkIfVmax3()) {
CIMObjectPath volumeGroupPath = _helper.getVolumeGroupPath(storage, storage, volume, null);
// COP-17240: For VMAX3, we will derive the target volumes from the source volumes SRP Pool
CIMObjectPath poolPath = _helper.getVolumeStoragePoolPath(storage, volume);
targetDeviceIds = createTargetDevices(storage, poolPath, volumeGroupPath, null, "SingleSnapshot", snapLabelToUse, createInactive, 1, volume.getCapacity(), taskCompleter);
CIMInstance replicaSettingData = _helper.getReplicationSettingData(storage, targetDeviceIds.get(0), false);
inArgs = _helper.getCreateElementReplicaSnapInputArgumentsWithTargetAndSetting(storage, volume, targetDeviceIds.get(0), replicaSettingData, createInactive, snapLabelToUse);
} else {
if (volume.getThinlyProvisioned()) {
CIMInstance replicationSetting = ReplicationUtils.getVPSnapReplicationSetting(storage, _helper, _cimPath);
inArgs = _helper.getCreateElementReplicaVPSnapInputArguments(storage, volume, createInactive, snapLabelToUse, replicationSetting);
} else {
inArgs = _helper.getCreateElementReplicaSnapInputArguments(storage, volume, createInactive, snapLabelToUse);
}
}
_helper.invokeMethod(storage, replicationSvcPath, SmisConstants.CREATE_ELEMENT_REPLICA, inArgs, outArgs);
CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
if (job != null) {
ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockCreateSnapshotJob(job, storage.getId(), !createInactive, taskCompleter)));
}
} catch (Exception e) {
_log.info("Problem making SMI-S call: ", e);
ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
taskCompleter.error(_dbClient, error);
setInactive(snapshot, true);
// Roll back changes
if (storage.checkIfVmax3()) {
rollbackCreateSnapshot(storage, null, targetDeviceIds, taskCompleter);
}
}
}
use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.
the class VnxExportOperations method getExportMaskHLUs.
@Override
public Map<URI, Integer> getExportMaskHLUs(StorageSystem storage, ExportMask exportMask) {
Map<URI, Integer> hlus = Collections.emptyMap();
try {
CIMInstance instance = _helper.getLunMaskingProtocolController(storage, exportMask);
// There's a StorageGroup on the array for the ExportMask and it has userAddedVolumes.
if (instance != null && exportMask.getUserAddedVolumes() != null) {
hlus = new HashMap<>();
WBEMClient client = _helper.getConnection(storage).getCimClient();
// Get the volume WWN to HLU mapping from the StorageGroup
Map<String, Integer> discoveredVolumes = _helper.getVolumesFromLunMaskingInstance(client, instance);
for (String wwn : discoveredVolumes.keySet()) {
Integer hlu = discoveredVolumes.get(wwn);
if (hlu != null && exportMask.getUserAddedVolumes().containsKey(wwn)) {
// Look up the volume URI given the WWN
String uriString = exportMask.getUserAddedVolumes().get(wwn);
// We have a proper HLU
hlus.put(URI.create(uriString), hlu);
}
}
}
_log.info(String.format("Retrieved these volumes from ExportMask %s (%s): %s", exportMask.getMaskName(), exportMask.getId(), CommonTransformerFunctions.collectionString(hlus.entrySet())));
} catch (Exception e) {
// Log an error, but return an empty list
_log.error(String.format("Encountered an exception when attempting to get volume to HLU mapping from ExportMask %s", exportMask.getMaskName()), e);
// We encountered an exception, so let's not return partial data ...
if (!hlus.isEmpty()) {
hlus.clear();
}
}
return hlus;
}
use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.
the class VnxExportOperations method getEMCTargetEndpoints.
/**
* Looks up the targets that are associated with the initiator (if any).
*
* @param idMgmtSvcPath
* [in] - Clar_StorageHardwareIDManagementService CIMObjectPath
* @param storage
* [in] - StorageSystem object representing the array
* @param initiator
* [in] - CIMObjectPath representing initiator to lookup target endpoints (StoragePorts) for
* @return List or StoragePort URIs that were found to be end points for the initiator
* @throws Exception
*/
private List<String> getEMCTargetEndpoints(CIMObjectPath idMgmtSvcPath, StorageSystem storage, CIMObjectPath initiator) throws Exception {
List<String> endpoints = new ArrayList<>();
try {
CIMArgument[] input = _helper.getEMCGetConnectedTargetEndpoints(initiator);
CIMArgument[] output = new CIMArgument[5];
_helper.invokeMethod(storage, idMgmtSvcPath, SmisConstants.EMC_GET_TARGET_ENDPOINTS, input, output);
CIMObjectPath[] tePaths = (CIMObjectPath[]) _cimPath.getFromOutputArgs(output, SmisConstants.CP_TARGET_ENDPOINTS);
if (tePaths != null) {
for (CIMObjectPath tePath : tePaths) {
CIMInstance teInstance = _helper.getInstance(storage, tePath, false, false, SmisConstants.PS_NAME);
String tePortNetworkId = CIMPropertyFactory.getPropertyValue(teInstance, SmisConstants.CP_NAME);
List<StoragePort> storagePorts = CustomQueryUtility.queryActiveResourcesByAltId(_dbClient, StoragePort.class, "portNetworkId", WWNUtility.getWWNWithColons(tePortNetworkId));
for (StoragePort port : storagePorts) {
endpoints.add(port.getNativeGuid());
}
}
}
_log.info(String.format("Initiator %s has these target endpoints: [ %s ]", initiator.toString(), Joiner.on(',').join(endpoints)));
} catch (WBEMException e) {
// The initiator CIMObjectPath passed into this function was determined by getting
// the associators to the StorageHardwareIDManagementService. When we call
// getEMCTargetEndpoints, it is done based on seeing that the initiator is in this
// associator list. Sometimes, the provider is returing initiator CIMObjectPaths
// that actually do not exist on the array. In this case, there will be WBEMException
// thrown when we try to get the targets storage ports using this CIMObject reference.
// So, here we're trying to protect against this possibility.
_log.info(String.format("Could not get TargetEndPoints for %s - %s", initiator, e.getMessage()));
}
return endpoints;
}
use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.
the class VnxExportOperations method modifyClarPrivileges.
/**
* Method invokes the SMI-S operation to modify the initiator parameters such as type and failovermode.
*
* @param storage
* [in] - StorageSystem representing the array
* @param initiators
* [in] - An array Initiator objects, whose representation will
* be removed from the array.
* @throws Exception
*/
@SuppressWarnings("rawtypes")
public void modifyClarPrivileges(StorageSystem storage, List<Initiator> initiators) throws Exception {
if (initiators == null || initiators.isEmpty()) {
_log.debug("No initiators ...");
return;
}
_log.info("Start -- modifyClarPrivileges");
List<String> initiatorStrings = new ArrayList<String>();
final String RP_INITIATOR_PREFIX = "500124";
final int RP_INITIATOR_TYPE = 31;
final int RP_INITIATOR_FAILOVERMODE = 4;
final CIMProperty[] RP_CLAR_PRIVILIEGE_CIM_PROPERTY = new CIMProperty[] { new CIMProperty<UnsignedInteger16>(SmisConstants.CP_EMC_INITIATOR_TYPE, CIMDataType.UINT16_T, new UnsignedInteger16(RP_INITIATOR_TYPE)), new CIMProperty<UnsignedInteger16>(SmisConstants.CP_EMC_FAILOVER_MODE, CIMDataType.UINT16_T, new UnsignedInteger16(RP_INITIATOR_FAILOVERMODE)) };
CloseableIterator<CIMInstance> privilegeInstances = null;
for (Initiator initiator : initiators) {
if (initiator.getProtocol().equalsIgnoreCase(Initiator.Protocol.FC.name())) {
initiatorStrings.add(WwnUtils.convertWWN(initiator.getInitiatorNode(), FORMAT.NOMARKERS).toString().concat(WwnUtils.convertWWN(initiator.getInitiatorPort(), FORMAT.NOMARKERS).toString()));
}
}
if (initiatorStrings.isEmpty()) {
_log.info("There are no initiators in the list whose privileges need to be changed.");
return;
}
try {
privilegeInstances = _helper.getClarPrivileges(storage);
while (privilegeInstances.hasNext()) {
CIMInstance existingInstance = privilegeInstances.next();
String initiatorType = CIMPropertyFactory.getPropertyValue(existingInstance, SmisConstants.CP_EMC_INITIATOR_TYPE);
// We are only interested in the RP initiators, so check if the initiators are RP initiators
if (existingInstance.toString().contains(storage.getSerialNumber()) && existingInstance.toString().contains(RP_INITIATOR_PREFIX)) {
for (String initiatorString : initiatorStrings) {
if (existingInstance.toString().contains(initiatorString) && (initiatorType != null && Integer.parseInt(initiatorType) != RP_INITIATOR_TYPE)) {
CIMInstance toUpdate = new CIMInstance(existingInstance.getObjectPath(), RP_CLAR_PRIVILIEGE_CIM_PROPERTY);
_log.info("Modifying -- " + existingInstance.toString());
_helper.modifyInstance(storage, toUpdate, SmisConstants.PS_EMC_CLAR_PRIVILEGE);
break;
}
}
}
}
_log.info("end -- modifyClarPrivileges");
} catch (Exception e1) {
_log.error("Unexpected error: modifyClarPrivileges failed");
throw e1;
} finally {
if (null != privilegeInstances) {
privilegeInstances.close();
}
}
}
Aggregations