Search in sources :

Example 1 with NetAppCException

use of com.iwave.ext.netappc.NetAppCException in project coprhd-controller by CoprHD.

the class NetAppClusterFacade method setQTreeOplocks.

/**
 * Sets the q tree oplocks.
 *
 * @param qtreePath the qtree path
 * @param oplocks the oplocks
 */
public void setQTreeOplocks(String qtreePath, String oplocks) {
    String infoString = "NetAppFacade::setQTreeOplocks -> Trying to set oplocks = " + oplocks + " on qtree = " + qtreePath;
    log.info(infoString);
    NaElement elem = new NaElement("system-cli");
    NaElement argsarray = new NaElement("args");
    argsarray.addChildElem(new NaElement("arg", "qtree"));
    argsarray.addChildElem(new NaElement("arg", "oplocks"));
    argsarray.addChildElem(new NaElement("arg", qtreePath));
    argsarray.addChildElem(new NaElement("arg", oplocks));
    elem.addChildElem(argsarray);
    try {
        server.getNaServer().invokeElem(elem);
    } catch (Exception e) {
        String msg = "NetAppFacade::setQTreeOplocks -> Failed to invoke CLI command ";
        log.error(msg, e);
        throw new NetAppCException(msg, e);
    }
}
Also used : NetAppCException(com.iwave.ext.netappc.NetAppCException) NaElement(netapp.manage.NaElement) NetAppCException(com.iwave.ext.netappc.NetAppCException)

Example 2 with NetAppCException

use of com.iwave.ext.netappc.NetAppCException in project coprhd-controller by CoprHD.

the class NetAppClusterFacade method invokeCliCommand.

/**
 * Invokes a CLI command through the API.
 *
 * @param args the args
 * @return the string
 */
public String invokeCliCommand(String[] args) {
    String cliResult;
    NaElement elem = new NaElement("system-cli");
    NaElement argsarray = new NaElement("args");
    for (int i = 0; i < args.length; i++) {
        argsarray.addNewChild("arg", args[i]);
    }
    elem.addChildElem(argsarray);
    // Call the NetApp API
    try {
        NaElement result = server.getNaServer().invokeElem(elem);
        cliResult = result.getChildContent("cli-output");
        return cliResult;
    } catch (Exception e) {
        String msg = "Failed to invoke CLI command ";
        log.error(msg, e);
        throw new NetAppCException(msg, e);
    }
}
Also used : NetAppCException(com.iwave.ext.netappc.NetAppCException) NaElement(netapp.manage.NaElement) NetAppCException(com.iwave.ext.netappc.NetAppCException)

Example 3 with NetAppCException

use of com.iwave.ext.netappc.NetAppCException in project coprhd-controller by CoprHD.

the class NetAppClusterFacade method systemInfo.

/**
 * get array system-info.
 *
 * @return map of name/values as returned from system-get-node-info-iter API
 */
public Map<String, String> systemInfo() {
    HashMap<String, String> info = new HashMap<String, String>();
    NaElement elem = new NaElement("system-get-node-info-iter");
    NaElement attributesList = null;
    try {
        List outputElements = (List) server.getNaServer().invokeElem(elem).getChildByName("attributes-list").getChildren();
        Iterator iter = outputElements.iterator();
        while (iter.hasNext()) {
            attributesList = (NaElement) iter.next();
            for (NaElement child : (List<NaElement>) attributesList.getChildren()) {
                String name = child.getName();
                info.put(name, child.getContent());
            }
        }
        return info;
    } catch (Exception e) {
        String msg = "Failed to get array system info";
        log.error(msg, e);
        throw new NetAppCException(msg, e);
    }
}
Also used : HashMap(java.util.HashMap) NetAppCException(com.iwave.ext.netappc.NetAppCException) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) NaElement(netapp.manage.NaElement) NetAppCException(com.iwave.ext.netappc.NetAppCException)

Example 4 with NetAppCException

use of com.iwave.ext.netappc.NetAppCException in project coprhd-controller by CoprHD.

the class NetAppClusterFacade method systemVersion.

/**
 * get array system-info.
 *
 * @return map of name/values as returned from system-get-info API
 */
public Map<String, String> systemVersion() {
    HashMap<String, String> info = new HashMap<String, String>();
    NaElement elem = new NaElement("system-get-version");
    NaElement result = null;
    try {
        result = server.getNaServer().invokeElem(elem).getChildByName("version");
        if (result != null) {
            String name = result.getName();
            info.put(name, result.getContent());
        }
        result = server.getNaServer().invokeElem(elem).getChildByName("is-clustered");
        if (result != null) {
            String name = result.getName();
            info.put(name, result.getContent());
        }
        return info;
    } catch (Exception e) {
        String msg = "Failed to get array system version " + e.getMessage();
        log.error(msg, e);
        throw new NetAppCException(msg, e);
    }
}
Also used : HashMap(java.util.HashMap) NetAppCException(com.iwave.ext.netappc.NetAppCException) NaElement(netapp.manage.NaElement) NetAppCException(com.iwave.ext.netappc.NetAppCException)

Aggregations

NetAppCException (com.iwave.ext.netappc.NetAppCException)4 NaElement (netapp.manage.NaElement)4 HashMap (java.util.HashMap)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1