Using REST in ENM Ericsson in Python

Hello. Not so long ago, Ericsson released the new Ericsson Network Manager ( ENM ) management system, which has already appeared in some mobile operators. It would be interesting to analyze some questions on working with it and, in this article, we will touch on the issue of working with the Northbound Interface, which has not been seen previously (in OSS-RC), namely the RESTful API. We will use python and the requests library.



Functions such as user administration, CM Bulk Import / Export, Virtual Network Function, collection management, cell management and more are available through the REST interface. The ALEX documentation contains fairly detailed descriptions of the capabilities of this API without being tied to a programming language. As an example, let's try to connect to NBI Cell Management using the requests library for python. The interface description is available in the ALEX library “Configuration Tasks - CM Cell Management REST Northbound Interface”.



The specified functionality allows you to control the configuration of the cells, the neighbors between them, the frequency neighbors on the nodes LTE, WCDMA and GSM within one ENM. It is also possible to manage handovers both towards neighboring ENM and towards OSS-RC.

The RESTful interface is available at the following address:



https: // <customer-domain> / configuration-tasks / v1 / tasks


The structure of the JSON request is:

  • Request URL: "configuration-tasks / v1 / tasks"
  • Request Type: POST
  • Content Type: application / json
  • Body: according to the documentation for the selected team.


In python, use the Session object from the requests library.



import requests import json from requests.packages.urllib3.exceptions import InsecureRequestWarning from requests import Session from requests.exceptions import HTTPError class enmRestSession(Session):
      
      





We weight it with the required ENM authorization and some “default settings”.



  def __init__(self, enm, login, password): super().__init__() #  /        self.enm = enm if enm[-1] == "/" else f"{enm}/" #   self.headers.update({"Content-Type": "application/json"}) #   https  self.verify = False #    requests.packages.urllib3.disable_warnings(InsecureRequestWarning) #    ENM login_str = f"{enm}login?IDToken1={login}&IDToken2={password}" rest_response = self.post(login_str) #      if rest_response.status_code != requests.codes.ok: raise HTTPError()
      
      





Let's make out a method of sending a REST request.



  #        request_body def send_configuration_task(self, request_body): url = f"{self.enm}configuration-tasks/v1/tasks" #    POST    URL resp = self.post(url, data=json.dumps(request_body)) return resp
      
      





Add automatic session closure to ENM when using the context manager.



  def __exit__(self, exc_type, exc_val, exc_tb): try: #      logout self.get(f"{self.enm}logout") finally: super().__exit__(self, exc_type, exc_val, exc_tb)
      
      





The resulting small add-on can be used in scripts for your needs. For example, receiving all cells of an RNC node.



 def main(): param = {"name": "readCells", "fdn": "NetworkElement=RNC01"} with enmRestSession( "https://iegtbl8030-7.gtoss.eng.ericsson.se/", "login", "pass" ) as s: print(s.send_configuration_task(param).json())
      
      





All possible queries are described in the above ALEX library. I don’t think I can publish it anywhere, but I’ll try to answer some questions. Full code is available on GitHub . Thanks to everyone who read.



All Articles