use of javax.cim.CIMArgument 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.CIMArgument in project coprhd-controller by CoprHD.
the class VmaxSnapshotOperations method deleteTargetDeviceGroup.
/**
* Deletes a target group represented by the given target group path
*
* @param storage - StorageSystem where the target group is
* @param targetGroupPath - Path representing target group to be deleted
*
* @throws DeviceControllerException
*/
private void deleteTargetDeviceGroup(final StorageSystem storage, final CIMObjectPath targetGroupPath) {
_log.info(format("Removing target device group {0} from storage system {1}", targetGroupPath, storage.getId()));
try {
CIMObjectPath replicationSvc = _cimPath.getControllerReplicationSvcPath(storage);
CIMArgument[] outArgs = new CIMArgument[5];
CIMArgument[] inArgs = _helper.getDeleteReplicationGroupInputArguments(storage, targetGroupPath, true);
_helper.invokeMethod(storage, replicationSvc, DELETE_GROUP, inArgs, outArgs);
} catch (Exception e) {
_log.error(format("An error occurred when removing target device group {0} from storage system {1}", targetGroupPath, storage.getId()), e);
}
}
use of javax.cim.CIMArgument in project coprhd-controller by CoprHD.
the class VnxExportOperations method deleteStorageHWIDs.
/**
* Method invokes the SMI-S operation to remove the initiator hardware ID from the
* array. This should be called whenever the initiator is removed from an export or
* when the export is deleted.
*
* @param storage
* [in] - StorageSystem representing the array
* @param initiators
* [in] - An array Initiator objects, whose representation will
* be removed from the array.
* @throws Exception
*/
private void deleteStorageHWIDs(StorageSystem storage, List<Initiator> initiators) throws Exception {
if (initiators == null || initiators.isEmpty()) {
_log.debug("No initiators ...");
return;
}
CIMObjectPath hwIdManagementSvc = _cimPath.getStorageHardwareIDManagementService(storage);
for (Initiator initiator : initiators) {
try {
CIMArgument[] createHwIdIn = _helper.getDeleteStorageHardwareIDArgs(storage, initiator);
CIMArgument[] createHwIdOut = new CIMArgument[5];
_helper.invokeMethod(storage, hwIdManagementSvc, SmisConstants.DELETE_STORAGE_HARDWARE_ID, createHwIdIn, createHwIdOut);
} catch (WBEMException e) {
_log.error("deleteStorageHWIDs -- WBEMException: " + e.getMessage());
throw e;
} catch (Exception e) {
_log.error("deleteStorageHWIDs -- Exception: " + e.getMessage());
throw e;
}
}
}
use of javax.cim.CIMArgument 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.CIMArgument in project coprhd-controller by CoprHD.
the class VmaxSnapshotOperations method establishVolumeSnapshotGroupRelation.
@Override
public void establishVolumeSnapshotGroupRelation(StorageSystem storage, URI sourceVolume, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
_log.info("establishVolumeSnapshotGroupRelation operation START");
try {
/**
* get groupPath for source volume
* get groupPath for snapshot
* get snapshots belonging to the same Replication Group
* get Element synchronizations between volumes and snapshots
* call CreateGroupReplicaFromElementSynchronizations
*/
BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
Volume volumeObj = _dbClient.queryObject(Volume.class, sourceVolume);
CIMObjectPath srcRepSvcPath = _cimPath.getControllerReplicationSvcPath(storage);
String volumeGroupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(volumeObj, _dbClient);
CIMObjectPath volumeGroupPath = _cimPath.getReplicationGroupPath(storage, volumeGroupName);
CIMObjectPath snapshotGroupPath = _cimPath.getReplicationGroupPath(storage, snapshotObj.getReplicationGroupInstance());
// Check if snapshot is referenced by a BlockSnapshotSession
// if so, we must pass in the RelationshipName with the value of the session name.
// NB. a SourceGroup aspect must exist
List<BlockSnapshotSession> snapshotSessions = queryActiveResourcesByConstraint(_dbClient, BlockSnapshotSession.class, getLinkedTargetSnapshotSessionConstraint(snapshot));
String relationshipName = null;
if (!snapshotSessions.isEmpty()) {
relationshipName = snapshotSessions.get(0).getSessionLabel();
_log.info("Found snapshot session relationship: {}", relationshipName);
}
CIMObjectPath groupSynchronizedPath = _cimPath.getGroupSynchronized(volumeGroupPath, snapshotGroupPath);
CIMInstance syncInstance = _helper.checkExists(storage, groupSynchronizedPath, false, false);
if (syncInstance == null) {
// get all snapshots belonging to a Replication Group. There may be multiple snapshots available for a Volume
List<BlockSnapshot> snapshots = ControllerUtils.getSnapshotsPartOfReplicationGroup(snapshotObj, _dbClient);
List<CIMObjectPath> elementSynchronizations = new ArrayList<CIMObjectPath>();
for (BlockSnapshot snapshotObject : snapshots) {
Volume volume = _dbClient.queryObject(Volume.class, snapshotObject.getParent());
elementSynchronizations.add(_cimPath.getStorageSynchronized(storage, volume, storage, snapshotObject));
}
_log.info("Creating Group synchronization between volume group and snapshot group");
CIMArgument[] inArgs = _helper.getCreateGroupReplicaFromElementSynchronizationsForSRDFInputArguments(volumeGroupPath, snapshotGroupPath, elementSynchronizations, relationshipName);
CIMArgument[] outArgs = new CIMArgument[5];
_helper.invokeMethod(storage, srcRepSvcPath, SmisConstants.CREATE_GROUP_REPLICA_FROM_ELEMENT_SYNCHRONIZATIONS, inArgs, outArgs);
// No Job returned
} else {
_log.info("Link already established..");
}
taskCompleter.ready(_dbClient);
} catch (Exception e) {
String msg = String.format("Failed to establish group relation between volume group and snapshot group. Volume: %s, Snapshot: %s", sourceVolume, snapshot);
_log.error(msg, e);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
taskCompleter.error(_dbClient, serviceError);
}
}
Aggregations