use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.
the class VPlexPerpetualCSVFileCollector method lookupVPlexDirectorByName.
/**
* Lookup the StorageHADomain with name 'directorName' and associated with VPlex array 'storageSystem'.
*
* @param dbClient [IN] - DbClient used for DB access
* @param storageSystem [IN] - StorageSystem representing the VPlex array
* @param directorName [IN] - Name of VPlex director to lookup
* @return StorageHADomain with named 'directorName' and associated to StorageSystem 'storageSystem', otherwise null
*/
private StorageHADomain lookupVPlexDirectorByName(DbClient dbClient, StorageSystem storageSystem, String directorName) {
String cacheKey = generateStorageHADomainKey(storageSystem, directorName);
StorageHADomain vplexDirector = (StorageHADomain) OBJECT_CACHE.get(cacheKey);
if (vplexDirector == null) {
vplexDirector = findStorageHADomainByNameInDB(dbClient, storageSystem, directorName);
if (vplexDirector != null) {
OBJECT_CACHE.put(cacheKey, vplexDirector);
return vplexDirector;
} else {
// TODO: Error!!!
}
}
return vplexDirector;
}
use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.
the class VNXFileCommApi method doDeleteExport.
public XMLApiResult doDeleteExport(final StorageSystem system, String exportPath, FileDeviceInputOutput args, boolean deleteMount) {
XMLApiResult result = new XMLApiResult();
result.setCommandSuccess();
Map<String, Object> reqAttributeMap = new ConcurrentHashMap<String, Object>();
_log.info("Delete VNX Export : {}", exportPath);
if (exportPath == null || (exportPath != null && exportPath.isEmpty())) {
_log.info("Invalid Export Path");
return result;
}
try {
updateAttributes(reqAttributeMap, system);
String moverId;
StorageHADomain dataMover = null;
String mountPath = "";
if (args.getFileOperation()) {
StoragePort storagePort = _dbClient.queryObject(StoragePort.class, args.getFs().getStoragePort());
URI dataMoverId = storagePort.getStorageHADomain();
dataMover = _dbClient.queryObject(StorageHADomain.class, dataMoverId);
moverId = dataMover.getName();
mountPath = args.getFsMountPath();
_log.info("Using Mover Id {} to unexport FS mounted at {}", moverId, exportPath);
// Delete export from storage system.
sshApi.setConnParams(system.getIpAddress(), system.getUsername(), system.getPassword());
if (sshApi.getNFSExportsForPath(dataMover.getAdapterName(), exportPath).containsKey(exportPath)) {
// Delete the Export.
String data = sshApi.formatDeleteNfsExportCmd(dataMover.getAdapterName(), exportPath);
result = sshApi.executeSshRetry(VNXFileSshApi.SERVER_EXPORT_CMD, data);
}
// we check for any exports and share exists and then run umount operation
if (result.isCommandSuccess() && getVNXFSDependencies(args.getFs(), false) <= 1) {
// Delete the mount
String data = sshApi.formatUnMountCmd(dataMover.getAdapterName(), mountPath, "NFS");
result = sshApi.executeSshRetry(VNXFileSshApi.SERVER_UNMOUNT_CMD, data);
}
sshApi.clearConnParams();
} else {
String isVdm = "false";
Snapshot snapshot = _dbClient.queryObject(Snapshot.class, args.getSnapshotId());
FileShare fileshare = _dbClient.queryObject(FileShare.class, snapshot.getParent().getURI());
StoragePort storagePort = _dbClient.queryObject(StoragePort.class, fileshare.getStoragePort());
URI dataMoverId = storagePort.getStorageHADomain();
dataMover = _dbClient.queryObject(StorageHADomain.class, dataMoverId);
moverId = dataMover.getName();
_log.info("Using Mover Id {} to unexport FS mounted at {}", moverId, exportPath);
if (dataMover.getVirtual()) {
isVdm = "true";
}
// Delete export from storage system.
reqAttributeMap.put(VNXFileConstants.MOVER_ID, moverId);
reqAttributeMap.put(VNXFileConstants.MOUNT_PATH, exportPath);
reqAttributeMap.put(VNXFileConstants.ISVDM, isVdm);
_provExecutor.setKeyMap(reqAttributeMap);
sshApi.setConnParams(system.getIpAddress(), system.getUsername(), system.getPassword());
if (sshApi.getNFSExportsForPath(dataMover.getAdapterName(), exportPath).containsKey(exportPath)) {
String data = sshApi.formatDeleteNfsExportCmd(dataMover.getAdapterName(), exportPath);
result = sshApi.executeSshRetry(VNXFileSshApi.SERVER_EXPORT_CMD, data);
}
// Delete the Snapshot mount, only if No depending exports, shares for that snapshot.
if (result.isCommandSuccess() && getVNXFSDependencies(args.getFs(), true) <= 1) {
// Delete the mount
String data = sshApi.formatUnMountCmd(dataMover.getAdapterName(), exportPath, "NFS");
result = sshApi.executeSshRetry(VNXFileSshApi.SERVER_UNMOUNT_CMD, data);
}
sshApi.clearConnParams();
}
} catch (Exception e) {
throw new VNXException("File Export Delete Exception: ", e);
}
return result;
}
use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.
the class VNXFileCommApi method doUnexport.
public XMLApiResult doUnexport(final StorageSystem system, VNXFileExport fileExport, FileDeviceInputOutput args, boolean deleteMount) throws VNXException {
_log.info("Unexport file sys mounted at : {}", fileExport.getMountPoint());
XMLApiResult result = new XMLApiResult();
result.setCommandSuccess();
Map<String, Object> reqAttributeMap = new ConcurrentHashMap<String, Object>();
try {
updateAttributes(reqAttributeMap, system);
String moverId;
StorageHADomain dataMover = null;
if (args.getFileOperation()) {
StoragePort storagePort = _dbClient.queryObject(StoragePort.class, args.getFs().getStoragePort());
URI dataMoverId = storagePort.getStorageHADomain();
dataMover = _dbClient.queryObject(StorageHADomain.class, dataMoverId);
moverId = dataMover.getName();
String fsMountPath = args.getFsPath();
_log.info("Using Mover Id {} to unexport FS mounted at {}", moverId, fsMountPath);
// Retrieve export object from the DB. If there are multiple "ro",
// "rw", "root", and "access" endpoints, just remove this entry and update
// export properties on the array and in the DB
boolean thisEntryFound = false;
boolean moreEntries = false;
Set<String> keysToRemove = new HashSet<String>();
String exportEntryKey = FileExport.exportLookupKey(fileExport.getProtocol(), fileExport.getSecurityType(), fileExport.getPermissions(), fileExport.getRootUserMapping(), fileExport.getMountPoint());
FileExport export = args.getFileObjExports().get(exportEntryKey);
if (export != null) {
thisEntryFound = true;
keysToRemove.add(exportEntryKey);
}
Set<String> keys = args.getFileObjExports().keySet();
for (String key : keys) {
if ((fileExport.getMountPoint().equals(args.getFileObjExports().get(key).getPath())) && (!exportEntryKey.equalsIgnoreCase(key))) {
moreEntries = true;
break;
}
}
for (String key : keysToRemove) {
args.getFsExports().remove(key);
}
boolean deleteExportFromDevice = true;
if ((!thisEntryFound) || (moreEntries)) {
// Don't unexport, just update properties
deleteExportFromDevice = false;
}
if (deleteExportFromDevice) {
// Delete export from storage system.
String mntPoint = fileExport.getMountPoint();
sshApi.setConnParams(system.getIpAddress(), system.getUsername(), system.getPassword());
if (sshApi.getNFSExportsForPath(dataMover.getAdapterName(), mntPoint).containsKey(mntPoint)) {
String data = sshApi.formatDeleteNfsExportCmd(dataMover.getAdapterName(), mntPoint);
result = sshApi.executeSshRetry(VNXFileSshApi.SERVER_EXPORT_CMD, data);
}
// As we already removed the export entry from Map, Check for any other dependents.
if (result.isCommandSuccess() && getVNXFSDependencies(args.getFs(), false) < 1) {
// Delete the mount
String data = sshApi.formatUnMountCmd(dataMover.getAdapterName(), fsMountPath, "NFS");
result = sshApi.executeSshRetry(VNXFileSshApi.SERVER_UNMOUNT_CMD, data);
}
sshApi.clearConnParams();
} else {
// Just update export properties.
List<VNXFileExport> vnxExports = new ArrayList<VNXFileExport>();
keys = args.getFsExports().keySet();
for (String key : keys) {
FileExport exp = args.getFileObjExports().get(key);
VNXFileExport vnxExp = new VNXFileExport(exp.getClients(), exp.getStoragePortName(), exp.getPath(), exp.getSecurityType(), exp.getPermissions(), exp.getRootUserMapping(), exp.getProtocol(), exp.getStoragePort(), exp.getSubDirectory(), exp.getComments());
vnxExports.add(vnxExp);
}
sshApi.setConnParams(system.getIpAddress(), system.getUsername(), system.getPassword());
String data = sshApi.formatExportCmd(dataMover.getAdapterName(), vnxExports, null, null);
result = sshApi.executeSshRetry(VNXFileSshApi.SERVER_EXPORT_CMD, data);
sshApi.clearConnParams();
if (result.isCommandSuccess()) {
result.setCommandSuccess();
} else {
result.setCommandFailed();
}
}
} else {
String isVdm = "false";
Snapshot snapshot = _dbClient.queryObject(Snapshot.class, args.getSnapshotId());
FileShare fileshare = _dbClient.queryObject(FileShare.class, snapshot.getParent().getURI());
StoragePort storagePort = _dbClient.queryObject(StoragePort.class, fileshare.getStoragePort());
URI dataMoverId = storagePort.getStorageHADomain();
dataMover = _dbClient.queryObject(StorageHADomain.class, dataMoverId);
moverId = dataMover.getName();
_log.info("Using Mover Id {} to unexport FS mounted at {}", moverId, fileExport.getMountPoint());
if (dataMover.getVirtual()) {
isVdm = "true";
}
// Delete export from storage system.
reqAttributeMap.put(VNXFileConstants.MOVER_ID, moverId);
reqAttributeMap.put(VNXFileConstants.MOUNT_PATH, fileExport.getMountPoint());
reqAttributeMap.put(VNXFileConstants.ISVDM, isVdm);
_provExecutor.setKeyMap(reqAttributeMap);
sshApi.setConnParams(system.getIpAddress(), system.getUsername(), system.getPassword());
String mntPoint = fileExport.getMountPoint();
if (sshApi.getNFSExportsForPath(dataMover.getAdapterName(), mntPoint).containsKey(mntPoint)) {
String data = sshApi.formatDeleteNfsExportCmd(dataMover.getAdapterName(), mntPoint);
result = sshApi.executeSshRetry(VNXFileSshApi.SERVER_EXPORT_CMD, data);
}
if (result.isCommandSuccess() && getVNXFSDependencies(fileshare, true) <= 1) {
// Delete the mount
String data = sshApi.formatUnMountCmd(dataMover.getAdapterName(), fileExport.getMountPoint(), "NFS");
result = sshApi.executeSshRetry(VNXFileSshApi.SERVER_UNMOUNT_CMD, data);
}
sshApi.clearConnParams();
}
} catch (Exception e) {
throw new VNXException("File unexport exception: ", e);
}
return result;
}
use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.
the class FileStorageScheduler method selectStorageHADomainMatchingVpool.
/**
* Select the right StorageHADomain matching vpool protocols.
*
* @param vpool
* @param vArray
* @param poolRecommends
* recommendations after selecting matching storage pools.
* @return list of FileRecommendation
*/
private List<FileRecommendation> selectStorageHADomainMatchingVpool(VirtualPool vpool, URI vArray, List<Recommendation> poolRecommends, List<VirtualNAS> invalidNasServers) {
// Get the storage ports from invalid vnas servers!!!
List<URI> invalidPorts = getvNasStoragePortUris(invalidNasServers);
_log.debug("select matching StorageHADomain");
List<FileRecommendation> result = new ArrayList<FileRecommendation>();
for (Recommendation recommendation : poolRecommends) {
FileRecommendation rec = new FileRecommendation(recommendation);
URI storageUri = recommendation.getSourceStorageSystem();
StorageSystem storage = _dbClient.queryObject(StorageSystem.class, storageUri);
// found
if (storage.getSystemType().equals(Type.unity.toString())) {
continue;
}
if (!storage.getSystemType().equals(Type.netapp.toString()) && !storage.getSystemType().equals(Type.netappc.toString()) && !storage.getSystemType().equals(Type.vnxe.toString()) && !storage.getSystemType().equals(Type.vnxfile.toString()) && !storage.getSystemType().equals(Type.datadomain.toString())) {
result.add(rec);
continue;
}
List<StoragePort> portList = getStorageSystemPortsInVarray(storageUri, vArray);
if (portList == null || portList.isEmpty()) {
_log.info("No valid storage port found from the virtual array: " + vArray);
continue;
}
List<URI> storagePorts = new ArrayList<URI>();
boolean foundValidPort = false;
for (StoragePort port : portList) {
if (invalidPorts.contains(port.getId())) {
_log.debug("Storage port {} belongs to invalid vNas server ", port.getIpAddress());
continue;
}
foundValidPort = true;
_log.debug("Looking for port {}", port.getLabel());
URI haDomainUri = port.getStorageHADomain();
// Data Domain does not have a filer entity.
if ((haDomainUri == null) && (!storage.getSystemType().equals(Type.datadomain.toString()))) {
_log.info("No StorageHADomain URI for port {}", port.getLabel());
continue;
}
StorageHADomain haDomain = null;
if (haDomainUri != null) {
haDomain = _dbClient.queryObject(StorageHADomain.class, haDomainUri);
}
if (haDomain != null) {
StringSet protocols = haDomain.getFileSharingProtocols();
// to see if it matches virtualPool's protocols
StringSet vpoolProtocols = vpool.getProtocols();
if (protocols != null && protocols.containsAll(vpoolProtocols)) {
_log.info("Found the StorageHADomain {} for recommended storagepool: {}", haDomain.getName(), recommendation.getSourceStoragePool());
storagePorts.add(port.getId());
}
} else if (storage.getSystemType().equals(Type.datadomain.toString())) {
// The same file system on DD can support NFS and CIFS
storagePorts.add(port.getId());
} else {
_log.error("No StorageHADomain for port {}", port.getIpAddress());
}
}
// minimize collisions).
if (foundValidPort) {
Collections.shuffle(storagePorts);
rec.setStoragePorts(storagePorts);
result.add(rec);
} else {
_log.info("No valid storage port found from the storage system : " + storageUri + ", All ports belongs to invalid vNas ");
}
}
return result;
}
use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.
the class FileStorageScheduler method getPortsWithFileSharingProtocol.
/**
* Removes storage ports that do not support the specified file sharing
* protocol.
*
* @param protocol
* the required protocol that the port must support.
* @param ports
* the list of available ports.
*/
private void getPortsWithFileSharingProtocol(String protocol, List<StoragePort> ports) {
if (null == protocol || null == ports || ports.isEmpty()) {
return;
}
_log.debug("Validate protocol: {}", protocol);
if (!StorageProtocol.File.NFS.name().equalsIgnoreCase(protocol) && !StorageProtocol.File.CIFS.name().equalsIgnoreCase(protocol)) {
_log.warn("Not a valid file sharing protocol: {}", protocol);
return;
}
StoragePort tempPort = null;
StorageHADomain haDomain = null;
Iterator<StoragePort> itr = ports.iterator();
while (itr.hasNext()) {
tempPort = itr.next();
haDomain = null;
URI domainUri = tempPort.getStorageHADomain();
if (null != domainUri) {
haDomain = _dbClient.queryObject(StorageHADomain.class, domainUri);
}
if (null != haDomain) {
StringSet supportedProtocols = haDomain.getFileSharingProtocols();
if (supportedProtocols == null || !supportedProtocols.contains(protocol)) {
itr.remove();
_log.debug("Removing port {}", tempPort.getPortName());
}
}
_log.debug("Number ports remainng: {}", ports.size());
}
}
Aggregations