Commit 22baa1be13d85dab5326861d9e2820ee0f9ffa6b
1 parent
e5e0bb74
Exists in
mlplasmas
and in
1 other branch
COnfig for orchestra
Showing
7 changed files
with
100 additions
and
51 deletions
Show diff stats
config/AMDAIntegrationConfig.php
@@ -40,6 +40,10 @@ define('TOOLS_BASE_DIR', $config['TOOLS_BASE_DIR']); | @@ -40,6 +40,10 @@ define('TOOLS_BASE_DIR', $config['TOOLS_BASE_DIR']); | ||
40 | define('KERNEL_BUILD_TYPE', $config['KERNEL_BUILD_TYPE']); | 40 | define('KERNEL_BUILD_TYPE', $config['KERNEL_BUILD_TYPE']); |
41 | define('AMDA_KERNEL_DIR', $config['AMDA_KERNEL_DIR']); | 41 | define('AMDA_KERNEL_DIR', $config['AMDA_KERNEL_DIR']); |
42 | define('IHM_SRC_DIR', $config['IHM_SRC_DIR']); | 42 | define('IHM_SRC_DIR', $config['IHM_SRC_DIR']); |
43 | +define('ORCHESTRA_HOST', $config['ORCHESTRA_HOST']); | ||
44 | +define('ORCHESTRA_PORT', $config['ORCHESTRA_PORT']); | ||
45 | +define('ORCHESTRA_ADMIN_IPS', $config['ORCHESTRA_ADMIN_IPS']); | ||
46 | + | ||
43 | 47 | ||
44 | define('GCC_BASE_DIR', TOOLS_BASE_DIR.'/gcc/4.7.2/rtf'); | 48 | define('GCC_BASE_DIR', TOOLS_BASE_DIR.'/gcc/4.7.2/rtf'); |
45 | define('BOOST_BASE_DIR', TOOLS_BASE_DIR.'/gcc/4.7.2/boost'); | 49 | define('BOOST_BASE_DIR', TOOLS_BASE_DIR.'/gcc/4.7.2/boost'); |
config/current.env.template
@@ -16,3 +16,7 @@ AMDA_KERNEL_DIR='{:AMDA_KERNEL_DIR:}' | @@ -16,3 +16,7 @@ AMDA_KERNEL_DIR='{:AMDA_KERNEL_DIR:}' | ||
16 | ;Path to AMDA_IHM base dir | 16 | ;Path to AMDA_IHM base dir |
17 | IHM_SRC_DIR='{:IHM_SRC_DIR:}' | 17 | IHM_SRC_DIR='{:IHM_SRC_DIR:}' |
18 | 18 | ||
19 | +;Config for ORCHESTRA | ||
20 | +ORCHESTRA_HOST='{:ORCHESTRA_HOST:}' | ||
21 | +ORCHESTRA_PORT='{:ORCHESTRA_PORT:}' | ||
22 | +ORCHESTRA_ADMIN_IPS='{:ORCHESTRA_ADMIN_IPS:}' | ||
19 | \ No newline at end of file | 23 | \ No newline at end of file |
src/InputOutput/IHMImpl/MachineLearning/IHMMachineLearningClass.php
@@ -31,11 +31,12 @@ class IHMMachineLearningClass implements InputOutputInterface | @@ -31,11 +31,12 @@ class IHMMachineLearningClass implements InputOutputInterface | ||
31 | 31 | ||
32 | 32 | ||
33 | $processData = new OrchestraRequestDataClass(); | 33 | $processData = new OrchestraRequestDataClass(); |
34 | - $processData->setHost('http://172.17.0.1'); | ||
35 | - $processData->setPort('5000'); | ||
36 | $processData->setBatchEnable(FALSE); | 34 | $processData->setBatchEnable(FALSE); |
37 | 35 | ||
38 | switch ($input->mode) { | 36 | switch ($input->mode) { |
37 | + case 'configinfo': | ||
38 | + $processData->setRequestType(OrchestraRequestTypeEnum::CONFIGINFO); | ||
39 | + break; | ||
39 | case 'moduleslist': | 40 | case 'moduleslist': |
40 | $processData->setRequestType(OrchestraRequestTypeEnum::MODULESLIST); | 41 | $processData->setRequestType(OrchestraRequestTypeEnum::MODULESLIST); |
41 | break; | 42 | break; |
@@ -144,7 +145,7 @@ class IHMMachineLearningClass implements InputOutputInterface | @@ -144,7 +145,7 @@ class IHMMachineLearningClass implements InputOutputInterface | ||
144 | case ProcessStatusEnumClass::ERROR : | 145 | case ProcessStatusEnumClass::ERROR : |
145 | case ProcessStatusEnumClass::RUNNING : | 146 | case ProcessStatusEnumClass::RUNNING : |
146 | case ProcessStatusEnumClass::DONE : | 147 | case ProcessStatusEnumClass::DONE : |
147 | - return $this->jobsManager->addJob( | 148 | + return $this->jobsManager->addJob( |
148 | $this->input, | 149 | $this->input, |
149 | $data->getId(), | 150 | $data->getId(), |
150 | $this->workingDirName, | 151 | $this->workingDirName, |
@@ -153,11 +154,11 @@ class IHMMachineLearningClass implements InputOutputInterface | @@ -153,11 +154,11 @@ class IHMMachineLearningClass implements InputOutputInterface | ||
153 | $data->getOrchestraResult(), | 154 | $data->getOrchestraResult(), |
154 | $data->getErrorCode(), | 155 | $data->getErrorCode(), |
155 | $data->getExecTime()); | 156 | $data->getExecTime()); |
156 | - default : | ||
157 | - return array( | ||
158 | - 'success' => false, | ||
159 | - 'message' => 'Unknown Process Status'); | ||
160 | - } | 157 | + default : |
158 | + return array( | ||
159 | + 'success' => false, | ||
160 | + 'message' => 'Unknown Process Status'); | ||
161 | + } | ||
161 | } | 162 | } |
162 | } | 163 | } |
163 | 164 |
src/InputOutput/IHMImpl/Process/IHMInputOutputGetInfoProcessClass.php
1 | -<?php | ||
2 | - | ||
3 | -/** | ||
4 | - * @class IHMInputOutputGetInfoProcessClass | ||
5 | - * @brief Class that's implement an InputOutputInterface used to treat a get info process request | ||
6 | - * @details | ||
7 | - */ | 1 | +<?php |
2 | + | ||
3 | +/** | ||
4 | + * @class IHMInputOutputGetInfoProcessClass | ||
5 | + * @brief Class that's implement an InputOutputInterface used to treat a get info process request | ||
6 | + * @details | ||
7 | + */ | ||
8 | class IHMInputOutputGetInfoProcessClass implements InputOutputInterface | 8 | class IHMInputOutputGetInfoProcessClass implements InputOutputInterface |
9 | { | 9 | { |
10 | protected $jobsManager = null; | 10 | protected $jobsManager = null; |
11 | protected $paramsData = null; | 11 | protected $paramsData = null; |
12 | - | ||
13 | - /* | ||
14 | - * @brief Constructor | 12 | + |
13 | + /* | ||
14 | + * @brief Constructor | ||
15 | */ | 15 | */ |
16 | function __construct() | 16 | function __construct() |
17 | { | 17 | { |
18 | $this->jobsManager = new IHMJobsManagerClass(); | 18 | $this->jobsManager = new IHMJobsManagerClass(); |
19 | } | 19 | } |
20 | - | ||
21 | - /* | ||
22 | - * @brief translate input data from IHM client to AMDA_Integration module for a get info process request | 20 | + |
21 | + /* | ||
22 | + * @brief translate input data from IHM client to AMDA_Integration module for a get info process request | ||
23 | */ | 23 | */ |
24 | public function getInputData($input,$function,$requestId="") | 24 | public function getInputData($input,$function,$requestId="") |
25 | { | 25 | { |
@@ -36,9 +36,9 @@ class IHMInputOutputGetInfoProcessClass implements InputOutputInterface | @@ -36,9 +36,9 @@ class IHMInputOutputGetInfoProcessClass implements InputOutputInterface | ||
36 | 36 | ||
37 | return $this->paramsData; | 37 | return $this->paramsData; |
38 | } | 38 | } |
39 | - | ||
40 | - /* | ||
41 | - * @brief translate output data from AMDA_Integration module to IHM client for a get info process request | 39 | + |
40 | + /* | ||
41 | + * @brief translate output data from AMDA_Integration module to IHM client for a get info process request | ||
42 | */ | 42 | */ |
43 | public function getOutput($data) | 43 | public function getOutput($data) |
44 | { | 44 | { |
@@ -0,0 +1,32 @@ | @@ -0,0 +1,32 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | + * @class OrchestraConfigClass | ||
5 | + * @brief Class that's contain all specific configuration of the orchestra module | ||
6 | + * @details | ||
7 | + */ | ||
8 | +class OrchestraConfigClass | ||
9 | +{ | ||
10 | + public static function getHost() | ||
11 | + { | ||
12 | + if (defined('ORCHESTRA_HOST')) | ||
13 | + return ORCHESTRA_HOST; | ||
14 | + return ""; | ||
15 | + } | ||
16 | + | ||
17 | + public static function getPort() | ||
18 | + { | ||
19 | + if (defined('ORCHESTRA_PORT')) | ||
20 | + return ORCHESTRA_PORT; | ||
21 | + return ""; | ||
22 | + } | ||
23 | + | ||
24 | + public static function getAdminIps() | ||
25 | + { | ||
26 | + if (defined('ORCHESTRA_ADMIN_IPS')) | ||
27 | + return explode(',', ORCHESTRA_ADMIN_IPS); | ||
28 | + return array(); | ||
29 | + } | ||
30 | +} | ||
31 | + | ||
32 | +?> |
src/Request/OrchestraRequestImpl/OrchestraRequestClass.php
@@ -6,6 +6,9 @@ | @@ -6,6 +6,9 @@ | ||
6 | */ | 6 | */ |
7 | class OrchestraRequestClass extends ProcessRequestClass | 7 | class OrchestraRequestClass extends ProcessRequestClass |
8 | { | 8 | { |
9 | + private $host = ""; | ||
10 | + private $port = ""; | ||
11 | + | ||
9 | /* | 12 | /* |
10 | * @brief Init a process request of type "run" | 13 | * @brief Init a process request of type "run" |
11 | */ | 14 | */ |
@@ -14,10 +17,36 @@ class OrchestraRequestClass extends ProcessRequestClass | @@ -14,10 +17,36 @@ class OrchestraRequestClass extends ProcessRequestClass | ||
14 | if (!isset($this->requestData)) | 17 | if (!isset($this->requestData)) |
15 | return false; | 18 | return false; |
16 | 19 | ||
17 | - $orchestraClient = new OrchestraClient($this->requestData->getHost().":".$this->requestData->getPort()); | 20 | + $this->host = OrchestraConfigClass::getHost(); |
21 | + $this->port = OrchestraConfigClass::getPort(); | ||
22 | + if (empty($this->host)) { | ||
23 | + $this->requestData->setLastErrorMessage('Missing orchestra host definition'); | ||
24 | + return false; | ||
25 | + } | ||
26 | + $orchestraEntryPoint = $this->host; | ||
27 | + if (!empty($this->port)) { | ||
28 | + $orchestraEntryPoint .= ":".$this->port; | ||
29 | + } | ||
30 | + | ||
31 | + $orchestraClient = new OrchestraClient($orchestraEntryPoint); | ||
18 | 32 | ||
19 | $params = $this->requestData->getParams(); | 33 | $params = $this->requestData->getParams(); |
20 | switch ($this->requestData->getRequestType()) { | 34 | switch ($this->requestData->getRequestType()) { |
35 | + case OrchestraRequestTypeEnum::CONFIGINFO: | ||
36 | + if (in_array(getenv("REMOTE_ADDR"), OrchestraConfigClass::getAdminIps())) { | ||
37 | + $result = array( | ||
38 | + 'success' => TRUE, | ||
39 | + 'entrypoint' => $orchestraEntryPoint | ||
40 | + ); | ||
41 | + } | ||
42 | + else { | ||
43 | + $result = array( | ||
44 | + 'success' => FALSE, | ||
45 | + 'message' => 'Forbidden' | ||
46 | + ); | ||
47 | + } | ||
48 | + $this->requestData->setOrchestraResult($result); | ||
49 | + break; | ||
21 | case OrchestraRequestTypeEnum::MODULESLIST: | 50 | case OrchestraRequestTypeEnum::MODULESLIST: |
22 | $result = $orchestraClient->getModules(); | 51 | $result = $orchestraClient->getModules(); |
23 | $this->requestData->setOrchestraResult($result); | 52 | $this->requestData->setOrchestraResult($result); |
@@ -77,7 +106,7 @@ class OrchestraRequestClass extends ProcessRequestClass | @@ -77,7 +106,7 @@ class OrchestraRequestClass extends ProcessRequestClass | ||
77 | // Generate a PHP script to run request (to be able to "detach" process for the batch mode) | 106 | // Generate a PHP script to run request (to be able to "detach" process for the batch mode) |
78 | $php_script = '<?php'.PHP_EOL; | 107 | $php_script = '<?php'.PHP_EOL; |
79 | $php_script .= 'require_once("'.$clientPath.'");'.PHP_EOL; | 108 | $php_script .= 'require_once("'.$clientPath.'");'.PHP_EOL; |
80 | - $php_script .= '$client = new OrchestraClient("'.$this->requestData->getHost().':'.$this->requestData->getPort().'");'.PHP_EOL; | 109 | + $php_script .= '$client = new OrchestraClient("'.$this->host.':'.$this->port.'");'.PHP_EOL; |
81 | $php_script .= '$params = array('; | 110 | $php_script .= '$params = array('; |
82 | $first_param = TRUE; | 111 | $first_param = TRUE; |
83 | foreach ($params as $key => $value) { | 112 | foreach ($params as $key => $value) { |
src/Request/OrchestraRequestImpl/OrchestraRequestDataClass.php
@@ -3,10 +3,11 @@ | @@ -3,10 +3,11 @@ | ||
3 | abstract class OrchestraRequestTypeEnum | 3 | abstract class OrchestraRequestTypeEnum |
4 | { | 4 | { |
5 | const UNKNOWN = ""; | 5 | const UNKNOWN = ""; |
6 | + const CONFIGINFO = "CONFIGINFO"; | ||
6 | const MODULESLIST = "MODULESLIST"; | 7 | const MODULESLIST = "MODULESLIST"; |
7 | - const MODULEINFO = "MODULEINFO"; | ||
8 | - const PREDICTION = "PREDICTION"; | ||
9 | - const FITTING = "FITTING"; | 8 | + const MODULEINFO = "MODULEINFO"; |
9 | + const PREDICTION = "PREDICTION"; | ||
10 | + const FITTING = "FITTING"; | ||
10 | const GETRESULT = "GETRESULT"; | 11 | const GETRESULT = "GETRESULT"; |
11 | } | 12 | } |
12 | 13 | ||
@@ -17,32 +18,10 @@ abstract class OrchestraRequestTypeEnum | @@ -17,32 +18,10 @@ abstract class OrchestraRequestTypeEnum | ||
17 | */ | 18 | */ |
18 | class OrchestraRequestDataClass extends ProcessRequestDataClass | 19 | class OrchestraRequestDataClass extends ProcessRequestDataClass |
19 | { | 20 | { |
20 | - private $host = "http://127.0.0.1"; | ||
21 | - private $port = "5000"; | ||
22 | private $type = OrchestraRequestTypeEnum::UNKNOWN; | 21 | private $type = OrchestraRequestTypeEnum::UNKNOWN; |
23 | private $params = array(); | 22 | private $params = array(); |
24 | private $orchestraResult = NULL; | 23 | private $orchestraResult = NULL; |
25 | 24 | ||
26 | - public function getHost() | ||
27 | - { | ||
28 | - return $this->host; | ||
29 | - } | ||
30 | - | ||
31 | - public function setHost($host) | ||
32 | - { | ||
33 | - $this->host = $host; | ||
34 | - } | ||
35 | - | ||
36 | - public function getPort() | ||
37 | - { | ||
38 | - return $this->port; | ||
39 | - } | ||
40 | - | ||
41 | - public function setPort($port) | ||
42 | - { | ||
43 | - $this->port = $port; | ||
44 | - } | ||
45 | - | ||
46 | public function getRequestType() | 25 | public function getRequestType() |
47 | { | 26 | { |
48 | return $this->type; | 27 | return $this->type; |