No relevant resource is found in the selected language.

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Read our privacy policy>Search

Reminder

To have a better experience, please upgrade your IE browser.

upgrade

eSight V300R010C00SPC200, 300, and 500 Self-Service Integration Guide 10

Rate and give feedback:
Huawei uses machine translation combined with human proofreading to translate this document to different languages in order to help you better understand the content of this document. Note: Even the most advanced machine translation cannot match the quality of professional translators. Huawei shall not bear any responsibility for translation accuracy and it is recommended that you refer to the English document (a link for which has been provided).
Device Change Message

Device Change Message

This section describes the device change message interface.

Message Subscription Interface

Function

This interface subscribes to the device change message based on the third-party system ID, openID of the interface for receiving third-party system messages, URL of the interface for receiving third-party system messages, and subscription operation description.

URI

/rest/openapi/notification/common/nedevice

Access Method

PUT

Parameter Description

Parameter

Mandatory/Optional

Location

Value Type

Description

openid

Mandatory

Request header parameter list

String

Indicates the session identifier. It is used for open API authentication.

NOTE:

A third-party invokes the login interface (section Log In to the eSight) for security management to obtain this parameter.

systemID

Mandatory

Request entity parameter list

String

Indicates the third-party system ID.

NOTE:

The value can be an IP address of 1 to 64 characters, including digits (0-9), lowercase letters (a-z), uppercase letters (A-Z), and the following special characters: @ _ - ( ) , . ^ $ ~ ` !

openID

Mandatory

Request entity parameter list

String

Indicates the credential used by eSight to proactively connect to a third-party system. Third-party systems assign credentials and use credentials for authentication.

NOTE:

The value consists of 1 to 1024 characters, including digits (0-9), lowercase letters (a-z), uppercase letters (A-Z), and the following special characters: @ _ - ( ) , . ^ $ ~ ` !

url

Mandatory

Request entity parameter list

String

eSight sends a notification message to the URL in POST mode.

NOTE:

For example, http://10.10.10.1:8080/device. The URL correctness must be ensured by the notification message subscriber. The IP address is specified in the OpenAPI whitelist. The value consists of 1 to 1024 characters complying with the HTTP URL encoding specification.

dataType

Optional

Request entity parameter list

String

Indicates the value type of the data field in the notification packet.

NOTE:

Currently, only the JSON value type is supported. The default value is JSON.

desc

Optional

Request entity parameter list

String

Indicates the description of a third-party system.

NOTE:

The default value is null, indicating that the parameter is not specified. The value consists of 0 to 1024 characters. The character set is not restricted.

Result

Field

Value Type

Description

code

int

Indicates the operation return code. The options are as follows:

  • 0: successful
  • Others: failed Value 1001 indicates that the license is invalid, 1002 indicates that the license cannot invoke OpenAPI, 1204 indicates that the authentication fails, 1501 indicates that no system ID is provided, 1502 indicates that the system ID is invalid, 1503 indicates that third-party system openID for authentication is not provided, 1504 indicates that third-party system openID for authentication is invalid, 1505 indicates that the data type is not supported, 1506 indicates that the URL for receiving third-party messages is not provided, 1507 indicates that the URL for receiving third-party messages is invalid, 1508 indicates that the URL for receiving third-party messages is not in the OpenAPI whitelist, 1509 indicates that the description provided is invalid, 1510 indicates that the requested resourceURI does not exist (that is, the resource corresponding to the entire request URL does not exist), and 1511 indicates that the subscription is invalid because the request URL is invalid.

data

String

The field is displayed as null.

description

String

Indicates the description of the interface invoking result.

Precautions

None

Invocation ExampleExample

Data Segment

Value

Request URL

PUT https://eSightIP: port/rest/openapi/notification/common/nedevice HTTP/1.1

Request header

openid: 775c47f9-9a1b-43f9-a24b-2c3db1a55622;

Request entity

systemID=example%40system&openID=1b7a6992-5d5f-4091-a49f-ec2e09640a05&url=https%3A%2F%2FdemoIP%3AdemoPort%2Fnotification&dataType=JSON&desc=eSight+DesignIn+Demo

Response entity

{"code":0,"data":null,"description":"Operation success."}

Usage Example

package com.huawei.nms.openapi.demo.notification;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpResponse;
import org.apache.http.message.BasicNameValuePair;

import com.huawei.nms.openapi.demo.global.GlobalVar;
import com.huawei.nms.openapi.demo.global.NewHttpsAccess;
import com.huawei.nms.openapi.demo.sm.Login;

public class PutNedeviceTest {

 public static void main(String[] args) throws Exception {
   Login.login();
   put();
 }

 public static void put() throws Exception {
        //set the URL and method
        final String openidURL = "/rest/openapi/notification/common/nedevice";
        final String method = "PUT";
        
        List<BasicNameValuePair> headers = new ArrayList<BasicNameValuePair>();
        headers.add(new BasicNameValuePair("openid", GlobalVar.globalOpenid));

        //set parameters
        final List<BasicNameValuePair> parameters = new ArrayList<BasicNameValuePair>();
        parameters.add(new BasicNameValuePair("systemID","NMSinfo1"));
        parameters.add(new BasicNameValuePair("openID","127.0.0.1"));
        parameters.add(new BasicNameValuePair("url","http://127.0.0.2:8080/device"));
        parameters.add(new BasicNameValuePair("dataType","JSON"));
        parameters.add(new BasicNameValuePair("desc",""));
        
        //send the request
        final HttpResponse response = NewHttpsAccess.access(GlobalVar.GLOBAL_IP,
                GlobalVar.GLOBAL_PORT,
                openidURL,
                method,
                headers,
                parameters);
        //get the result
        final String ret = NewHttpsAccess.getResult(response);
        System.out.println(ret);
 }
}

The returned result is as follows:

{
    "code": 0, 
    "data": null, 
    "description": "Operation success."
}

Message Unsubscription Interface

Function

This interface unsubscribes from the device change message based on the description of third-party system ID unsubscription operations.

URI

/rest/openapi/notification/common/nedevice

Access Method

DELETE

Parameter Description

Parameter

Mandatory/Optional

Location

Value Type

Description

openid

Mandatory

Message header parameter list

String

Indicates the session identifier. It is used for open API authentication.

NOTE:

A third-party invokes the login interface (section Log In to the eSight) for security management to obtain this parameter.

systemID

Mandatory

URL parameter list

String

Indicates the third-party system ID.

NOTE:

The value can be an IP address of 1 to 64 characters, including digits (0-9), lowercase letters (a-z), uppercase letters (A-Z), and the following special characters: @ _ - ( ) , . ^ $ ~ ` !

desc

Optional

URL parameter list

String

Indicates the description of a third-party system.

NOTE:

The default value is null, indicating that the parameter is not specified. The value consists of 0 to 1024 characters. The character set is not restricted.

Result

Field

Value Type

Description

code

int

Indicates the operation return code. The options are as follows:

  • 0: successful
  • Others: failed Value 1001 indicates that the license is invalid, 1002 indicates that the license cannot invoke OpenAPI, 1204 indicates that the authentication fails, 1501 indicates that no system ID is provided, 1502 indicates that the system ID is invalid, and 1512 indicates that the unsubscription is invalid because the request URL is invalid.

data

String

The field is displayed as null.

description

String

Indicates the description of the interface invoking result.

Precautions

In the requests whose MIME type is application/x-www-form-urlencoded, space characters are encoded as plus signs, and plus signs are encoded as %2B.

Invocation Example

Data Segment

Value

Request URL

DELETE https://eSightIP:port/rest/openapi/notification/common/nedevice?systemID=example%40system&desc=eSight+DesignIn+Demo+Unsubscription. HTTP/1.1

Request header

openid: 775c47f9-9a1b-43f9-a24b-2c3db1a55622;

Request entity

N/A

Response entity

{"code":0,"data":null,"description":"Operation success."}

Usage Example

package com.huawei.nms.openapi.demo.notification;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpResponse;
import org.apache.http.message.BasicNameValuePair;

import com.huawei.nms.openapi.demo.global.GlobalVar;
import com.huawei.nms.openapi.demo.global.NewHttpsAccess;
import com.huawei.nms.openapi.demo.sm.Login;

public class DeteleNedeviceTest {

  public static void main(String[] args) throws Exception {
    Login.login();
    detele();
  }

  public static void detele() throws Exception {
        //set the URL and method
        final String openidURL = "/rest/openapi/notification/common/nedevice";
        final String method = "DELETE";
        
        List<BasicNameValuePair> headers = new ArrayList<BasicNameValuePair>();
        headers.add(new BasicNameValuePair("openid",GlobalVar.globalOpenid));

        //set parameters
        final List<BasicNameValuePair> parameters = new ArrayList<BasicNameValuePair>();
        parameters.add(new BasicNameValuePair("systemID","NMSinfo1"));
        parameters.add(new BasicNameValuePair("desc",""));
        
        //send the request
        final HttpResponse response = NewHttpsAccess.access(GlobalVar.GLOBAL_IP,
                GlobalVar.GLOBAL_PORT,
                openidURL,
                method,
                headers,
                parameters);

        //get the result
        final String ret = NewHttpsAccess.getResult(response);
        System.out.println(ret);
 }
}

The returned result is as follows:

{
    "code": 0, 
    "data": null, 
    "description": "Operation success."
}

Message Sending Interface

Message Data

Field

Value Type

Description

resourceURI

String

Indicates the resource type URI. For a device change message notification, the URI is /rest/openapi/notification/common/nedevice.

msgType

Int

Indicates the message type. The options are as follows:

  • 1: create
  • 2: delete
  • 3: modify

data

List

Indicates the data object described in JSON data array format.

NOTE:

If the message receiving address uses HTTP, the value of data is an encrypted string. The third-party system must decrypt the value using the values of KEY and IV in the configuration file and then parse the data object. For details about the decryption method, see Decryption Example.

description

String

Indicates the message notification description.

timestamp

String

Indicates the timestamp when a message is sent. The eSight server determines the value format.

The following table describes the data structure of the data field.

Field

Value Type

Description

deviceId

String

Indicates the unique device identifier.

deviceName

String

Indicates the device name.

classification

String

Indicates the device category.

deviceType

String

Indicates the device type.

vendorName

String

Indicates the vendor name.

deviceIPList

List<String>

Indicates the IP address list of the device.

sysoid

String

Indicates the SYSOID of the device.

timezone

String

Indicates the time zone of the device.

softwareVersion

String

Indicates the version number of the device software.

adminStatus

Int

Indicates the management status. The options are as follows:

  • 0: unknown, that is, the actual management status of the device is not detected.
  • 1: managed, that is, the device can be managed.
  • 2: unmanaged, that is, the device cannot be managed, but will not be deleted from the system.

connectStatus

Int

Indicates the connection status. The options are as follows:

  • 0: undetected
  • 1: online
  • 2: offline
  • 3: invalid

alarmStatus

Int

Indicates the alarm status. The options are as follows:

  • 0: unknown
  • 1: critical
  • 2: major
  • 3: minor
  • 4: suggestion
  • 5: cleared

geographicalLocation

String

Indicates the geographical location of the device.

description

String

Indicates the device description.

Decryption Example

private static String decrypt(String data){
  String result = "";

  // Note: The following two key strings are added by referring to fetc/oms.ros/ros.web.notification.xml and must be in plaintext.
  String decryptedKey = "E5DF96DE53ED56CBAE25368624DC25Ef";
  String decryptedIv = "E2CDBCA5693654EF2E6F38693653564E";
  // Obtain the result, KEY and IV values.
  final byte[] key = strToBytes( decryptedKey.toUpperCase() );
  final byte[] iv = strToBytes( decryptedIv.toUpperCase() );
  try {
   // Obtain the key generator.
   KeyGenerator kgen = KeyGenerator.getInstance("AES", "SunJCE");

   SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG", "SUN");
   secureRandom.setSeed( key );
   // Initialize the key generator.
   kgen.init( 128, secureRandom );
   // Algorithm parameters.
   AlgorithmParameterSpec paramSpec = new IvParameterSpec(iv);
   // Generate the key.
   SecretKey secretKey = kgen.generateKey();
   // Encipher.
   Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding", "SunJCE");
   // Initialize the encipher.
   cipher.init( Cipher.DECRYPT_MODE, secretKey, paramSpec);
   // Obtain the decryption result.
   byte[] res = cipher.doFinal(strToBytes(data));
   try {
    result = new String( res,"UTF-8" );
   } catch (UnsupportedEncodingException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   }
  } catch( final GeneralSecurityException e ) {
   e.printStackTrace();
   result = null;
  }
  return result;
 }
 public static byte[] strToBytes(final String str)
    {
        // Verify parameters.
        if (null == str || str.isEmpty() || !str.matches("[0-9a-zA-Z]{1,}"))
        {
            return null;
        }

        // Convert parameter characters to uppercase characters.
        final String upperCaseString = str.toUpperCase(Locale.US);

        // String length.
        final int strLen = upperCaseString.length();

        // Encrypted arrays.
        final byte[] bytes = new byte[16];

        // Compute encrypted arrays in a cyclic manner.
        for (int i = 0; i < (strLen / 2); i++)
        {
            // High and low bits.
            int high = charToHex(upperCaseString.charAt(i * 2));
            int low = charToHex(upperCaseString.charAt(i * 2 + 1));
            // Obtain the result.
            bytes[i] = (byte) ((high << 4) | low);
        }

        return bytes;
    }
/**
     * Convert the char into hexadecimal characters and enter the characters that only contain [0-9A-Z].
     * 
     * @param ch Characters.
     * @return Return the array represented by the characters.
     */
    private static int charToHex(final char ch)
    {
        if (Character.isUpperCase(ch))
        {
            // Return the uppercase characters.
            return ch - 'A' + 10;
        }
        else
        {
            // Return numbers.
            return ch - '0';
        }
    }

Example

The following provides an example of adding an NE:

{
    "timestamp": "2015-01-06 21:02:20",
    "extendedData": {
        
    },
    "resourceURI": "/rest/openapi/notification/common/nedevice",
    "description": "Device related notification.",
    "data": [{
        "geographicalLocation": "null",
        "vendorName": "Huawei",
        "sysoid": "1.3.6.1.4.1.2011.2.236.2",
        "adminStatus": 2,
        "deviceIPList": ["10.137.63.36"],
        "timezone": "null",
        "connectStatus": 0,
        "alarmStatus": 5,
        "deviceName": "S9700_1",
        "description": "Quidway S9706\r\nHuawei Versatile Routing Platform Software\r\nVRP (R) Software, Version 5.150 (S9700 V200R005C00SPC300)\r\nCopyright (c) 2000-2014 Huawei Technologies Co., Ltd\r\n",
        "deviceType": "{Huawei}S9706",
        "classification": "switch_S9700",
        "softwareVersion": "{Huawei}S9706V200R005C00",
        "deviceId": "NE=34604009"
    }],
    "msgType": 1
}

The following provides an example of modifying an NE. The methods for changing the management status, connection status, alarm status, remarks, and device name are similar.

{
    "timestamp": "2015-01-07 09:02:03",
    "extendedData": {
        
    },
    "resourceURI": "/rest/openapi/notification/common/nedevice",
    "description": "Device related notification.",
    "data": [{
        "geographicalLocation": "null",
        "vendorName": "Huawei",
        "sysoid": "1.3.6.1.4.1.2011.2.236.2",
        "adminStatus": 2,
        "deviceIPList": ["10.137.63.36"],
        "timezone": "null",
        "connectStatus": 0,
        "alarmStatus": 5,
        "deviceName": "S9700_1",
        "description": "Quidway S9706\r\nHuawei Versatile Routing Platform Software\r\nVRP (R) Software, Version 5.150 (S9700 V200R005C00SPC300)\r\nCopyright (c) 2000-2014 Huawei Technologies Co., Ltd\r\n",
        "deviceType": "{Huawei}S9706",
        "classification": "switch_S9700",
        "softwareVersion": "{Huawei}S9706V200R005C00",
        "deviceId": "NE=34604009"
    }],
    "msgType": 3
}

The following provides an example of deleting an NE:

{
    "timestamp": "2015-01-06 21:02:11",
    "extendedData": {
        
    },
    "resourceURI": "/rest/openapi/notification/common/nedevice",
    "description": "Device related notification.",
    "data": [{
        "geographicalLocation": "null",
        "vendorName": "Huawei",
        "sysoid": "1.3.6.1.4.1.2011.2.236.2",
        "adminStatus": 2,
        "deviceIPList": ["10.137.63.36"],
        "timezone": "null",
        "connectStatus": 1,
        "alarmStatus": 5,
        "deviceName": "S9700_1",
        "description": "Quidway S9706\r\nHuawei Versatile Routing Platform Software\r\nVRP (R) Software, Version 5.150 (S9700 V200R005C00SPC300)\r\nCopyright (c) 2000-2014 Huawei Technologies Co., Ltd\r\n",
        "deviceType": "{Huawei}S9706",
        "classification": "switch_S9700",
        "softwareVersion": "{Huawei}S9706V200R005C00",
        "deviceId": "NE=34603809"
    }],
    "msgType": 2
}
Translation
Download
Updated: 2019-10-30

Document ID: EDOC1100044386

Views: 15782

Downloads: 83

Average rating:
This Document Applies to these Products
Related Version
Related Documents
Share
Previous Next