com.hp.ucmdb.discovery.library.clients
Class BaseClient

java.lang.Object
  extended by com.hp.ucmdb.discovery.library.clients.BaseClient
Direct Known Subclasses:
JmxClient, QueryClient, SAPClient, ShellClient, VmwareClient

public abstract class BaseClient
extends java.lang.Object

The BaseClient provides services for running specific protocol commands. When a Client instance is created, it is already connected to its destination. Use the ClientFactory class to create the client.
All supported clients inherit from the Base Client. This class supplies the basic APIs, such as getting the protocol timeout, retrieving the credential Id , getting username, and others. These APIs can be used from all Client instances. Each client is associated with one of the protocols defined in ClientsConsts. By default, the Client uses all the properties defined in its credentials. However, the defaults can be overridden by supplying custom properties when the client is created.


        props = Properties()
        # Here we overide timeout property defined in wmi protocol with new value - 60 sec
        props.setProperty(Protocol.PROTOCOL_ATTRIBUTE_TIMEOUT, "60000")
        wmiClient = Framework.getClientFactory().createClient(props)
 
Call the close() method when finished working with the client.

See Also:
ClientFactory, ClientsConsts

Field Summary
static java.lang.String CREDENTIALS_ID
           
static java.lang.String ENCODING
           
 
Method Summary
 void close()
          Releases the resources allocated to the client.
 java.lang.String getClientType()
          Returns the client's protocol name.
 java.lang.String getCredentialId()
          Returns the ID of the credentials used to connect.
 java.lang.String getIpAddress()
          Returns the IP to which the client is connected.
 java.lang.String getProperty(java.lang.String propertyName)
          Returns the value of the specified property.
 java.lang.String getShellCmdSeperator()
          Returns the character used to separate multiple commands on a command line.
 java.lang.String getSudoCommands()
           
 java.lang.String getSudoPaths()
          Return a string which represents comma-separated possible paths of a sudo commands
 int getTimeout()
          Returns the timeout for connection set in the protocol definition.
 java.lang.String getUserName()
          Returns the username set in the protocol definition that is used for connection.
 boolean isConnected()
          Checks if the client is connected.
 boolean supportsSudo()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENCODING

public static final java.lang.String ENCODING
See Also:
Constant Field Values

CREDENTIALS_ID

public static final java.lang.String CREDENTIALS_ID
Method Detail

supportsSudo

public boolean supportsSudo()

getUserName

public java.lang.String getUserName()
                             throws java.lang.Exception
Returns the username set in the protocol definition that is used for connection. The name can be overidden when creating the client.

Returns:
The username
Throws:
java.lang.Exception

getTimeout

public int getTimeout()
               throws java.lang.Exception
Returns the timeout for connection set in the protocol definition. The timeout can be overidden when creating the client.

Returns:
The timeout in milliseconds
Throws:
java.lang.Exception

isConnected

public boolean isConnected()
Checks if the client is connected.

Returns:
true if the client successfully connected

getCredentialId

public java.lang.String getCredentialId()
Returns the ID of the credentials used to connect. When the agent CI (wmi, snmp, telnet, ssh, and so on) is created in the UCMDB system, one of its attributes contains this parameter.
If the protocol credential is deleted and recreated, any previously retrieved value is invalid.

Returns:
The credential client ID

close

public void close()
           throws java.lang.Exception
Releases the resources allocated to the client. You must call close when finished using the client.

Throws:
java.lang.Exception

getProperty

public java.lang.String getProperty(java.lang.String propertyName)
Returns the value of the specified property. If the value is not available in 'this' object, searchs in the trigger CI data and the framework.

Returns:
The value. If property not found, returns null.

getClientType

public java.lang.String getClientType()
Returns the client's protocol name.

Returns:
The client type
See Also:
com.hp.ucmdb.discovery.probe.clients.ClientsConsts

getIpAddress

public java.lang.String getIpAddress()
Returns the IP to which the client is connected.

Returns:
An IP address

getShellCmdSeperator

public java.lang.String getShellCmdSeperator()
                                      throws java.lang.Exception
Returns the character used to separate multiple commands on a command line.

Returns:
The operating system specific separator
Throws:
java.lang.Exception

getSudoPaths

public java.lang.String getSudoPaths()
                              throws java.lang.Exception
Return a string which represents comma-separated possible paths of a sudo commands

Throws:
java.lang.Exception

getSudoCommands

public java.lang.String getSudoCommands()
                                 throws java.lang.Exception
Returns:
string which represents comma-separated commands names which should be ran with sudo command
Throws:
java.lang.Exception


Documentation Feedback
Copyright 2010 Hewlett-Packard Development Company, L.P.