134
Version 7.0b | Last Updated 2018-01-10 Copyright ©2004-2017 NetBrain Technologies, Inc. All rights reserved. NetBrain ® Integrated Edition 7.0 API and System Integration Guide

NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

  • Upload
    others

  • View
    28

  • Download
    0

Embed Size (px)

Citation preview

Page 1: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

Version 7.0b | Last Updated 2018-01-10 Copyright ©2004-2017 NetBrain Technologies, Inc. All rights reserved.

NetBrain® Integrated Edition 7.0 API and System Integration Guide

Page 2: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

Contents

1. Introduction ................................................................................................................................................................................. 5

2. Single Pane of Glass ................................................................................................................................................................... 6

2.1. Workflow ............................................................................................................................................................................... 6

2.1.1. Defining an API Plugin............................................................................................................................................... 6

2.1.2. Adding an API Server ............................................................................................................................................... 10

2.1.3. Using API Data in NetBrain .................................................................................................................................... 11

2.2. Writing an API Plugin ........................................................................................................................................................ 13

3. API-Triggered Diagnosis .......................................................................................................................................................... 19

3.1. Adding API-Triggered Tasks in NetBrain ...................................................................................................................... 19

3.2. Calling Tasks in Third-Party Systems ............................................................................................................................ 20

3.3. Viewing Task Results ........................................................................................................................................................ 22

4. Pop-up API Stub ........................................................................................................................................................................ 24

4.1. Adding an API Vendor ...................................................................................................................................................... 27

5. Single Source of Truth .............................................................................................................................................................. 28

5.1. Login .................................................................................................................................................................................... 31

5.2. SetCurrentDomain ............................................................................................................................................................ 32

5.3. Logout.................................................................................................................................................................................. 33

5.4. GetDevicesByIP .................................................................................................................................................................. 34

5.5. GetDeviceAttribute ........................................................................................................................................................... 36

5.6. GetInterfaceAttribute ....................................................................................................................................................... 39

5.7. GetModuleAttribute ......................................................................................................................................................... 42

5.8. GetAllInterfaces ................................................................................................................................................................. 44

5.9. GetAllModules ................................................................................................................................................................... 45

Page 3: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

5.10. CalcPath .......................................................................................................................................................................... 47

5.11. GetPath ........................................................................................................................................................................... 49

5.12. AddIPforDiscovery ........................................................................................................................................................ 50

5.13. RemoveIPforDiscovery ................................................................................................................................................. 52

5.14. RemoveAllIPforDiscovery ............................................................................................................................................ 54

5.15. RunDiscoveryNow ......................................................................................................................................................... 55

5.16. DiscoverIPNow .............................................................................................................................................................. 57

5.17. GetDiscoveryIPResult ................................................................................................................................................... 58

5.18. DeleteDevice .................................................................................................................................................................. 60

5.19. CreateDeviceAttribute.................................................................................................................................................. 61

5.20. SetDeviceAttribute ........................................................................................................................................................ 63

5.21. SetInterfaceAttribute .................................................................................................................................................... 64

5.22. CreateInterfaceAttribute ............................................................................................................................................. 67

5.23. CreateModuleAttribute ................................................................................................................................................ 69

5.24. SetModuleAttribute ...................................................................................................................................................... 70

5.25. DeleteDeviceAttribute .................................................................................................................................................. 72

5.26. DeleteInterfaceAttribute.............................................................................................................................................. 73

5.27. DeleteModuleAttribute ................................................................................................................................................ 74

5.28. RebuildL3Topology ....................................................................................................................................................... 75

5.29. GetGroupDevices .......................................................................................................................................................... 76

5.30. GetDeviceProxyServer ................................................................................................................................................. 77

5.31. GetAvailableTenants .................................................................................................................................................... 79

5.32. AddUser .......................................................................................................................................................................... 79

5.33. ModifyUser ..................................................................................................................................................................... 82

5.34. DeleteUser ...................................................................................................................................................................... 84

5.35. GetDeviceData ............................................................................................................................................................... 85

5.36. AddBenchmarkTask ..................................................................................................................................................... 87

Page 4: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

5.37. EditBenchmarkTask ...................................................................................................................................................... 90

5.38. DeleteBenchmarkTask ................................................................................................................................................. 93

5.39. RunBenchmarkTaskNow ............................................................................................................................................. 94

5.40. GetDeviceNbrs ............................................................................................................................................................... 95

5.41. GetConnectedSwitchPort ............................................................................................................................................ 96

5.42. DeleteMap ...................................................................................................................................................................... 97

5.43. ExportMap ...................................................................................................................................................................... 98

5.44. ImportSiteTree ............................................................................................................................................................. 100

5.45. AddRole ......................................................................................................................................................................... 101

5.46. EditRole ......................................................................................................................................................................... 106

5.47. DeleteRole .................................................................................................................................................................... 107

5.48. AddTenant .................................................................................................................................................................... 108

5.49. EditTenant .................................................................................................................................................................... 109

5.50. DeleteTenant................................................................................................................................................................ 111

5.51. AssignUsersForTenant ............................................................................................................................................... 112

5.52. CreateDomain .............................................................................................................................................................. 113

5.53. EditDomain ................................................................................................................................................................... 114

5.54. DeleteDomain .............................................................................................................................................................. 116

5.55. AssignUsersForDomain ............................................................................................................................................. 117

5.56. RemoveUsersFromDomain ...................................................................................................................................... 118

5.57. AddNetworkSetting .................................................................................................................................................... 120

5.58. DeleteNetworkSetting ................................................................................................................................................ 124

6. Device Type Name and ID ..................................................................................................................................................... 127

7. Error Code List ......................................................................................................................................................................... 133

Page 5: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 5

1. Introduction

NetBrain Integrated Edition 7.0 provides a set of REST APIs for third-party systems to query and set the data of

NetBrain. For example:

Use APIs to create a map and/or execute the runbook within the map. A common use case is Triggered Diagnosis: any alert or incident management system (such as ServiceNow) can be configured to automatically call these APIs to map the problem area, collect the related data and run the basic analysis

while an alert or incident occurs.

Use APIs to synchronize the data between NetBrain and the central CMDB system (as known as Single Source of Truth). The majority data of CMDB system is manually added or discovered from the live network via SNMP. With NetBrain system, you can schedule to discover and/or benchmark the whole network via both SNMP and CLI commands and provide a much richer set of data. NetBrain system can be used as the

Single Source of Truth or can be used to update the data for any CMDB system.

NetBrain maps equipped with data views provide a better way for network engineers to visualize network design and operational status than a Visio map can do. The data can be either from live network or from third-party

systems. NetBrain also provides a framework to enable the data of third-party systems to be retrieved and viewed in NetBrain maps. This use case is as known as Single Pane of Glass since the data from live network and third-

party systems can be displayed on a single map.

Page 6: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

6 | NetBrain Integrated Edition 7.0b API and System Integration Guide

2. Single Pane of Glass

Besides the data from live network, NetBrain provides a framework to retrieve the data from third-party API

systems via APIs and display the data on NetBrain maps.

To help you fully understand the framework, a use case related to ServiceNow integration is introduced in this section. In this case, NetBrain system will firstly retrieve the alert information for all devices included on a map

from ServiceNow, and then display the number of alerts and the detail alert tables on the map.

2.1. Workflow

The following major steps describe a general flow to retrieve the data from a third-party system and display it in

NetBrain system as a single pane of glass.

1. Define a System-level API Plugin. The API Plugin defines what data to be retrieved from the third-party system

and how to retrieve them.

2. Add a Tenant-level API Plugin Instance (API Server). The API Server defines the endpoints and user credentials

to access the third-party system.

3. Retrieve and Display Data on a Map by Running Qapps.

2.1.1. Defining an API Plugin

API Plugin is a component to define the methods and data to be retrieved from a certain type of third-party

systems.

To define a new API plugin, complete the following steps.

1. Log in to NetBrain System Management page.

Page 7: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 7

2. Select the API Plugin Manager tab and click Add.

3. Enter a name in the Plugin Name field, such as ServiceNow Alerts.

4. Enter descriptions about the API plugin in the Description field.

5. Enter the API script in the Script field. The sample code can be:

import requests class APIPlugin: def __init__(self, user, pwd, url): self._usr = user self._pwd = pwd self._urlprefix = '/'.join([url, 'api/now/table']) def _test(self): paras = {"deviceName": "BIGIP1"} alerts = self.getAlertsByDev(paras) return alerts ''' <function> <name>getAlertsByDev</name> <desc>Get alerts Info by device name</desc> <input> <var name="deviceId" type="string" /> <var name="deviceName" type="string" /> </input> <output> <var name="NumberOfAlerts" type="string" /> <var name="Alerts" type="table"> <var name="Severity" type="string" /> <var name="Short_Description" type="string" /> </var> </output> </function> '''

Page 8: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

8 | NetBrain Integrated Edition 7.0b API and System Integration Guide

def getAlertsByDev(self, params): # Set the request parameters url_table = '/'.join([self._urlprefix, 'em_alert']) # Set proper headers headers = {"Content-Type": "application/json", "Accept": "application/json"} #authentication auth =(self._usr, self._pwd) #query parameters deviceName = params['deviceName'] urlparams = { "sysparm_fields":"short_description,severity,node", "node":deviceName} response = requests.get(url_table, auth = auth, headers=headers, params = urlparams) if response.status_code != 200: return [] result = response.json().get('result') alerts = [] for i in result : alerts.append({'Severity' : i['severity'], 'Short_Description' : i['short_description'], }) return {'NumberOfAlerts' : len(result), 'Alerts' : alerts}

Tip: You can click Popup to bring up a larger script interface. Alternatively, you can click Import to add an existing python file directly.

This Python script defines a Python class APIPlugin which has three methods:

__init__(self, user, pwd, url) - will be called when an instance of the class (API Server) is created.

_test(self) - will be called when you click Test.

getAlertsByDev(self, params) - defines what data will be retrieved and how to retrieve them.

The details to implement these methods will be covered in Writing an API Plugin. You can skip the code details, but better pay attention to the multi-line comments before the function getAlertsByDev.

<function> <name>getAlertsByDev</name> <desc>Get alerts Info by device name</desc> <input> <var name="deviceId" type="string" /> <var name="deviceName" type="string" />

Page 9: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 9

</input> <output> <var name="NumberOfAlerts" type="string" /> <var name="Alerts" type="table"> <var name="Severity" type="string" /> <var name="Short_Description" type="string" /> </var> </output> </function>

In this example, it tells NetBrain system that this APIPlugin defines a function getAlertsByDev which has input

parameters deviceId and deviceName and output NumberOfAlerts as a string and Alerts as a table which has two columns Severity and Short_Description. More precisely from the perspective of programmer, the input of this function is a dictionary (params) having two keys deviceId and deviceName and its output is a dictionary having two keys NumberOfAlerts and Alerts which itself is also a dictionary with two keys Severity and

Short_Description.

6. Click Test, and enter an endpoint and login credentials to test the script. For example, enter an endpoint https://ven01749.service-now.com/ with the related username and password to log in to this endpoint.

The return value of the _test method is transferred as a string and printed out in the dialog. This is an example

of output:

{ "Alerts" : [ { "Severity" : "1", "Short_Description" : "BIGIP1 interface e0 is down" } ], "NumberOfAlerts" : 1 }

Page 10: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

10 | NetBrain Integrated Edition 7.0b API and System Integration Guide

7. Click Parse to display all functions having the multi-comment lines.

8. Click Save to save the definition.

2.1.2. Adding an API Server

After defining a system-level API plugin, you can create an instance of this plugin for a tenant, that is, an API

Server.

An API Server is related to a real third-party system which provides API access and defines the endpoint and

credentials (such as username and password) to access the third-party system via API.

1. Click System from the quick access toolbar and select a tenant (such as the default one Initial Tenant) to go to the Tenant Management page.

Page 11: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 11

2. Select the API Manager > API Server tab and then click Add.

3. Enter the server name and the description.

4. In the Endpoint field, enter the third-party API service address.

5. Enter the user name and password to access the third-party API sever.

6. In the drop-down menu of the Plugin field, select the API plugin you created from all available API functions.

7. Click Test to check the connection. The system will use the _test method of API Plugin, and the return value of

this method is transferred as a string and printed out.

8. Click Save.

2.1.3. Using API Data in NetBrain

After defining the API Plugin and API Server, you can call third-party API data in NetBrain system and monitor the

parsed data on NetBrain maps.

1. Open a map with your interested devices.

Page 12: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

12 | NetBrain Integrated Edition 7.0b API and System Integration Guide

2. In the map-based search bar, search for API variables by API function name or variable name. For example,

getAlertsByDev.

3. To select variables in the search results, check the circles at the upper-right corner. For example, NumberOfAlerts and Alerts. Drag the variables to the map and the data will be displayed on the map once retrieved.

4. To save this Qapp for future use, click the icon and select Save as Qapp from the drop-down menu.

5. Open the Qapp file you saved. If you are familiar with Qapp Editor, you can view the details about how the API server requests are implemented.

Page 13: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 13

2.2. Writing an API Plugin

Note: API plugins must be implemented in Python and the following code samples are based on Python 3.1.

This plugin defines a class API Plugin and must meet the following requirements:

Class Parameter Value Explanation

Class Name APIPlugin Case-sensitive.

Member Function _init__(self, user, pwd, url) When you create an instance of API plugin, NetBrain API framework will invoke this function and set the parameters to be the ones defined in the API server for a tenant.

The instantiation operation must have four parameters:

the object itself

username

password

the endpoint of the server

This is the sample code for this function:

def __init__(self, user, pwd, url): self._usr = user self._pwd = pwd self._urlprefix = '/'.join([url, 'api/now/table'])

Here the instance variables _usr, _pwd and _urlprefix are set according to the inputs when you define an API server. The endpoint of ServiceNow API call is https://<ServiceNowUrl>/api/now/table, so you can join ServiceNow URL with /api/now/table.

