Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CONF
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UvA
CONF
Commits
03737f98
Commit
03737f98
authored
Oct 24, 2019
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added interface type
parent
ba498120
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
108 additions
and
57 deletions
+108
-57
nodes.yaml
TOSCA/types/nodes.yaml
+0
-7
TOSCAUtils.java
...c/main/java/nl/uva/sne/drip/commons/utils/TOSCAUtils.java
+26
-28
ProvisionerApiController.java
...in/java/nl/uva/sne/drip/api/ProvisionerApiController.java
+10
-7
ProvisionerService.java
...main/java/nl/uva/sne/drip/service/ProvisionerService.java
+45
-0
application.properties
drip-manager/src/main/resources/application.properties
+4
-1
pom.xml
drip-provisioner/pom.xml
+12
-2
Consumer.java
.../main/java/nl/uva/sne/drip/drip/provisioner/Consumer.java
+10
-11
RPCServer.java
...main/java/nl/uva/sne/drip/drip/provisioner/RPCServer.java
+1
-1
No files found.
TOSCA/types/nodes.yaml
View file @
03737f98
...
...
@@ -111,13 +111,6 @@ node_types:
credential
:
type
:
tosca.datatypes.Credential
required
:
false
status
:
type
:
string
required
:
true
default
:
"
fresh"
description
:
The state of this topology
constraints
:
-
valid_values
:
[
"
fresh"
,
"
running"
,
"
deleted"
,
"
failed"
,
"
stopped"
]
subnet
:
type
:
string
required
:
false
...
...
drip-commons/src/main/java/nl/uva/sne/drip/commons/utils/TOSCAUtils.java
View file @
03737f98
...
...
@@ -22,6 +22,9 @@ import java.util.Iterator;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
nl.uva.sne.drip.model.TopologyTemplate
;
import
nl.uva.sne.drip.model.ToscaTemplate
;
import
sun.reflect.generics.reflectiveObjects.NotImplementedException
;
/**
*
...
...
@@ -29,9 +32,10 @@ import java.util.Set;
*/
public
class
TOSCAUtils
{
public
static
List
<
Map
<
String
,
Object
>>
getVMsFromTopology
(
Map
<
String
,
Object
>
toscaPlan
)
{
List
<
String
>
vmNames
=
getVMsNodeNamesFromTopology
(
toscaPlan
);
Map
<
String
,
Object
>
nodeTemplates
=
(
Map
<
String
,
Object
>)
((
Map
<
String
,
Object
>)
toscaPlan
.
get
(
"topology_template"
)).
get
(
"node_templates"
);
public
static
List
<
Map
<
String
,
Object
>>
getVMsFromTopology
(
ToscaTemplate
toscaTemplate
)
{
List
<
String
>
vmNames
=
getVMsNodeNamesFromTopology
(
toscaTemplate
);
TopologyTemplate
topologyTemplate
=
toscaTemplate
.
getTopologyTemplate
();
Map
<
String
,
Object
>
nodeTemplates
=
topologyTemplate
.
getNodeTemplates
();
List
<
Map
<
String
,
Object
>>
vmList
=
new
ArrayList
<>();
for
(
String
vmName
:
vmNames
)
{
Map
<
String
,
Object
>
vm
=
(
Map
<
String
,
Object
>)
nodeTemplates
.
get
(
vmName
);
...
...
@@ -41,9 +45,11 @@ public class TOSCAUtils {
return
vmList
;
}
public
static
List
<
String
>
getVMsNodeNamesFromTopology
(
Map
<
String
,
Object
>
toscaPlan
)
{
Map
<
String
,
Object
>
topologyTemplate
=
(
Map
<
String
,
Object
>)
toscaPlan
.
get
(
"topology_template"
);
Map
<
String
,
Object
>
nodeTemplates
=
(
Map
<
String
,
Object
>)
(
topologyTemplate
).
get
(
"node_templates"
);
public
static
List
<
String
>
getVMsNodeNamesFromTopology
(
ToscaTemplate
toscaTemplate
)
{
TopologyTemplate
topologyTemplate
=
toscaTemplate
.
getTopologyTemplate
();
Map
<
String
,
Object
>
nodeTemplates
=
topologyTemplate
.
getNodeTemplates
();
Iterator
it
=
nodeTemplates
.
entrySet
().
iterator
();
List
<
String
>
vmNames
=
new
ArrayList
<>();
while
(
it
.
hasNext
())
{
...
...
@@ -79,21 +85,13 @@ public class TOSCAUtils {
return
outputs
;
}
public
static
Map
<
String
,
String
>
getOutputsForNode
(
Map
<
String
,
Object
>
toscaProvisonMap
,
String
nodeName
)
{
Map
<
String
,
Object
>
topologyTemplate
=
(
Map
<
String
,
Object
>)
((
Map
<
String
,
Object
>)
toscaProvisonMap
.
get
(
"topology_template"
));
Map
<
String
,
Object
>
outputs
=
(
Map
<
String
,
Object
>)
topologyTemplate
.
get
(
"outputs"
);
Map
<
String
,
String
>
matchedOutputs
=
new
HashMap
<>();
Iterator
it
=
outputs
.
entrySet
().
iterator
();
while
(
it
.
hasNext
())
{
Map
.
Entry
output
=
(
Map
.
Entry
)
it
.
next
();
List
<
Map
<
String
,
String
>>
val
=
(
List
<
Map
<
String
,
String
>>)
output
.
getValue
();
for
(
Map
<
String
,
String
>
map
:
val
)
{
if
(
map
.
containsKey
(
nodeName
))
{
matchedOutputs
.
put
((
String
)
output
.
getKey
(),
map
.
get
(
nodeName
));
}
}
}
return
matchedOutputs
;
public
static
Map
<
String
,
String
>
getOutputsForNode
(
ToscaTemplate
toscaTemplate
,
String
nodeName
)
{
TopologyTemplate
topologyTemplate
=
toscaTemplate
.
getTopologyTemplate
();
List
<
Map
<
String
,
Object
>>
outputs
=
topologyTemplate
.
getOutputs
();
List
<
Map
<
String
,
Object
>>
matchedOutputs
=
new
ArrayList
<>();
throw
new
NotImplementedException
();
}
public
static
List
<
String
>
getOutputPair
(
Map
<
String
,
Object
>
outputs
,
String
key
)
{
...
...
@@ -101,9 +99,9 @@ public class TOSCAUtils {
return
outputPair
;
}
public
static
List
<
Map
.
Entry
>
getDockerContainers
(
Map
<
String
,
Object
>
toscaPlan
)
{
Map
<
String
,
Object
>
topologyTemplate
=
(
Map
<
String
,
Object
>)
toscaPlan
.
get
(
"topology_template"
);
Map
<
String
,
Object
>
nodeTemplates
=
(
Map
<
String
,
Object
>)
(
topologyTemplate
).
get
(
"node_templates"
);
public
static
List
<
Map
.
Entry
>
getDockerContainers
(
ToscaTemplate
toscaTemplate
)
{
TopologyTemplate
topologyTemplate
=
toscaTemplate
.
getTopologyTemplate
(
);
Map
<
String
,
Object
>
nodeTemplates
=
topologyTemplate
.
getNodeTemplates
(
);
Iterator
it
=
nodeTemplates
.
entrySet
().
iterator
();
List
<
Map
.
Entry
>
dockerContainers
=
new
ArrayList
<>();
while
(
it
.
hasNext
())
{
...
...
@@ -117,8 +115,8 @@ public class TOSCAUtils {
return
dockerContainers
;
}
public
static
List
<
Map
<
String
,
Object
>>
tosca2KubernetesDeployment
(
Map
<
String
,
Object
>
toscaPlan
)
{
List
<
Map
.
Entry
>
dockerContainers
=
getDockerContainers
(
tosca
Plan
);
public
static
List
<
Map
<
String
,
Object
>>
tosca2KubernetesDeployment
(
ToscaTemplate
toscaTemplate
)
{
List
<
Map
.
Entry
>
dockerContainers
=
getDockerContainers
(
tosca
Template
);
List
<
Map
<
String
,
Object
>>
deployments
=
new
ArrayList
<>();
Iterator
<
Map
.
Entry
>
dicIt
=
dockerContainers
.
iterator
();
...
...
@@ -162,8 +160,8 @@ public class TOSCAUtils {
return
deployments
;
}
public
static
List
<
Map
<
String
,
Object
>>
tosca2KubernetesService
(
Map
<
String
,
Object
>
toscaPlan
)
{
List
<
Map
.
Entry
>
dockerContainers
=
getDockerContainers
(
tosca
Plan
);
public
static
List
<
Map
<
String
,
Object
>>
tosca2KubernetesService
(
ToscaTemplate
toscaTemplate
)
{
List
<
Map
.
Entry
>
dockerContainers
=
getDockerContainers
(
tosca
Template
);
List
<
Map
<
String
,
Object
>>
services
=
new
ArrayList
<>();
Iterator
<
Map
.
Entry
>
dicIt
=
dockerContainers
.
iterator
();
while
(
dicIt
.
hasNext
())
{
...
...
drip-manager/src/main/java/nl/uva/sne/drip/api/ProvisionerApiController.java
View file @
03737f98
...
...
@@ -11,7 +11,9 @@ import org.springframework.web.bind.annotation.PathVariable;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.logging.Level
;
import
nl.uva.sne.drip.service.DRIPService
;
import
nl.uva.sne.drip.service.ProvisionerService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
@@ -26,10 +28,8 @@ public class ProvisionerApiController implements ProvisionerApi {
private
final
HttpServletRequest
request
;
@Value
(
"${message.broker.queue.provisioner}"
)
private
String
queueName
;
@Autowired
private
DRIPService
drip
Service
;
private
ProvisionerService
provisioner
Service
;
@org
.
springframework
.
beans
.
factory
.
annotation
.
Autowired
public
ProvisionerApiController
(
ObjectMapper
objectMapper
,
HttpServletRequest
request
)
{
...
...
@@ -39,13 +39,16 @@ public class ProvisionerApiController implements ProvisionerApi {
@Override
public
ResponseEntity
<
String
>
provisionPlanToscaTemplateByID
(
@ApiParam
(
value
=
"ID of topolog template to p
la
n"
,
required
=
true
)
@ApiParam
(
value
=
"ID of topolog template to p
rovisio
n"
,
required
=
true
)
@PathVariable
(
"id"
)
String
id
)
{
String
accept
=
request
.
getHeader
(
"Accept"
);
if
(
accept
!=
null
&&
accept
.
contains
(
"text/plain"
))
{
dripService
.
setRequestQeueName
(
queueName
);
String
planedYemplateId
=
dripService
.
execute
(
id
);
return
new
ResponseEntity
<>(
planedYemplateId
,
HttpStatus
.
NOT_IMPLEMENTED
);
try
{
String
planedYemplateId
=
provisionerService
.
provision
(
id
);
return
new
ResponseEntity
<>(
planedYemplateId
,
HttpStatus
.
OK
);
}
catch
(
IOException
ex
)
{
java
.
util
.
logging
.
Logger
.
getLogger
(
ProvisionerApiController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
return
new
ResponseEntity
<>(
HttpStatus
.
INTERNAL_SERVER_ERROR
);
...
...
drip-manager/src/main/java/nl/uva/sne/drip/service/ProvisionerService.java
0 → 100644
View file @
03737f98
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package
nl
.
uva
.
sne
.
drip
.
service
;
import
java.io.IOException
;
import
java.util.concurrent.TimeoutException
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
nl.uva.sne.drip.commons.utils.TOSCAUtils
;
import
nl.uva.sne.drip.model.Message
;
import
nl.uva.sne.drip.model.ToscaTemplate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
/**
*
* @author S. Koulouzis
*/
@Service
public
class
ProvisionerService
{
@Value
(
"${message.broker.queue.provisioner}"
)
private
String
queueName
;
@Value
(
"${tosca.types.interface}"
)
private
String
toscaTypesInterface
;
@Autowired
private
ToscaTemplateService
toscaTemplateService
;
public
String
provision
(
String
id
)
throws
IOException
{
String
ymlToscaTemplate
=
toscaTemplateService
.
findByID
(
id
);
ToscaTemplate
toscaTemplate
=
toscaTemplateService
.
getYaml2ToscaTemplate
(
ymlToscaTemplate
);
TOSCAUtils
.
getVMsFromTopology
(
toscaTemplate
);
return
null
;
}
}
drip-manager/src/main/resources/application.properties
View file @
03737f98
...
...
@@ -18,3 +18,6 @@ db.password=drip-pass
spring.jackson.deserialization.UNWRAP_ROOT_VALUE
=
true
tosca.types.interface
=
https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/interfaces/interface_types.yml
\ No newline at end of file
drip-provisioner/pom.xml
View file @
03737f98
...
...
@@ -25,8 +25,18 @@
<groupId>
com.rabbitmq
</groupId>
<artifactId>
amqp-client
</artifactId>
</dependency>
<dependency>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-databind
</artifactId>
<version>
2.9.9.3
</version>
<type>
jar
</type>
</dependency>
<dependency>
<groupId>
nl.uva.sne.drip
</groupId>
<artifactId>
drip-commons
</artifactId>
<version>
3.0.0
</version>
<type>
jar
</type>
</dependency>
</dependencies>
...
...
drip-provisioner/src/main/java/nl/uva/sne/drip/drip/provisioner/Consumer.java
View file @
03737f98
...
...
@@ -15,6 +15,8 @@
*/
package
nl
.
uva
.
sne
.
drip
.
drip
.
provisioner
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.SerializationFeature
;
import
com.rabbitmq.client.AMQP
;
import
com.rabbitmq.client.Channel
;
import
com.rabbitmq.client.DefaultConsumer
;
...
...
@@ -25,6 +27,7 @@ import java.io.IOException;
import
java.util.concurrent.TimeoutException
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
nl.uva.sne.drip.model.Message
;
/**
*
...
...
@@ -36,16 +39,15 @@ import java.util.logging.Logger;
public
class
Consumer
extends
DefaultConsumer
{
private
final
Channel
channel
;
// Map<String, String> em = new HashMap<>();
private
final
Logger
logger
;
private
final
String
messageBrokerHost
;
private
final
ObjectMapper
objectMapper
;
public
Consumer
(
Channel
channel
,
String
messageBrokerHost
)
throws
IOException
,
TimeoutException
{
public
Consumer
(
Channel
channel
)
throws
IOException
,
TimeoutException
{
super
(
channel
);
this
.
channel
=
channel
;
this
.
messageBrokerHost
=
messageBrokerHost
;
logger
=
Logger
.
getLogger
(
Consumer
.
class
.
getName
());
this
.
objectMapper
=
new
ObjectMapper
();
objectMapper
.
disable
(
SerializationFeature
.
WRITE_DATES_AS_TIMESTAMPS
);
}
@Override
...
...
@@ -56,10 +58,7 @@ public class Consumer extends DefaultConsumer {
.
correlationId
(
properties
.
getCorrelationId
())
.
build
();
String
response
=
""
;
//The queue only moves bytes so we need to convert them to string
String
message
=
new
String
(
body
,
"UTF-8"
);
Message
message
=
objectMapper
.
readValue
(
new
String
(
body
,
"UTF-8"
),
Message
.
class
);
String
tempInputDirPath
=
System
.
getProperty
(
"java.io.tmpdir"
)
+
File
.
separator
+
"Input-"
+
Long
.
toString
(
System
.
nanoTime
())
+
File
.
separator
;
File
tempInputDir
=
new
File
(
tempInputDirPath
);
...
...
@@ -67,7 +66,7 @@ public class Consumer extends DefaultConsumer {
throw
new
FileNotFoundException
(
"Could not create input directory: "
+
tempInputDir
.
getAbsolutePath
());
}
response
=
"response"
;
String
response
=
objectMapper
.
writeValueAsString
(
message
)
;
logger
.
log
(
Level
.
INFO
,
"Sending Response: '{'0'}'{0}"
,
response
);
// Logger.getLogger(Consumer.class.getName()).log(Level.INFO, "Sending Response: {0}", response);
...
...
drip-provisioner/src/main/java/nl/uva/sne/drip/drip/provisioner/RPCServer.java
View file @
03737f98
...
...
@@ -70,7 +70,7 @@ public class RPCServer {
//We define the queue name
channel
.
queueDeclare
(
prop
.
getProperty
(
"message.broker.queue.provisioner"
,
"provisioner"
),
false
,
false
,
false
,
null
);
DefaultConsumer
c
;
c
=
new
nl
.
uva
.
sne
.
drip
.
drip
.
provisioner
.
Consumer
(
channel
,
prop
.
getProperty
(
"message.broker.host"
)
);
c
=
new
nl
.
uva
.
sne
.
drip
.
drip
.
provisioner
.
Consumer
(
channel
);
//Start listening for messages
channel
.
basicConsume
(
prop
.
getProperty
(
"message.broker.queue.provisioner"
,
"provisioner"
),
false
,
c
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment