use of com.emc.storageos.volumecontroller.FileDeviceInputOutput in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method prepareFileDeviceInputOutput.
private FileDeviceInputOutput prepareFileDeviceInputOutput(boolean forceDelete, URI uri, String opId) {
FileDeviceInputOutput args = new FileDeviceInputOutput();
boolean isFile = false;
args.setOpId(opId);
if (URIUtil.isType(uri, FileShare.class)) {
isFile = true;
args.setForceDelete(forceDelete);
FileShare fsObj = _dbClient.queryObject(FileShare.class, uri);
if (fsObj.getVirtualNAS() != null) {
VirtualNAS vNAS = _dbClient.queryObject(VirtualNAS.class, fsObj.getVirtualNAS());
args.setvNAS(vNAS);
}
args.addFileShare(fsObj);
args.setFileOperation(isFile);
}
return args;
}
use of com.emc.storageos.volumecontroller.FileDeviceInputOutput in project coprhd-controller by CoprHD.
the class VNXFileCommApi method deleteAllExportsAndShares.
private XMLApiResult deleteAllExportsAndShares(StorageSystem system, StorageHADomain dataMover, FileShare fs, Snapshot snapshot) {
FSExportMap exports;
SMBShareMap shares;
XMLApiResult result = new XMLApiResult();
result.setCommandSuccess();
String fileId = fs.getId().toString();
FileObject fObj = fs;
_log.info("deleteAllExportsAndShares for {} {}", fs.getName(), snapshot);
boolean fileOperation = false;
if (snapshot == null) {
// FileShare operation
_log.info("deleteAllExportsAndShares FileShare delete operation");
exports = fs.getFsExports();
shares = fs.getSMBFileShares();
fileOperation = true;
fObj = fs;
} else {
_log.info("deleteAllExportsAndShares Snapshot delete operation");
exports = snapshot.getFsExports();
shares = snapshot.getSMBFileShares();
fObj = snapshot;
fileId = snapshot.getId().toString();
}
int exportsToUnExport = 0;
Set<String> keys = new HashSet();
if (exports != null) {
exportsToUnExport = exports.size();
keys = exports.keySet();
}
int noOfShares = 0;
if (shares != null) {
noOfShares = shares.size();
}
_log.info("Number of NFS exports {} SMB Shares found {} for File/Snapshot Id {}", new Object[] { exportsToUnExport, noOfShares, fileId });
// To avoid concurrent modification exceptions
Set<String> exportKeys = new HashSet();
exportKeys.addAll(keys);
FileDeviceInputOutput args = new FileDeviceInputOutput();
args.setFileOperation(fileOperation);
args.addFSFileObject(fs);
if (fileOperation) {
args.setFileOperation(true);
args.addFSFileObject(fs);
} else {
args.setFileOperation(false);
args.addFSFileObject(fs);
args.addSnapshot(snapshot);
}
for (String key : exportKeys) {
FileExport exp = exports.get(key);
VNXFileExport fileExport = new VNXFileExport(exp.getClients(), exp.getStoragePortName(), exp.getPath(), exp.getSecurityType(), exp.getPermissions(), exp.getRootUserMapping(), exp.getProtocol(), exp.getStoragePort(), exp.getSubDirectory(), exp.getComments());
fileExport.setStoragePort(fs.getStoragePort().toString());
boolean deleteMount = false;
if (exportsToUnExport == 1 && noOfShares == 0 && fileOperation) {
deleteMount = true;
}
XMLApiResult status = doUnexport(system, fileExport, args, deleteMount);
if (!status.isCommandSuccess()) {
String errMsg = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_DESC);
result.setCommandFailed();
result.setMessage(errMsg);
return result;
} else {
fObj.getFsExports().remove(key);
_log.info("Export removed : " + key);
exportsToUnExport--;
}
// Persist the object after exports removed
_dbClient.persistObject(fObj);
}
// Now Let Handle SMB/CIFS Shares
keys = new HashSet<>();
int noOfSharesToDelete = 0;
if (shares != null) {
keys = shares.keySet();
noOfSharesToDelete = keys.size();
}
int noOfExports = 0;
if (exports != null) {
noOfExports = exports.size();
}
_log.info("Number of CIFS/SMB Shares {} NFS Exports found {} for File/Snapshot Id {}", new Object[] { noOfSharesToDelete, noOfExports, fileId });
// To avoid concurrent modification exceptions
Set<String> shareKeys = new HashSet();
shareKeys.addAll(keys);
for (String key : shareKeys) {
SMBFileShare share = shares.get(key);
_log.info("Delete SMB/CIFS Share {} from FS/Snapshot {}", share.getName(), fileId);
boolean deleteMount = false;
if (noOfSharesToDelete == 1 && noOfExports == 0 && fileOperation) {
deleteMount = true;
}
XMLApiResult status = doDeleteShare(system, dataMover, share.getName(), fs.getMountPath(), deleteMount, args);
if (!status.isCommandSuccess()) {
_log.info("SMBFileShare deletion failed key {} : {} ", key, share.getName());
String errMsg = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_DESC);
result.setCommandFailed();
result.setMessage(errMsg);
return result;
} else {
fObj.getSMBFileShares().remove(key);
_log.info("SMBFileShare removed : " + key);
noOfSharesToDelete--;
}
// Persist the object after SMBShares removed
_dbClient.persistObject(fObj);
}
return result;
}
use of com.emc.storageos.volumecontroller.FileDeviceInputOutput in project coprhd-controller by CoprHD.
the class IsilonFileStorageDeviceTest method testFileSystemDelete.
/**
* Tests file system delete with existing smb shares and nfs exports.
*
* @throws Exception
*/
@Test
public void testFileSystemDelete() throws Exception {
FileShare fs = new FileShare();
fs.setId(URIUtil.createId(FileShare.class));
fs.setLabel("test");
fs.setCapacity(102400L);
FileDeviceInputOutput args = new FileDeviceInputOutput();
args.addStoragePool(_pool);
args.addFSFileObject(fs);
Assert.assertTrue("doCreateFS failed", _isi.doCreateFS(_device, args).getCommandStatus().equals(Operation.Status.ready.name()));
// share file system with SMB
SMBFileShare smbFileShare = new SMBFileShare("TestSMBShare", "Share created by unit test.", "allow", "change", -1);
Assert.assertTrue("SMB share doShare() failed", _isi.doShare(_device, args, smbFileShare).getCommandStatus().equals(Operation.Status.ready.name()));
Assert.assertTrue("SMB share doShare() failed, share not added to FS", fs.getSMBFileShares().keySet().contains(smbFileShare.getName()));
Assert.assertTrue("SMB share doShare() failed, number of shares does not match", fs.getSMBFileShares().keySet().size() == 1);
// add additional share
SMBFileShare smbFileShare01 = new SMBFileShare("TestSMBShare01", "Share created by unit test.", "allow", "change", -1);
Assert.assertTrue("SMB share doShare() failed", _isi.doShare(_device, args, smbFileShare01).getCommandStatus().equals(Operation.Status.ready.name()));
Assert.assertTrue("SMB share doShare() failed, share not added to FS", fs.getSMBFileShares().keySet().contains(smbFileShare01.getName()));
Assert.assertTrue("SMB share doShare() failed, number of shares does not match", fs.getSMBFileShares().keySet().size() == 2);
// add additional share
SMBFileShare smbFileShare02 = new SMBFileShare("TestSMBShare02", "Share created by unit test.", "allow", "change", -1);
Assert.assertTrue("SMB share doShare() failed", _isi.doShare(_device, args, smbFileShare02).getCommandStatus().equals(Operation.Status.ready.name()));
Assert.assertTrue("SMB share doShare() failed, share not added to FS", fs.getSMBFileShares().keySet().contains(smbFileShare02.getName()));
Assert.assertTrue("SMB share doShare() failed, number of shares does not match", fs.getSMBFileShares().keySet().size() == 3);
// delete one SMB share for FS
Assert.assertTrue("SMB share doDeleteShare() failed", _isi.doDeleteShare(_device, args, smbFileShare).getCommandStatus().equals(Operation.Status.ready.name()));
Assert.assertFalse("SMB share doDeleteShare() failed, share was not deleted from FS", fs.getSMBFileShares().keySet().contains(smbFileShare.getName()));
Assert.assertTrue("SMB share doDeleteShare() failed, number of shares does not match", fs.getSMBFileShares().keySet().size() == 2);
// export
List<String> clients = new ArrayList<String>();
clients.add(client1);
FileExport export1 = new FileExport(clients, "port1", "sys", "root", "nobody", "nfs");
Assert.assertTrue("doExport failed", _isi.doExport(_device, args, Arrays.asList(export1)).getCommandStatus().equals(Operation.Status.ready.name()));
Assert.assertTrue("doExport failed, export not added to FS", fs.getFsExports().keySet().size() == 1);
// add client
clients.add(client2);
FileExport export2 = new FileExport(clients, "port1", "sys", "root", "nobody", "nfs");
Assert.assertTrue("doExport failed", _isi.doExport(_device, args, Arrays.asList(export2)).getCommandStatus().equals(Operation.Status.ready.name()));
Assert.assertTrue("doExport failed, export not added to FS", fs.getFsExports().keySet().size() == 1);
// create a new export
clients = new ArrayList<String>();
clients.add(client3);
FileExport export3 = new FileExport(clients, "port1", "sys", "rw", "root", "nfs");
Assert.assertTrue("doExport failed", _isi.doExport(_device, args, Arrays.asList(export3)).getCommandStatus().equals(Operation.Status.ready.name()));
Assert.assertTrue("doExport failed, export not added to FS", fs.getFsExports().keySet().size() == 2);
// delete
Assert.assertTrue("doDeleteFs failed", _isi.doDeleteFS(_device, args).getCommandStatus().equals(Operation.Status.ready.name()));
IsilonApi isilonApi = _isi.getIsilonDevice(_device);
try {
isilonApi.listDir(args.getFileObjMountPath(), null);
Assert.assertTrue("File system delete failed: " + args.getFileObjMountPath(), false);
} catch (IsilonException iex) {
System.out.println("doDeleteFS --- delete FS success: " + iex.getCause());
}
}
use of com.emc.storageos.volumecontroller.FileDeviceInputOutput in project coprhd-controller by CoprHD.
the class IsilonFileStorageDeviceTest method testSnapshotDelete.
/**
* Tests snapshot delete with existing SMB shares and NFS exports.
*
* @throws Exception
*/
@Test
public void testSnapshotDelete() throws Exception {
// create FS to use
FileShare fs = new FileShare();
fs.setId(URIUtil.createId(FileShare.class));
fs.setLabel("test");
fs.setCapacity(102400L);
FileDeviceInputOutput args = new FileDeviceInputOutput();
args.addStoragePool(_pool);
args.addFSFileObject(fs);
Assert.assertTrue("doCreateFS failed", _isi.doCreateFS(_device, args).getCommandStatus().equals(Operation.Status.ready.name()));
// create snap
Snapshot snap = new Snapshot();
snap.setId(URIUtil.createId(Snapshot.class));
snap.setLabel("test_snap");
args.addSnapshotFileObject(snap);
Assert.assertTrue("doSnapshotFS failed", _isi.doSnapshotFS(_device, args).getCommandStatus().equals(Operation.Status.ready.name()));
// share snap with SMB
SMBFileShare smbFileShare = new SMBFileShare("TestSMBShare", "Share created by unit test.", "allow", "change", -1);
Assert.assertTrue("SMB share doShare() failed", _isi.doShare(_device, args, smbFileShare).getCommandStatus().equals(Operation.Status.ready.name()));
Assert.assertTrue("SMB share doShare() failed, share not added to snap", snap.getSMBFileShares().keySet().contains(smbFileShare.getName()));
Assert.assertTrue("SMB share doShare() failed, number of shares does not match", snap.getSMBFileShares().keySet().size() == 1);
// add additional share
SMBFileShare smbFileShare01 = new SMBFileShare("TestSMBShare01", "Share created by unit test.", "allow", "change", -1);
Assert.assertTrue("SMB share doShare() failed", _isi.doShare(_device, args, smbFileShare01).getCommandStatus().equals(Operation.Status.ready.name()));
Assert.assertTrue("SMB share doShare() failed, share not added to snap", snap.getSMBFileShares().keySet().contains(smbFileShare01.getName()));
Assert.assertTrue("SMB share doShare() failed, number of shares does not match", snap.getSMBFileShares().keySet().size() == 2);
// add additional share
SMBFileShare smbFileShare02 = new SMBFileShare("TestSMBShare02", "Share created by unit test.", "allow", "change", -1);
Assert.assertTrue("SMB share doShare() failed", _isi.doShare(_device, args, smbFileShare02).getCommandStatus().equals(Operation.Status.ready.name()));
Assert.assertTrue("SMB share doShare() failed, share not added to snap", snap.getSMBFileShares().keySet().contains(smbFileShare02.getName()));
Assert.assertTrue("SMB share doShare() failed, number of shares does not match", snap.getSMBFileShares().keySet().size() == 3);
// export snap
List<String> clients = new ArrayList<String>();
clients.add(client1);
FileExport export1 = new FileExport(clients, "", "sys", "root", "nobody", "nfs");
Assert.assertTrue("doExport failed", _isi.doExport(_device, args, Arrays.asList(export1)).getCommandStatus().equals(Operation.Status.ready.name()));
Assert.assertTrue("doExport failed, export not added to snapshot", snap.getFsExports().keySet().size() == 1);
// add client to the same export
clients.add(client2);
FileExport export2 = new FileExport(clients, "", "sys", "root", "nobody", "nfs");
Assert.assertTrue("doExport failed", _isi.doExport(_device, args, Arrays.asList(export1)).getCommandStatus().equals(Operation.Status.ready.name()));
Assert.assertTrue("doExport failed, export not added to snapshot", snap.getFsExports().keySet().size() == 1);
// create a new export
clients = new ArrayList<String>();
clients.add(client3);
clients.add(client4);
FileExport export3 = new FileExport(clients, "", "sys", "rw", "nobody", "nfs");
Assert.assertTrue("doExport failed", _isi.doExport(_device, args, Arrays.asList(export3)).getCommandStatus().equals(Operation.Status.ready.name()));
Assert.assertTrue("doExport failed, export not added to snapshot", snap.getFsExports().keySet().size() == 2);
// delete snap
Assert.assertTrue("doDeleteSnapshot failed", _isi.doDeleteSnapshot(_device, args).getCommandStatus().equals(Operation.Status.ready.name()));
IsilonApi isilonApi = _isi.getIsilonDevice(_device);
try {
isilonApi.listDir(args.getFileObjMountPath(), null);
Assert.assertTrue("Snapshot delete failed: " + args.getFileObjMountPath(), false);
} catch (IsilonException iex) {
System.out.println("doDeleteSnapshot --- delete snapshot success: " + iex.getCause());
}
// delete file system
Assert.assertTrue("doDeleteFS failed", _isi.doDeleteFS(_device, args).getCommandStatus().equals(Operation.Status.ready.name()));
try {
isilonApi.listDir(args.getFsMountPath(), null);
Assert.assertTrue("FS delete failed: " + args.getFsMountPath(), false);
} catch (IsilonException iex) {
System.out.println("doDeleteFS --- delete FS success: " + iex.getCause());
}
}
use of com.emc.storageos.volumecontroller.FileDeviceInputOutput in project coprhd-controller by CoprHD.
the class IsilonFileStorageDeviceTest method testFileShares.
/**
* Tests file system create, expand, smb share, nfs exports, file system delete.
*
* @throws Exception
*/
@Test
public void testFileShares() throws Exception {
FileShare fs = new FileShare();
fs.setId(URIUtil.createId(FileShare.class));
fs.setLabel("test");
fs.setCapacity(204800L);
FileDeviceInputOutput args = new FileDeviceInputOutput();
args.addStoragePool(_pool);
args.addFSFileObject(fs);
Assert.assertTrue("doCreateFS failed", _isi.doCreateFS(_device, args).getCommandStatus().equals(Operation.Status.ready.name()));
// test expand capacity
args.setNewFSCapacity(102400L);
Assert.assertTrue("doExpandFS failed", _isi.doExpandFS(_device, args).getCommandStatus().equals(Operation.Status.error.name()));
args.setNewFSCapacity(307200L);
Assert.assertTrue("doExpandFS failed", _isi.doExpandFS(_device, args).getCommandStatus().equals(Operation.Status.ready.name()));
// share file system with SMB
SMBFileShare smbFileShare = new SMBFileShare("TestSMBShare", "Share created by unit test.", "allow", "change", -1);
Assert.assertTrue("SMB share doShare() failed", _isi.doShare(_device, args, smbFileShare).getCommandStatus().equals(Operation.Status.ready.name()));
Assert.assertTrue("SMB share doShare() failed, share not added to FS", fs.getSMBFileShares().keySet().contains(smbFileShare.getName()));
Assert.assertTrue("SMB share doShare() failed, number of shares does not match", fs.getSMBFileShares().keySet().size() == 1);
// add additional share
SMBFileShare smbFileShare01 = new SMBFileShare("TestSMBShare01", "Share created by unit test.", "allow", "change", -1);
Assert.assertTrue("SMB share doShare() failed", _isi.doShare(_device, args, smbFileShare01).getCommandStatus().equals(Operation.Status.ready.name()));
Assert.assertTrue("SMB share doShare() failed, share not added to FS", fs.getSMBFileShares().keySet().contains(smbFileShare01.getName()));
Assert.assertTrue("SMB share doShare() failed, number of shares does not match", fs.getSMBFileShares().keySet().size() == 2);
// add additional share
SMBFileShare smbFileShare02 = new SMBFileShare("TestSMBShare02", "Share created by unit test.", "allow", "change", -1);
Assert.assertTrue("SMB share doShare() failed", _isi.doShare(_device, args, smbFileShare02).getCommandStatus().equals(Operation.Status.ready.name()));
Assert.assertTrue("SMB share doShare() failed, share not added to FS", fs.getSMBFileShares().keySet().contains(smbFileShare02.getName()));
Assert.assertTrue("SMB share doShare() failed, number of shares does not match", fs.getSMBFileShares().keySet().size() == 3);
// modify SMB share
smbFileShare02.setDescription("Share was modified.");
Assert.assertTrue("SMB share doShare() for modify failed", _isi.doShare(_device, args, smbFileShare02).getCommandStatus().equals(Operation.Status.ready.name()));
Assert.assertTrue("SMB share doShare() failed, share not added to FS", fs.getSMBFileShares().keySet().contains(smbFileShare02.getName()));
Assert.assertTrue("SMB share doShare() failed, share was not modified", fs.getSMBFileShares().get(smbFileShare02.getName()).getDescription().equals("Share was modified."));
Assert.assertTrue("SMB share doShare() failed, number of shares does not match", fs.getSMBFileShares().keySet().size() == 3);
// delete one SMB share for FS
Assert.assertTrue("SMB share doDeleteShare() failed", _isi.doDeleteShare(_device, args, smbFileShare).getCommandStatus().equals(Operation.Status.ready.name()));
Assert.assertFalse("SMB share doDeleteShare() failed, share was not deleted from FS", fs.getSMBFileShares().keySet().contains(smbFileShare.getName()));
Assert.assertTrue("SMB share doDeleteShare() failed, number of shares does not match", fs.getSMBFileShares().keySet().size() == 2);
// delete all SMB shareds for FS
Assert.assertTrue("SMB share doDeleteShares() failed", _isi.doDeleteShares(_device, args).getCommandStatus().equals(Operation.Status.ready.name()));
Assert.assertTrue("SMB share doDeleteShares() failed, shares were not deleted from FS", fs.getSMBFileShares().isEmpty());
// export
List<String> clients = new ArrayList<String>();
clients.add(client1);
FileExport export1 = new FileExport(clients, "port1", "sys", "root", "nobody", "nfs");
Assert.assertTrue("doExport failed", _isi.doExport(_device, args, Arrays.asList(export1)).getCommandStatus().equals(Operation.Status.ready.name()));
Assert.assertTrue("doExport failed, export not added to FS", fs.getFsExports().keySet().size() == 1);
// add client
clients.add(client2);
FileExport export2 = new FileExport(clients, "port1", "sys", "root", "nobody", "nfs");
Assert.assertTrue("doExport failed", _isi.doExport(_device, args, Arrays.asList(export2)).getCommandStatus().equals(Operation.Status.ready.name()));
Assert.assertTrue("doExport failed, export not added to FS", fs.getFsExports().keySet().size() == 1);
// create a new export
clients = new ArrayList<String>();
clients.add(client3);
FileExport export3 = new FileExport(clients, "port1", "sys", "rw", "root", "nfs");
Assert.assertTrue("doExport failed", _isi.doExport(_device, args, Arrays.asList(export3)).getCommandStatus().equals(Operation.Status.ready.name()));
Assert.assertTrue("doExport failed, export not added to FS", fs.getFsExports().keySet().size() == 2);
// unexport
Assert.assertTrue("doUnexport failed", _isi.doUnexport(_device, args, Arrays.asList(export1)).getCommandStatus().equals(Operation.Status.ready.name()));
Assert.assertTrue("doUnexport failed, export not deleted from FS", fs.getFsExports().keySet().size() == 1);
Assert.assertTrue("doUnexport failed", _isi.doUnexport(_device, args, Arrays.asList(export3)).getCommandStatus().equals(Operation.Status.ready.name()));
Assert.assertTrue("doUnexport failed, export not deleted from FS", fs.getFsExports().keySet().isEmpty());
// delete
Assert.assertTrue("doDeleteFs failed", _isi.doDeleteFS(_device, args).getCommandStatus().equals(Operation.Status.ready.name()));
IsilonApi isilonApi = _isi.getIsilonDevice(_device);
try {
isilonApi.listDir(args.getFileObjMountPath(), null);
Assert.assertTrue("File system delete failed: " + args.getFileObjMountPath(), false);
} catch (IsilonException iex) {
System.out.println("doDeleteFS --- delete FS success: " + iex.getCause());
}
}
Aggregations