Member Function _test(self) This function is used to debug the plugin function. It does not have any parameters except the API server object itself.

Now you can define the member functions to retrieve the data from the API server. The definition includes the following two parts:

Definition Explanation

Multi-line comments (mandatory) It works as protocols between NetBrain system and APIPlugin class.

Page 14: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

14 | NetBrain Integrated Edition 7.0b API and System Integration Guide

NetBrain API framework will parse these comments, and then pass the corresponding method and variables to other components of NetBrain system, such as Search function.

The followings are an example of multi-line comments for a member function getAlertsByDev(self, params):

''' <function> <name>getAlertsByDev</name> <desc>Get alerts Info by device name</desc> <input> <var name="deviceId" type="string" /> <var name="deviceName" type="string" /> </input> <output> <var name="NumberOfAlerts" type="string" /> <var name="Alerts" type="table"> <var name="Severity" type="string" /> <var name="Short_Description" type="string" /> </var> </output> </function> ''' def getAlertsByDev(self, params):

The comments are quoted by delimiter (’’’) and are in XML format. The comments include the following parameters:

name - mandatory and must be exactly the same as the function name.

desc - optional description.

input - mandatory and corresponds to the key values of input parameters params, which is a dictionary. It should always include deviceID and deviceName, indicating that the function returns the data for this device. It can also include interfacename, indicating that the function returns the data for this specific interface of this device.

output - mandatory and defines what data is returned. The function always returns the data as a dictionary. In this sample, the returned dictionary has two keys NumberOfAlerts and Alerts which is a dictionary with two keys Severity and Short_Description. The implementation of the function must return a dictionary which includes the key and values defined in these comments.

Python codes to implement the function

The function retrieves the data from third-party API servers. The implementation is based on API calls of third-party systems and can be different. However, if the third-party system supports REST API, the codes are similar and usually includes three major steps:

1. Set Proper Request Parameters.

2. Make an API Call.

3. Parse the Response.

Page 15: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 15

Setting Proper Request Parameters

ServiceNow offers a friendly API Browser for you to browse and test its API calls.

1. Log in to a ServiceNow instance and navigate to REST API Browser (search for Rest API to find the link to API browser).

In this case, Table API will be used to retrieve records from a table with the URL https://{ServiceNow InstanceURL}/api/now/table/{tableName}. The table name for Alert records is em_alert and so the full URL to

get records for alerts from ServiceNow will be https://{ServiceNow InstanceURL}/api/now/table/em_alert.

2. Set the query parameters for this table. To make the sample code simple, you can keep the most parameters as default and select sysparm_fields as short_description, severity, node and add an additional parameter node

as the device name.

Note: The node field is mandatory for an alert and assumed to be the device name.

Page 16: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

16 | NetBrain Integrated Edition 7.0b API and System Integration Guide

A sample response from ServiceNow is as follows:

3. Put these together in Python codes:

# Set the request parameters. #URL for Table API: urlprefix is https://<ServiceNowUrl>/api/now/table url_table = '/'.join([self._urlprefix, 'em_alert']) #query parameters deviceName = params['deviceName'] urlparams = { "sysparm_fields":"short_description,severity,node", "node":deviceName} # Set proper headers headers = {"Content-Type": "application/json", "Accept": "application/json"} #authentication auth =(self._usr, self._pwd)

The last two paragraphs set the headers and authentication of the request.

These two request headers must have one of the following valid values and require proper data formatting.

Here we use the JSON format.

o Content-Type: application/json, application/xml

o Accept: application/json, application/xml

For authentication, ServiceNow supports the basic authentication (the credentials are sent for each HTTP request) and OAuth (authentication will be performed in advance and a unique token will be generated

which can be used in HTTP requests). Here we use the basic authentication.

Page 17: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 17

In addition, you can set a version number, like /api/now/v1/table/{tablename}. By specifying a version number in the URL, you can ensure that any future updates to the REST API will not negatively impact your integration. URLs that do not specify a version number will use the most recent REST API behavior available with your instance

version, which may change as soon as you upgrade. In the sample, we do not set API version in the URL.

Making an API call

Making an API call is easy with the help of Python Request library. See http://docs.python-requests.org/en/master/

for more details.

response = requests.get(url_table, auth = auth, headers=headers, params = urlparams) if response.status_code != 200: return []

After the Get class, the codes check whether the API call is successful (200 indicates a success). If not, an empty

dictionary will be returned.

Building Dictionary from API Response

The result is in the JSON format as specified in the request headers. You need to loop through the result and build the dictionary as defined in the multi-line comments of this function. The key words of the returned dictionary must be identical to those defined in the comments.

result = response.json().get('result') alerts = [] for i in result : alerts.append({'Severity' : i['severity'], 'Short_Description' : i['short_description'], }) return {'NumberOfAlerts' : len(result), 'Alerts' : alerts}

After finishing this function, you can modify the _test function as follows to debug it:

def _test(self): paras = {"deviceName": "BIGIP1"} alerts = self.getAlertsByDev(paras) return alerts

The _test function should always return an object type of dictionary. If the function call succeeds, the returned value will be printed out. Otherwise, the error message (with the call stack) will be displayed in the Testing dialog.

Page 18: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

18 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Note: Python print statements will not be displayed.

Page 19: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 19

3. API-Triggered Diagnosis

NetBrain provides an API interface for third-party systems to trigger NetBrain maps and runbooks to achieve event-triggered diagnosis, such as mapping problem devices, collecting live network data and returning a map link to the third-party system when alerts are generated.

The following major steps describe a general flow to define and use API-triggered diagnosis task:

1. Define an API-triggered diagnosis task in NetBrain. See Adding API-triggered Tasks for more details.

2. Call API-triggered diagnosis task in your third-party systems. See Calling Tasks in Third-Party Systems for more

details.

3. View triggered tasks and results. See Viewing Task Results for more details.

3.1. Adding API-Triggered Tasks in NetBrain

1. Log in to your NetBrain domain.

2. Click the start menu , select System Automation Manager.

3. Select the API Stub Manager tab and click Add Stub.

4. Enter an API stub name. Third-party systems recognize API tasks in Netbrain system by API stub name.

4. Enter a description about the API task in the Description field.

5. To define the mode of the API task, click Edit in the Trigger Option field.

Real-time - indicates the API task will run immediately and automatically when triggered. You can also define the maximum waiting time before transforming to the On-demand mode.

Page 20: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

20 | NetBrain Integrated Edition 7.0b API and System Integration Guide

On-demand - indicates the API task will be put in the task queue (Pending) when triggered. Only when you

click the Task ID or Map URL in the third-party system, the task will be executed.

6. Specify how to create a map in NetBrain system.

Map Device and Its Neighbors- draw the problem device and its neighbor devices on map.

Map a path - draw the traffic flow from a device to another device. You need to specify the destination and source devices in the third-party system.

Open Site Map of the Device - open the site where the problem device locates. In case the original site data

is changed, check the Do not change the original Site Map, make a copy instead check box.

Open Existing map - open an existing map in your domain.

7. Optional: Click Browse Runbooks to select a Runbook to run on a map.

8. View variables and their values in the Variable Input pane. Some variables and their values are required when you define scripts in the third-party system.

9. Click Save.

3.2. Calling Tasks in Third-Party Systems

Page 21: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 21

If the third-party API server supports python script inputs, you can launch the pre-defined API-triggered diagnosis

tasks through the following sample scripts (replace sample parameters with real instances):

import requests import json # Need to install requests package for python # pip install requests user = "admin" # NetBrain login account pwd = "admin" # NetBrain login password host_url = "https://127.0.0.1" # the URL of your NetBrain domain headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} ''' Get token for netbrain ''' TENANT = 'tenant_name' # the tenant name. For example, tenant1 DOMAIN = "domain_name" # the domain name. For example, domain1 def getTokens(): login_api_url = r"/ServicesAPI/API/login" Login_url = host_url + login_api_url data = { "username": user, "password": pwd } token = requests.post(Login_url, data=json.dumps( data), headers=headers, verify=False) if token.status_code == 200: return token.json()["token"] else: return "error" # get token token = getTokens() headers["Token"] = token # Trigger API function def TriggerTask(API_Body): # Trigger API url API_URL = r"/ServicesAPI/API/task" # Trigger API payload api_full_url = host_url + API_URL api_result = requests.post(api_full_url, data=json.dumps( API_Body), headers=headers, verify=False) if api_result.status_code == 200: return api_result.json() if __name__ =="__main__": API_BODY = { 'domain_setting': { 'tenant_name': TENANT, 'domain_name': DOMAIN }, 'basic_setting': {

Page 22: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

22 | NetBrain Integrated Edition 7.0b API and System Integration Guide

'user': 'admin', 'device': "MPLS_PE1",, 'stub_name': 'stub1', # the name of the stub you created in NetBrain 'triggered_by':"Netbrain", 'intf_name': 'FastEthernet0/0' }, # the following map setting fields is only required when you map a path "map_setting": { "map_create_mode":3, "map_path_para": { "is_live":True, "source":"24.1.1.4", "destination":"35.1.1.1", # "source_port":1025, # "destination_port":80 } } } print(TriggerTask(API_BODY))

3.3. Viewing Task Results

1. In the System Automation Task Manager, click the API Triggered Tasks tab (selected by default). All triggered

tasks are listed.

2. Click the map hyperlink of the triggered task to view the created map as well as the data collected by runbook (as long as you have added a runbook when defining the task).

Page 23: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 23

A map URL will be returned in the script output of your third-party system when API task is triggered, and you can visit the map containing the devices with alerts via this URL.

Page 24: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

24 | NetBrain Integrated Edition 7.0b API and System Integration Guide

4. Pop-up API Stub

NetBrain Pop-up API Stub is another way to integrate with NetBrain maps and runbooks to collect network data or troubleshoot network issues in third-party systems. Users can directly define a pop-up API stub, use maps and runbooks by clicking a hyperlink in their third-party systems, without the needs to predefine API tasks, and only a

few scripts are required.

The general workflow to use Pop-up API Stub is as follows:

1. In a third-party system: Define Scripts to Generate a Hyperlink for NetBrain Pop-up API Stub.

2. Click the hyperlink to Define Pop-up API Stub, such as map and runbook settings.

Step 1: Define Scripts to Generate a Hyperlink for Pop-up API Stub

For a third-party system like ServiceNow, a hyperlink can be created to track an incident. You can write scripts in

the third-party system to generate a hyperlink for NetBrain pop-up API stub.

A sample script is as follows (replace sample parameters with real instances):

Page 25: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 25

