Remove duplicate auth to SAL
Change-Id: Ie81deb9cc2c6e02c6820ef28c87bc0779f0b8a2a
This commit is contained in:
parent
dab29d1654
commit
988fedcb7f
.gitignore
exn-middleware-core
.gradle
7.5.1
buildOutputCleanup
file-system.probevcs-1
build/classes/groovy/main/eu/nebulouscloud/exn/modules/sal
config
src/main/groovy/eu/nebulouscloud/exn/modules/sal
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +1,4 @@
|
||||
__pycache__/
|
||||
.nox/
|
||||
|
||||
**/.gradle
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,2 +0,0 @@
|
||||
#Mon Feb 05 14:24:01 EET 2024
|
||||
gradle.version=7.5.1
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
logging:
|
||||
level:
|
||||
eu.nebulouscloud.exn.modules: TRACE
|
||||
eu.nebulouscloud.exn: TRACE
|
||||
|
||||
spring:
|
||||
profiles: default
|
||||
@ -12,13 +12,12 @@ spring:
|
||||
application:
|
||||
exn:
|
||||
config:
|
||||
url: 'nebulous-nebulous-activemq'
|
||||
port: 5672
|
||||
url: 'nebulous-activemq'
|
||||
port: '5672'
|
||||
username: 'admin'
|
||||
password: 'admin'
|
||||
sal:
|
||||
protocol: 'http'
|
||||
# host: 'fa84-194-219-170-2.ngrok-free.app/'
|
||||
host: 'sal'
|
||||
port: '8080'
|
||||
api: 'sal'
|
||||
|
@ -50,6 +50,7 @@ public class AMQPSalMessageHandler extends Handler {
|
||||
|
||||
Map response = p.process(destination, message)
|
||||
|
||||
log.info('REPLYING {}',response)
|
||||
Map amqpProperties =
|
||||
['correlation-id': message.correlationId()?.toString(),
|
||||
'reply-to' : message.replyTo()]
|
||||
|
@ -7,6 +7,7 @@ import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.http.HttpStatus
|
||||
import org.springframework.web.client.HttpClientErrorException
|
||||
import org.springframework.web.client.HttpServerErrorException
|
||||
|
||||
/**
|
||||
@ -25,9 +26,11 @@ abstract class AbstractProcessor implements Processor {
|
||||
@Override
|
||||
Map process(String destination, ClientMessage message) {
|
||||
|
||||
//Maybe move it to message property(?) and don't blend with application's payload
|
||||
Map payload = message.body() as Map
|
||||
Map metaData = payload.metaData as Map
|
||||
if(!metaData){
|
||||
metaData =[:]
|
||||
}
|
||||
String o = payload.body
|
||||
|
||||
Map ret = [:]
|
||||
@ -53,19 +56,26 @@ abstract class AbstractProcessor implements Processor {
|
||||
ret = post(metaData,o)
|
||||
}
|
||||
|
||||
} catch (HttpServerErrorException e) {
|
||||
logger.error("[{} -> {}] Exception during gateway request for {}", metaData.user, method, o, e)
|
||||
ret.status = HttpStatus.BAD_GATEWAY.value()
|
||||
ret.body = ["key": "gateway-exception-error", "message": 'Gateway exception while handling request with reason' + StringUtils.substring(e.getMessage(),0,50)]
|
||||
} catch (HttpClientErrorException e) {
|
||||
logger.error("[{} -> {}] Client Exception during gateway request for {}", metaData?.user, method, o, e)
|
||||
logger.error('RAW HTTP CLIENT ERROR:\n {}', e.getMessage())
|
||||
ret.status = e.getStatusCode().value()
|
||||
ret.body = ["key": "gateway-client-exception-error", "message": StringUtils.substring(e.getMessage(), 0, 50)]
|
||||
}
|
||||
catch (HttpServerErrorException e) {
|
||||
logger.error("[{} -> {}] Server Exception during gateway request for {}", metaData?.user, method, o, e)
|
||||
logger.error('RAW HTTP SERVER ERROR:\n {}',e.getMessage())
|
||||
ret.status = e.getStatusCode().value()
|
||||
ret.body = ["key": "gateway-server-exception-error", "message": StringUtils.substring(e.getMessage(),0,50)]
|
||||
} catch (Exception e) {
|
||||
logger.error("[{} -> {}] Exception for {}", metaData.user, method, o, e)
|
||||
logger.error("[{} -> {}] Exception for {}", metaData?.user, method, o, e)
|
||||
logger.error('RAW EXCEPTION ERROR:\n {}',e.getMessage())
|
||||
ret.status = HttpStatus.INTERNAL_SERVER_ERROR.value()
|
||||
// ret.body = ["key": "generic-exception-error", "message": 'Generic exception while handling request for user ' + metaData.user + ' and reason:\n' + StringUtils.left(e.getMessage(),100)]
|
||||
ret.body = ["key": "generic-exception-error", "message": 'Generic exception while handling request for user ' + StringUtils.substring(e.getMessage(),0,50)]
|
||||
}
|
||||
|
||||
metaData.status = ret.status
|
||||
// metaData.protocol = 'HTTP'
|
||||
metaData.protocol = 'HTTP'
|
||||
ret.remove('status')
|
||||
ret.metaData = metaData
|
||||
ret.body = mapper.writeValueAsString(ret.body)
|
||||
@ -85,7 +95,7 @@ abstract class AbstractProcessor implements Processor {
|
||||
Map delete(Map metaData, String body) { return noop(metaData, body) }
|
||||
|
||||
Map noop(Map metaData, String body) {
|
||||
return ["status": HttpStatus.ACCEPTED.value(), "body": metaData.user + " { " + body + "}"]
|
||||
return ["status": HttpStatus.ACCEPTED.value(), "body": metaData?.user + " { " + body + "}"]
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ class CloudProcessor extends AbstractProcessor{
|
||||
"body": {}
|
||||
]
|
||||
|
||||
logger.info('{} - Registering cloud {}',metaData.user, o)
|
||||
logger.info('{} - Registering cloud {}',metaData?.user, o)
|
||||
|
||||
// User Credentials for connecting to ProActive Server.
|
||||
// SAL is a REST interface to PWS. Get it from UI or store in middleware db?
|
||||
@ -61,7 +61,7 @@ class CloudProcessor extends AbstractProcessor{
|
||||
"body": {}
|
||||
]
|
||||
|
||||
logger.info('{} - Getting clouds {}',metaData.user, o)
|
||||
logger.info('{} - Getting clouds {}',metaData?.user, o)
|
||||
|
||||
//User Credentials for connecting to ProActive Server.
|
||||
//SAL is a REST interface to PWS. Get it from UI or store behind the scenes ?
|
||||
@ -88,7 +88,7 @@ class CloudProcessor extends AbstractProcessor{
|
||||
"body": {}
|
||||
]
|
||||
|
||||
logger.info('{} - Deleting clouds {}',metaData.user, o)
|
||||
logger.info('{} - Deleting clouds {}',metaData?.user, o)
|
||||
|
||||
//User Credentials for connecting to ProActive Server.
|
||||
//SAL is a REST interface to PWS. Get it from UI or store behind the scenes ?
|
||||
|
@ -35,7 +35,7 @@ class JobProcessor extends AbstractProcessor{
|
||||
"body": {}
|
||||
]
|
||||
|
||||
logger.info('{} - Creating job {}',metaData.user, o)
|
||||
logger.info('{} - Creating job {}',metaData?.user, o)
|
||||
|
||||
// User Credentials for connecting to ProActive Server.
|
||||
// SAL is a REST interface to PWS. Get it from UI or store in middleware db?
|
||||
@ -48,11 +48,11 @@ class JobProcessor extends AbstractProcessor{
|
||||
headers.add('sessionid',sessionId)
|
||||
headers.setContentType(MediaType.APPLICATION_JSON)
|
||||
|
||||
def response = jobRepository.save(o,headers,Object.class)
|
||||
Boolean response = jobRepository.save(o,headers,Boolean.class)
|
||||
|
||||
return [
|
||||
"status": HttpStatus.OK.value(),
|
||||
"body": response
|
||||
"body": ["success":response]
|
||||
]
|
||||
|
||||
}
|
||||
@ -65,7 +65,7 @@ class JobProcessor extends AbstractProcessor{
|
||||
"body": {}
|
||||
]
|
||||
|
||||
logger.info('{} - Getting clouds {}',metaData.user, o)
|
||||
logger.info('{} - Getting clouds {}',metaData?.user, o)
|
||||
|
||||
//User Credentials for connecting to ProActive Server.
|
||||
//SAL is a REST interface to PWS. Get it from UI or store behind the scenes ?
|
||||
@ -101,7 +101,7 @@ class JobProcessor extends AbstractProcessor{
|
||||
String jobId = metaData.jobId
|
||||
String action = metaData.action
|
||||
|
||||
logger.info('{} - [{}] job {} and payload {}',metaData.user, action, jobId, o)
|
||||
logger.info('{} - [{}] job {} and payload {}',metaData?.user, action, jobId, o)
|
||||
|
||||
//User Credentials for connecting to ProActive Server.
|
||||
//SAL is a REST interface to PWS. Get it from UI or store behind the scenes ?
|
||||
@ -140,7 +140,7 @@ class JobProcessor extends AbstractProcessor{
|
||||
"body": {}
|
||||
]
|
||||
|
||||
logger.info('{} - Submitting job {} with body {}',metaData.user, metaData.jobId, o)
|
||||
logger.info('{} - Submitting job {} with body {}',metaData?.user, metaData.jobId, o)
|
||||
|
||||
//User Credentials for connecting to ProActive Server.
|
||||
//SAL is a REST interface to PWS. Get it from UI or store behind the scenes ?
|
||||
|
@ -30,7 +30,7 @@ class NodeCandidateProcessor extends AbstractProcessor{
|
||||
@Override
|
||||
Map get(Map metaData, String o) {
|
||||
|
||||
logger.info('{} - Getting node candidates {}',metaData.user, o)
|
||||
logger.info('{} - Getting node candidates {}',metaData?.user, o)
|
||||
|
||||
//User Credentials for connecting to ProActive Server.
|
||||
//SAL is a REST interface to PWS. Get it from UI or store behind the scenes ?
|
||||
@ -50,5 +50,25 @@ class NodeCandidateProcessor extends AbstractProcessor{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
Map post(Map metaData, String o) {
|
||||
|
||||
logger.info('{} - Ranking node candidates {}',metaData?.user, o)
|
||||
|
||||
String sessionId = gatewayRepository.login(salConfiguration.username,salConfiguration.password)
|
||||
|
||||
HttpHeaders headers = new HttpHeaders()
|
||||
headers.add('sessionid',sessionId)
|
||||
headers.setContentType(MediaType.APPLICATION_JSON)
|
||||
|
||||
//Check jobId mentioned above
|
||||
List response = nodeCandidateRepository.rankCandidates(o,headers,Object.class)
|
||||
|
||||
return [
|
||||
"status": HttpStatus.OK.value(),
|
||||
"body": response
|
||||
]
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class NodeProcessor extends AbstractProcessor{
|
||||
"body": {}
|
||||
]
|
||||
|
||||
logger.info('{} - Registering node {}',metaData.user, o)
|
||||
logger.info('{} - Registering node {}',metaData?.user, o)
|
||||
|
||||
//User Credentials for connecting to ProActive Server.
|
||||
//SAL is a REST interface to PWS. Get it from UI or store in middleware db?
|
||||
@ -66,7 +66,7 @@ class NodeProcessor extends AbstractProcessor{
|
||||
"body": {}
|
||||
]
|
||||
|
||||
logger.info('{} - Getting node for Job {}',metaData.user, metaData.jobId)
|
||||
logger.info('{} - Getting node for Job {}',metaData?.user, metaData.jobId)
|
||||
|
||||
//User Credentials for connecting to ProActive Server.
|
||||
//SAL is a REST interface to PWS. Get it from UI or store behind the scenes ?
|
||||
@ -103,7 +103,7 @@ class NodeProcessor extends AbstractProcessor{
|
||||
"body": {}
|
||||
]
|
||||
|
||||
logger.info('{} - Deleting nodes for Job {}',metaData.user, metaData.jobId)
|
||||
logger.info('{} - Deleting nodes for Job {}',metaData?.user, metaData.jobId)
|
||||
|
||||
//User Credentials for connecting to ProActive Server.
|
||||
//SAL is a REST interface to PWS. Get it from UI or store behind the scenes ?
|
||||
@ -140,7 +140,7 @@ class NodeProcessor extends AbstractProcessor{
|
||||
"body": {}
|
||||
]
|
||||
|
||||
logger.info('{} - Assigning node {} to job with payload: {}',metaData.user, metaData.jobId, o)
|
||||
logger.info('{} - Assigning node {} to job with payload: {}',metaData?.user, metaData.jobId, o)
|
||||
|
||||
//User Credentials for connecting to ProActive Server.
|
||||
//SAL is a REST interface to PWS. Get it from UI or store in middleware db?
|
||||
|
@ -1,5 +1,6 @@
|
||||
package eu.nebulouscloud.exn.modules.sal.repository
|
||||
|
||||
import groovy.util.logging.Slf4j
|
||||
import org.springframework.http.HttpHeaders
|
||||
import org.springframework.http.MediaType
|
||||
import org.springframework.stereotype.Repository
|
||||
@ -8,6 +9,7 @@ import org.springframework.util.MultiValueMap
|
||||
import org.springframework.web.client.HttpClientErrorException
|
||||
|
||||
@Repository
|
||||
@Slf4j
|
||||
class GatewayRepository extends AbstractSalRepository{
|
||||
|
||||
GatewayRepository() {
|
||||
@ -23,7 +25,9 @@ class GatewayRepository extends AbstractSalRepository{
|
||||
|
||||
HttpHeaders headers = new HttpHeaders()
|
||||
headers.setContentType(MediaType.MULTIPART_FORM_DATA)
|
||||
String sessionId = post('connect', credentials, headers)
|
||||
log.trace('Logging in with username: {} and password {}',username,password)
|
||||
String sessionId = post('connect', credentials, headers)
|
||||
log.trace('Logged in with sessionId {}',sessionId)
|
||||
|
||||
return sessionId
|
||||
|
||||
|
@ -15,5 +15,8 @@ class NodeCandidateRepository extends AbstractSalRepository{
|
||||
post('filter',body,headers,responseType)
|
||||
}
|
||||
|
||||
List rankCandidates(String body, HttpHeaders headers, Class responseType){
|
||||
post('orderfiltered',body,headers,responseType)
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user