use of com.emc.storageos.volumecontroller.ControllerException in project coprhd-controller by CoprHD.
the class NetworkDeviceController method addSanZones.
@Override
public void addSanZones(URI uri, String fabricId, String fabricWwn, List<Zone> zones, boolean activateZones, String taskId) throws ControllerException {
NetworkSystem device = getNetworkSystemObject(uri);
// Lock to prevent concurrent operations on the same VSAN / FABRIC.
InterProcessLock fabricLock = NetworkFabricLocker.lockFabric(fabricId, _coordinator);
try {
// Get the file device reference for the type of file device managed
// by the controller.
NetworkSystemDevice networkDevice = getDevice(device.getSystemType());
if (networkDevice == null) {
throw NetworkDeviceControllerException.exceptions.addSanZonesFailedNull(device.getSystemType());
}
BiosCommandResult result = networkDevice.addZones(device, zones, fabricId, fabricWwn, activateZones);
setStatus(NetworkSystem.class, device.getId(), taskId, result.isCommandSuccess(), result.getServiceCoded());
_auditMgr.recordAuditLog(null, null, EVENT_SERVICE_TYPE, OperationTypeEnum.ADD_SAN_ZONE, System.currentTimeMillis(), AuditLogManager.AUDITLOG_SUCCESS, AuditLogManager.AUDITOP_END, device.getId().toString(), device.getLabel(), device.getPortNumber(), device.getUsername(), device.getSmisProviderIP(), device.getSmisPortNumber(), device.getSmisUserName(), device.getSmisUseSSL());
} catch (Exception ex) {
ServiceError serviceError = NetworkDeviceControllerException.errors.addSanZonesFailedExc(device.getSystemType(), ex);
_dbClient.error(NetworkSystem.class, device.getId(), taskId, serviceError);
} finally {
NetworkFabricLocker.unlockFabric(fabricId, fabricLock);
}
}
use of com.emc.storageos.volumecontroller.ControllerException in project coprhd-controller by CoprHD.
the class NetworkDeviceController method removeZone.
/**
* Remove a zone.
*
* @param volUri URI of the Volume
* @param fabricInfo NetworkFabricInfo generated by NetworkScheduler
* @return BiosCommandResult
*/
public BiosCommandResult removeZone(URI volUri, NetworkFCZoneInfo fabricInfo, boolean activateZones) throws ControllerException {
ServiceError serviceError = NetworkDeviceControllerException.errors.zoningFailedArgs(volUri.toString());
BiosCommandResult result = BiosCommandResult.createErrorResult(serviceError);
List<Zone> zones = new ArrayList<Zone>();
Zone zone = new Zone(fabricInfo.getZoneName());
zones.add(zone);
String taskId = UUID.randomUUID().toString();
for (String address : fabricInfo.getEndPoints()) {
ZoneMember member = new ZoneMember(address, ConnectivityMemberType.WWPN);
zone.getMembers().add(member);
}
// Lock to prevent concurrent operations on the same VSAN / FABRIC.
InterProcessLock fabricLock = NetworkFabricLocker.lockFabric(fabricInfo.getFabricId(), _coordinator);
try {
NetworkSystem device = getNetworkSystemObject(fabricInfo.getNetworkDeviceId());
// Get the file device reference for the type of file device managed
// by the controller.
NetworkSystemDevice networkDevice = getDevice(device.getSystemType());
if (networkDevice == null) {
throw NetworkDeviceControllerException.exceptions.removeZoneFailedNull(device.getSystemType());
}
if (fabricInfo.isLastReference() == true && !fabricInfo.isExistingZone()) {
result = networkDevice.removeZones(device, zones, fabricInfo.getFabricId(), fabricInfo.getFabricWwn(), activateZones);
} else {
// This is not the last reference, just mark our FCZoneReference for deletion
result = BiosCommandResult.createSuccessfulResult();
}
if (result.isCommandSuccess()) {
if (fabricInfo.getFcZoneReferenceId() != null) {
try {
// Mark our FcZoneReference object for removal
FCZoneReference reference = _dbClient.queryObject(FCZoneReference.class, fabricInfo.getFcZoneReferenceId());
if (reference != null) {
_dbClient.markForDeletion(reference);
recordZoneEvent(reference, OperationTypeEnum.REMOVE_SAN_ZONE.name(), OperationTypeEnum.REMOVE_SAN_ZONE.getDescription());
}
} catch (Exception ex) {
_log.error("Can't mark object for removal: " + fabricInfo.getFcZoneReferenceId());
}
}
}
if (!result.isCommandSuccess()) {
ServiceError svcError = NetworkDeviceControllerException.errors.removeZoneFailed(volUri.toString(), device.getSystemType());
setStatus(Volume.class, volUri, taskId, false, svcError);
} else {
setStatus(Volume.class, volUri, taskId, true, null);
}
} catch (ControllerException ex) {
_log.info("waiting for 2 min before retrying removeZone with alternate device");
try {
Thread.sleep(1000 * 120);
} catch (InterruptedException e) {
_log.warn("Thread sleep interrupted. Allowing to continue without sleep");
}
URI primaryUri = fabricInfo.getNetworkDeviceId();
URI altUri = fabricInfo.getAltNetworkDeviceId();
if (altUri != null && altUri != primaryUri) {
NetworkFabricLocker.unlockFabric(fabricInfo.getFabricId(), fabricLock);
fabricLock = null;
_log.error("Remove Zone failed using device: " + primaryUri + " retrying with alternate device: " + altUri);
fabricInfo.setNetworkDeviceId(altUri);
return removeZone(volUri, fabricInfo, activateZones);
} else {
ServiceError svcError = NetworkDeviceControllerException.errors.removeZoneFailedExc(volUri.toString());
setStatus(Volume.class, volUri, taskId, false, svcError);
throw ex;
}
} finally {
NetworkFabricLocker.unlockFabric(fabricInfo.getFabricId(), fabricLock);
}
return result;
}
use of com.emc.storageos.volumecontroller.ControllerException in project coprhd-controller by CoprHD.
the class BlockDeviceController method expandVolume.
@Override
public void expandVolume(URI storage, URI pool, URI volume, Long size, String opId) throws ControllerException {
try {
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
Volume volumeObj = _dbClient.queryObject(Volume.class, volume);
_log.info(String.format("expandVolume start - Array: %s Pool:%s Volume:%s, IsMetaVolume: %s, OldSize: %s, NewSize: %s", storage.toString(), pool.toString(), volume.toString(), volumeObj.getIsComposite(), volumeObj.getCapacity(), size));
StoragePool poolObj = _dbClient.queryObject(StoragePool.class, pool);
VolumeExpandCompleter completer = new VolumeExpandCompleter(volume, size, opId);
long metaMemberSize = volumeObj.getIsComposite() ? volumeObj.getMetaMemberSize() : volumeObj.getCapacity();
long metaCapacity = volumeObj.getIsComposite() ? volumeObj.getTotalMetaMemberCapacity() : volumeObj.getCapacity();
VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, volumeObj.getVirtualPool());
boolean isThinlyProvisioned = volumeObj.getThinlyProvisioned();
MetaVolumeRecommendation recommendation = MetaVolumeUtils.getExpandRecommendation(storageObj, poolObj, metaCapacity, size, metaMemberSize, isThinlyProvisioned, vpool.getFastExpansion());
if (recommendation.isCreateMetaVolumes()) {
// Also check that this is not recovery to clean dangling meta volumes with zero-capacity expansion.
if (recommendation.getMetaMemberCount() == 0 && (volumeObj.getMetaVolumeMembers() == null || volumeObj.getMetaVolumeMembers().isEmpty())) {
volumeObj.setCapacity(size);
_dbClient.updateObject(volumeObj);
_log.info(String.format("Expanded volume within its total meta volume capacity (simple case) - Array: %s Pool:%s Volume:%s, IsMetaVolume: %s, Total meta volume capacity: %s, NewSize: %s", storage.toString(), pool.toString(), volume.toString(), volumeObj.getIsComposite(), volumeObj.getTotalMetaMemberCapacity(), volumeObj.getCapacity()));
completer.ready(_dbClient);
} else {
// set meta related data in task completer
long metaMemberCount = volumeObj.getIsComposite() ? recommendation.getMetaMemberCount() + volumeObj.getMetaMemberCount() : recommendation.getMetaMemberCount() + 1;
completer.setMetaMemberSize(recommendation.getMetaMemberSize());
completer.setMetaMemberCount((int) metaMemberCount);
completer.setTotalMetaMembersSize(metaMemberCount * recommendation.getMetaMemberSize());
completer.setComposite(true);
completer.setMetaVolumeType(recommendation.getMetaVolumeType().toString());
getDevice(storageObj.getSystemType()).doExpandAsMetaVolume(storageObj, poolObj, volumeObj, size, recommendation, completer);
}
} else {
// expand as regular volume
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_080);
getDevice(storageObj.getSystemType()).doExpandVolume(storageObj, poolObj, volumeObj, size, completer);
}
_log.info(String.format("expandVolume end - Array: %s Pool:%s Volume:%s", storage.toString(), pool.toString(), volume.toString()));
} catch (Exception e) {
_log.error(String.format("expandVolume Failed - Array: %s Pool:%s Volume:%s", storage.toString(), pool.toString(), volume.toString()), e);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
List<URI> volumes = Arrays.asList(volume);
doFailTask(Volume.class, volumes, opId, serviceError);
WorkflowStepCompleter.stepFailed(opId, serviceError);
}
}
use of com.emc.storageos.volumecontroller.ControllerException in project coprhd-controller by CoprHD.
the class BlockDeviceController method createMirror.
/**
* {@inheritDoc} NOTE NOTE: The signature here MUST match the Workflow.Method createMirrorMethod just above (except
* opId).
*/
@Override
public void createMirror(URI storage, List<URI> mirrorList, Boolean isCG, Boolean createInactive, String opId) throws ControllerException {
TaskCompleter completer = null;
try {
WorkflowStepCompleter.stepExecuting(opId);
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
if (!isCG && mirrorList.size() == 1) {
completer = new BlockMirrorCreateCompleter(mirrorList.get(0), opId);
getDevice(storageObj.getSystemType()).doCreateMirror(storageObj, mirrorList.get(0), createInactive, completer);
} else {
boolean isListReplicaFlow = false;
BlockMirror mirrorObj = _dbClient.queryObject(BlockMirror.class, mirrorList.get(0));
Volume sourceVolume = _dbClient.queryObject(Volume.class, mirrorObj.getSource().getURI());
/**
* VPLEX/RP CG volumes may not be having back end Array Group.
* In this case we should create element replica using createListReplica.
* We should not use createGroup replica as backend cg will not be available in this case.
*/
isListReplicaFlow = isListReplicaFlow(sourceVolume);
completer = new BlockMirrorCreateCompleter(mirrorList, opId);
if (!isListReplicaFlow) {
getDevice(storageObj.getSystemType()).doCreateGroupMirrors(storageObj, mirrorList, createInactive, completer);
} else {
// List Replica
getDevice(storageObj.getSystemType()).doCreateListReplica(storageObj, mirrorList, createInactive, completer);
}
}
} catch (Exception e) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
if (completer != null) {
completer.error(_dbClient, serviceError);
}
WorkflowStepCompleter.stepFailed(opId, serviceError);
}
}
use of com.emc.storageos.volumecontroller.ControllerException in project coprhd-controller by CoprHD.
the class BlockDeviceController method establishVolumeSnapshotGroupRelation.
public void establishVolumeSnapshotGroupRelation(URI storage, URI sourceVolume, URI snapshot, String opId) throws ControllerException {
try {
WorkflowStepCompleter.stepExecuting(opId);
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
TaskCompleter completer = new BlockSnapshotEstablishGroupTaskCompleter(snapshot, opId);
getDevice(storageObj.getSystemType()).doEstablishVolumeSnapshotGroupRelation(storageObj, sourceVolume, snapshot, completer);
} catch (Exception e) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(opId, serviceError);
}
}
Aggregations