import urllib.parse data1={ 'tenant': 'tenant_name‘, 'domain':'domain_name', 'vendor':'ServiceNow', # the vendor name of your third-party system 'device':'device_name', # the hostname of the problem device 'search':'device_to_search', # this parameter is optional 'interface':'interface_name', # one interface of the problem devices and it is required to extend neighbors from the interface 'source':’172.24.32.210‘, # the source of a path, only used for calculating a path 'destination':'172.24.31.125', # the destination of a path, only used for calculating a path } print('https://IP address of your NetBrain Domain/apimaplink.html?'+ urllib.parse.urlencode(data1))

Step 2: Define Pop-up API Stub

1. Click the hyperlink generated, and you will be required to log in to NetBrain system. Then the Pop-up API Stub dialog will prompt as follows, with the parameters defined in the scripts populated.

Page 26: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

26 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Tip: To have the vendor logo displayed at the upper-right corner, you need to manually add it in NetBrain system. See Adding an API Vendor for more details.

2. Select a way to create a map in the Define Map area. By default the pop-up API stub creates a map as per the definitions in your scripts.

Map Device and its Neighbors - draw the problem device and its neighbors on a map. You need to specify the neighbor interfaces that you want to extend in the third-party system.

Map a Path - draw the traffic flow from a device to another. For a path, you can also define path parameters

such as data source, protocol and so on by clicking the Path Settings hyperlink.

Open Site Map of the Device - open the site where the problem device locates. To avoid changing the original site data, select the Make a copy of the Site Map check box.

Open Existing Map - open an existing map in your domain.

New Empty Map - create a map page without any devices on it.

3. In the Open Runbook field, select a runbook to be executed on the map.

Tip: You can predefine preferred runbooks for a third-party vendor in NetBrain System, see Adding an API Vendor for more details.

4. Select whether to search for devices.

5. Click Create Map.

Page 27: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 27

4.1. Adding an API Vendor

1. Log in to NetBrain Tenant Management page.

2. Select the API Manager > API Vendor tab and then click Add.

3. Enter the vendor name in the Vendor Name field.

4. To upload the vendor logo, click Upload to select an image file.

5. Click Add Runbook to add preferred runbooks for the vendor.

6. Click Add to save.

Page 28: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

28 | NetBrain Integrated Edition 7.0b API and System Integration Guide

5. Single Source of Truth

For enterprises deploying centralized database such as IP Address Management (IPAM) or Configuration Management Database (CMDB) to maintain basic device information, NetBrain can synchronize with these CMDB or inventory systems as well as serve as a CMDB for them to query data stored in NetBrain as a single source of truth.

NetBrain RESTful APIs

NetBrain provides dozens of RESTful APIs to read (Get) and write (Set) NetBrain Data.

API Description Permissions Required

Login Log in to NetBrain database. No

SetCurrentDomain Specify which domain you will work on to get or set NetBrain data. No

Logout Log out of NetBrain database. No

GetDevicesByIP Get devices by an IP address. No

GetDeviceAttribute Get value of a specified attribute. No

GetInterfaceAttribute Get value of a specified interface attribute. No

GetModuleAttribute Get value of a specified module attribute. No

GetAllInterfaces Get all interfaces of a device. No

GetAllModules Get all modules of a device. No

CalcPath Calculate the traffic path between two devices. Power User or Domain Admin

Page 29: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 29

API Description Permissions Required

GetPath Get the hop information of a path calculated. No

AddIPforDiscovery Add IP addresses to NetBrain database for future data collection. Power User or Domain Admin

RemoveIPforDiscovery Remove specific IP items added through the AddIPforDiscovery API from your NetBrain database.

Power User or Domain Admin

RemoveAllIPforDiscovery Remove all IP addresses added through the AddIPforDiscovery API from your NetBrain database.

Power User or Domain Admin

RunDiscoveryNow Run discovery tasks for all IP addresses added by the AddIPforDiscovery API.

Power User or Domain Admin

DiscoverIPNow Add IP addresses to NetBrain database and immediately run the discovery task with the IP addresses as seed routers.

Power User or Domain Admin

GetDiscoveryIPResult Get the results (including discovered devices) of discovery tasks run by the APIs RunDiscoveryNow and DiscoverIPNow.

Power User or Domain Admin

DeleteDevice Delete a device from NetBrain database and rebuild L3 topology after deletion.

Power User or Domain Admin

SetDeviceAttribute Set a value for a specified property of a device. Power User or Domain Admin

SetInterfaceAttribute Set a value for a specified interface property. Power User or Domain Admin

SetModuleAttribute Set a value for a specified module property. Power User or Domain Admin

CreateDeviceAttribute Create a customized device attribute for certain device types. Power User or Domain Admin

CreateInterfaceAttribute Create a customized interface attribute for certain device types. Power User or Domain Admin

CreateModuleAttribute Create a customized module attribute for certain device types. Power User or Domain Admin

DeleteDeviceAttribute Delete an attribute/property for certain device types. Tenant Admin

DeleteInterfaceAttribute Delete an interface attribute/property. Tenant Admin

DeleteModuleAttribute Delete a module attribute/property. Tenant Admin

RebuildL3Topology Rebuild the Layer 3 topology for all network devices in a domain. Tenant Admin

GetGroupDevices Get devices in a device group. No

GetDeviceProxyServer Get the Proxy Server of a specified device. No

AddUser Create user accounts to access your NetBrain tenants and domains. System Admin

ModifyUser Modify user information. System Admin

DeleteUser Delete users. System Admin

Page 30: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

30 | NetBrain Integrated Edition 7.0b API and System Integration Guide

API Description Permissions Required

GetDeviceData Get the data of a device, such as configuration file, route table and so on.

No

AddBenchmarkTask Create a benchmark task. Power User or Domain Admin

EditBenchmarkTask Edit a benchmark task. Power User or Domain Admin

DeleteBenchmarkTask Delete a benchmark task. Power User or Domain Admin

RunBenchmarkTaskNow Run a benchmark task immediately. Power User or Domain Admin

GetDeviceNbrs Get neighbors of a specified device. No

GetConnectedSwitchPort Get the connected L2 switch ports of an interface and the device that the interface belongs to.

No

DeleteMap Delete a map file from a domain. No

ExportMap Export a map from a domain. No

ImportSiteTree Import a site tree. Power User or Domain Admin

AddRole Add a role and grant privileges to the role. System Admin

EditRole Edit a role and its privileges. System Admin

DeleteRole Delete a role. System Admin

AddTenant Add a tenant. System Admin

EditTenant Edit a tenant. System Admin

DeleteTenant Delete a tenant. System Admin

AssignUsersForTenant Assign users for a tenant. System Admin

CreateDomain Create a domain. System Admin

EditDomain Edit a domain. System Admin

DeleteDomain Delete a domain. System Admin

AssignUsersForDomain Assign users for a domain. System Admin

Page 31: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 31

API Description Permissions Required

RemoveUsersFromDomain Remove users from a domain. System Admin

AddNetworkSetting Add network settings for a domain. Power User or Domain Admin

DeleteNetworkSetting Delete network settings for a domain. Power User or Domain Admin

5.1. Login

This API call is used to send a request to log in to NetBrain database by specifying the login credentials and

generate an authentication token for subsequent API calls.

Note: 1) All API requests require that you have an authentication token, so that you need to add an authorization header to each request with your authentication token as the value. 2) After login, next you need to specify the domain that you will work on by the SetCurrentDomain API.

Resource Information

Method URL Authentication

POST http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/login

Add an authorization header to the request with your authentication token as the value.

Request Information

Parameter Type Description

username string The user name to log in to your NetBrain domain.

password string The password to log in to your NetBrain domain as the API credentials. The following two ways are supported to post the user name and password:

data{username:username, password:password}

header: ”Authorization”:”Basic base64_of_username:password”. For example, Authorization: Basic YWRtaW46YWRtaW4=

Page 32: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

32 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Response Information

Parameter Type Description

token string Return an authentication token for subsequent API calls.

statusCode int Return a status code. 0 means no errors.

See Status Codes for more error codes.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'Tenant name' DOMAIN = "Domain name" def Login(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers,verify=False).json()['token'] return token if __name__ == '__main__': print(Login())

5.2. SetCurrentDomain

This API call is used to specify which domain you will work on to get or set NetBrain data.

Page 33: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 33

Resource Information

Method URL Authentication

POST http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/setCurrentDomain

Yes

Request Information

Parameter Type Description

tenantName string Specify the tenant that you want to work on.

domainName string Specify one domain in the selected tenant.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def SetCurrentDomain(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] full_url = server_url + "API/setCurrentDomain" headers['Token']=token #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers)

5.3. Logout

Page 34: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

34 | NetBrain Integrated Edition 7.0b API and System Integration Guide

This API call is used to send a request to log out of NetBrain database.

Resource Information

Method URL Authentication

POST http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/logout Yes

Request Information

Parameter Type Description

Token string Input the authentication token.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def Logout(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] full_url = server_url + "API/logout" headers['Token']=token #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data requests.post(full_url,data=json.dumps({"token": token}),headers=headers)

5.4. GetDevicesByIP

Page 35: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 35

This API call is used to get the corresponding devices by an IP address. For duplicate IP addresses, this API returns

a device list.

Resource Information

Method URL Authentication

POST http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/device/getDevicesByIP/{IP}

Yes

Request Parameters

Parameter Type Description

IP string Input the IP address.

Response Information

Parameter Type Description

devices string [ ] A list of devices.

ID string The device ID.

deviceTypeName: string The type of the returned device, such as Cisco Router.

mgmtIP string The management IP address of the returned device.

hostname string The hostname of returned device.

statusCode int Return a status code. 0 means no errors.

See Status Codes for more error codes.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name"

Page 36: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

36 | NetBrain Integrated Edition 7.0b API and System Integration Guide

def GetDevicesByIP(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] full_url = server_url + "API/CMDB/device/GetDevicesByIP" headers['Token']=token #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data body = { "IP":'1.1.1.1' } requests.get(full_url,params=body,headers=headers)

5.5. GetDeviceAttribute

This API call is used to get the value for a specified attribute of a device.

Resource Information

Method URL Authentication

POST http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/device/getDeviceAttribute/{hostname}/{attributeName}

Yes

Request Parameters

Parameter Type Description

hostname string The hostname of the target device.

attributeName string The name of the attribute that you want to get its value. Please note that the attribute name here is case sensitive and not the name displayed in the Device Details pane of NetBrain IE system. See Applicable Device Attributes for system built-in device attributes.

Response Information

Parameter Type Description

attributeName string The name of the attribute.

Page 37: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 37

Parameter Type Description

attributeValue string The returned attribute value.

hostname string The hostname of returned device.

statusCode int Return a status code. 0 means no errors.

See Status Codes for more error codes.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def GetDeviceAttribute(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] full_url = server_url + "API/CMDB/device/getDeviceAttribute" headers['Token']=token #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data data = { 'hostname': 'device', 'attributeName': 'attrs' } requests.get(full_url,params=data,headers=headers)

Applicable Device Attributes

The following table lists the device properties/attributes (case-sensitive) that you can retrieve by using the

GetDeviceAttribute API.

Page 38: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

38 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Property/Attribute Name

Display Name in Device Details Pane

Description

name Hostname The hostname of a device.

mgmtIP Management IP The management IP of a device.

subTypeName Device Type The device type of a device.

mgmtIntf Management Interface The management interface of a device.

vendor Vendor The vendor information of a device.

model Model The model information of a device.

ver Software Version The version of a device.

sn Serial Number The serial number of a device.

site Site The site that a device belongs to.

loc Location The location of a device.

contact Contact The contact person of a device.

mem System Memory Size The system memory size of a device.

assetTag Asset Tag The asset tag of a device.

layer Hierarchy Layer The network layer that a device belongs to.

descr Description The description of a device.

oid sysObjectID The system object ID of a device. .

driverName Driver The driver that a device uses.

mgmtMAC Management MAC The management MAC of a device.

lwap_defaultGW Default Gateway The default gateway of a LWAP device.

lwap_group Group The group that a LWAP device belongs to.

lwap_priCntrllr Primary Controller The primary controller of a LWAP device.

Page 39: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 39

lwap_secCntrllr Second Controller The second controller of a LWAP device.

Tip: Customized device properties can also be retrieved by the GetDeviceAttribute API.

5.6. GetInterfaceAttribute

This API call is used to get the value for a specified attribute of a device interface.

Resource Information

Method URL Authentication

GET http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/interface/getInterfaceAttribute

Yes

Request Parameters

Parameter Type Description

hostname string The hostname of the target device.

attributeName string The name of the attribute that you want to get its value. Please note that the attribute name here is case sensitive and not the name displayed in the Device Details pane of NetBrain IE system. See Applicable Interface Attributes for system built-in interface attributes.

interfaceName string Input the full name of the interface.

Response Information

Parameter Type Description

attributeName string The name of the attribute.

interfaceAttributeValue string The returned attribute value.

hostname string The hostname of the returned device.

statusCode int Return a status code. 0 means no errors.

See Status Codes for more error codes.

Page 40: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

40 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def GetInterfaceAttribute(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] full_url = server_url + "API/CMDB/interface/getInterfaceAttribute" headers['Token']=token #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data data = { "hostname": 'xx', "interfaceName": 'xx', "attributeName": 'xx' } requests.get(full_url,params=data,headers=headers)

Applicable Interface Attributes

The following table lists the interface properties/attributes (case-sensitive) that you can retrieve by using the

GetInterfaceAttribute API.

Property Name Display Name in Device Details Pane

Description

name Interface Name The name of an interface.

ips IPv4 Address The IPv4 address of an interface.

ipv6s IPv6 Address The IPv6 address of an interface.

Page 41: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 41

Property Name Display Name in Device Details Pane

Description

ipv6LinkLocalAddress

IPv6 Link Local Address The IPv6 local address of an interface.

mibIndex MIB Index The MIB index of an interface.

bandwidth Bandwidth The bandwidth of an interface.

speed Speed The speed of an interface.

duplex Duplex The duplex of an interface.

intfStatus Live Status The state of an interface.

macAddr MAC Address The MAC address of an interface.

moduleSlot Slot# The module slot number of an interface.

moduleType Module Type The module type of an interface.

descr Description The description of an interface.

routingProtocol Routing Protocol. The routing protocol configured on an interface.

multicastMode Multicasting Mode The multicasting mode of an interface.

mplsVrf MPLS VRF The name of the VRF configured on an interface.

mplsVpn MPLS VPN The MPLS VPN configured on an interface.

inAclName Inbound ACL The inbound ACL of an interface.

outAclName Outbound ACL The outbound ACL of an interface.

mode Switchport Mode The switchport mode of an interface.

vlan VLAN The VLAN number that an interface belongs to.

trunkNativeVlan Native VLAN The native VLAN of an interface as switchport.

Page 42: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

42 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Property Name Display Name in Device Details Pane

Description

trunkEncapsulation Trunk Encapsulation The trunk encapsulation protocol of an interface as trunk port.

ipUnnumberedIp Trunk Unnumbered IP The unnumbered IP address of an interface as an unnumbered interface.

5.7. GetModuleAttribute

This API call is used to get the value for a specified attribute of a device module.

Resource Information

Method URL Authentication

POST http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/module/getModuleAttribute

Yes

Request Parameters

Parameter Type Description

hostname string The hostname of the target device.

attributeName string The name of the attribute that you want to get its value. Please note that the attribute name here is case sensitive and not the name displayed in the Device Details pane of NetBrain IE system. See Applicable Module Attribute for system built-in module attributes.

moduleName string The full name of the module.

Response Information

Parameter Type Description

attributeName string The name of the attribute.

moduleAttributeValue string The returned attribute value.

hostname string The hostname of the returned device.

statusCode int Return a status code. 0 means no errors.

Page 43: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 43

Parameter Type Description

See Status Codes for more error codes.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def GetModuleAttribute(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] full_url = server_url + "API/CMDB/module/getModuleAttribute" headers['Token']=token #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data data = { 'hostname': 'xx', 'moduleName': 'xx', 'attributeName': 'xx' } requests.get(full_url,params=data,headers=headers)

Applicable Module Attributes

The following table lists the module properties (case-sensitive) that you can retrieve by using the

GetModuleAttribute API.

Property Name Display Name in Device Details Pane Description

name Slot# The modules of a device.

Page 44: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

44 | NetBrain Integrated Edition 7.0b API and System Integration Guide

type Module Type The port counts of a module.

ports Ports The module type of a module.

sn Module Serial Number The serial number of a module.

hwrev HW Rev The hardware revision of a module.

fwrev FW Rev The firmware revision of a module.

swrev SW Rev The software revision of a module.

descr Description The description of a module.

5.8. GetAllInterfaces

This API call is used to get all interfaces of a device.

Resource Information

Method URL Authentication

POST http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/interface/getAllInterfaces/{hostname}

Yes

Request Parameters

Parameter Type Description

hostname string The hostname of the target device.

Response Information

Parameter Type Description

interfaces string A list of all interfaces of the device.

statusCode int Return a status code. 0 means no errors.

See Status Codes for more error codes.

Page 45: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 45

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def GetAllInterfaces(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] full_url = server_url + "API/CMDB/interface/getAllInterfaces" headers['Token']=token #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data data = { "hostname": 'xx', } requests.get(full_url,params=data,headers=headers)

