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:
Method | EndPoint | Parameters |
---|---|---|
GET | https://localhost/api/v1/agent/<action> | action : { start | stop | restart } |
Example | https://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.
- Python
- Php
- Go
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)
echo "START AGENT \n";
$url = 'https://'.$ip.'/api/v1/agent/start';
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $hed);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, 0);
$response = curl_exec($curl);
curl_close($curl);
//TODO
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.
- Python
- Php
- Go
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)
//TODO
echo "STOP AGENT \n";
$url = 'https://'.$ip.'/api/v1/agent/stop';
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $hed);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, 0);
$response = curl_exec($curl);
curl_close($curl);
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.
- Python
- Php
- Go
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)
echo "RESTART AGENT \n";
$url = 'https://'.$ip.'/api/v1/agent/restart';
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $hed);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, 0);
$response = curl_exec($curl);
curl_close($curl);
//TODO
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