Server Automation Practitioners Forum

Help with the java opswclient.jar

Honored Contributor.

Help with the java opswclient.jar

Does anyone have any experience using the opswclient.jar?


We have a situation where we need to write a single script that connects to two different meshes.  I'm looking at the twist docs, and the inital OpswareClient object, but I can't see how to create multiple connections.


The 'connect' method states:



Create a connection to the specified Opsware server. Once a connection is formed, the connection remains for duration of the application until it is explicitly disconnected or a new connection is formed in favor of the existing connection. Only one connection to an Opsware server can exist at any given time, though multiple users may share the same connection. Multiple connections can exist if each connection is directed at a unique Opsware server. Each connection is robust in it will attempt to automatically reconnect if a network failure is detected, or a laptop revives from a sleep state. By default, the connection uses IIOP/HTTPS to connect to the Opsware server.



It does state 'Multiple connections can exist if each connection is directed at a unique Opsware server.', which is why I'm guessing this *can* work, but it sure doesn't seem to - When I try to connect to the second mesh, it just overwrites the original object with the new connection.  Looking at OpswClientEndpoint, it states that it's a singleton, so I'm afraid that the documentation is wrong.


Here's some quick dummy code:


import com.opsware.client.*;
import java.rmi.*;

public class ClientTest {
    public static void main(String[] args) {
        OpswareClient client = new OpswareClient();
        OpswareClient client2 = new OpswareClient();
        String client1url;
        String client2url;
        try {
        } catch (AuthenticationException e) {
            System.out.println("Caught auth exception");
        } catch (RemoteException e) {
            System.out.println("Caught remote exception");
        client1url = client.getServerURL();
        client2url = client2.getServerURL();


This will print out '' both times.


Any insight to this would be helpful.








Dimiter Todorov
Honored Contributor.

Re: Help with the java opswclient.jar

Im having a similar issue issue. I wrap java with jruby. I think the OpswareEndpoint would be useful, but havent found out how I would do it.



I have had a web-app in development for a while using the Java API for twist. I am using JRUBY and Sinatra for the front-end.


One problem I have had is that I cannot switch the permission context of the app based on the user accessing it. 


This has led me to have to custom-code privileges in my own app which is essentially running as a super-user.


What I want is for a user to log in and be authenticated agains the twist similar to the OCC, after which that session is bound by that user's SA boundaries.


The twists docs say a connection can be shared, however I have yet to find out how,

Honored Contributor.

Re: Help with the java opswclient.jar

Yeah, the OpswClientEndPoint is the actual singleton.  OpswareClient is just a wrapper around it.


The way we're attempting to do it now is that we spawn off multiple processes for each Core connection and then communicate between the processes w/ sockets.


It's a pain and totally unnecessary, but Support says it's a Prof. Services issue, so can't help at all.

New Member.

Re: Help with the java opswclient.jar

Hi i was trying to  open the twister docs on the browser and this https://<HOST IP>/twister/docs/index.html,but i get a blank page ,is there any way that i can view this  twister docs