5.9. GetAllModules

This API call is used to get the information for all modules of a specified device.

Resource Information

Method URL Authentication

POST http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/module/getAllModules/{hostname}

Yes

Page 46: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

46 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Request Parameters

Parameter Type Description

hostname string The hostname of the target device.

Response Information

Parameter Type Description

modules string A list of all modules of the device.

statusCode int Return a status code. 0 means no errors.

See Status Codes for more error codes.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def GetAllModules(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] full_url = server_url + "API/CMDB/module/getAllModules" headers['Token']=token #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data data = { "hostname": 'xx' } requests.get(full_url,params=data,headers=headers)

Page 47: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 47

5.10. CalcPath

This API call is used to calculate the path from endpoint A (source) to endpoint B (destination). It returns the result of the calculated path in the form of a path ID (a string), and you can use the path ID in the GetPath API as the

input parameter to get each hop information of the path.

Resource Information

Method URL Authentication

POST http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/path/calcPath

Yes

Request Information

Parameter Type Description

sourceIP string Input the IP address of the source device.

sourcePort int Specify the source protocol port If TCP/UDP is selected such as 23 for telnet. This parameter can be null.

sourceGwIP string Specify the gateway for path calculation.

sourceGwDevice - the hostname of the gateway device.

sourceGwIntf - the name of the gateway interface.

Tip: If you leave this parameter empty, the system will auto select the gateway.

destIP string Input the IP address of the destination device.

destPort int Specify the destination protocol port If TCP/UDP is selected, such as 23 for telnet. This parameter can be null.

pathAnalysisSet int Specify the path type to calculate:

1 - L3 Path

2 - L2 Path

3 - L3 Active Path

protocol int Specify the application protocol, such as IPv4.

Page 48: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

48 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Response Information

Parameter Type Description

taskID string The task ID of the calculated path. You can call the hop information of the path with the taskID in the GetPath API.

statusCode int Return a status code. 0 means no errors.

See Status Codes for more error codes.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'Tenant name' DOMAIN = "Domain name" def CalcPath(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] headers['Token']=token #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data full_url = server_url + "API/CMDB/path/calcPath" data = { "sourceIP": 'xx', "sourcePort": 'xx', "sourceGwIP": 'xx', "sourceGWDev": 'xx', "sourceGwIntf": 'xx', "destIP": 'xx', "destPort": 'xx', "pathAnalysisSet":1, "dataSourceType": 'xx', "protocol":"IPv4", "isLive":1 } requests.post(full_url,data=json.dumps(data),headers=headers)

Page 49: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 49

5.11. GetPath

This API call is used to get the hop information of a path calculated through the CalcPath API.

Resource Information

Method URL Authentication

Get http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/path/getPath/{taskID}

Yes

Request Parameters

Parameter Type Description

taskID taskID Input the task ID returned by the CalcPath API.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def GetPath(task_id): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] full_url = server_url + "API/CMDB/path/getPath/" +task_id headers['Token']=token #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data requests.get(full_url,headers=headers)

Page 50: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

50 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Sample Outputs

"hopList": [ { "srcDeviceName": "NY_POPP", "inboundInterface": "Ethernet0/0", "mediaName": "172.24.31.64/26", "outboundInterface": "FastEthernet0/0" }, { "srcDeviceName": "NY-core-bak", "inboundInterface": "FastEthernet0/1.1", "mediaName": "172.24.31.192/26", "outboundInterface": "FastEthernet0/0.10" }, { "srcDeviceName": "BJ-L2-Core-A", "inboundInterface": "", "mediaName": "", "outboundInterface": "" } ], "statusCode": 0 }

5.12. AddIPforDiscovery

This API call is used to send a request to add IP addresses to NetBrain scheduled discovery task for future data collection. After adding the IP addresses, you can use the RunDiscoverNow API to instantly discover your network

with these IP addresses set as seed routers.

Note: Before running a discovery task by the RunDiscoverNow API, make sure that the following settings are

made:

The discovery task has been enabled

Page 51: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 51

The discovery task type “Scan the following IPs” is selected.

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/discovery/addIPforDiscovery

Yes

Request Information

Parameter Type Description

mgmtIPS string Input the management IP addresses of seed devices, such as [“IP1”,”IP2”...]. This parameter is required.

cliType int Specify the access method to the devices:

0 - Telnet

1 - SSH

Tip: This parameter can be null. When it is null, it will access the device with SNMP.

username string Specify the username to access the devices. This parameter is optional.

password string Specify the password to access the devices. This parameter is optional.

privilegeUsername string Specify the username to enter the privilege mode of the devices. This parameter is optional.

privilegePassword string Specify the password to enter the privilege mode of the devices. This parameter is optional.

designatedCredentials bool Determine whether the API only uses the credentials you have specified. If false, the API will use credentials in network settings. This parameter is optional.

snmpCommunity string The SNMP community of the devices. This parameter is optional.

proxyServerAlias string Specify the NetBrain Proxy Server to access live network by alias . This parameter is optional.

Page 52: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

52 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Parameter Type Description

discoverTask string The task name of a discovery. You can specify the added IP address to associate with which discovery task in your domain. If null, the added IPs will be placed in to the built-in discovery task (Scheduled Discovery Task).

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'Tenant name' DOMAIN = "Domain name" def AddIPforDiscovery(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] headers['Token']=token full_url = server_url + "API/CMDB/discovery/addIPforDiscovery" #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) data= { "mgmtIPs": 'xx', "cliType": 'xx', "username": 'xx', "password": 'xx', "privilegeUsername": 'xx', "privilegePassword": 'xx', "snmpCommunityString": 'xx', "proxyServerAlias": 'xx', 'discoverTask': 'xx' } requests.post(full_url,data=json.dumps(data),headers=headers)

5.13. RemoveIPforDiscovery

Page 53: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 53

This API call is used to remove specific IP addresses added through the AddIPforDiscovery API from your NetBrain

database.

Resource Information

Method URL Authentication

Delete http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/discovery/ removeIPforDiscovery

Yes

Request Information

Parameter Type Description

mgmtIPs list The management IP addresses of seed devices, such as [“IP1”,”IP2”...].

discoverTask string The task name of a discovery.

If the IP addresses you want to delete are associated with a specified discovery task in your domain, you need to specify the name of the discovery task. If the task is the default built-in discovery task (Scheduled Discovery Task), the parameter can be none.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def RemoveIPforDiscovery(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] full_url = server_url + "API/CMDB/discovery/removeIPforDiscovery" headers['Token']=token #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers)

Page 54: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

54 | NetBrain Integrated Edition 7.0b API and System Integration Guide

#get data data = { 'mgmtIPs': 'xx' #ip type->list [15.0.0.1,15.0.0.2] 'discoverTask': 'xx' } requests.delete(full_url,data=json.dumps(data),headers=headers)

5.14. RemoveAllIPforDiscovery

This API call is used to send a request to remove all IP addresses added through the AddIPforDiscovery API from

your NetBrain database.

Resource Information

Method URL Authentication

Delete http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/discovery/removeAllIPforDiscovery

Yes

Request Information

Parameter Type Description

discoverTask string The task name of a discovery. The name of a discovery task. If the task is the default built-in discovery task (Scheduled Discovery Task), the parameter can be none.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def RemoveAllIPforDiscovery(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii")

Page 55: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 55

auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] full_url = server_url + "API/CMDB/discovery/removeAllIPforDiscovery" headers['Token']=token #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data data={ 'discoveryTask': 'task_name' } requests.delete(full_url,data=json.dumps(data),headers=headers)

5.15. RunDiscoveryNow

This API call is used to send a request to run discovery tasks for all IP addresses added through the

AddIPforDiscovery API.

Note: Before running a discovery task by the RunDiscoverNow API, make sure that the following settings are

made:

The discovery task has been enabled

The discovery task type “Scan the following IPs” is selected.

Page 56: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

56 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/discovery/runDiscoveryNow

Yes

Request Information

Parameter Type Description

discoverTask string The task name of a discovery.

If the IP addresses added through the AddIPforDiscovery API are associated with a discovery task in your domain, you need to specify the name of the discovery task. Otherwise, leave it as it is.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def RunDiscoveryNow(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] full_url = server_url + "API/CMDB/discovery/runDiscoveryNow" headers['Token']=token #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data data ={ 'discoveryTask':"" } requests.post(full_url,data=json.dumps(data),headers=headers)

Page 57: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 57

5.16. DiscoverIPNow

This API call is used to sends a request to add IP addresses to NetBrain database and immediately run the

discovery task with the IP addresses set as seed routers.

Note: The discovery results will not be displayed at the discovery interface, but you can use the GetDiscoveryIPResult API to get the detailed discovery results.

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/discovery/discoverIPNow

Yes

Request Information

Parameter Type Description

mgmtIPs string Input the IP address(es) for discovery. you can input multiple IP addresses, such as [“IP1”,”IP2”, "..."].

cliType int Specify the access method to the devices:

0 - Telnet

1 - SSH

Tip: This parameter can be null. When it is null, it will access the device with SNMP.

username string Input the username to access the devices.

password string Input the password to access the devices.

privilegeUsername string Input the username to enter the privilege mode of the devices.

privilegePassword string Input the password to enter the privilege mode of the devices.

snmpCommunity string The SNMP community of the devices.

proxyServerAlias string The alias of NetBrain Proxy Server.

Page 58: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

58 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Response Information

Parameter Type Description

taskID string The ID of this task. You can use the task ID in the GetDiscoveryIPResult API to obtain the discovery results.

statusCode int Return a status code. 0 means no errors. See Status Codes for more error codes.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def DiscoverIPNow(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] full_url = server_url + "API/CMDB/discovery/discoverIPNow" headers['Token']=token #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data data={ "mgmtIPs":None,# ip type is list;e.g mgmtIPs=['15.0.0.1',15.0.0.2] 'cliType':None,#Telnet or SSH 'username':None, 'password':None, 'privilegeUsername':None, 'privilegePassword':None, 'snmpCommunity':None, 'proxyServerAlias':None } requests.post(full_url,data=json.dumps(data),headers=headers)

5.17. GetDiscoveryIPResult

Page 59: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 59

This API call is used to get the results (including discovered devices) of discovery tasks run by the DiscoverIPNow

APIs.

Resource Information

Method URL Authentication

Get http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/discovery/getDiscoveryResult/{taskId}

Yes

URL Parameters

Parameter Type Description

taskID string Input the discovery task ID.

Response Information

Parameter Type Description

completed bool Indicate the discovery task is finished.

devices int Return discovered devices with hostnames and management IPs.

statusCode int Return a status code. 0 means no errors.

See Status Codes for more error codes.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def GetDiscoveryIPResult(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii")

Page 60: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

60 | NetBrain Integrated Edition 7.0b API and System Integration Guide

auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] full_url = server_url + "API/CMDB/discovery/getDiscoveryResult/" + 'bbb583a4-24fb-ae8a-3431-c7230bd13d5d' #Task id headers['Token']=token #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data requests.get(full_url,headers=headers)

5.18. DeleteDevice

This API call is used to delete a device from NetBrain database by its hostname or management IP, and rebuild L3

topology after deletion.

Resource Information

Method URL Authentication

Delete http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/device/deleteDevice

Yes

Request Information

Parameter Type Description

hostname string The hostname of the target device. You can also delete a device by its management IP.

IP string The management IP of the target device.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name"

Page 61: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 61

def DeleteDevice(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] full_url = server_url + "API/CMDB/device/deleteDevice" headers['Token']=token #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data data = { 'hostname':'hostname', 'IP':'ip' } requests.delete(full_url,data=json.dumps(data),headers=headers)

5.19. CreateDeviceAttribute

This API call is used to create a customized attribute for certain device types. You can use the SetDeviceAttribute

API to set a value for the created attribute.

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/device/createDeviceAttribute

Yes

Request Information

Parameter Type Description

attributeName string The name of the attribute.

attributeDisplayName string The display name of the attribute in Device Details pane of NetBrain IE system.

deviceTypeNames string [ ] Specify the device types that the created attribute applies to. if set to null, it will apply to all device types. See Device Type Name and ID for available device types.

Page 62: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

62 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Parameter Type Description

dataType string/double/int/bool/list/table The supported data types of the attribute.

subDataType string Only available for list or table type property.

The data type of each value in a list type property.

If the data type is table, specify the sub properties of table type property as follows:

o name - the sub property name (displayed as a column header).

o displayName - the display name (alias) of the sub property (can be null).

o dataType - the data type of the sub property. o isKey (bool) - control whether to use the sub property as the

key when comparing the table type property. The default value is false.

isFullSearch bool Set whether to use the property as an index in full scope search, including extended search and default search.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'Tenant name' DOMAIN = "Domain name" def CreateDeviceAttribute(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] headers['Token']=token full_url = server_url + "API/CMDB/device/createDeviceAttribute" #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data data = { "attributeName": 'xx', "attributeDisplayName": 'xx', "deviceTypeNames": 'xx',

Page 63: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 63

# data type:int;str;bool;list "dataType": "string", #"subDataType":"string",#"'subDataType' param must be set,when 'dataType' param is list type. } requests.post(full_url,data=json.dumps(data),headers=headers)

5.20. SetDeviceAttribute

This API call is used to set a value for the specified property of a device.

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/device/setDeviceAttribute Yes

Request Information

Parameter Type Description

attributeName string The name of the attribute that you want to set a value for. Please note that some properties, such as Hostname and Device Type cannot be set. See Applicable Device Attributes for this API.

attributeValue string The value for the attribute.

hostname string The hostname of the device.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name"

Page 64: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

64 | NetBrain Integrated Edition 7.0b API and System Integration Guide

def SetDeviceAttribute(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] full_url = server_url + "API/CMDB/device/setDeviceAttribute" headers['Token']=token #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data data = { "hostname": 'xx', "attributeName": 'xx', "attributeValue": 'xx' } requests.post(full_url,data=json.dumps(data),headers=headers)

