use of com.emc.storageos.vnxe.VNXeApiClient in project coprhd-controller by CoprHD.
the class VNXeStorageDevice method doDeleteConsistencyGroup.
@Override
public void doDeleteConsistencyGroup(StorageSystem storage, URI consistencyGroupId, String replicationGroupName, Boolean keepRGName, Boolean markInactive, TaskCompleter taskCompleter) throws DeviceControllerException {
_logger.info("Deleting consistency group, array: {}", storage.getSerialNumber());
BlockConsistencyGroup consistencyGroup = _dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroupId);
// check if lungroup has been created in the array
String lunGroupId = consistencyGroup.getCgNameOnStorageSystem(storage.getId());
if (lunGroupId == null || lunGroupId.isEmpty()) {
_logger.error("The consistency group does not exist in the array: {}", storage.getSerialNumber());
taskCompleter.error(_dbClient, DeviceControllerException.exceptions.consistencyGroupNotFound(consistencyGroup.getLabel(), consistencyGroup.getCgNameOnStorageSystem(storage.getId())));
return;
}
VNXeApiClient apiClient = getVnxeClient(storage);
try {
apiClient.deleteLunGroup(lunGroupId, false, false);
if (keepRGName) {
taskCompleter.ready(_dbClient);
return;
}
// Clean up the system consistency group references
BlockConsistencyGroupUtils.cleanUpCGAndUpdate(consistencyGroup, storage.getId(), lunGroupId, markInactive, _dbClient);
_logger.info("Consistency group {} deleted", consistencyGroup.getLabel());
taskCompleter.ready(_dbClient);
} catch (Exception e) {
_logger.info("Failed to delete consistency group: " + e);
// Set task to error
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("doDeleteConsistencyGroup", e.getMessage());
taskCompleter.error(_dbClient, error);
}
}
use of com.emc.storageos.vnxe.VNXeApiClient in project coprhd-controller by CoprHD.
the class VNXeStorageDevice method doDisconnect.
@Override
public void doDisconnect(StorageSystem storage) {
try {
_logger.info("doConnect {} - start", storage.getId());
VNXeApiClient client = getVnxeClient(storage);
client.logout();
String msg = String.format("doDisconnect %1$s - complete", storage.getId());
_logger.info(msg);
} catch (VNXeException e) {
_logger.error("doDisconnect failed.", e);
throw DeviceControllerException.exceptions.disconnectStorageFailed(e);
}
}
use of com.emc.storageos.vnxe.VNXeApiClient in project coprhd-controller by CoprHD.
the class VNXeStorageDevice method doCreateFS.
@Override
public BiosCommandResult doCreateFS(StorageSystem storage, FileDeviceInputOutput fileInOut) throws ControllerException {
_logger.info("creating file system: ", fileInOut.getFsName());
Long fsSize = fileInOut.getFsCapacity();
if (fsSize < 1) {
// Invalid size throw an error
_logger.error("doCreateFS failed : FileSystem size in bytes is not valid {}", fileInOut.getFsCapacity());
ServiceError error = DeviceControllerErrors.vnxe.unableToCreateFileSystem("FileSystem size in bytes is not valid");
return BiosCommandResult.createErrorResult(error);
}
VNXeFileTaskCompleter completer = null;
VNXeApiClient apiClient = getVnxeClient(storage);
VNXeCommandJob job = null;
try {
FileShare fs = fileInOut.getFs();
URI port = fs.getStoragePort();
if (port == null) {
_logger.error("No storageport uri found in the fs");
ServiceError error = DeviceControllerErrors.vnxe.unableToCreateFileSystem("No storageport uri found in the fs");
return BiosCommandResult.createErrorResult(error);
}
StoragePort portObj = _dbClient.queryObject(StoragePort.class, port);
URI haDomainUri = portObj.getStorageHADomain();
StorageHADomain haDomainObj = _dbClient.queryObject(StorageHADomain.class, haDomainUri);
StringSet protocols = fs.getProtocol();
if (protocols.contains(StorageProtocol.File.NFS_OR_CIFS.name())) {
/*
* the protocol is set to NFS_OR_CIFS, only if virtual pool's protocol is not set
* and the pool's protocol is set to NFS_OR_CIFS, since pool's protocol is set based on
* storageHADomain's protocol, setting the protocols to the selected StorageHADomain.
*/
protocols = haDomainObj.getFileSharingProtocols();
}
VNXeFSSupportedProtocolEnum protocolEnum = null;
if (protocols.contains(StorageProtocol.File.NFS.name()) && protocols.contains(StorageProtocol.File.CIFS.name())) {
protocolEnum = VNXeFSSupportedProtocolEnum.NFS_CIFS;
} else if (protocols.contains(StorageProtocol.File.NFS.name())) {
protocolEnum = VNXeFSSupportedProtocolEnum.NFS;
} else if (protocols.contains(StorageProtocol.File.CIFS.name())) {
protocolEnum = VNXeFSSupportedProtocolEnum.CIFS;
} else {
_logger.error("protocol is not support: " + protocols);
ServiceError error = DeviceControllerErrors.vnxe.unableToCreateFileSystem("protocol is not support:" + protocols);
return BiosCommandResult.createErrorResult(error);
}
job = apiClient.createFileSystem(fileInOut.getFsName(), fsSize, fileInOut.getPoolNativeId(), haDomainObj.getSerialNumber(), fileInOut.getThinProvision(), protocolEnum);
if (job != null) {
_logger.info("opid:" + fileInOut.getOpId());
completer = new VNXeFileTaskCompleter(FileShare.class, fileInOut.getFsId(), fileInOut.getOpId());
if (fileInOut.getFs() == null) {
_logger.error("Could not find the fs object");
}
VNXeCreateFileSystemJob createFSJob = new VNXeCreateFileSystemJob(job.getId(), storage.getId(), completer, fileInOut.getPoolId());
ControllerServiceImpl.enqueueJob(new QueueJob(createFSJob));
} else {
_logger.error("No job returned from creatFileSystem");
ServiceError error = DeviceControllerErrors.vnxe.unableToCreateFileSystem("No Job returned from createFileSystem");
return BiosCommandResult.createErrorResult(error);
}
} catch (VNXeException e) {
_logger.error("Create file system got the exception", e);
if (completer != null) {
completer.error(_dbClient, e);
}
return BiosCommandResult.createErrorResult(e);
} catch (Exception ex) {
_logger.error("Create file system got the exception", ex);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateFileSystem", ex.getMessage());
if (completer != null) {
completer.error(_dbClient, error);
}
return BiosCommandResult.createErrorResult(error);
}
StringBuilder logMsgBuilder = new StringBuilder(String.format("Create filesystem job submitted - Array:%s, Pool:%s, fileSystem: %s", storage.getSerialNumber(), fileInOut.getPoolNativeId(), fileInOut.getFsName()));
_logger.info(logMsgBuilder.toString());
return BiosCommandResult.createPendingResult();
}
use of com.emc.storageos.vnxe.VNXeApiClient in project coprhd-controller by CoprHD.
the class VNXeExportMaskInitiatorsValidator method validate.
/**
* Get list of initiators associated with the host.
* If there are unknown initiators on the host, fail the validation
*/
@Override
public boolean validate() throws Exception {
log.info("Initiating initiator validation of VNXe ExportMask: " + getId());
DbClient dbClient = getDbClient();
VNXeApiClient apiClient = getApiClient();
ExportMask exportMask = getExportMask();
try {
// Don't validate against backing masks or RP
if (ExportMaskUtils.isBackendExportMask(getDbClient(), exportMask)) {
log.info("validation against backing mask for VPLEX or RP is disabled.");
return true;
}
// all initiators of VNXe host should be on single ViPR host, or unknown to ViPR
String vnxeHostId = getHostId();
if (vnxeHostId == null) {
return true;
}
List<VNXeHostInitiator> initiatorList = apiClient.getInitiatorsByHostId(vnxeHostId);
URI hostId = null;
if (initiatorList != null) {
for (VNXeHostInitiator initiator : initiatorList) {
String portWWN = null;
if (HostInitiatorTypeEnum.INITIATOR_TYPE_ISCSI.equals(initiator.getType())) {
portWWN = initiator.getInitiatorId();
} else {
portWWN = initiator.getPortWWN();
}
Initiator viprInitiator = NetworkUtil.findInitiatorInDB(portWWN, dbClient);
if (viprInitiator != null) {
if (NullColumnValueGetter.isNullURI(hostId)) {
hostId = viprInitiator.getHost();
} else if (!hostId.equals(viprInitiator.getHost())) {
log.info("Initiator {} belongs to different host", portWWN);
setRemediation(misMatchInitiatorRemediation);
getLogger().logDiff(exportMask.getId().toString(), "initiators", ValidatorLogger.NO_MATCHING_ENTRY, portWWN);
break;
}
} else {
// initiator not found in ViPR
log.info("Unknown initiator found: {}", portWWN);
setRemediation(unknownInitiatorRemediation);
getLogger().logDiff(exportMask.getId().toString(), "initiators", ValidatorLogger.NO_MATCHING_ENTRY, portWWN);
break;
}
}
}
} catch (Exception ex) {
log.error("Unexpected exception validating ExportMask initiators: " + ex.getMessage(), ex);
if (getConfig().isValidationEnabled()) {
throw DeviceControllerException.exceptions.unexpectedCondition("Unexpected exception validating ExportMask initiators: " + ex.getMessage());
}
}
checkForErrors();
log.info("Completed initiator validation of VNXe ExportMask: " + getId());
return true;
}
use of com.emc.storageos.vnxe.VNXeApiClient in project coprhd-controller by CoprHD.
the class VNXeExportMaskVolumesValidator method validate.
@Override
public boolean validate() throws Exception {
log.info("Initiating volume validation of VNXe ExportMask: " + getId());
DbClient dbClient = getDbClient();
VNXeApiClient apiClient = getApiClient();
ExportMask exportMask = getExportMask();
try {
String vnxeHostId = getHostId();
if (vnxeHostId != null) {
VNXeHost vnxeHost = apiClient.getHostById(vnxeHostId);
if (vnxeHost != null) {
Set<String> lunIds = ExportUtils.getAllLUNsForHost(dbClient, exportMask);
Set<String> lunIdsOnArray = apiClient.getHostLUNIds(vnxeHostId);
lunIdsOnArray.removeAll(lunIds);
if (!lunIdsOnArray.isEmpty()) {
String unknownLUNs = Joiner.on(',').join(lunIdsOnArray);
log.info("Unknown LUN/LUN Snap {}", unknownLUNs);
getLogger().logDiff(exportMask.getId().toString(), "volumes", ValidatorLogger.NO_MATCHING_ENTRY, unknownLUNs);
}
}
}
} catch (Exception ex) {
log.error("Unexpected exception validating ExportMask volumes: " + ex.getMessage(), ex);
throw DeviceControllerException.exceptions.unexpectedCondition("Unexpected exception validating ExportMask volumes: " + ex.getMessage());
}
setRemediation(unknownLUNRemediation);
checkForErrors();
log.info("Completed volume validation of VNXe ExportMask: " + getId());
return true;
}
Aggregations