use of com.iwave.ext.netapp.model.ExportsHostnameInfo in project coprhd-controller by CoprHD.
the class FlexFileShare method listNFSExportRules.
@SuppressWarnings("unchecked")
List<ExportsRuleInfo> listNFSExportRules(String pathName) {
List<ExportsRuleInfo> exports = Lists.newArrayList();
NaElement elem = new NaElement("nfs-exportfs-list-rules-2");
// if true, returns entries from exports file; else from memory. For Cluster mode, it is always true.
elem.addNewChild("persistent", String.valueOf(true));
if (StringUtils.isNotBlank(pathName)) {
elem.addNewChild("pathname", pathName);
}
try {
NaElement results = server.invokeElem(elem);
List<NaElement> rules = results.getChildByName("rules").getChildren();
for (NaElement rule : rules) {
ExportsRuleInfo exportsRuleInfo = new ExportsRuleInfo();
exportsRuleInfo.setActualPathname(rule.getChildContent("actual-pathname"));
exportsRuleInfo.setPathname(rule.getChildContent("pathname"));
for (NaElement securityRule : (List<NaElement>) rule.getChildByName("security-rules").getChildren()) {
SecurityRuleInfo securityRuleInfo = new SecurityRuleInfo();
securityRuleInfo.setAnon(securityRule.getChildContent("anon"));
// String nonsuid = securityRule.getChildContent("nonsuid"); // This is not correct.. Modified by [Gopi] as per API.
String nonsuid = securityRule.getChildContent("nosuid");
if (StringUtils.isNotBlank(nonsuid)) {
securityRuleInfo.setNosuid(Boolean.parseBoolean(nonsuid));
}
List<NaElement> secFlavors = (List<NaElement>) securityRule.getChildByName("sec-flavor").getChildren();
for (NaElement secFlavor : secFlavors) {
if (secFlavor != null) {
if (securityRuleInfo.getSecFlavor() != null) {
securityRuleInfo.setSecFlavor(securityRuleInfo.getSecFlavor() + "," + secFlavor.getChildContent("flavor"));
} else {
securityRuleInfo.setSecFlavor(secFlavor.getChildContent("flavor"));
}
}
}
List<ExportsHostnameInfo> readOnly = extractExportsHostnameInfos(securityRule.getChildByName("read-only"));
securityRuleInfo.getReadOnly().addAll(readOnly);
List<ExportsHostnameInfo> readWrite = extractExportsHostnameInfos(securityRule.getChildByName("read-write"));
securityRuleInfo.getReadWrite().addAll(readWrite);
List<ExportsHostnameInfo> root = extractExportsHostnameInfos(securityRule.getChildByName("root"));
securityRuleInfo.getRoot().addAll(root);
exportsRuleInfo.getSecurityRuleInfos().add(securityRuleInfo);
}
exports.add(exportsRuleInfo);
}
return exports;
} catch (Exception e) {
String msg = "Failed to list NFS exports.";
log.error(msg, e);
throw new NetAppCException(msg, e);
}
}
use of com.iwave.ext.netapp.model.ExportsHostnameInfo in project coprhd-controller by CoprHD.
the class FileShare method listNFSExportRules.
@SuppressWarnings("unchecked")
List<ExportsRuleInfo> listNFSExportRules(String pathName) {
List<ExportsRuleInfo> exports = Lists.newArrayList();
NaElement elem = new NaElement("nfs-exportfs-list-rules-2");
// if true, returns entries from exports file; else from memory
elem.addNewChild("persistent", String.valueOf(false));
if (StringUtils.isNotBlank(pathName)) {
elem.addNewChild("pathname", pathName);
}
try {
NaElement results = server.invokeElem(elem);
List<NaElement> rules = results.getChildByName("rules").getChildren();
for (NaElement rule : rules) {
ExportsRuleInfo exportsRuleInfo = new ExportsRuleInfo();
exportsRuleInfo.setActualPathname(rule.getChildContent("actual-pathname"));
exportsRuleInfo.setPathname(rule.getChildContent("pathname"));
for (NaElement securityRule : (List<NaElement>) rule.getChildByName("security-rules").getChildren()) {
SecurityRuleInfo securityRuleInfo = new SecurityRuleInfo();
securityRuleInfo.setAnon(securityRule.getChildContent("anon"));
// String nonsuid = securityRule.getChildContent("nonsuid"); // This is not correct.. Modified by [Gopi] as per API.
String nonsuid = securityRule.getChildContent("nosuid");
if (StringUtils.isNotBlank(nonsuid)) {
securityRuleInfo.setNosuid(Boolean.parseBoolean(nonsuid));
}
List<NaElement> secFlavors = (List<NaElement>) securityRule.getChildByName("sec-flavor").getChildren();
for (NaElement secFlavor : secFlavors) {
if (secFlavor != null) {
if (securityRuleInfo.getSecFlavor() != null) {
securityRuleInfo.setSecFlavor(securityRuleInfo.getSecFlavor() + "," + secFlavor.getChildContent("flavor"));
} else {
securityRuleInfo.setSecFlavor(secFlavor.getChildContent("flavor"));
}
}
}
List<ExportsHostnameInfo> readOnly = extractExportsHostnameInfos(securityRule.getChildByName("read-only"));
securityRuleInfo.getReadOnly().addAll(readOnly);
List<ExportsHostnameInfo> readWrite = extractExportsHostnameInfos(securityRule.getChildByName("read-write"));
securityRuleInfo.getReadWrite().addAll(readWrite);
List<ExportsHostnameInfo> root = extractExportsHostnameInfos(securityRule.getChildByName("root"));
securityRuleInfo.getRoot().addAll(root);
exportsRuleInfo.getSecurityRuleInfos().add(securityRuleInfo);
}
exports.add(exportsRuleInfo);
}
return exports;
} catch (Exception e) {
String msg = "Failed to list NFS exports.";
log.error(msg, e);
throw new NetAppException(msg, e);
}
}
use of com.iwave.ext.netapp.model.ExportsHostnameInfo in project coprhd-controller by CoprHD.
the class FileShare method extractExportsHostnameInfos.
private List<ExportsHostnameInfo> extractExportsHostnameInfos(NaElement elem) {
List<ExportsHostnameInfo> exportsHostnameInfos = Lists.newArrayList();
if (elem != null && elem.getChildren() != null) {
for (NaElement exportsHostname : (List<NaElement>) elem.getChildren()) {
ExportsHostnameInfo exportsHostnameInfo = new ExportsHostnameInfo();
String allHosts = exportsHostname.getChildContent("all-hosts");
if (StringUtils.isNotBlank(allHosts)) {
exportsHostnameInfo.setAllHosts(Boolean.parseBoolean(allHosts));
}
exportsHostnameInfo.setName(exportsHostname.getChildContent("name"));
String negate = exportsHostname.getChildContent("negate");
if (StringUtils.isNotBlank(negate)) {
exportsHostnameInfo.setNegate(Boolean.parseBoolean(negate));
}
exportsHostnameInfos.add(exportsHostnameInfo);
}
}
return exportsHostnameInfos;
}
use of com.iwave.ext.netapp.model.ExportsHostnameInfo in project coprhd-controller by CoprHD.
the class MiscTests method test2.
@Test
public void test2() {
// NaElement result = server.invoke("nfs-exportfs-list-rules");
// NetAppUtils.output(result);
List<ExportsRuleInfo> bla = netAppFacade.listNFSExportRules(null);
for (ExportsRuleInfo exportsRuleInfo : bla) {
System.out.println("Pathname: " + exportsRuleInfo.getPathname());
System.out.println("Actual Pathname: " + exportsRuleInfo.getActualPathname());
for (SecurityRuleInfo securityRuleInfo : exportsRuleInfo.getSecurityRuleInfos()) {
System.out.println(" -- anon: " + securityRuleInfo.getAnon());
System.out.println(" -- nosuid: " + securityRuleInfo.getNosuid());
System.out.println(" -- sec-flavor: " + securityRuleInfo.getSecFlavor());
for (ExportsHostnameInfo exportsHostnameInfo : securityRuleInfo.getReadOnly()) {
System.out.println(" ---- ReadOnly: " + exportsHostnameInfo.getAllHosts() + " " + exportsHostnameInfo.getName() + " " + exportsHostnameInfo.getNegate());
}
for (ExportsHostnameInfo exportsHostnameInfo : securityRuleInfo.getReadWrite()) {
System.out.println(" ---- ReadWrite: " + exportsHostnameInfo.getAllHosts() + " " + exportsHostnameInfo.getName() + " " + exportsHostnameInfo.getNegate());
}
for (ExportsHostnameInfo exportsHostnameInfo : securityRuleInfo.getRoot()) {
System.out.println(" ---- Root: " + exportsHostnameInfo.getAllHosts() + " " + exportsHostnameInfo.getName() + " " + exportsHostnameInfo.getNegate());
}
}
}
}
use of com.iwave.ext.netapp.model.ExportsHostnameInfo in project coprhd-controller by CoprHD.
the class NetAppClusterModeCommIntf method createUnManagedExport.
private UnManagedFSExport createUnManagedExport(ExportsRuleInfo export, List<ExportsHostnameInfo> typeHosts, String permission, String port) {
List<String> clientList = new ArrayList<String>();
UnManagedFSExport tempUnManagedFSExport = null;
if ((null != typeHosts) && (!typeHosts.isEmpty())) {
for (ExportsHostnameInfo client : typeHosts) {
boolean negate = false;
if (client.getNegate() != null) {
negate = client.getNegate();
}
if (!negate) {
if ((null != client.getName() && !(clientList.contains(client.getName())))) {
if (!clientList.contains(client.getName())) {
clientList.add(client.getName());
}
} else if ((null != client.getAllHosts()) && (client.getAllHosts())) {
// All hosts means empty clientList in ViPR.
clientList.clear();
_logger.info("Settng ClientList to empty as the export is meant to be accsible to all hosts");
}
}
}
String anon = export.getSecurityRuleInfos().get(0).getAnon();
if ((null != anon) && (anon.equals(ROOT_UID))) {
anon = ROOT_USER_ACCESS;
} else {
anon = DEFAULT_ANONMOUS_ACCESS;
}
tempUnManagedFSExport = new UnManagedFSExport(clientList, port, port + ":" + export.getPathname(), export.getSecurityRuleInfos().get(0).getSecFlavor(), permission, anon, NFS, port, export.getPathname(), export.getPathname());
}
return tempUnManagedFSExport;
}
Aggregations