Applicable Device Attributes

Property/Attribute Name

Display Name in Device Details Pane

Description

vendor Vendor The vendor information of a device.

model Model The model information of a device.

ver Software Version The version of a device.

sn Serial Number The serial number of a device.

loc Location The location of a device.

contact Contact The contact person of a device.

mem System Memory Size The system memory size of a device.

assetTag Asset Tag The asset tag of a device.

layer Hierarchy Layer The network layer that a device belongs to.

descr Description The description of a device.

5.21. SetInterfaceAttribute

Page 65: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 65

This API call is used to set a value for the specific property of an interface.

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/interface/setInterfaceAttribute

Yes

Request Information

Parameter Type Description

attributeName string The name of the attribute that you want to set a value for. Please note that some interface properties such as Interface Name and IP address cannot be set. See Applicable Interface Attributes for this API.

attributeValue string The value for the attribute.

hostname string The hostname of the device.

InterfaceName string The full name of the interface.

Request Format

Python

import requests import json # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def SetInterfaceAttribute(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] full_url = server_url + "API/CMDB/interface/setInterfaceAttribute" headers['Token']=token #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain"

Page 66: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

66 | NetBrain Integrated Edition 7.0b API and System Integration Guide

requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data data = { "hostname": 'xx', "interfaceName": 'xx', "attributeName": 'xx', "attributeValue": 'xx', } requests.post(full_url,data=json.dumps(data),headers=headers)

Applicable Interface Attributes

Property Name Display Name in Device Details Pane

Description

mibIndex MIB Index The MIB index of an interface.

bandwidth Bandwidth The bandwidth of an interface.

speed Speed The speed of an interface.

duplex Duplex The duplex of an interface.

intfStatus Live Status The state of an interface.

macAddr MAC Address The MAC address of an interface.

descr Description The description of an interface.

routingProtocol Routing Protocol. The routing protocol configured on an interface.

multicastMode Multicasting Mode The multicasting mode of an interface.

mplsVrf MPLS VRF The name of the VRF configured on an interface.

mplsVpn MPLS VPN The MPLS VPN configured on an interface.

inAclName Inbound ACL The inbound ACL of an interface.

outAclName Outbound ACL The outbound ACL of an interface.

mode Switchport Mode The switchport mode of an interface.

vlan VLAN The VLAN number that an interface belongs to.

Page 67: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 67

Property Name Display Name in Device Details Pane

Description

trunkNativeVlan Native VLAN The native VLAN of an interface as switchport.

trunkEncapsulation Trunk Encapsulation The trunk encapsulation protocol of an interface as trunk port.

5.22. CreateInterfaceAttribute

This API call is used to create a customized interface attribute for certain device types. You can use the

SetInterfaceAttribute API to set a value for the created attribute.

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/interface/createInterfaceAttribute

Yes

Request Information

Parameter Type Description

InterfaceType string The interface type that the created attribute belongs to, such as intfs (Layer 2 topology type interfaces), ipIntfs (IPv4 L3 topology type interfaces), and ip6Intfs (IPv6 L3 topology type interfaces).

attributeName string The name of the attribute.

attributeDisplayName string The display name of the attribute in NetBrain IE system. If set to null, it will use the attribute name.

deviceTypeNames string [ ] The device types that the created attribute applies to. If set to null, it will apply to all device types. See Device Type Name and ID for available device types.

dataType string The supported data types of the attribute.

subDataType string Only available for list or table type property.

The data type of each value in a list type property.

If the data type is table, specify the sub properties of table type property as follows:

o name - the sub property name (displayed as a column header).

Page 68: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

68 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Parameter Type Description

o displayName - the display name (alias) of the sub property (can be null).

o dataType - the data type of the sub property. o isKey (bool) - control whether to use the sub property as the

key when comparing the table type property. The default value is false.

isFullSearch bool Set whether to use the property as an index in full scope search, including extended search and default search.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'Tenant name' DOMAIN = "Domain name" def CreateInterfaceAttribute(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] headers['Token']=token full_url = server_url + "API/CMDB/interface/createInterfaceAttribute" #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data data = { "interfaceType": 'xx', "attributeName": 'xx', "attributeDisplayName": 'xx', "deviceTypeNames": 'xx', "dataType": 'string', # "'subDataType' param must be set,when 'dataType' param is list type. "subDataType": 'xx', "isfullsearch": 'xx' } requests.post(full_url,data=json.dumps(data),headers=headers)

Page 69: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 69

5.23. CreateModuleAttribute

This API call is used to create a customized module attribute for certain device types. You can use the

SetModuleAttribute API to set a value for the created attribute.

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/module/createModuleAttribute

Yes

Request Information

Parameter Type Description

attributeName string The name of the attribute.

attributeDisplayName string The display name of the attribute in Device Details pane of NetBrain IE system.

deviceTypeNames string The device types that the created attribute applies to. If set to null, it will apply to all device types. See Device Type Name and ID for available device types.

dataType string The data type of the attribute.

subDataType string Only available for list or table type property.

The data type of each value in a list type property.

If the data type is table, specify the sub properties of table type property as follows:

o name - the sub property name (displayed as a column header).

o displayName - the display name (alias) of the sub property (can be null).

o dataType - the data type of the sub property. o isKey (bool) - control whether to use the sub property as the key

when comparing the table type property. The default value is false.

isFullSearch bool Set whether to use the property as an index in full scope search, including extended search and default search.

Page 70: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

70 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def CreateModuleAttribute(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] headers['Token']=token #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) full_url = server_url + "API/CMDB/module/createModuleAttribute" #get data data = { "attributeName": 'xx', "attributeDisplayName": 'xx', "deviceTypeNames": 'xx', "dataType": 'string', # string, double, int, bool, list, table # "'subDataType' param must be set,when 'dataType' param is list type. "subDataType": 'xx', "isfullsearch": 'xx' } requests.post(full_url,data=json.dumps(data),headers=headers)

5.24. SetModuleAttribute

This API call is used to set a value for the specific property of a device module.

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/module/setModuleAttribute

Yes

Page 71: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 71

Request Information

Parameter Type Description

attributeName string The name of the attribute that you want to set a value for. Please note that the slot name cannot be set. See Applicable Module Attribute this API.

attributeValue string/int/double The value for the attribute.

hostname string The hostname of the device.

moduleName string The full name of the module.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def SetModuleAttribute(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] full_url = server_url + "API/CMDB/module/setModuleAttribute" headers['Token']=token #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) data = { "hostname":'hostname', "moduleName": 'modulename', "attributeName": 'attr_name', "attributeValue": 'attr_value' } requests.post(full_url,data=json.dumps(data),headers=headers)

Page 72: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

72 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Applicable Module Attribute

Property Name Display Name in Device Details Pane Description

type Module Type The port counts of a module.

ports Ports The module type of a module.

sn Module Serial Number The serial number of a module.

hwrev HW Rev The hardware revision of a module.

fwrev FW Rev The firmware revision of a module.

swrev SW Rev The software revision of a module.

descr Description The description of a module.

5.25. DeleteDeviceAttribute

This API call is used to delete a device attribute (property).

Resource Information

Method URL Authentication

Delete http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/device/deleteDeviceAttribute

Yes

Request Information

Parameter Type Description

attributeName string The name of the attribute that you want to delete. Please note that the attribute name here is case sensitive.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests

Page 73: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 73

user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def DeleteDeviceAttribute(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] full_url = server_url + "API/CMDB/device/deleteDeviceAttribute" headers['Token']=token #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data data = { 'attributeName':'attributeName' } requests.delete(full_url,data=json.dumps(data),headers=headers)

5.26. DeleteInterfaceAttribute

This API call is used to delete an interface attribute (property).

Resource Information

Method URL Authentication

Delete http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/interface/deleteInterfaceAttribute

Yes

Request Information

Parameter Type Description

attributeName string The name of the attribute that you want to delete. Please note that the attribute name here is case sensitive.

InterfaceType string The interface type that the attribute belongs to, such as intfs (Layer 2 topology type interfaces), ipIntfs (IPv4 L3 topology type interfaces), and ip6Intfs (IPv6 L3 topology type interfaces).

Page 74: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

74 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def DeleteInterfaceAttribute(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] full_url = server_url + "API/CMDB/interface/deleteInterfaceAttribute" headers['Token']=token #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data data ={ 'interfaceType':'interfaceType', 'attributeName':'attrName' } requests.delete(full_url,data=json.dumps(data),headers=headers)

5.27. DeleteModuleAttribute

This API call is used to delete a module attribute (property).

Resource Information

Method URL Authentication

Delete http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/module/deleteModuleAttribute

Yes

Page 75: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 75

Request Information

Parameter Type Description

attributeName string The name of the attribute that you want to delete. Please note that the attribute name here is case sensitive.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def DeleteModuleAttribute(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] full_url = server_url + "API/CMDB/module/deleteModuleAttribute" headers['Token']=token #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data data={ 'attributeName':'attrName' } requests.delete(full_url,data=json.dumps(data),headers=headers)

5.28. RebuildL3Topology

This API call is used to rebuild the Layer 3 topology for all network devices in a domain.

Page 76: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

76 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/topo/ rebuildL3Topo

Yes

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def RebuildL3Topology(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] full_url = server_url + "API/CMDB/topo/rebuildL3Topo" headers['Token']=token #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data requests.post(full_url,data=None,headers=headers)

5.29. GetGroupDevices

This API call is used to get devices in a device group.

Page 77: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 77

Resource Information

Method URL Authentication

Get http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/device/getGroupDevices

Yes

Request Information

Parameter Type Description

groupName string The name of the device group.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def GetGroupDevices(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] full_url = server_url + "API/CMDB/device/getGroupDevices" headers['Token']=token #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data data={ 'groupName':'device group name' } requests.get(full_url,params=data,headers=headers)

5.30. GetDeviceProxyServer

Page 78: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

78 | NetBrain Integrated Edition 7.0b API and System Integration Guide

This API call is used to get the proxy server of a specified device.

Resource Information

Method URL Authentication

Get http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/device/getDeivceProxyServer

Yes

Request Information

Parameter Type Description

hostname string The hostname of the device.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'Tenant name' DOMAIN = "Domain name" def GetDeviceProxyServer(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] full_url = server_url + "API/CMDB/device/getDeviceProxyServer" headers['Token']=token #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" tenant_data = requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data data={ 'hostname':'device_name' } result = requests.get(full_url,params=data,headers=headers)

Page 79: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 79

5.31. GetAvailableTenants

This API call is used to get tenants and the corresponding domain information of the tenants for the logged

account.

Resource Information

Method URL Authentication

Get http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/admin/getAvailableTenants

Yes

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def GetAvailableTenants(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] full_url = server_url + "API/CMDB/admin/getAvailableTenants" headers['Token']=token #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data requests.get(full_url,headers=headers)

5.32. AddUser

Page 80: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

80 | NetBrain Integrated Edition 7.0b API and System Integration Guide

This API call is used to create user accounts to access your NetBrain tenants and domains.

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/user/addUser

Yes

Request Information

Parameter Type Description

username string The user name. This parameter is required.

email string The email address of the user. This parameter is required.

firstName string The first name of the user. This parameter is required.

lastName string The last name of the user. This parameter is required.

password string The login password. The allowed length is 6-128 characters by default. This parameter is required.

authenticationType int The authentication type for the user account.

1 - Local

2 - External

phoneNumber string The phone number of the user.

department string The department that the user belongs to.

description string Any description about the account.

allowChangePassword bool Specify whether to allow the user to change password independently.

deactivatedTime string Specify the time when the account is expired.

isSystemAdmin bool Decide whether to allocate system administrator role to the user.

tenants object Specify a tenant for the user.

Only required if the parameter isSystemAdmin is false.

tenantName (string) - the tenant that the user can access.

Page 81: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 81

Parameter Type Description

isTenantAdmin (bool) - decide whether to allocate the tenant administrator role to the user. If false, you need to specify a domain for the user to access.

allowCreateDomain (bool) - decide whether to allow the user to create domains.

domains - required only if the parameter isTenantAdmin is false.

o domainName - the domain name.

o domainRoles - the role of the domain user.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'Tenant name' DOMAIN = "Domain name" def AddUser(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] headers['Token']=token full_url = server_url + "API/CMDB/user/addUser" #get data data={ 'username':'xx',#*must input 'email':'xx', 'firstName':'xx', 'lastName':'xx', 'password':'xx', 'authenticationType':1, 'PhoneNumber':'', 'department':'Netbrain', 'description':'', 'allowChangePassword':True, 'deactivtedTime':'xx', 'isSystemAdmin':True, 'tenants':[], } requests.post(full_url,data=json.dumps(data),headers=headers)

Page 82: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

82 | NetBrain Integrated Edition 7.0b API and System Integration Guide

5.33. ModifyUser

This API call is used to modify user information.

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/user/modifyUser

Yes

Request Information

Parameter Type Description

username string The user name.

email string The email address of the user.

firstName string The first name of the user.

lastName string The last name of the user.

password string The login password. The allowed length is 6-128 characters by default.

authenticationType int The authentication type for the user account.

1 - Local

2 - External

phoneNumber string The phone number of the user.

department string The department that the user belongs to.

description string Any description about the user.

allowChangePassword bool Decide whether to allow the user to change his/her password independently.

deactivatedTime string Specify the time when the user account is expired.

isSystemAdmin bool Decide whether to allocate the system administrator role to the user.

Page 83: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 83

Parameter Type Description

tenants object Specify a tenant for the user.

Only required if the parameter isSystemAdmin is false.

tenantName (string) - the tenant that the user can access.

isTenantAdmin (bool) - decide whether to allocate the tenant administrator role to the user. If it is false, you need to specify a domain for the user to access.

allowCreateDomain (bool) - decide whether to allow the user to create domains.

domains - required only if the parameter isTenantAdmin is false.

o domainName - the domain name. o domainRoles - the role of the domain user.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def ModifyUser(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] full_url = server_url + "API/CMDB/user/modifyUser" headers['Token']=token #get data data = { 'username':'xx', 'email':'[email protected]', 'firstName':'xx', 'lastName':'xx', 'password':'xx', 'authenticationType':1, 'phoneNumber':'xx', 'department':'Netbrain', 'description':'create user test by single source of glass', 'allowChangePassword':True,

Page 84: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

84 | NetBrain Integrated Edition 7.0b API and System Integration Guide

'deactivatedTime':'xx', 'isSystemAdmin':True, 'tenants':[] } requests.post(full_url,data=json.dumps(data),headers=headers)

5.34. DeleteUser

This API call is used to delete users from NetBrain system.

Resource Information

Method URL Authentication

Delete http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/user/deleteUser

Yes

Request Information

Parameter Type Description

username string The name of the user that you want to delete.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def DeleteUser(): token_url= server_url + "API/login" #get token basic_data = user + ":" + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers['Authorization'] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token']

Page 85: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 85

full_url = server_url + "API/CMDB/user/deleteUser" headers['Token']=token #get data data={ 'usernames': ['testuser01', 'testuser02'] #[name1,name2] } requests.delete(full_url,data=json.dumps(data),headers=headers)

5.35. GetDeviceData

This API call is used to get the data of a device, including configuration file, route table, ARP table, MAC table, NDP

table, STP table, BGP table and NCT table.

Resource Information

Method URL Authentication

Get http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/device/getDeviceData

Yes

Request Information

Parameter Type Description

hostname string The hostname of the device.

dataType The data type that you want to retrieve. The following data types are supported (not case-sensitive):

ConfigurationFile

RouteTable

MACTable

ARPTable

NDPTable

STPTable

BGPAdvertised-routeTable

NCTTable

vrf string The vrf name. This field is optional and only valid for route, arp or bgpadvertised-routetable type. If not specified, it will return the global vrf content.

Page 86: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

86 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Parameter Type Description

peip string The IP address of PE device. This field is only required when the data type is NCTTable.

nctName string The name of the NCT table. This field is only required when the data type is NCTTable.

subName string The subname of NCT, such as 'Global'. This field is optional and only valid for NCTTable.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def GetDevicedata(): token_url = server_url + "API/login" # get token basic_data = user + ':' + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers["Authorization"] = "Basic " + auth_data.decode() token = requests.post(token_url, headers=headers).json()['token'] headers['Token'] = token full_url = server_url + "API/CMDB/device/getDeviceData" # set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url, data=json.dumps( {'tenantName': TENANT, 'domainName': DOMAIN}), headers=headers) # get data data = { 'hostname': 'deviceName', # require, support the following types: “ConfigurationFile”,“RouteTable”, “MACTable”,”ARPTable”, “NDPTable”,”STPTable”,”BGPAdvertised-routeTable”,”NCTTable”. should ignore letter case. 'dataType': 'arptable', # //optional, only valid for route, arp, or bgp table type, when not specified, return the global vrf content. 'vrf': 'vrfName', 'nctName': 'NCT', # // required by nct table, ignored by other type 'subName': 'NCT sub name' # //optional, only valid for nct table } requests.get(full_url, params=data, headers=headers)

Page 87: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 87

5.36. AddBenchmarkTask

This API call is used to add a benchmark task to a domain.

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/benchmark/addBenchmarkTask

Yes

Request Information

Parameter Type Description

taskName string The name of the task.

description string The description of the task. This field is optional.

startDate string The date when the task starts to run. The standard time format is required, for example, '2017-07-13', '2017/07/13'.

schedule The schedule to run the task. The following sub parameters are included in this object:

frequency - the frequency to run the task. This field is required and includes ”once”, “hourly”,” daily”, “weekly” and “monthly” options.

interval - the interval to run the task (optional). This field is only valid for “hourly”,” daily”, and “weekly” options and the default value is 1, such as every 1 hour, 1 week.

startTime - the time to run the task. This field is required and the time format is full UTC time. For example, ['2017/7/11 16:20:20']. Please note that set the time according to your IIS server time zone since the time zone of your ISS server rather than your physical time zone is adopted by the benchmark task.

weekday - the day of the week to run the task. This field is optional and only valid when the frequency is weekly. 0 stands for Sunday, 6 for Saturday and 1-5 for Monday to Friday respectively.

Page 88: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

88 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Parameter Type Description

dayOfMonth - which day of a month to run the task. This field is optional and only valid when the frequency is monthly. The default is 1.

Months - which month to run the task. This field is optional and only valid when the frequency is monthly. The default is all 12 months.

deviceScope string The devices included in this task. The device scope includes three types - 'all', 'deviceGroup' and 'site'.

when the type is deviceGroup, the scope should be the array of full path of deviceGroups (for example, Public/xxx Private/xxx, System/xxx).

when the type is site, the scope should be the array of full path of sites ( for example, My Network/Unnamed-site1/Site1).

retrieveData string The data to be retrieved in this task. This field is optional and the default data is 'Built-in Live Data'.

limitRunMins string The time used to retrieve the data. When it reaches the specified time, the task will stop retrieving more data. This field is optional.

cliCommands string The customized CLI commands to retrieve data (for example, ["show version", "show arp"]. This field is optional.

isBuildIPv4L3Topo bool Determine whether to build IPv4 L3 topology. This field is optional and the default value is false.

isBuildIPv6L3Topo bool Determine whether to build IPv6 L3 topology. This field is optional and the default value is false.

isBuildL2Topo bool Determine whether to build L2 topology. This field is optional and the default value is false.

isBuildIPsecVPNTopology bool Determine whether to build IPsecVPN topology. This field is optional and the default value is false.

isRecalculateDynamicDeviceGroups

bool Determine whether to recalculate dynamic device groups. This field is optional and the default value is false.

isRecalculateSite bool Determine whether to rebuild sites. This field is optional and the default value is false.

isRecalculateMPLSVirtualRouteTables

bool Determine whether to recalculate MPLS Virtual Route Table. This field is optional and the default value is false.

Page 89: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 89

Parameter Type Description

isbuildDefaultDeviceDataView bool Determine whether to build default device data view. This field is optional and the default value is false.

isEnable bool Determine whether to enable the task. This field is optional and the default value is true.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def AddBenchmarkTask(): token_url= server_url + "API/login" #get token basic_data = user +':'+ pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers["Authorization"] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] headers['Token']=token full_url = server_url + "API/CMDB/benchmark/addBenchmarkTask" #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data data = { 'taskName':'Taskname', 'description':"xxxxx", 'startDate':'2017/7/3', # 'endDate': '2017/7/12', 'schedule':{ 'frequency':'weekly', 'startTime':['2017/7/11 16:20:20'], 'interval':1, 'weekday':[1,3,5], } } requests.post(full_url,data=json.dumps(data),headers=headers)

Page 90: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

90 | NetBrain Integrated Edition 7.0b API and System Integration Guide

5.37. EditBenchmarkTask

This API call is used to edit a specific benchmark task in a domain.

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/benchmark/editBenchmarkTask

Yes

Request Information

Parameter Type Description

taskName string The name of the task.

description string The description of the task. This field is optional.

startDate string The date when the task starts to run. The standard time format is required, for example, '2017-07-13', "2017/07/13".

schedule The schedule to run the task. The following sub parameters are included in this object:

frequency

- the frequency to run the task. This field is required and includes ”once”, “hourly”,” daily”, “weekly” and “monthly” options.

interval - the interval to run the task (optional). This field is only valid for “hourly”,” daily”, and “weekly” options and the default value is 1, such as every 1 hour, 1 week.

startTime - the time to run the task. This field is required and the time format is full UTC time. For example, ['2017/7/11 16:20:20'].

weekday - the day of the week to run the task. This field is optional and only valid when the frequency is weekly. 0 stands for Sunday, 6 for Saturday and 1-5 for Monday to Friday respectively.

Page 91: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 91

Parameter Type Description

dayOfMoDnth - which day of a month to run the task. This field is optional and only valid when the frequency is monthly. The default is 1.

Months - which month to run the task. This field is optional and only valid when the frequency is monthly. The default is all 12 months

deviceScope string The devices included in this task. The device scope includes three types - 'all', 'deviceGroup' and 'site'.

when the type is deviceGroup, the scope should be the array of full path of deviceGroups (for example, Public/xxx Private/xxx, System/xxx);

when the type is site, the scope should be the array of full path of sites ( for example, My Network/Unnamed-site1/Site1).

retrieveData string The data to be retrieved in this task. This field is optional and the default data is 'Built-in Live Data'.

limitRunMins string The time used to retrieve the data. When specified time reaches, the task will stop retrieving more data. This field is optional.

cliCommands tring The customized CLI commands to retrieve data (for example, ["show version", "show arp"]. This field is optional.

isBuildIPv4L3Topo bool Determine whether to build IPv4 L3 topology. This field is optional and the default value is false.

isBuildIPv6L3Topo bool Determine whether to build IPv6 L3 topology. This field is optional and the default value is false.

isBuildL2Topo bool Determine whether to build L2 topology. This field is optional and the default value is false.

isBuildIPsecVPNTopology bool Determine whether to build IPsecVPN topology. This field is optional and the default value is false.

isRecalculateDynamicDeviceGroups bool Determine whether to recalculate dynamic device groups. This field is optional and the default value is false.

Page 92: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

92 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Parameter Type Description

isRecalculateSite bool Determine whether to rebuild sites. This field is optional and the default value is false.

isRecalculateMPLSVirtualRouteTables bool Determine whether to recalculate MPLS Virtual Route Table. This field is optional and the default value is false.

isbuildDefaultDeviceDataView bool Determine whether to build the default device data view. This field is optional and the default value is false.

isEnable bool Determine whether to enable the task. This field is optional and the default value is true.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def EditBenchmarkTask(): token_url= server_url + "API/login" #get token basic_data = user +':'+ pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers["Authorization"] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] headers['Token']=token full_url = server_url + "API/CMDB/benchmark/editBenchmarkTask" #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data data = { 'taskName': 'taskName',# required, name of the task 'newTaskName': 'newTaskName',# optional 'startDate': '2017/6/30', #optional 'schedule': { 'frequency':'once',# once, hourly, daily, weekly, monthly 'interval': 1, #for hourly, daily, weekly 'startTime': [],# daily support multi, other support single

Page 93: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 93

} } requests.post(full_url,data=json.dumps(data),headers=headers)

5.38. DeleteBenchmarkTask

This API call is used to delete a specific benchmark task in a domain.

Resource Information

Method URL Authentication

Delete http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/benchmark/deleteBenchmarkTask

Yes

Request Information

Parameter Type Description

taskName string The name of the task.

isDeleteRelatedDataFolders bool Determine whether to delete the related benchmark folder. This field is optional and the default value is false.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def DeleteBenchmarkTask(): token_url= server_url + "API/login"

Page 94: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

94 | NetBrain Integrated Edition 7.0b API and System Integration Guide

#get token basic_data = user +':'+ pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers["Authorization"] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] headers['Token']=token full_url = server_url + "API/CMDB/benchmark/deleteBenchmarkTask" #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data data = { 'taskName':'xx', 'isDeletedDataFolders': True } requests.delete(full_url,data=json.dumps(data),headers=headers)

5.39. RunBenchmarkTaskNow

This API call is used to run a benchmark task immediately.

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/benchmark/runBenchmarkTaskNow

Yes

Request Information

Parameter Type Description

taskName string The name of the task.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin"

Page 95: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 95

server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def RunBenchmarkTaskNow(): token_url= server_url + "API/login" #get token basic_data = user +':'+ pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers["Authorization"] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] headers['Token']=token full_url = server_url + "API/CMDB/benchmark/runBenchmarkTaskNow" #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data data = { 'taskName':'taskName', } requests.post(full_url,data=json.dumps(data),headers=headers)

5.40. GetDeviceNbrs

This API call is used to get neighbors of a specified device.

Resource Information

Method URL Authentication

Get http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/neighbor/getDeviceNbrs

Yes

Request Information

Parameter Type Description

hostname string The device name.

topoType string Return the neighbors in a specified topology type, such as 'L2_Topo_Type’, ‘L3_Topo_Type’, ‘Ipv6_L3_Topo_Type’ or ‘VPN_Topo_Type'.

Page 96: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

96 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def GetDeviceNbrs(): token_url= server_url + "API/login" #get token basic_data = user +':'+ pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers["Authorization"] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] headers['Token']=token full_url = server_url + "API/CMDB/neighbor/getDeviceNbrs" #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data data = { 'hostname':'DeviceName', 'topoType' : 'topology_type' # 'L2_Topo_Type’, ‘L3_Topo_Type’, ‘Ipv6_L3_Topo_Type’ or ‘VPN_Topo_Type'. } requests.get(full_url,params=data,headers=headers)

5.41. GetConnectedSwitchPort

This API call is used to get the connected L2 switch ports (not the L3 router interfaces) of an interface and the

device that the interface belongs to.

Resource Information

Method URL Authentication

Get http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/site/getConnectedSwitchPort

Yes

Page 97: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 97

Request Information

Parameter Type Description

IP string The IP address of a device interface.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def GetConnectedSwitchPort(): token_url= server_url + "API/login" #get token basic_data = user +':'+ pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers["Authorization"] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] headers['Token']=token full_url = server_url + "API/CMDB/site/getConnectedSwitchPort" #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data data = { 'ip':'1.1.1.1' } requests.get(full_url,params=data,headers=headers)

5.42. DeleteMap

This API call is used to delete a map file from a domain.

Page 98: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

98 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Resource Information

Method URL Authentication

Delete http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/map/deleteMap Yes

Request Information

Parameter Type Description

