Re: Help with the java opswclient.jar (255 Views)
Reply
Trusted Contributor
sjmh
Posts: 52
Registered: ‎08-03-2012
Message 1 of 4 (288 Views)

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 com.opsware.fido.*;
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 {
            client.connect("mesh1.example.com","steve","test");
            client2.connect("mesh2.example.com","steve","test");
        } catch (AuthenticationException e) {
            System.out.println("Caught auth exception");
        } catch (RemoteException e) {
            System.out.println("Caught remote exception");
        }
    
        client1url = client.getServerURL();
        client2url = client2.getServerURL();
        System.out.println(client1url);
        System.out.println(client2url);
    }
}

 

This will print out 'mesh2.example.com' both times.

 

Any insight to this would be helpful.

 

Thanks.

 

 

 

 

 

Please use plain text.
Valued Contributor
Dimiter Todorov
Posts: 108
Registered: ‎03-02-2010
Message 2 of 4 (263 Views)

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.

 

https://hpln.hp.com/content/it-possible-authenticate-multiple-users-same-java-opswareclient-session

 

Quoted:

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,

Please use plain text.
Trusted Contributor
sjmh
Posts: 52
Registered: ‎08-03-2012
Message 3 of 4 (255 Views)

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.

Please use plain text.
Occasional Visitor
ginu
Posts: 1
Registered: ‎08-01-2013
Message 4 of 4 (206 Views)

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

Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation