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).
System Power off Message

System Power off Message

This section describes the system power-off message interface.

Message Subscription Interface

Function

This interface subscribes to the system power-off 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/systemStatus

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 third-party system description.

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

After successful subscription, eSight attempts to send power-off messages upon normal power-off. Upon abnormal power-off, eSight may not send power-off messages.

Invocation Example

Data Segment

Value

Request URL

PUT https://eSightIP: port/rest/openapi/notification/common/systemStatus 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 PutSystemStatusTest {

  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/systemStatus";
        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 system power-off message based on the description of third-party system ID unsubscription operations.

URI

/rest/openapi/notification/common/systemStatus

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 third-party system description.

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/systemStatus?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 DeleteSystemStatusTest {

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

  public static void delete() throws Exception {
        //set the URL and method
        final String openidURL = "/rest/openapi/notification/common/systemStatus";
        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

eSight provides the timeout protection mechanism when a function is disabled. During full-component installation, eSight may fail to send system power-off messages due to this protection mechanism. Third-party systems can determine whether eSight is online based on system keepalive messages and power-on messages.

Field

Value Type

Description

resourceURI

String

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

msgType

Int

Indicates the message type. The value is fixed at 97 (system power-off).

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.

extendedData

String

Indicates the additional data object described in JSON format. Here, the value is the null object {}.

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

systemID

String

Indicates the unique ID of the eSight system.

NOTE:

The value can be set in the configuration file. you can also configure it in local system information page. For details, see section Preparation Using Open APIs.

systemName

String

Indicates the name of the eSight system.

NOTE:

The value can be set in the configuration file. you can also configure it in local system information page. For details, see section Preparation Using Open APIs.

version

String

Indicates the eSight version number.

NOTE:

The value can be set in the configuration file. For details, see section Preparation Using Open APIs.

vendor

String

Indicates the eSight vendor. The value is fixed at Huawei.

systemEscapedTime

String

Indicates the system escaped time. The value format is d Day hh Hour mm Min ss Sec xxx MilliSec.

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

{
    "timestamp":"2014-12-19 11:11:27",
    "extendedData":{},
    "resourceURI":"/rest/openapi/notification/common/systemStatus",
    "description":"System shutdown.",
    "data":
    [
        {
        "systemEscapedTime":"0 Day 00 Hour 02 Min 35 Sec 675 MilliSec",
        "vendor":"Huawei",
        "systemName":"HuaweiPlatform",
        "systemID":"HuaweiPlatform",
        "version":"V300R003C00"
        }
    ],
    "msgType":97
}
Translation
Download
Updated: 2019-10-30

Document ID: EDOC1100044386

Views: 15788

Downloads: 83

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