url string The url of the map that you will delete.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def DeleteMap(): token_url= server_url + "API/login" #get token basic_data = user +':'+ pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers["Authorization"] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] headers['Token']=token full_url = server_url + "API/CMDB/map/deleteMap" #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data data = { 'url':'mapurl' } requests.delete(full_url,data=json.dumps(data),headers=headers)

5.43. ExportMap

Page 99: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 99

This API call is used to export a map.

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/map/exportMap Yes

Request Information

Parameter Type Description

url string The url of the map that you will export.

format string The format of the exported map file, such as 'xmap', 'visio'.

pages string The name of the map page that you want to export. This field is optional and only valid for the visio format.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def ExportMap(): token_url= server_url + "API/login" #get token basic_data = user +':'+ pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers["Authorization"] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] headers['Token']=token full_url = server_url + "API/CMDB/map/exportMap" #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data

Page 100: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

100 | NetBrain Integrated Edition 7.0b API and System Integration Guide

data = { 'url':'map url', 'format':'xmap',#xmap,visio 'pages':[] #/optional, only for visio format, not valid for qmap format, # qmap must be full map, the export file can be import later. # this will not be supported in this version unless the requirement changed. } map_data=requests.post(full_url,data=json.dumps(data),headers=headers).json() path='c:\\map.xmap' with open(path,'wb') as ff: ff.write(base64.b64decode(map_data['fileData']))

5.44. ImportSiteTree

This API call is used to import a site tree.

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/site/importSiteTree Yes

Request Information

Parameter Type Description

fullPath string The full path where to import the site. For example, 'My Network/Site1/Boston'.

isContainer bool Used to determine whether it is a container site. The default value is false.

devices object The devices contained in the imported site.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/"

Page 101: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 101

headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def ImportSiteTree(): token_url= server_url + "API/login" #get token basic_data = user +':'+ pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers["Authorization"] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] headers['Token']=token full_url = server_url + "API/CMDB/site/importSiteTree" #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data data = { 'sites': [ { 'fullPath':'path', 'isContainer':'false', 'devices': ['device1', 'device2', 'device3'], } ] } requests.post(full_url,data=json.dumps(data),headers=headers)

5.45. AddRole

This API call is used to add a role and grant privileges to the role.

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/role/addRole

Yes

Request Information

Parameter Type Description

roleName string The name of the created role.

Page 102: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

102 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Parameter Type Description

description string The description of the role. This field is optional.

privileges string The privileges that the role owns. See roles and privileges for more details. this field is optional.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def AddRole(): token_url= server_url + "API/login" #get token basic_data = user +':'+ pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers["Authorization"] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] headers['Token']=token full_url = server_url + "API/CMDB/role/addRole" #get data data = { 'roleName': 'RoleName', 'description': 'This is a API test...', 'privileges': ["domainManagement","sharePolicyManagement"] #input the privilege name in required format. } requests.post(full_url,data=json.dumps(data),headers=headers)

Roles and Privileges

The system provides the following pre-defined roles and the default privileges of each role are listed as follows:

Page 103: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 103

Privileges Explanation Domain Admin

Power User

Engineer Guest Network Change Creator

Network Change Executor

Domain Management

Log in to the Domain Management page and do the following domain management tasks:

View, export, and delete discovery report in the Domain Manager

Add network definition

Resolve unknown end systems in the Unknown End System Manager

View created snapshots in the Snapshot Manager

View and export global Data Folders in Global Data Folder Manager

View, add, modify, delete, disable topology links in the Topology Link Manager

Resolve duplicated IPs and subnets in the Duplicated IP and Subnet Manager

Add checkpoint OPSEC tasks in the Checkpoint OPSEC Manager

Configure network security settings and minimum subnet mask in L2 topology building

Configure desktop profile for all users under a domain

√ √ √ √

Share Policy Management

Configure share policy (assign domain access and privileges to other users in this domain)

Device Management

Add, modify, and remove MPLS cloud

Remove devices from a domain √ √ √ √

Shared Device Group Management

Add devices into a device group from Map Data Folder Manager, Global Data Folder Manager, Data Folder Manager

Create a shared device group or set a private device group as public in the Device Group pane

√ √ √ √

Page 104: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

104 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Privileges Explanation Domain Admin

Power User

Engineer Guest Network Change Creator

Network Change Executor

Save discovered devices into a device group from on-demand discovery results

Add devices into a device group from the Domain Manager

Site Management

Add MPLS clouds and unclassified network devices from the Domain Manager into a site

Open the Site Manager to do site management, such as creating, editing, deleting, importing, committing, rebuilding sites, and so on

√ √ √ √

Discover/Tune Network Device

Create a do-not-scan list

Add discovery tasks from the Start Page or the Schedule Task page

Rediscover selected IPs and devices in the Domain Manager

Tune live access

Run on-demand discoveries

√ √ √ √

Schedule Benchmark

Add benchmark tasks from the Start Page or the Schedule Task page

√ √ √ √

Global Data Folder/Snapshot Management

Create, edit, and delete snapshots in the Snapshot Manager

Modify and delete data in Global Data Folders

Delete Global Data Folders manually or schedule a regular auto clear up

√ √ √ √

Manage Network Settings

Configure and manage shared network settings √ √ √ √

Manage Device Settings

Configure and manage shared device settings for each device in a domain from the following entries:

o Site pane

√ √ √ √ √

Page 105: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 105

Privileges Explanation Domain Admin

Power User

Engineer Guest Network Change Creator

Network Change Executor

o Map

o Domain Manager

o Discover

o Tune Live Access

Access to Live Network

Download the shared network settings or device settings data from the server and use these data to retrieve live device data from the network, which includes:

Run CLI commands and Qapps on a map page or in a runbook

Re-run CLI commands in the Map Data Folder Manager, Data Folder Manager, and Global Data Folder Manager

Run monitor (Qapp-based) widgets and retrieve live data in static widgets in a dashboard

Run Data View Template using the live network as the data source

Retrieve variables once or monitor variables periodically from the live network in Instant Qapp

Calculate live paths (use live network as the data source)

Configure SNMP, CLI timeout, SNMP hostname trim rules, management interface selection order, and live access method polling order (SNMP/Telnet/SSH/Jumpbox)

Browse live access logs in the Domain Manager

√ √ √ √ √ √

Create Network Change

Create network change tasks. √ √ √

Execute Network Change

Execute network change tasks. √ √ √

Page 106: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

106 | NetBrain Integrated Edition 7.0b API and System Integration Guide

5.46. EditRole

This API call is used to edit a role and its privileges.

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/role/editRole Yes

Request Information

Parameter Type Description

newRoleName string A new name of the role. This field is optional.

roleName string The current name of the role.

description string The description of the role. This field is optional.

privileges string The privileges that the role owns. See roles and privileges for more details.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def EditRole(): token_url= server_url + "API/login" #get token basic_data = user +':'+ pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data)

Page 107: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 107

headers["Authorization"] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] headers['Token']=token full_url = server_url + "API/CMDB/role/editRole" #get data data = { 'newRoleName': 'newRoleName', 'roleName': 'RoleName', 'description': "edit role api test", 'privileges': ['xx', 'xx'] } requests.post(full_url,data=json.dumps(data),headers=headers)

5.47. DeleteRole

This API call is used to delete a role.

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/role/deleteRole Yes

Request Information

Parameter Type Description

roleName string The name of the role.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name"

Page 108: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

108 | NetBrain Integrated Edition 7.0b API and System Integration Guide

def deleteRole(): token_url= server_url + "API/login" #get token basic_data = user +':'+ pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers["Authorization"] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] headers['Token']=token full_url = server_url + "API/CMDB/role/deleteRole" #get data data = { 'roleName': 'roleName' } requests.delete(full_url,data=json.dumps(data),headers=headers)

5.48. AddTenant

This API call is used to create a tenant.

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/tenant/addTenant Yes

Request Information

Parameter Type Description

tenantName string The name of the created tenant.

description string The description about the tenant. This field is optional.

maximumNodes Int The maximum license nodes that the tenant owns. The number must be greater than 0.

advancedOptions This field is optional and used to configure advanced options for the created tenant.

