Absent Member.
Absent Member.

UCMDB Tip: How to build a connection to UCMDB API from python?

This is an example:

import com.hp.ucmdb.api.*; import java.net.MalformedURLException; /** * This is a sample of how to establish a connection to the UCMDB server. * This sample is connecting to the server according to the constants below. */ public class Connection {     //Server Address     public static final String HOST ="";     //Server Protocol     public static final String PROTOCOL ="http";     //Server Port     public static final int PORT = 8080;         //Credentials     private static final String USER_NAME = "admin";     private static final String PASSWORD = "admin";     /**      * Creates a UCMDB SDK connection.      *      * @throws java.net.MalformedURLException in case of a wrong host/protocol/port input      */     public static void createSDKConnection() throws MalformedURLException {         //Creating a service provider for a given UCMDB server address         UcmdbServiceProvider serviceProvider = UcmdbServiceFactory.getServiceProvider(PROTOCOL, HOST, PORT);         //Creating a client context according to the name of this integration (for auditing)         ClientContext clientContext = serviceProvider.createClientContext("MyAppName");         //Creating the credentials for authentication         Credentials credentials = serviceProvider.createCredentials(USER_NAME, PASSWORD);         // Creating the connection object         /serviceProvider.connect(credentials,clientContext);

        System.out.println("Connected to uCMDB server \"" + HOST + "\" on port " + PORT);      }


public static void main(String[] args) {
try {   Connection.createSDKConnection(); } catch (Exception e) {   System.out.println("Failed to connect");   e.printStackTrace(); }
} } // end main()

Best regards,
Andrei Matei
uCMDB Support Engineer

“HP Support
If you find that this or any post resolves your issue, please be sure to mark it as an accepted solution.”
Labels (1)
Tags (1)
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.