SUSE Manager and the A-REST API | SUSE Communities

SUSE Manager and the A-REST API

Share
Share

What is SUSE Manager? 

SUSE Manager is an open-source infrastructure management solution designed to simplify and secure your entire mixed Linux environment. Some of the core benefits of SUSE Manager are:

  • Maintain infrastructure security & compliance<
  • Centralized control and reporting at any scale: from 10 to 1 million clients theoretically — from a single console. (In production with +20.000 clients)
  • Manage almost any Linux, anywhere: at the core, on the edge, or in the cloud(s)

As our motto goes, “Any Linux, anywhere, any scale”.  

SUSE Manager, or SUMA for short, is completely open source, for which you have an upstream project, where we work as a community on getting contributions and engagement anyone involved, which is called Uyuni. 

 

How to use it? 

SUSE manager provides a web UI to the operators, which is designed to help with the day-to-day tasks. Operators can have an overlook of the systems landscape and schedule action for the registered systems. 

To enhance automation and facilitate integration with external tools, we have made available an API. This API offers all the options available in the web UI, and even goes beyond by providing additional features optimized for managing large-scale environments and systems integration. With the API, you can streamline your workflows, enhance your productivity, and achieve your goals faster and more efficiently. 

The API flexibility allows SUSE Manager to be used as the central management platform for all your Linux based infrastructure. The API is available in two flavors: the original XML-RPC and the modern JSON based. This second option is the one that we will review in the next point. 

The A-REST JSON API 

SUSE Manager JSON based API is an “Almost”-REST API, that’s why we refer to it as the A-REST. The JSON over HTTP(S) API is not a RESTful API, but it behaves completely like it. Anyone who has used a RESTful API will feel completely at home when using the SUMA A-REST API. 

What are the differences then?  

  • Well, it does GET like REST, and it also does POST like REST. Easy. 
  • But it doesn’t PUT or DELETE like REST, but slightly differently. 

Users should use GET in calls that only retrieve data from the application which doesn’t make any changes. A call that will transform data should be made using the POST HTTP method.
This means that to update an entity, users should make a POST call with the desired state instead of making a PUT request. 

To delete you make a POST request to a specific endpoint, which has “delete” in the name, like “channel/software/delete”. 

This means that the methods are simpler and easier to use in an A-REST API, but familiar to anyone that knows how to use a RESTful API. 

Feeling overwhelmed or uncertain about the available endpoints and corresponding HTTP methods? No need to worry!, we have an extensive documentation resource at your disposal, providing clear and concise information regarding the available endpoints and the suitable HTTP methods to be utilized.

Simply visit https://documentation.suse.com/suma/api/suse-manager/index.html to access this invaluable resource.
 

Here is an example of how to integrate with the SUSE Manager API using python 3.  

SUSE Manager python3 API integration 

#!/usr/bin/env python3
import requests
import pprint
 
MANAGER_URL = "https://manager.example.com/rhn/manager/api"
MANAGER_LOGIN = "username"
MANAGER_PASSWORD = "password"
SSLVERIFY = "/path/to/CA" # or False to disable verify;
 
data = {"login": MANAGER_LOGIN, "password": MANAGER_PASSWORD}
response = requests.post(MANAGER_URL + '/auth/login', json=data, verify=SSLVERIFY)
print("LOGIN: {}:{}".format(response.status_code, response.json()))
 
cookies = response.cookies
active_systems = requests.get(MANAGER_URL + '/system/listActiveSystems', cookies=cookies, verify=SSLVERIFY)
print("RETCODE: {}".format(active_systems.status_code))
pprint.pprint(active_systems.json())
 
logout = requests.post(MANAGER_URL + '/auth/logout', cookies=cookies, verify=SSLVERIFY)
print("RETCODE: {}".format(logout.status_code))  

This simple code snippet shows how to log in and get a list of all your registered servers in JSON format. Easy, isn’t it? 

Want to know more? 

You may find more examples in the SUSE Manager documentation: 

https://documentation.suse.com/suma/api/suse-manager/api/scripts/json-http-get.html 

And don’t forget about our YouTube playlists with additional technical content related to SUSE Manager: 

Share
Avatar photo
4,112 views
Ricardo Mateus Software Engineer and Architect for SUSE Manager product.