{ tenantName: xx, description: xx maximumNodes: xx advancedOptions: { tenantConnSetting: {# configure the server to store tenant data 'replicaSet': 'xx' 'servers': 'xx'

Page 109: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 109

Parameter Type Description 'user': 'xx' 'password': 'xx' }, liveDataConnSetting: {# configure the server to store live data 'replicaSet': 'xx' 'servers': 'xx' 'user': 'xx' 'password':'xx' } } }

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def AddTenant(): token_url= server_url + "API/login" #get token basic_data = user +':'+ pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers["Authorization"] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] headers['Token']=token full_url = server_url + "API/CMDB/tenant/addTenant" #get data data = { 'tenantName': 'xx', 'description': 'test', 'maximumNodes': 20, } requests.post(full_url,data=json.dumps(data),headers=headers)

5.49. EditTenant

Page 110: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

110 | NetBrain Integrated Edition 7.0b API and System Integration Guide

This API call is used to edit a tenant.

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/tenant/editTenant

Yes

Request Information

Parameter Type Description

newTenantName string A new name for the tenant. This field is optional.

tenantName string The current name of the tenant.

description string The description of the tenant. This field is optional.

maximumNodes Int The maximum license nodes that the tenant owns. The number must be greater than 0.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def EditTenant(): token_url= server_url + "API/login" #get token basic_data = user +':'+ pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers["Authorization"] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] headers['Token']=token full_url = server_url + "API/CMDB/tenant/editTenant" #get data

Page 111: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 111

data = { 'newTenantName': 'newTenantName', 'tenantName': 'tenantName', 'description': 'Test edit tenant Name', 'maximumNodes': 20, } requests.post(full_url,data=json.dumps(data),headers=headers)

5.50. DeleteTenant

This API call is used to delete a tenant.

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/tenant/deleteTenant

Yes

Request Information

Parameter Type Description

tenantName string The name of the tenant.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def deleteTenant(): token_url= server_url + "API/login" #get token basic_data = user +':'+ pwd

Page 112: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

112 | NetBrain Integrated Edition 7.0b API and System Integration Guide

basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers["Authorization"] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] headers['Token']=token full_url = server_url + "API/CMDB/tenant/deleteTenant" #get data data = { 'tenantName': 'xx', } requests.delete(full_url,data=json.dumps(data),headers=headers)

5.51. AssignUsersForTenant

This API call is used to assign users for a specified tenant.

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/tenant/assignUsersForTenant

Yes

Request Information

Parameter Type Description

TenantName string The name of the tenant. This field is optional. If this parameter has an incoming value, then the incoming value will be used; If not, this parameter uses the value of tenantName in the SetCurrentDomain; If this parameter cannot get a value by either of the above ways, an error will prompt.

userName string The names of the users that you want to assign.

isTenantAdmin bool Determine whether the assigned user is an admin. This field is optional.

"tenantName": "testTenant001", "users":[{"userName":"user1","isTenantAdmin":true}]

Request Format

Python

Page 113: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 113

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def assignUserForTenant(): token_url= server_url + "API/login" #get token basic_data = user +':'+ pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers["Authorization"] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] headers['Token']=token full_url = server_url + "API/CMDB/tenant/assignUsersForTenant" #get data data = { 'tenantName': 'xx', 'users': [ { 'userName':'User1',"isTenantAdmin":True } ] } requests.post(full_url,data=json.dumps(data),headers=headers)

5.52. CreateDomain

This API call is used to create a domain.

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/domain/createDomain

Yes

Page 114: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

114 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Request Information

Parameter Type Description

tenantName string The name of the tenant where you will create a domain.

domainName string The name of the created domain.

maximumNodes Int The maximum license nodes that the domain owns. The number must be greater than 0.

description string The description of the tenant. This field is optional.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def CreateDomain(): token_url= server_url + "API/login" #get token basic_data = user +':'+ pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers["Authorization"] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] headers['Token']=token full_url = server_url + "API/CMDB/domain/createDomain" #get data data = { 'tenantName': 'xx', 'domainName': 'xx', 'maximumNodes': 100, 'description': 'This is a test for creating domain' } requests.post(full_url,data=json.dumps(data),headers=headers)

5.53. EditDomain

Page 115: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 115

This API call is used to edit a domain.

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/domain/editDomain

Yes

Request Information

Parameter Type Description

tenantName string The name of the tenant.

domainName string The name of the domain.

newDomainName string A new name for the domain. This field is optional.

maximumNodes Int The maximum license nodes that the domain owns. The number must be greater than 0.

description string The description of the tenant. This field is optional.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def EditDomain(): token_url= server_url + "API/login" #get token basic_data = user +':'+ pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers["Authorization"] = "Basic " + auth_data.decode()

Page 116: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

116 | NetBrain Integrated Edition 7.0b API and System Integration Guide

token = requests.post(token_url,headers=headers).json()['token'] headers['Token']=token full_url = server_url + "API/CMDB/domain/editDomain" #get data data = { 'tenantName': 'xx', 'newDomainName': 'newDomainNone', 'domainName': 'domainName', 'maximumNodes': 200, 'description': 'edit domain API' } requests.post(full_url,data=json.dumps(data),headers=headers)

5.54. DeleteDomain

This API call is used to delete a domain.

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/domain/deleteDomain Yes

Request Information

Parameter Type Description

domainName string The name of the domain.

tenantName string The name of the tenant.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name'

Page 117: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 117

DOMAIN = "domain_name" def deleteDomain(): token_url= server_url + "API/login" #get token basic_data = user +':'+ pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers["Authorization"] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] headers['Token']=token full_url = server_url + "API/CMDB/domain/deleteDomain" #get data data = { 'tenantName': 'xx', 'domainName': 'domainName' } requests.delete(full_url,data=json.dumps(data),headers=headers)

5.55. AssignUsersForDomain

This API call is used to assign users for a specified domain.

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/domain/assignUsersForDomain

Yes

Request Information

Parameter Type Description

tenantName string The name of the tenant. This field is optional. If this parameter has an incoming value, then the incoming value will be used; If not, this parameter uses the value of tenantName in the SetCurrentDomain; If this parameter cannot get a value by either of the above ways, an error will prompt.

domainName string The name of the domain.

userName string The name of the created user.

Page 118: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

118 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Parameter Type Description

roles object The roles of the created user.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def AssignUsersForDomain(): token_url = server_url + "API/login" # get token basic_data = user + ':' + pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers["Authorization"] = "Basic " + auth_data.decode() token = requests.post(token_url, headers=headers).json()['token'] headers['Token'] = token full_url = server_url + "API/CMDB/domain/assignUsersForDomain" # get data data = { 'tenantName': 'xx', 'domainName': 'domainName', 'users': [ {'userName': 'xxx', 'roles': ['xxxx', 'xxxx'] } ] } requests.post(full_url, data=json.dumps(data), headers=headers)

5.56. RemoveUsersFromDomain

This API call is used to remove users from a domain.

Page 119: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 119

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/domain/removeUsersFromDomain

Yes

Request Information

Parameter Type Description

tenantName string The name of the tenant.

domainName string The name of the domain.

users object The users to be deleted.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def removeUsersForDomain(): token_url= server_url + "API/login" #get token basic_data = user +':'+ pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers["Authorization"] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] headers['Token']=token full_url = server_url + "API/CMDB/domain/removeUsersFromDomain" #get data data = { 'tenantName': 'xx', 'domainName': 'domainName', 'users': ['xx','xx']

Page 120: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

120 | NetBrain Integrated Edition 7.0b API and System Integration Guide

} requests.delete(full_url,data=json.dumps(data),headers=headers)

5.57. AddNetworkSetting

This API call is used to add more entries in the Network Settings, including NetBrain Proxy Server, private key,

jump boxes , telnet/SSH, privilege and SNMP information.

Resource Information

Method URL Authentication

Post http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/networkSettings/addNetworkSetting

Yes

Request Information

Parameter Type Description

proxyServer Object Used to add a proxy server. The following sub parameters are included in this object:

alias (string): the alias of the NetBrain Proxy Server. This field is required.

ipOrHostname (string): the IP address or hostname of the proxy server. This field is required.

port (int): the communication port of the proxy server. This field is required and the default value is 9099.

timeOut (int): the threshold for live access timeout. This field is required and the default value is 2 second.

encryptionKey (string): the encryption key configured during the installation of the NetBrain Proxy Server. This field is optional.

privateKey Object Used to add a private key. The following sub parameters are included in this object:

alias (string): the alias of the private key. This field is required.

keyName (string): the name of the private key. This field is required.

md5KeyContent: the MD5 content of the key. This field is optional.

keyContent: the content of the key. This field is optional.

Page 121: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 121

Parameter Type Description

passphrase: the passphrase of the key. This field is optional.

jumpBox Object Used to add a jump box. The following sub parameters are included in this object:

alias (string): the alias of the jump box. This field is required.

ipAddr (string): the IP address of the jump box. This field is required.

mode (int): the access mode from the Proxy Server to the Jump box. This field is required.

o 0: Telnet

o 1: SSH

o 2: SSH Public Key

port (int): the port of the access port such as 23 for telnet. This field is required.

userName (string): the username to access the jump box. This field is only required when the mode is 1 or 2.

password (string): the password to access the jump box. This field is only required when the mode is 1.

keyName (string): the name of the SSH public key. This field is only required when the mode is 2.

loginPrompt (string): the login prompt to connect the jump box. This field is optional.

passwordPrompt (string): the login password to connect the jump box. This field is optional.

commandPrompt (string): the prompt to enter CLI command, such as >. This field is optional.

yesNoPrompt (string): the prompt to save the SSH key.

telnetCommand (string): configure a special command to access via Telnet if necessary. For example, telnet $(IP) $(PORT). This field is optional.

SSHCommand(string): configure a special command to access via SSH if necessary. For example, ssh -l $(USERNAME) -p $(PORT) $(IP). This field is optional.

cmd2 (string): the login command for the special command. This field is optional.

cmd2PasswordPrompt (string): the login prompt to connect the jump box for the special command. This field is optional.

Page 122: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

122 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Parameter Type Description

cmd2Password (string): the login password to connect the jump box for the special command. This field is optional.

cmd2ModePrompt (string): the mode prompt for the special command. This field is optional.

quitCmd (string): the quit command. This field is optional.

telnetInfo Object Used to add telnet/SSH login credentials. The following sub parameters are included in this object:

alias (string): the alias of telnet/SSH login credentials. This field is required.

userName (string): the user name of the non-privilege login. This field is optional.

password (string): the password of of the non-privilege login. This field is optional.

cliMode (int): the authentication method. This field is required

o 0: Telnet/SSH Password

o 2: SSH public key

keyName (string): the name of the SSH public key. This field is only required when cli mode is 2.

privilegeInfo Object Used to add privilege credentials.

alias (string): the alias of the privilege credentials. This field is required.

userName (string): the user name of the privilege login. This field is optional.

password (string): the password of of the privilege login. This field is optional.

snmpInfo Object Used to add SNMP credentials.

alias (string): the alias of the privilege credentials. This field is required.

snmpVersion (int): the version of the SNMP string. This field is required.

o 1: SNMP v1 and v2c

o 3: SNMP v3

The other parameters are different based on SNMP version.

SNMP v1 and v2c:

o roString (string): SNMP read-only community string.

Page 123: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 123

Parameter Type Description

'snmpInfo': { 'alias': xx, 'snmpVersion':1, 'roString': xx, }

SNMP v3:

o authMode (int): the authentication mode of SNMP V3. This field is required

1: no authen no priv

2: auth no priv

3: auth priv

o authPro (int): the authentication method. This field is required

1: md5

2: SHA

o encryptPro (int): the encryption method. This field is required.

1: DES

2: AES

3: AES192

4: AES256

o userName (string): the user name to access the network devices. This field is required.

o contextName (string): the context name of authentication privilege. This field is optional.

o authPassword (string): the authentication password. This field is only required when the authMode is 2 or 3.

o encryptPassword (string): the encryption password. This field is only required when the authMode is 3.

'snmpInfo': { 'alias': xx, 'snmpVersion':3 'v3':{ 'userName':xx, 'contextName':

'authMode':xx, #1:no authen no priv 2:auth no priv 3:auth priv)

Page 124: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

124 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Parameter Type Description

'authPro':xx, #1:md5 2:SHA) 'encryptPro':xx, #1:DES 2:AES 3:AES192 4:AES256 'authPassword': xx , 'encryptPassword': xx , } }

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def addNetworkSetting(): token_url= server_url + "API/login" #get token basic_data = user +':'+ pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data) headers["Authorization"] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] headers['Token']=token full_url = server_url + "API/CMDB/networkSettings/addNetworkSetting" #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data data = { 'proxyServer': { 'alias':'xxxx', 'ipOrHostName':'192.168.1.23', 'Port':9099, 'timeOut': 2, 'encryptionKey': 'netbrain12345' } } requests.post(full_url,data=json.dumps(data),headers=headers)

5.58. DeleteNetworkSetting

Page 125: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 125

This API call is used to delete NetBrain Proxy Server and related credentials configured in the Network Settings.

Resource Information

Method URL Authentication

Delete http(s)://IP address of NetBrain Web API Server/ServicesAPI/API/CMDB/networkSettings/deleteNetworkSetting

Yes

Request Information

Parameter Type Description

proxyServer Object Delete a proxy server by alias.

privateKey Object Delete a private key credential by alias.

jumpBox Object Delete a jump box by alias.

telnetInfo Object Delete a telnet/SSH login credential by alias.

PrivilegeInfo Object Delete a privilege credential by alias.

snmpInfo Object Delete a SNMP credential by alias.

Request Format

Python

import requests import json import base64 # Need to install requests package for python # pip install requests user = "admin" pwd = "admin" server_url = "http://127.0.0.1/ServicesAPI/" headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} TENANT = 'tenant_name' DOMAIN = "domain_name" def deleteNetworkSetting(): token_url= server_url + "API/login" #get token basic_data = user +':'+ pwd basic_data = basic_data.encode("ascii") auth_data = base64.b64encode(basic_data)

Page 126: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

126 | NetBrain Integrated Edition 7.0b API and System Integration Guide

headers["Authorization"] = "Basic " + auth_data.decode() token = requests.post(token_url,headers=headers).json()['token'] headers['Token']=token full_url = server_url + "API/CMDB/networkSettings/deleteNetworkSettings #set tenant and domain Tenant_url = server_url + "API/setCurrentDomain" requests.post(Tenant_url,data=json.dumps({'tenantName':TENANT,'domainName':DOMAIN}),headers=headers) #get data data={ 'proxyServer':{ 'alias':"xxxx" }, 'privatekey':{ 'alias':'xxx' }, 'jumpBox':{ 'alias':'xxx' }, 'telnetInfo':{ 'alias':'xxaww' }, 'privilegeInfo':{ 'alias':"xxxx" }, 'snmpInfo':{ 'alias':'xxx' } } requests.delete(full_url,data=json.dumps(data),headers=headers)

Page 127: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 127

6. Device Type Name and ID

The following table lists the predefined device types and the corresponding IDs.

Type Name ID

End System 1004

LAN 1007

WAN 1008

DMVPN 1010

Juniper Router 102

Unclassified Device 1021

Cisco WAP 1025

Mute LAN 1026

Dell Networking Switch 10327

MikroTik 10336

Xirrus Wireless Array 10339

Adtran 10352

Cisco ACE 10357

Unknown IP Device 1036

A10 Load Balancer 10369

Internet Wan 1037

Fortinet FortiGate Firewall 10380

Netscaler Load Balancer 10381

Page 128: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

128 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Type Name ID

Sidewinder Firewall 10402

Hirschmann Switch 10416

Alcatel Lucent Service Router 10417

Alcatel OmniSwitch 10418

Radwin Radio Devices 10429

HuaWei Switch 10430

Cisco UCS Fabric 10441

MRV 10455

RuggedCom ROX Switch 10457

Uplogix 10464

SMC Switch 10465

Riverbed WAN Optimizer 10466

Tellabs Router 10485

RuggedCom RS(G) 10487

Avaya Switch 10513

Dell Sonicwall 10515

Casa 10516

Tellabs Switch 10524

Aruba LWAP 10529

Alcatel OmniStack Switch 10530

Dlink Switch 10531

Page 129: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 129

Type Name ID

Cisco WAAS 10532

Brocade Vyatta Router 10533

Juniper QFabric System 10540

SilverPeak WAN Optimizer 10541

Aruba IAP 10547

Cisco VDS 10563

Arris Router 10566

Calix E-Series 10567

Cisco Meraki AP 10571

Adva Optical 10586

Cisco Meraki Switch 10591

Avaya Router 10592

GigaVUE-OS 10611

Cisco Meraki Cloud 10613

Bluecoat 10615

Cisco Meraki Firewall 10616

Cisco MDS 10617

Fujitsu Switch 10618

Viptela 10619

Redback Router 10623

Calix B-Series 10624

Page 130: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

130 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Type Name ID

T-Marc 300 Series 10632

Avaya VSP 10659

IBM Switch 10660

Cisco Router 2

Cisco IOS Switch 2001

Cisco PIX Firewall 2002

F5 Load Balancer 2003

Cisco Nexus Switch 2004

Checkpoint Firewall 2007

NetScreen Firewall 2008

Cisco ASA Firewall 2009

HP ProCurve Switch 2011

Juniper EX Switch 2012

Arista Switch 2013

Dell Force10 Switch 2015

Juniper SRX Firewall 2018

Unclassified Router 2021

Extreme Switch 2023

Brocade Switch 2024

Unclassified Firewall 2030

Unclassified Load Balancer 2035

Page 131: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 131

Type Name ID

HP Menu-Driven Switch 2041

Cisco Catalyst Switch 2060

Unclassified Switch 2061

Cisco CSS 2062

Nortel Switch 2110

Palo Alto Firewall 2130

Ciena Switch 2140

Enterasys Switch 2150

Cisco IOS XR 2999

Call Manager 3001

IP Phone 3002

Cache Engine 3003

Cisco WLC 3033

LWAP 3034

Aruba WLC 3035

3Com Switch 3333

Crossbeam Firewall 10811

Moxa Switch 10921

Big Switch 10930

Oracle Acme 10951

Cisco IPS 10953

Page 132: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

132 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Page 133: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

NetBrain Integrated Edition 7.0b API and System Integration Guide | 133

7. Error Code List

When calling RESTful APIs, you may encounter resource errors for invalid inputs or other reasons. The returned error codes (referred to as statusCode in NetBrain system) and their descriptions are listed as follows:

Status Code Description

0 No errors.

790000 Null parameter.

790001 Invalid parameter.

790002 No permissions to access an API.

790003 Session expired.

790004 Request expired.

790005 Invalid token.

790006 Invalid tenant.

790007 Invalid domain.

790008 The {0} does not exist in the system.

790009 The {0} already exists in the system.

790010 The {0} does not support the {1} feature.

798000 Unexpected Error.

798001 Inner exception.

791000 Invalid username or password.

798000 Unexpected exception.

792000 Can't edit the entered attributes.

792001 The entered attribute has been locked.

792002 The device type does not support the attribute {0}.

792003 This is a system built-in attribute. Please enter a valid one.

793000 Source gateway is not found.

793001 Error occurs during path calculation.

794000 Can't perform the discovery task due to no IP addresses.

Page 134: NetBrain Integrated Edition API and System Integration Guide...NetBrain Integrated Edition 7.0b API and System Integration Guide | 11 2. Select the API Manager > API Server tab and

134 | NetBrain Integrated Edition 7.0b API and System Integration Guide

Status Code Description

794001 The discover task is currently running.

795001 System users can not be added and edited.

795002 Domain node count exceeds tenant available node count.

795003 Do not allow resetting passwords.