use of com.emc.storageos.vnxe.models.VNXeCommandJob in project coprhd-controller by CoprHD.
the class VNXUnitySnapshotOperations method createSingleVolumeSnapshot.
@Override
public void createSingleVolumeSnapshot(StorageSystem storage, URI snapshot, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
if (readOnly) {
snapshotObj.setIsReadOnly(readOnly);
_dbClient.updateObject(snapshotObj);
}
Volume volume = _dbClient.queryObject(Volume.class, snapshotObj.getParent());
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
String tenantName = tenant.getLabel();
String snapLabelToUse = _nameGenerator.generate(tenantName, snapshotObj.getLabel(), snapshot.toString(), '-', SmisConstants.MAX_SNAPSHOT_NAME_LENGTH);
VNXeApiClient apiClient = getVnxeClient(storage);
VNXeCommandJob job = apiClient.createSnap(volume.getNativeId(), snapLabelToUse, readOnly);
if (job != null) {
ControllerServiceImpl.enqueueJob(new QueueJob(new VNXeBlockSnapshotCreateJob(job.getId(), storage.getId(), !createInactive, taskCompleter)));
}
} catch (Exception ex) {
log.error("Create volume snapshot got the exception", ex);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateVolumeSnapshot", ex.getMessage());
taskCompleter.error(_dbClient, error);
}
}
use of com.emc.storageos.vnxe.models.VNXeCommandJob in project coprhd-controller by CoprHD.
the class VNXUnitySnapshotOperations method restoreGroupSnapshots.
@Override
public void restoreGroupSnapshots(StorageSystem storage, URI volume, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
VNXeApiClient apiClient = getVnxeClient(storage);
Snap groupSnap = apiClient.getSnapshot(snapshotObj.getReplicationGroupInstance());
Snap snap = apiClient.getSnapshot(snapshotObj.getNativeId());
// Error out if the snapshot is attached
if (snap.isAttached()) {
log.error("Snapshot {})is exported and cannot be used for restore", snapshotObj.getLabel());
ServiceError error = DeviceControllerErrors.vnxe.cannotRestoreAttachedSnapshot(snapshotObj.getLabel());
taskCompleter.error(_dbClient, error);
}
VNXeCommandJob job = apiClient.restoreSnap(groupSnap.getId());
if (job != null) {
ControllerServiceImpl.enqueueJob(new QueueJob(new VNXUnityRestoreSnapshotJob(job.getId(), storage.getId(), taskCompleter)));
}
} catch (Exception ex) {
log.error("Restore group snapshot got the exception", ex);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("RestoreSnapshotJob", ex.getMessage());
taskCompleter.error(_dbClient, error);
}
}
use of com.emc.storageos.vnxe.models.VNXeCommandJob in project coprhd-controller by CoprHD.
the class VNXeApiClient method removeCifsShare.
/**
* Delete cifsShare
*
* @param cifsShareId
* cifsShare Id
* @param fsId
* file system Id
* @return VNXeCommandJob
*/
public VNXeCommandJob removeCifsShare(String cifsShareId, String fsId) {
VNXeCommandJob job = null;
_logger.info("deleting cifs share" + cifsShareId);
FileSystemRequest fsRequest = new FileSystemRequest(_khClient, fsId);
VNXeFileSystem fs = fsRequest.get();
if (fs == null) {
_logger.info("Could not find file system in the vxne");
throw VNXeException.exceptions.vnxeCommandFailed("Could not find file system in the vnxe for: " + fsId);
}
String resourceId = fs.getStorageResource().getId();
ModifyFileSystemParam modifyFSParm = new ModifyFileSystemParam();
// set cifsShare delete parm
CifsShareDeleteParam deleteParam = new CifsShareDeleteParam();
VNXeBase share = new VNXeBase();
share.setId(cifsShareId);
deleteParam.setCifsShare(share);
List<CifsShareDeleteParam> deleteList = new ArrayList<CifsShareDeleteParam>();
deleteList.add(deleteParam);
modifyFSParm.setCifsShareDelete(deleteList);
FileSystemActionRequest req = new FileSystemActionRequest(_khClient);
job = req.modifyFileSystemAsync(modifyFSParm, resourceId);
return job;
}
use of com.emc.storageos.vnxe.models.VNXeCommandJob in project coprhd-controller by CoprHD.
the class KHRequests method postRequestAsync.
public VNXeCommandJob postRequestAsync(ParamBase param) {
setAsyncMode();
ClientResponse response = postRequest(param);
VNXeCommandJob job;
String resString = response.getEntity(String.class);
ObjectMapper mapper = new ObjectMapper();
try {
job = mapper.readValue(resString, VNXeCommandJob.class);
} catch (JsonParseException e) {
_logger.error(String.format("unexpected data returned: %s from: %s", resString, _url), e);
throw VNXeException.exceptions.unexpectedDataError("unexpected data returned:" + resString, e);
} catch (JsonMappingException e) {
_logger.error(String.format("unexpected data returned: %s from: %s", resString, _url), e);
throw VNXeException.exceptions.unexpectedDataError("unexpected data returned:" + resString, e);
} catch (IOException e) {
_logger.error(String.format("unexpected data returned: %s from: %s", resString, _url), e);
throw VNXeException.exceptions.unexpectedDataError("unexpected data returned:" + resString, e);
}
if (job != null) {
_logger.info("submitted the job: " + job.getId());
} else {
_logger.warn("No job returned.");
}
return job;
}
use of com.emc.storageos.vnxe.models.VNXeCommandJob in project coprhd-controller by CoprHD.
the class KHRequests method deleteRequestAsync.
/*
* Send DELETE request to KittyHawk server in async mode
*
* @param resource webResource
*
* @param param parameters for delete
*
* @return VNXeCommandJob
*
* @throws VNXeException
*/
public VNXeCommandJob deleteRequestAsync(Object param) throws VNXeException {
_logger.debug("delete data: " + _url);
setAsyncMode();
ClientResponse response = deleteRequest(param);
VNXeCommandJob job;
String resString = response.getEntity(String.class);
ObjectMapper mapper = new ObjectMapper();
try {
job = mapper.readValue(resString, VNXeCommandJob.class);
} catch (JsonParseException e) {
_logger.error(String.format("unexpected data returned: %s from: %s ", resString, _url), e);
throw VNXeException.exceptions.unexpectedDataError(String.format("unexpected data returned: %s", resString), e);
} catch (JsonMappingException e) {
_logger.error(String.format("unexpected data returned: %s from: %s ", resString, _url), e);
throw VNXeException.exceptions.unexpectedDataError(String.format("unexpected data returned: %s", resString), e);
} catch (IOException e) {
_logger.error(String.format("unexpected data returned: %s from: %s ", resString, _url), e);
throw VNXeException.exceptions.unexpectedDataError(String.format("unexpected data returned: %s", resString), e);
}
if (job != null) {
_logger.info("submitted the deleting file system job: {} ", job.getId());
}
return job;
}
Aggregations