Package com.mks.api

Examples of com.mks.api.CmdRunner


            logger.info( "Using a common session.  Connection information is obtained from client preferences" );
            session = ip.getCommonSession();
        }
        // Test the connection to the MKS Integrity Server
        Command ping = new Command( Command.SI, "connect" );
        CmdRunner cmdRunner = session.createCmdRunner();
        // Initialize the command runner with valid connection information
        if ( null != host && host.length() > 0 )
        {
            cmdRunner.setDefaultHostname( host );
        }
        if ( portNum > 0 )
        {
            cmdRunner.setDefaultPort( portNum );
        }
        if ( null != user && user.length() > 0 )
        {
            cmdRunner.setDefaultUsername( user );
        }
        if ( null != paswd && paswd.length() > 0 )
        {
            cmdRunner.setDefaultPassword( paswd );
        }
        // Execute the connection
        Response res = cmdRunner.execute( ping );
        logger.debug( res.getCommandString() + " returned exit code " + res.getExitCode() );
        // Initialize class variables based on the connection information
        hostName = res.getConnectionHostname();
        port = res.getConnectionPort();
        userName = res.getConnectionUsername();
        password = paswd;
        cmdRunner.release();
        logger.info( "Successfully established connection " + userName + "@" + hostName + ":" + port );
        return res;
    }
View Full Code Here


            logger.info( "Using a common session.  Connection information is obtained from client preferences" );
            session = ip.getCommonSession();
        }
        // Test the connection to the MKS Integrity Server
        Command ping = new Command( Command.SI, "connect" );
        CmdRunner cmdRunner = session.createCmdRunner();
        // Initialize the command runner with valid connection information
        if ( null != host && host.length() > 0 )
        {
            cmdRunner.setDefaultHostname( host );
        }
        if ( portNum > 0 )
        {
            cmdRunner.setDefaultPort( portNum );
        }
        if ( null != user && user.length() > 0 )
        {
            cmdRunner.setDefaultUsername( user );
        }
        if ( null != paswd && paswd.length() > 0 )
        {
            cmdRunner.setDefaultPassword( paswd );
        }
        // Execute the connection
        Response res = cmdRunner.execute( ping );
        logger.debug( res.getCommandString() + " returned exit code " + res.getExitCode() );
        // Initialize class variables based on the connection information
        hostName = res.getConnectionHostname();
        port = res.getConnectionPort();
        userName = res.getConnectionUsername();
        password = paswd;
        cmdRunner.release();
        logger.info( "Successfully established connection " + userName + "@" + hostName + ":" + port );
        return res;
    }
View Full Code Here

     * @throws APIException
     */
    public Response runCommand( Command cmd )
        throws APIException
    {
        CmdRunner cmdRunner = session.createCmdRunner();
        cmdRunner.setDefaultHostname( hostName );
        cmdRunner.setDefaultPort( port );
        cmdRunner.setDefaultUsername( userName );
        if ( null != password && password.length() > 0 )
        {
            cmdRunner.setDefaultPassword( password );
        }
        Response res = cmdRunner.execute( cmd );
        logger.debug( res.getCommandString() + " returned exit code " + res.getExitCode() );
        cmdRunner.release();
        return res;
    }
View Full Code Here

     * @throws APIException
     */
    public Response runCommandAs( Command cmd, String impersonateUser )
        throws APIException
    {
        CmdRunner cmdRunner = session.createCmdRunner();
        cmdRunner.setDefaultHostname( hostName );
        cmdRunner.setDefaultPort( port );
        cmdRunner.setDefaultUsername( userName );
        if ( null != password && password.length() > 0 )
        {
            cmdRunner.setDefaultPassword( password );
        }
        cmdRunner.setDefaultImpersonationUser( impersonateUser );
        Response res = cmdRunner.execute( cmd );
        logger.debug( res.getCommandString() + " returned exit code " + res.getExitCode() );
        cmdRunner.release();
        return res;
    }
View Full Code Here

TOP

Related Classes of com.mks.api.CmdRunner

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.