Skip to main content

Expedition Agent

In this section we describe the Expedition's agent and the calls that we can execute to change its status.

Description

Some of the background tasks in Expedition 2.0 are better performed within jobs that can be monitored, are non-blocking and in some cases, can be cancelled. Importing a configuration is one of such actions as, depending on the configuration size, the required time for importing may be excessive for a blocking code.

Those actions are handled by an agent that is expeting for tasks to be executed.

The calls comply with the following structure:

MethodEndPointParameters
GEThttps://localhost/api/v1/agent/<action>action : { start | stop | restart }
Examplehttps://localhost/api/v1/agent/restart

Starting the Agent

Starting the agent would require having an authenticated session. If stopped, the agent will start running, if already started, the request will have no implications. In the provided code, SSL certificate verification is bypassed, so it would run with the defaults Expedition installation in case no SSL certificates have been generated to certify the HTTPS service.

import requests
import urllib3

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

print('START AGENT')
url = 'https://'+ip+'/api/v1/agent/start'
r = requests.get(url, verify=False, headers=hed)

Stopping the Agent

Likewise, stopping the agent is simply done with a validated HTTPS GET request to the stop route. Currently, there is no validation on the tasks that an agent may be executing during the stop action, so keep in mind that undergoing execution may become incomplete.

import requests
import urllib3

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

print('STOP AGENT')
url = 'https://'+ip+'/api/v1/agent/stop'
r = requests.get(url, verify=False, headers=hed)

Restarting the Agent

And to restart, we will require the restart route. If the agent is started, restart will stop the agent and start it again. If already stopped, the agent will get started. Currently, there is no validation on the tasks that an agent may be executing during the restart action, so keep in mind that undergoing execution may become incomplete.

import requests
import urllib3

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

print('RESTART AGENT')
url = 'https://'+ip+'/api/v1/agent/restart'
r = requests.get(url, verify=False, headers=hed)

The agent logs

Multiple code executions will be performed by the agent(s) during the Expedition 2.0 API consumption. If something does not behave as expected, agent logs can be found under the following system path /home/userSpace/panReadOrders.log

For debugging actions, we could recommend leaving the file open to see agents output execution logs with the following system command:

tail -f /home/userSpace/panReadOrders.log