CA Configuration Automation

 View Only

 Register Hosts without Agent

Joao Silva's profile image
Joao Silva posted Apr 26, 2023 05:52 PM

Hello,
In our environment we currently have a incompatability issue, regarding Operating System and the CCA Agent. 

We have virtual machines with RHEL 9 installed and the CCA agent does not support this Operating System.

We have already developed a way to collect information about the hosts, but our current issue is regarding registering the host itself in the platform.

We know of two ways: 
- Through the interface, which is a manual process
- Through the SDK, which can be automated using a script.

We have tried to use the documentation available for the SDK, and used the classes and methods available to do this but to no avail. 

While trying to register a new host, we always get the error: Cannot add the server "host" : host

Based on what we know, we think it's because it is trying to do an automatic discovery of the machine, but we don't want it to.

So, my question is how can we do this? Our most basic requirement right now is to just register the new machine in the platform without using the manual process via interface.  I will paste here the code we are using for reference:

package CCACreateNewServer;
 
import java.io.*;
import com.ca.acm.sdk.net.SDKException;
import com.ca.acm.sdk.ci.Server;
import com.ca.acm.sdk.net.ACMSDKService;
import com.ca.acm.sdk.ci.*;
 
public class CCACreateNewServer {
 
    private String url;
    private String username;
    private String password;
    private String server_name;
    private String server_ip;
    
    public CCACreateNewServer(final String par_url, final String par_username, final String par_password, final String par_server, final String par_ip) {
        this.url = "http://" + par_url + "/services/SDKService";
        this.username = par_username;
        this.password = par_password;
        this.server_name = par_server;
        this.server_ip = par_ip;
    }
    
    public void AddNewServer() throws SDKException {
        try {
            System.out.println(">> Locating service for the url: " + this.url);
            if (ACMSDKService.locateService(this.url)) {
                System.out.println(">> Trying to begin session...\n");
                if (ACMSDKService.beginSession(this.username, this.password)) {
                    ACMSDKService.setSessionTimeOut(60);
                    System.out.println(">> Session has been started. Timeout was set to 60 minutes...");
                               
                    Server sv = null;
sv = new Server();
sv.setAttribute("srvr_name", this.server_name);
sv.setAttribute("ip_addr", this.server_ip);
                    sv.setAttribute("os_name","Linux");
if (this.server_ip.indexOf(":") >= 0) {
sv.setAttribute("ipv6_addr", this.server_ip);
} else {
sv.setAttribute("ipv4_addr", this.server_ip);
}
Server serverObj = (Server)sv.add();
String Id = null;
Id = serverObj.getId();
if (serverObj.getId() != "-1") {
System.out.println("Server Success");
}
                }
            }
        }
        catch (Exception ex) {
            System.out.println("\n" + ">> Exception ex: <<" + "\n" + ex);
        }
        finally {
            ACMSDKService.endSession();
            System.out.println("\n" + ">> Session ended <<");
        }
    }
    
    public static void main(final String[] args) throws SDKException {
        System.out.println("\n\n>>>>> Program CCACreateNewServer FS has been started! <<<<<\n");
        
        final CCACreateNewServer CreateServer = new CCACreateNewServer(
                "url:port", 
                "username", 
                "password", 
                "host", 
                "ip_addr" 
        );
        
        CreateServer.AddNewServer();
        System.out.println(">>>>> Program Ended! <<<<<\n");
        
    }
    
}



Can anyone help with this please?

Adnan Hafeezullah's profile image
Broadcom Employee Adnan Hafeezullah

Hi, there are 2 additional ways
1 - You can run a Network Scan, with one of the options that "adds the server to the list", regardless of creds, but having the creds does help in the network credentials set
2 - If you have the list of IPs in a file, you can bulk import them in using actions

Joao Silva's profile image
Joao Silva

Are you able to provide us with an example for the first method please?

And for the second method, i saw there is a thing called ccautil with the import option.. i tried it using the sample provided in the samples folder inside the CCA server installation path but i also got an error.
Are you able to provide us with an example for the second method too please?

What about the code example i provided? Shouldn't it work?

Thanks in advance!

Regards.

Adnan Hafeezullah's profile image
Broadcom Employee Adnan Hafeezullah
Joao Silva's profile image
Joao Silva

Thank you for your response! 
Although our need right now is to automate this process, so that's why we're trying not to use the UI since the register of the server will be made through CA Process Automation.. that's why we created the script, to try to automate the process in which servers are registered in CCA.

So, is it possible to automate this process?

Adnan Hafeezullah's profile image
Broadcom Employee Adnan Hafeezullah

Use the Network Scan / Network Discovery
You can scan the network for all servers and once found, it will be added to the server list automatically

You can also leverage the softagent which will do remote discovery of the servers based on the credentials set; you can even setup Network Realms and do scans of certain IP ranges and assigned them to a group (Network Realm)

Joao Silva's profile image
Joao Silva

Hello! Thanks for your response!

How do we modify the script to use the Network Scan/ Network Discovery?

Thanks!

Joao Silva's profile image
Joao Silva

I managed to add the server with the Network Scan.. now i only have trouble with changing the properties of the server via script..

It seems that i can change the properties of the server with the methods provided, but when i do server.update(); it doesn't update the database...

Do you know if i need to do anything after it?

Does the update() method inherited from the CI class update the database or does it send the information to a different place?

Regards,
Joao