use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.
the class CephCloneOperations method createSingleClone.
@Override
public void createSingleClone(StorageSystem storageSystem, URI source, URI cloneVolume, Boolean createInactive, TaskCompleter taskCompleter) {
_log.info("START createSingleClone operation");
try (CephClient cephClient = getClient(storageSystem)) {
Volume cloneObject = _dbClient.queryObject(Volume.class, cloneVolume);
BlockObject sourceObject = BlockObject.fetch(_dbClient, source);
BlockSnapshot sourceSnapshot = null;
Volume parentVolume = null;
if (sourceObject instanceof BlockSnapshot) {
// Use source snapshot as clone source
sourceSnapshot = (BlockSnapshot) sourceObject;
parentVolume = _dbClient.queryObject(Volume.class, sourceSnapshot.getParent());
} else if (sourceObject instanceof Volume) {
// Use interim snapshot as clone source, since Ceph can clone snapshots only
// http://docs.ceph.com/docs/master/rbd/rbd-snapshot/#getting-started-with-layering
parentVolume = (Volume) sourceObject;
sourceSnapshot = prepareInternalSnapshotForVolume(parentVolume);
} else {
String msg = String.format("Unsupported block object type URI %s", source);
ServiceCoded code = DeviceControllerErrors.ceph.operationFailed("createSingleClone", msg);
taskCompleter.error(_dbClient, code);
return;
}
StoragePool pool = _dbClient.queryObject(StoragePool.class, parentVolume.getPool());
String poolId = pool.getPoolName();
String parentVolumeId = parentVolume.getNativeId();
String snapshotId = sourceSnapshot.getNativeId();
String cloneId = null;
try {
if (snapshotId == null || snapshotId.isEmpty()) {
// Create Ceph snapshot of volume requested to clone
snapshotId = CephUtils.createNativeId(sourceSnapshot);
cephClient.createSnap(poolId, parentVolumeId, snapshotId);
sourceSnapshot.setNativeId(snapshotId);
sourceSnapshot.setDeviceLabel(snapshotId);
sourceSnapshot.setIsSyncActive(true);
sourceSnapshot.setParent(new NamedURI(parentVolume.getId(), parentVolume.getLabel()));
_dbClient.updateObject(sourceSnapshot);
_log.info("Interim shapshot {} created for clone {}", sourceSnapshot.getId(), cloneObject.getId());
}
// Ceph requires cloning snapshot to be protected (from deleting)
if (!cephClient.snapIsProtected(poolId, parentVolumeId, snapshotId)) {
cephClient.protectSnap(poolId, parentVolumeId, snapshotId);
}
// Do cloning
String cloneVolumeId = CephUtils.createNativeId(cloneObject);
cephClient.cloneSnap(poolId, parentVolumeId, snapshotId, cloneVolumeId);
cloneId = cloneVolumeId;
// Update clone object
cloneObject.setDeviceLabel(cloneId);
cloneObject.setNativeId(cloneId);
cloneObject.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(_dbClient, cloneObject));
cloneObject.setProvisionedCapacity(parentVolume.getProvisionedCapacity());
cloneObject.setAllocatedCapacity(parentVolume.getAllocatedCapacity());
cloneObject.setAssociatedSourceVolume(sourceSnapshot.getId());
_dbClient.updateObject(cloneObject);
// Finish task
taskCompleter.ready(_dbClient);
} catch (Exception e) {
// Clean up created objects
cleanUpCloneObjects(cephClient, poolId, cloneId, snapshotId, parentVolumeId, sourceSnapshot);
throw e;
}
} catch (Exception e) {
BlockObject obj = BlockObject.fetch(_dbClient, cloneVolume);
if (obj != null) {
obj.setInactive(true);
_dbClient.updateObject(obj);
}
_log.error("Encountered an exception", e);
ServiceCoded code = DeviceControllerErrors.ceph.operationFailed("createSingleClone", e.getMessage());
taskCompleter.error(_dbClient, code);
}
}
use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.
the class CephStorageDevice method mapVolumes.
/**
* Map volumes to hosts on the hosts themselves.
*
* @param storage
* [in] - Storage System object
* @param volumeMap
* [in] - Volume URI to Integer LUN map
* @param initiators
* [in] - Collection of Initiator objects
* @param completer
* [in] - TaskCompleter
*/
private void mapVolumes(StorageSystem storage, Map<URI, Integer> volumeMap, Collection<Initiator> initiators, TaskCompleter completer) {
_log.info("mapVolumes: volumeMap: {}", volumeMap);
_log.info("mapVolumes: initiators: {}", initiators);
try {
for (Map.Entry<URI, Integer> volMapEntry : volumeMap.entrySet()) {
URI objectUri = volMapEntry.getKey();
BlockObject object = Volume.fetchExportMaskBlockObject(_dbClient, objectUri);
String monitorAddress = storage.getSmisProviderIP();
String monitorUser = storage.getSmisUserName();
String monitorKey = storage.getSmisPassword();
RBDMappingOptions rbdOptions = new RBDMappingOptions(object);
for (Initiator initiator : initiators) {
Host host = _dbClient.queryObject(Host.class, initiator.getHost());
if (initiator.getProtocol().equalsIgnoreCase(HostInterface.Protocol.RBD.name())) {
_log.info(String.format("mapVolume: host %s pool %s volume %s", host.getHostName(), rbdOptions.poolName, rbdOptions.volumeName));
LinuxSystemCLI linuxClient = getLinuxClient(host);
linuxClient.mapRBD(monitorAddress, monitorUser, monitorKey, rbdOptions.poolName, rbdOptions.volumeName, rbdOptions.snapshotName);
} else {
String msg = String.format("Unexpected initiator protocol %s, port %s, pool %s, volume %s", initiator.getProtocol(), initiator.getInitiatorPort(), rbdOptions.poolName, rbdOptions.volumeName);
ServiceCoded code = DeviceControllerErrors.ceph.operationFailed("mapVolumes", msg);
completer.error(_dbClient, code);
return;
}
}
}
completer.ready(_dbClient);
} catch (Exception e) {
_log.error("Encountered an exception", e);
ServiceCoded code = DeviceControllerErrors.ceph.operationFailed("mapVolumes", e.getMessage());
completer.error(_dbClient, code);
}
}
use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method updateStorageSystemFileProtectionPolicy.
@Override
public BiosCommandResult updateStorageSystemFileProtectionPolicy(StorageSystem storage, FileDeviceInputOutput args) {
FilePolicy existingPolicy = args.getFileProtectionPolicy();
PolicyStorageResource policyRes = args.getPolicyStorageResource();
FilePolicyUpdateParam policyUpdateParam = args.getFileProtectionPolicyUpdateParam();
IsilonApi isi = getIsilonDevice(storage);
BiosCommandResult result = null;
try {
if (existingPolicy.getFilePolicyType().equals(FilePolicy.FilePolicyType.file_replication.name())) {
boolean isVersion8above = false;
if (VersionChecker.verifyVersionDetails(ONEFS_V8, storage.getFirmwareVersion()) >= 0) {
isVersion8above = true;
}
return updateStorageSystemFileReplicationPolicy(isi, policyRes, existingPolicy, policyUpdateParam, isVersion8above);
} else if (existingPolicy.getFilePolicyType().equals(FilePolicy.FilePolicyType.file_snapshot.name())) {
return updateStorageSystemFileSnapshotPolicy(isi, policyRes, existingPolicy, policyUpdateParam);
} else {
String errorMsg = "Invalid policy type {} " + existingPolicy.getFilePolicyType();
_log.error(errorMsg);
final ServiceCoded serviceCoded = DeviceControllerException.errors.jobFailedOpMsg(OperationTypeEnum.UPDATE_STORAGE_SYSTEM_POLICY_BY_POLICY_RESOURCE.toString(), errorMsg);
result = BiosCommandResult.createErrorResult(serviceCoded);
existingPolicy.getOpStatus().updateTaskStatus(args.getOpId(), result.toOperation());
return result;
}
} catch (IsilonException e) {
_log.error("Update storage system policy for file policy failed.", e);
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method updateNfsACLs.
@Override
public BiosCommandResult updateNfsACLs(StorageSystem storage, FileDeviceInputOutput args) {
try {
// read nameToSid flag from controller config.
Boolean sidEnable = customConfigHandler.getComputedCustomConfigBooleanValue(CustomConfigConstants.ISILON_USER_TO_SID_MAPPING_FOR_NFS_ENABLED, storage.getSystemType(), null);
// get sid mapping based on Controller config and it belong to VirtualNAS.
if (sidEnable && args.getvNAS() != null) {
updateSidInfoForNfsACE(args, storage);
}
IsilonNFSACL isilonAcl = new IsilonNFSACL();
ArrayList<Acl> aclCompleteList = new ArrayList<Acl>();
List<NfsACE> aceToAdd = args.getNfsAclsToAdd();
for (NfsACE nfsACE : aceToAdd) {
Acl acl = getIsilonAclFromNfsACE(nfsACE);
acl.setOp("add");
aclCompleteList.add(acl);
}
List<NfsACE> aceToModify = args.getNfsAclsToModify();
for (NfsACE nfsACE : aceToModify) {
Acl acl = getIsilonAclFromNfsACE(nfsACE);
acl.setOp("replace");
aclCompleteList.add(acl);
}
List<NfsACE> aceToDelete = args.getNfsAclsToDelete();
for (NfsACE nfsACE : aceToDelete) {
Acl acl = getIsilonAclFromNfsACE(nfsACE);
acl.setOp("delete");
aclCompleteList.add(acl);
}
isilonAcl.setAction("update");
isilonAcl.setAuthoritative("acl");
isilonAcl.setAcl(aclCompleteList);
String path = args.getFileSystemPath();
if (args.getSubDirectory() != null && !args.getSubDirectory().isEmpty()) {
path = path + "/" + args.getSubDirectory();
}
// Process new ACLs
IsilonApi isi = getIsilonDevice(storage);
_log.info("Calling Isilon API: modify NFS Acl for {}, acl {}", args.getFileSystemPath(), isilonAcl);
isi.modifyNFSACL(path, isilonAcl);
_log.info("End updateNfsACLs");
BiosCommandResult result = BiosCommandResult.createSuccessfulResult();
return result;
} catch (IsilonException e) {
_log.error("updateNfsACLs failed ", e);
return BiosCommandResult.createErrorResult(e);
} catch (Exception e) {
_log.error("updateNfsACLs failed ", e);
final ServiceCoded serviceCoded = DeviceControllerException.errors.jobFailedOpMsg(OperationTypeEnum.UPDATE_FILE_SYSTEM_NFS_ACL.toString(), e.getMessage());
return BiosCommandResult.createErrorResult(serviceCoded);
}
}
use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.
the class ScaleIOCloneOperations method createGroupClone.
@Override
public void createGroupClone(StorageSystem storage, List<URI> cloneList, Boolean createInactive, TaskCompleter taskCompleter) {
try {
ScaleIORestClient scaleIOHandle = scaleIOHandleFactory.using(dbClient).getClientHandle(storage);
List<Volume> clones = dbClient.queryObject(Volume.class, cloneList);
Map<String, String> parent2snap = new HashMap<>();
Set<URI> poolsToUpdate = new HashSet<>();
for (Volume clone : clones) {
Volume parent = dbClient.queryObject(Volume.class, clone.getAssociatedSourceVolume());
parent2snap.put(parent.getNativeId(), clone.getLabel());
poolsToUpdate.add(parent.getPool());
}
String systemId = scaleIOHandle.getSystemId();
ScaleIOSnapshotVolumeResponse result = scaleIOHandle.snapshotMultiVolume(parent2snap, systemId);
List<String> nativeIds = result.getVolumeIdList();
Map<String, ScaleIOVolume> cloneNameMap = scaleIOHandle.getVolumeNameMap(nativeIds);
Multimap<URI, String> poolToVolumesMap = ArrayListMultimap.create();
for (Volume clone : clones) {
String name = clone.getLabel();
ScaleIOVolume sioVolume = cloneNameMap.get(name);
ScaleIOHelper.updateSnapshotWithSnapshotVolumeResult(dbClient, clone, systemId, sioVolume.getId(), storage);
clone.setAllocatedCapacity(Long.parseLong(sioVolume.getSizeInKb()) * 1024L);
clone.setProvisionedCapacity(clone.getAllocatedCapacity());
clone.setCapacity(clone.getAllocatedCapacity());
clone.setReplicationGroupInstance(result.getSnapshotGroupId());
poolToVolumesMap.put(clone.getPool(), clone.getId().toString());
}
dbClient.updateObject(clones);
List<StoragePool> pools = dbClient.queryObject(StoragePool.class, Lists.newArrayList(poolsToUpdate));
for (StoragePool pool : pools) {
pool.removeReservedCapacityForVolumes(poolToVolumesMap.get(pool.getId()));
ScaleIOHelper.updateStoragePoolCapacity(dbClient, scaleIOHandle, pool, storage);
}
taskCompleter.ready(dbClient);
} catch (Exception e) {
log.error("Encountered an exception", e);
ServiceCoded code = DeviceControllerErrors.scaleio.encounteredAnExceptionFromScaleIOOperation("createGroupClone", e.getMessage());
taskCompleter.error(dbClient, code);
}
}
Aggregations