Connecting to IEF to Manage Edge Nodes
Intelligent EdgeFabric (IEF) provides integrated edge-cloud synergy services for enterprises, and enables remote control, data processing, and analysis of edge computing resources.
You can connect your applications to IEF to manage edge nodes and send service commands to edge nodes in the 5G smart gas station solution.
Prerequisites
- You have applied for the IEF service. For details, see Intelligent EdgeFabric.
- You have obtained the access key ID (AK) and secret access key (SK). For details, see Obtaining an AK/SK.
Billing
After connecting an application to the IEF connector, you must pay for the IEF service separately. For details, see Huawei Cloud Pricing. After an application is disabled, IEF is still billed based on the preset billing rules.
Creating an IEF Connector
- Log in to the application designer by referring to Logging In to the Application Designer.
- In the navigation pane, choose Integrations.
- Click Connector Instance under Connector.
- In the navigation pane on the left, choose AI > IEF.
- In the right pane, click + and set the parameters.
Figure 1 Creating an IEF connector
Table 1 Parameters for creating an IEF connector Parameter
Description
Name
Name of the connector to be created. The naming requirements are as follows:
- The value cannot exceed 64 characters, including the prefix namespace.
To prevent duplicate data names among different tenants, each tenant must define a unique namespace when first creating an application. A tenant can create only one namespace. After being created, the namespace cannot be modified.
- Start with a letter and can contain only letters, digits, and underscores (_). Do not end with an underscore (_).
Region
Region where IEF is deployed.
Access Key ID
The AK and the secret access key (SK) are used together to encrypt and sign a request. Set this parameter to the value of AK in Prerequisites.
Secret Access Key
Secret access key (SK). The SK and AK are used together to encrypt and sign a request to identify the sender and prevent the request from being modified. Set this parameter to the value of AK in Prerequisites.
Package Current Configuration
If this parameter is selected, the connector will be packed together with applications. For example, if an application package is released to the runtime environment, the current configuration is synchronized to the runtime environment by default. If this option is not selected, the connector will not be packaged and released to the runtime environment. In this case, you need to create the corresponding connector by referring to Managing Connectors in Applications.
This parameter is selected by default. You are advised not to select this option in information-sensitive scenarios.
- The value cannot exceed 64 characters, including the prefix namespace.
- (Optional) Test the connector.
- Click Test on the connector details page.
- Select an API, set input parameters, and click Test.
Figure 2 Configuration page
- Choose API: name of the IEF API to be called.
- Participation: input parameters for calling the API. The input parameter set of all APIs is as follows:
- project_id: project ID
- node_id: edge node ID.
- device_id: edge device ID.
- topic: value of the source endpoint resource in the IEF message route, excluding the leading slash (/). To obtain the value, perform the following steps:
- In the navigation pane of the IEF console, choose Edge-Cloud Messages > Routes.
- Obtain the source endpoint resource of the message route.
- Message(json): JSON format of the message to be sent.
If the following information is displayed, the test is successful.
Figure 3 Successful test
Calling a Connector in a Script
Call the connector in the script to connect to IEF.
- Create an empty script by referring to Creating a Blank Script.
- In the script editor, enter the following code:
import { Decimal } from 'decimal'; import { Error } from 'error'; import * as ief from 'ief'; export class Input { @action.param({ type: "String", required: true, description: "type" }) project_id: string; // @action.param({ type: "String", required: true, description: "the operation value 2" }) // node_id: string; } export class Output { @action.param({ type: "Object", required: true }) result: Object; } export class Calculator { @action.method({ input: "Input", output: "Output", description: "do an operation" }) run(input: Input): Output { let output = new Output(); let cli = ief.newClient("ief_test"); output.result = cli.getProjectNode(input.project_id); //console.log(output.result); return output; } }
In ief.newClient("ief_test"), ief_test is the connector name.
- Click
in the upper part of the script editor to save the script.
- Click
to execute the script.
- On the input parameters tab page, enter the project ID of the request parameter and click
in the upper right corner of the test window.
{ "project_id":"XXXXXXXXXXX" }
If the edge node list is displayed on the output parameter tab page, the event is successfully executed.
- Click
in the upper part of the script editor to activate the script.
Calling a Connector in a Flow
Call the connector in a flow to connect to IEF.
- Create a blank flow by referring to Creating a Blank Flow.
- On the flow design page, choose Connectors > AI, and drag the IEF diagram element to the canvas.
The IEF diagram element is preset in the system for connecting to IEF.
Figure 4 Dragging the IEF diagram element to the canvas - Create the input and output parameters of the flow.
The flow calls the IEF API to query the edge node list. Therefore, the flow's input and output parameters must be defined and match the API's parameter types.
Table 2 Flow variables Variable Type
Parameter
Parameter Type
Input/Output Type
Description
Common
projectID
Text
Input Only
Project ID.
Structure.
result1
Private structure variable
Output Only
Output query result.
- Click the blank area on the flow designer and click
on the right of the editor page.
- On the Private Structure page, click Add under Struct.
Before creating the output parameter structure variable result1, you need to create a private structure.Figure 5 Adding a private struct
- Set the private structure name; defining its members is not required.
Figure 6 Configuring a private structure
- On the right of the flow designer, click
.
- On the Context panel, click
next to Object Variable.
Figure 7 Clicking the plus sign next to the object variable - Select Private, complete the configuration, and click Save.
Figure 8 Setting a private structure variable
- Name: Name of a structure variable.
- Private Structure: Select a created struct, for example, result.
- Default Value: Default value of the variable.
- Description: Description of a variable.
- Is Collection: Whether a variable is an array variable, that is, a collection variable.
- External Use: If this option is selected, the formula is used externally. During compilation, the system does not check whether the formula is used.
- On the Context panel, click
next to Variable.
Figure 9 Creating a variable - Double-click the variable name and change it to projectID.
Figure 10 Setting a variable
- Click the blank area on the flow designer and click
- On the service orchestration design page, select the IEF diagram element, click
, and set basic information.
Figure 11 Setting basic informationTable 3 Basic information parameters of the IEF diagram element Parameter
Description
Label
Label of a diagram element displayed on the page.
Name
Unique ID of the diagram element in the system. The ID cannot be the same as that of other diagram elements. The naming requirements are as follows:
- Enter up to 80 characters.
- Start with a letter and can contain only letters, digits, and underscores (_). It cannot end with an underscore (_).
Description
Enter the description of the connector.
Connector
Select the target connector from the drop-down list, that is, the connector created in Creating an IEF Connector.
- Click
and set action parameters.
Figure 12 Configuring action parameters- Action: Specific IEF API (taking the edge node list querying API as an example)
- Input Parameters: Set the input parameters of the API. Set Target to project_id and drag projectID in Context to Source. The input parameters of all APIs are as follows:
- project_id: project ID
- node_id: edge node ID.
- device_id: edge device ID.
- topic: value of the source endpoint resource in the IEF message route, excluding the leading slash (/). To obtain the source endpoint resource value, perform the following steps:
- In the navigation pane of the IEF console, choose Edge-Cloud Messages > Routes.
- Obtain the source endpoint resource of the message route.
- msg: JSON format of the message to be sent.
- Connect the Start and IEF diagram elements.
Figure 13 Connecting diagram elements
- Click
to save the flow.
- Click
to activate the flow.
- Set the project ID of the input parameters and click the run button.
{ "project_id":"XXXXXXXXXXX" }
If the edge node list is displayed, the connector is successfully called.
- Click
to activate the flow.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot