use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.
the class VNXFileStorageDeviceXML method getDataMover.
private StorageHADomain getDataMover(FileShare fileShare) {
StoragePort port = _dbClient.queryObject(StoragePort.class, fileShare.getStoragePort());
StorageHADomain dm = null;
if (port != null) {
dm = _dbClient.queryObject(StorageHADomain.class, port.getStorageHADomain());
}
return dm;
}
use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.
the class VNXFileStorageDeviceXML method doShare.
@Override
public BiosCommandResult doShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws ControllerException {
_log.info("Call FileShare doShare");
boolean firstExport = false;
if (args.getFileObjShares() == null || args.getFileObjShares().isEmpty()) {
args.initFileObjShares();
}
firstExport = !(args.isFileShareMounted());
if (firstExport) {
_log.debug("First export: no existing file obj shares");
}
if (!args.getFileOperation()) {
firstExport = false;
}
String portName = smbFileShare.getPortGroup();
String path = smbFileShare.getPath();
if (path == null || path.length() == 0) {
if (args.getFileOperation()) {
path = args.getFsMountPath();
} else {
path = args.getSnapshotMountPath();
}
}
_log.debug("Data Mover: {}", portName);
_log.debug("Mount path: {}", path);
XMLApiResult result = null;
ApplicationContext context = null;
try {
List<String> clients = new ArrayList<String>();
VNXFileExport fileExport = new VNXFileExport(clients, portName, path, // no security type
"", smbFileShare.getPermission(), // root user mapping n/a for CIFS
"", VNXFileSshApi.VNX_CIFS, // Port information is never used for for CIFS or NFS exports.
"", // SUB DIR
"", // Comments -- TODO
"");
fileExport.setExportName(smbFileShare.getName());
fileExport.setComment(smbFileShare.getDescription());
fileExport.setMaxUsers(Integer.toString(smbFileShare.getMaxUsers()));
List<VNXFileExport> vnxExports = new ArrayList<VNXFileExport>();
vnxExports.add(fileExport);
context = loadContext();
VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
if (null == vnxComm) {
throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
}
// Get DataMover
StorageHADomain dm = this.getDataMover(args.getFs());
if (dm == null) {
Exception e = new Exception("VNX File Share creation Failed Data Mover not found");
throw VNXException.exceptions.createExportFailed("VNX File Share creation Failed Data Mover not found", e);
}
List<String> paths = new ArrayList<String>();
paths.add(path);
if (args.getFileOperation()) {
// Perform FileSystem export
result = vnxComm.doExport(storage, dm, vnxExports, paths, args.getFileObj(), args.getFsNativeId(), firstExport);
} else {
// perform Snapshot export
result = vnxComm.doExport(storage, dm, vnxExports, paths, args.getFileObj(), args.getSnapNativeId(), firstExport);
}
if ((result != null) && (result.isCommandSuccess())) {
// Set MountPoint
smbFileShare.setMountPoint(fileExport.getNetBios(), smbFileShare.getStoragePortNetworkId(), smbFileShare.getStoragePortName(), smbFileShare.getName());
args.getFileObjShares().put(smbFileShare.getName(), smbFileShare);
}
} catch (VNXException e) {
throw new DeviceControllerException(e);
} catch (NumberFormatException e) {
// Placeholder until real handling is determined.
throw new DeviceControllerException(e);
} finally {
clearContext(context);
}
BiosCommandResult cmdResult = null;
if (result.isCommandSuccess()) {
cmdResult = BiosCommandResult.createSuccessfulResult();
} else {
cmdResult = BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToCreateFileShare(result.getMessage()));
}
return cmdResult;
}
use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.
the class VNXFileStorageDeviceXML method doExport.
@Override
public BiosCommandResult doExport(StorageSystem storage, FileDeviceInputOutput args, List<FileExport> exportList) throws ControllerException {
boolean firstExport = false;
if (args.getFileObjExports() == null || args.getFileObjExports().isEmpty()) {
args.initFileObjExports();
}
// mount the FileSystem
firstExport = !(args.isFileShareMounted());
if (firstExport) {
_log.debug("First export: no existing file exports");
}
// Mounting is only necessary for FileSystem and not snapshot for the first time export
if (!args.getFileOperation()) {
firstExport = false;
}
// Create a list of the new exports.
FSExportMap newExpList = new FSExportMap();
FSExportMap curExpList = args.getFileObjExports();
FileExport curExport = null;
FileExport newExport = null;
List<String> newPaths = new ArrayList<String>();
Iterator<String> it = curExpList.keySet().iterator();
while (it.hasNext()) {
curExport = curExpList.get(it.next());
newExport = new FileExport(curExport.getClients(), curExport.getStoragePortName(), ExportUtils.getFileMountPoint(curExport.getStoragePort(), curExport.getPath()), curExport.getSecurityType(), curExport.getPermissions(), curExport.getRootUserMapping(), curExport.getProtocol(), curExport.getStoragePort(), curExport.getPath(), curExport.getMountPath(), curExport.getSubDirectory(), curExport.getComments());
_log.info("FileExport key : {} ", newExport.getFileExportKey());
newExpList.put(newExport.getFileExportKey(), newExport);
}
for (FileExport exp : exportList) {
newExport = new FileExport(exp.getClients(), exp.getStoragePortName(), ExportUtils.getFileMountPoint(exp.getStoragePort(), exp.getPath()), exp.getSecurityType(), exp.getPermissions(), exp.getRootUserMapping(), exp.getProtocol(), exp.getStoragePort(), exp.getPath(), exp.getMountPath(), exp.getSubDirectory(), exp.getComments());
_log.info("FileExport key : {} ", newExport.getFileExportKey());
newExpList.put(newExport.getFileExportKey(), newExport);
if (!newPaths.contains(newExport.getPath())) {
newPaths.add(newExport.getPath());
}
}
XMLApiResult result = null;
ApplicationContext context = null;
try {
context = loadContext();
VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
if (null == vnxComm) {
throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
}
// Get DataMover Name and whether it is virtual
StorageHADomain dm = this.getDataMover(args.getFs());
if (dm == null) {
Exception e = new Exception("VNX File Export Failed Data Mover not found");
throw VNXException.exceptions.createExportFailed("VNX File Export Failed Data Mover not found", e);
}
List<VNXFileExport> vnxExports = getVNXFileExports(newExpList);
if (args.getFileOperation()) {
// Perform FileSystem export
result = vnxComm.doExport(storage, dm, vnxExports, newPaths, args.getFileObj(), args.getFsNativeId(), firstExport);
} else {
// perform Snapshot export
result = vnxComm.doExport(storage, dm, vnxExports, newPaths, args.getFileObj(), args.getSnapNativeId(), firstExport);
}
if (result.isCommandSuccess()) {
curExpList.putAll(newExpList);
}
} catch (VNXException e) {
throw VNXException.exceptions.createExportFailed("VNX File Export Failed", e);
} finally {
clearContext(context);
}
BiosCommandResult cmdResult = null;
if (result.isCommandSuccess()) {
cmdResult = BiosCommandResult.createSuccessfulResult();
} else {
cmdResult = BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToExportFileSystem(result.getMessage()));
}
return cmdResult;
}
use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.
the class StoragePortsAllocator method addPortsToAlreadyAllocatedContext.
/**
* Adds a list of Storage Ports to the context _alreadyAllocatedXXX sets.
* This will carry state from an a previous allocation in one network to
* a new allocation for Vpool update in another network.
* Does nothing if previouslyAllocatedPorts is null or an empty set.
*
* @param dbClient
* @param net
* @param previouslyAllocatedPorts
*/
public void addPortsToAlreadyAllocatedContext(DbClient dbClient, NetworkLite net, Set<StoragePort> previouslyAllocatedPorts) {
if (previouslyAllocatedPorts == null || previouslyAllocatedPorts.isEmpty()) {
return;
}
for (StoragePort sp : previouslyAllocatedPorts) {
StorageHADomain haDomain = null;
if (null != sp.getStorageHADomain()) {
haDomain = dbClient.queryObject(StorageHADomain.class, sp.getStorageHADomain());
}
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, sp.getStorageDevice());
String switchName = PlacementUtils.getSwitchName(sp, dbClient);
if (context == null) {
context = new PortAllocationContext(net, storageSystem.getNativeGuid());
}
context.addPortToAlreadyAllocatedContext(sp, haDomain, StorageSystem.Type.valueOf(storageSystem.getSystemType()), switchName);
}
}
use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.
the class StoragePortHADomainPopulater method process.
/*
* (non-Javadoc)
*
* @see com.emc.storageos.db.client.upgrade.BaseCustomMigrationCallback#process()
*/
@Override
public void process() throws MigrationCallbackException {
log.info("START - StoragePortHADomainPopulater migration call back");
DbClient dbClient = getDbClient();
List<URI> storagePortURIs = dbClient.queryByType(StoragePort.class, false);
Iterator<StoragePort> storagePortsIter = dbClient.queryIterativeObjects(StoragePort.class, storagePortURIs);
Map<URI, StorageSystem> uriVsSystem = new HashMap<>();
List<StoragePort> modifiedPorts = new ArrayList<>();
while (storagePortsIter.hasNext()) {
StoragePort storagePort = storagePortsIter.next();
URI deviceURI = storagePort.getStorageDevice();
StorageSystem system = null;
if (uriVsSystem.containsKey(deviceURI)) {
system = uriVsSystem.get(deviceURI);
} else {
system = dbClient.queryObject(StorageSystem.class, deviceURI);
if (null != system) {
uriVsSystem.put(deviceURI, system);
} else {
log.warn("No storage system found for the port - {} , it will be skipped from" + "migration, storageHADomain will continue to remain empty", storagePort.getId().toString());
continue;
}
}
if (storagePort.getStorageHADomain() == null && DiscoveredDataObject.Type.openstack.name().equalsIgnoreCase((system.getSystemType()))) {
StorageHADomain haDomain = createStorageAdapter(system, dbClient);
log.info("Populating the storageHADomian for the port - {} ", storagePort.getId().toString());
storagePort.setStorageHADomain(haDomain.getId());
modifiedPorts.add(storagePort);
}
}
// Persist the change
if (!modifiedPorts.isEmpty()) {
dbClient.persistObject(modifiedPorts);
}
log.info("END - StoragePortHADomainPopulater migration call back");
}
Aggregations