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
90df0ed0
Commit
90df0ed0
authored
Mar 03, 2017
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Plain Diff
Merge origin/package into package
parents
fb608589
a984715a
Changes
21
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
479 additions
and
18 deletions
+479
-18
rpc_server.py
drip-planner/rpc_server.py
+7
-5
server.py
drip-planner/server.py
+11
-5
input.json
drip-planner2provisioner/input.json
+27
-0
pom.xml
drip-planner2provisioner/pom.xml
+58
-0
.DS_Store
drip-planner2provisioner/src/main/.DS_Store
+0
-0
.DS_Store
drip-planner2provisioner/src/main/java/.DS_Store
+0
-0
P2PConverter.java
drip-planner2provisioner/src/main/java/P2PConverter.java
+126
-0
SimplePlanContainer.java
...lanner2provisioner/src/main/java/SimplePlanContainer.java
+9
-0
Parameter.java
...anner2provisioner/src/main/java/plannerOut/Parameter.java
+12
-0
PlannerOutput.java
...r2provisioner/src/main/java/plannerOut/PlannerOutput.java
+11
-0
Value.java
drip-planner2provisioner/src/main/java/plannerOut/Value.java
+9
-0
Eth.java
...-planner2provisioner/src/main/java/provisionerIn/Eth.java
+9
-0
SubTopology.java
...2provisioner/src/main/java/provisionerIn/SubTopology.java
+19
-0
SubTopologyInfo.java
...visioner/src/main/java/provisionerIn/SubTopologyInfo.java
+21
-0
Subnet.java
...anner2provisioner/src/main/java/provisionerIn/Subnet.java
+13
-0
TopTopology.java
...2provisioner/src/main/java/provisionerIn/TopTopology.java
+14
-0
VM.java
drip-planner2provisioner/src/main/java/provisionerIn/VM.java
+45
-0
.DS_Store
drip-planner2provisioner/src/test/.DS_Store
+0
-0
.DS_Store
drip-planner2provisioner/src/test/java/.DS_Store
+0
-0
testConverter.java
drip-planner2provisioner/src/test/java/testConverter.java
+39
-0
pom.xml
pom.xml
+49
-8
No files found.
drip-planner/rpc_server.py
View file @
90df0ed0
...
...
@@ -49,9 +49,9 @@ def handleDelivery(message):
for
j
in
json1
:
if
not
json1
[
j
][
'type'
]
==
"Switch.nodes.Application.Connection"
:
print
j
,
json1
[
j
]
nodeDic
[
j
]
=
i
nodeDic1
[
i
]
=
j
i
=
i
+
1
nodeDic
[
j
]
=
i
nodeDic1
[
i
]
=
j
i
=
i
+
1
#get the links from the json
links
=
[]
...
...
@@ -105,8 +105,10 @@ def handleDelivery(message):
# convert the json to the file required
res1
=
{}
for
key
,
value
in
sorted_nodeDic
:
print
value
,
res
[
str
(
value
)]
res1
[
nodeDic1
[
value
]]
=
res
[
str
(
value
)]
res1_value
=
{}
res1_value
[
"size"
]
=
res
[
str
(
value
)]
res1_value
[
"docker"
]
=
json1
[
nodeDic1
[
value
]]
.
get
(
'artifacts'
)
.
get
(
'docker_image'
)
.
get
(
'file'
)
res1
[
str
(
nodeDic1
[
value
])]
=
res1_value
print
res1
# generate the json files in the corresponding format as the
outcontent
=
{}
...
...
drip-planner/server.py
View file @
90df0ed0
...
...
@@ -33,7 +33,7 @@ def main(argv):
SDI_file
=
arg
data
=
{}
print
workflow_file
#
print workflow_file
with
open
(
workflow_file
)
as
data_file
:
data
=
json
.
load
(
data_file
)
#print data
...
...
@@ -58,13 +58,14 @@ def main(argv):
#get the nodes from the json
nodeDic
=
{}
nodeDic1
=
{}
i
=
1
for
j
in
json1
:
if
not
json1
[
j
][
'type'
]
==
"Switch.nodes.Application.Connection"
:
print
j
,
json1
[
j
]
nodeDic
[
j
]
=
i
nodeDic1
[
i
]
=
j
i
=
i
+
1
nodeDic
[
j
]
=
i
nodeDic1
[
i
]
=
j
i
=
i
+
1
#get the links from the json
links
=
[]
...
...
@@ -118,7 +119,11 @@ def main(argv):
res1
=
{}
for
key
,
value
in
sorted_nodeDic
:
print
value
,
res
[
str
(
value
)]
res1
[
nodeDic1
[
value
]]
=
res
[
str
(
value
)]
res1_value
=
{}
res1_value
[
"size"
]
=
res
[
str
(
value
)]
res1_value
[
"docker"
]
=
json1
[
nodeDic1
[
value
]]
.
get
(
'artifacts'
)
.
get
(
'docker_image'
)
.
get
(
'file'
)
res1
[
str
(
nodeDic1
[
value
])]
=
res1_value
print
res1
# generate the json files in the corresponding format as the
outcontent
=
{}
...
...
@@ -130,6 +135,7 @@ def main(argv):
par1
[
"value"
]
=
res1
par1
[
"attributes"
]
=
"null"
outcontent
[
"parameters"
]
.
append
(
par1
)
#print outcontent
return
outcontent
...
...
drip-planner2provisioner/input.json
0 → 100644
View file @
90df0ed0
{
"creationDate"
:
1488459287833
,
"parameters"
:
[
{
"url"
:
null
,
"attributes"
:
null
,
"value"
:
[
{
"name"
:
"2d13d708e3a9441ab8336ce874e08dd1"
,
"size"
:
"Small"
,
"docker"
:
"mogswitch/InputDistributor"
},
{
"name"
:
"8fcc1788d9ee462c826572c79fdb2a6a"
,
"size"
:
"Small"
,
"docker"
:
"mogswitch/InputDistributor"
},
{
"name"
:
"5e0add703c8a43938a39301f572e46c0"
,
"size"
:
"Small"
,
"docker"
:
"mogswitch/InputDistributor"
}
],
"encoding"
:
"UTF-8"
}
]
}
\ No newline at end of file
drip-planner2provisioner/pom.xml
0 → 100644
View file @
90df0ed0
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
nl.uva.sne.drip
</groupId>
<artifactId>
drip-planner2provisioner
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<packaging>
jar
</packaging>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<maven.compiler.source>
1.7
</maven.compiler.source>
<maven.compiler.target>
1.7
</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>
com.fasterxml.jackson.dataformat
</groupId>
<artifactId>
jackson-dataformat-yaml
</artifactId>
<version>
2.5.0
</version>
</dependency>
<dependency>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-databind
</artifactId>
<version>
2.5.0
</version>
</dependency>
<dependency>
<groupId>
commons-io
</groupId>
<artifactId>
commons-io
</artifactId>
<version>
2.5
</version>
</dependency>
</dependencies>
<build>
<plugins>
<!--mvn clean compile assembly:single-->
<plugin>
<artifactId>
maven-assembly-plugin
</artifactId>
<configuration>
<archive>
<manifest>
<mainClass></mainClass>
</manifest>
<manifestEntries>
<Class-Path>
.
</Class-Path>
</manifestEntries>
</archive>
<descriptorRefs>
<descriptorRef>
jar-with-dependencies
</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
drip-planner2provisioner/src/main/.DS_Store
0 → 100644
View file @
90df0ed0
File added
drip-planner2provisioner/src/main/java/.DS_Store
0 → 100644
View file @
90df0ed0
File added
drip-planner2provisioner/src/main/java/P2PConverter.java
0 → 100644
View file @
90df0ed0
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.UUID
;
import
com.fasterxml.jackson.core.JsonParseException
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.JsonMappingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.dataformat.yaml.YAMLFactory
;
import
plannerOut.Parameter
;
import
plannerOut.PlannerOutput
;
import
plannerOut.Value
;
import
provisionerIn.Eth
;
import
provisionerIn.SubTopology
;
import
provisionerIn.SubTopologyInfo
;
import
provisionerIn.Subnet
;
import
provisionerIn.TopTopology
;
import
provisionerIn.VM
;
public
class
P2PConverter
{
public
static
SimplePlanContainer
transfer
(
String
plannerOutputJson
,
String
userName
,
String
OStype
,
String
clusterType
)
throws
JsonParseException
,
JsonMappingException
,
IOException
{
Parameter
plannerOutput
=
getInfoFromPlanner
(
plannerOutputJson
);
TopTopology
topTopology
=
new
TopTopology
();
SubTopology
subTopology
=
new
SubTopology
();
SubTopologyInfo
sti
=
new
SubTopologyInfo
();
sti
.
cloudProvider
=
"EC2"
;
sti
.
topology
=
UUID
.
randomUUID
().
toString
();
subTopology
.
publicKeyPath
=
null
;
subTopology
.
userName
=
userName
;
Subnet
s
=
new
Subnet
();
s
.
name
=
"s1"
;
s
.
subnet
=
"192.168.10.0"
;
s
.
netmask
=
"255.255.255.0"
;
subTopology
.
subnets
=
new
ArrayList
<
Subnet
>();
subTopology
.
subnets
.
add
(
s
);
subTopology
.
components
=
new
ArrayList
<
VM
>();
boolean
firstVM
=
true
;
for
(
int
vi
=
0
;
vi
<
plannerOutput
.
value
.
size
()
;
vi
++){
Value
curValue
=
plannerOutput
.
value
.
get
(
vi
);
VM
curVM
=
new
VM
();
curVM
.
name
=
curValue
.
name
;
curVM
.
type
=
"Switch.nodes.Compute"
;
curVM
.
OStype
=
OStype
;
curVM
.
domain
=
"ec2.us-east-1.amazonaws.com"
;
curVM
.
clusterType
=
clusterType
;
curVM
.
dockers
=
curValue
.
docker
;
curVM
.
public_address
=
curValue
.
name
;
if
(
curValue
.
size
.
trim
().
toLowerCase
().
equals
(
"small"
))
curVM
.
nodeType
=
"t2.small"
;
else
if
(
curValue
.
size
.
trim
().
toLowerCase
().
equals
(
"medium"
))
curVM
.
nodeType
=
"t2.medium"
;
else
if
(
curValue
.
size
.
trim
().
toLowerCase
().
equals
(
"large"
))
curVM
.
nodeType
=
"t2.large"
;
else
{
throw
new
IllegalArgumentException
(
"Invalid value for field 'size' in input JSON String"
);
}
Eth
eth
=
new
Eth
();
eth
.
name
=
"p1"
;
eth
.
subnet_name
=
"s1"
;
int
hostNum
=
10
+
vi
;
String
priAddress
=
"192.168.10."
+
hostNum
;
eth
.
address
=
priAddress
;
curVM
.
ethernet_port
=
new
ArrayList
<
Eth
>();
curVM
.
ethernet_port
.
add
(
eth
);
if
(
firstVM
){
curVM
.
role
=
"master"
;
firstVM
=
false
;
}
else
curVM
.
role
=
"slave"
;
subTopology
.
components
.
add
(
curVM
);
}
sti
.
subTopology
=
subTopology
;
topTopology
.
topologies
=
new
ArrayList
<
SubTopologyInfo
>();
topTopology
.
topologies
.
add
(
sti
);
SimplePlanContainer
spc
=
generateInfo
(
topTopology
);
return
spc
;
}
private
static
Parameter
getInfoFromPlanner
(
String
json
)
throws
JsonParseException
,
JsonMappingException
,
IOException
{
ObjectMapper
mapper
=
new
ObjectMapper
();
PlannerOutput
po
=
mapper
.
readValue
(
json
,
PlannerOutput
.
class
);
System
.
out
.
println
(
""
);
return
po
.
parameters
.
get
(
0
);
}
private
static
SimplePlanContainer
generateInfo
(
TopTopology
topTopology
)
throws
JsonProcessingException
{
SimplePlanContainer
spc
=
new
SimplePlanContainer
();
ObjectMapper
mapper
=
new
ObjectMapper
(
new
YAMLFactory
());
String
yamlString
=
mapper
.
writeValueAsString
(
topTopology
);
spc
.
topLevelContents
=
yamlString
.
substring
(
4
);
Map
<
String
,
String
>
output
=
new
HashMap
<
String
,
String
>();
for
(
int
i
=
0
;
i
<
topTopology
.
topologies
.
size
()
;
i
++){
String
key
=
topTopology
.
topologies
.
get
(
i
).
topology
;
String
value
=
mapper
.
writeValueAsString
(
topTopology
.
topologies
.
get
(
i
).
subTopology
);
output
.
put
(
key
,
value
.
substring
(
4
));
}
spc
.
lowerLevelContents
=
output
;
return
spc
;
}
}
drip-planner2provisioner/src/main/java/SimplePlanContainer.java
0 → 100644
View file @
90df0ed0
import
java.util.Map
;
public
class
SimplePlanContainer
{
public
String
topLevelContents
;
public
Map
<
String
,
String
>
lowerLevelContents
;
}
drip-planner2provisioner/src/main/java/plannerOut/Parameter.java
0 → 100644
View file @
90df0ed0
package
plannerOut
;
import
java.util.ArrayList
;
public
class
Parameter
{
public
String
url
;
public
String
attributes
;
public
ArrayList
<
Value
>
value
;
public
String
encoding
;
}
drip-planner2provisioner/src/main/java/plannerOut/PlannerOutput.java
0 → 100644
View file @
90df0ed0
package
plannerOut
;
import
java.util.ArrayList
;
public
class
PlannerOutput
{
public
String
creationDate
;
public
ArrayList
<
Parameter
>
parameters
;
}
drip-planner2provisioner/src/main/java/plannerOut/Value.java
0 → 100644
View file @
90df0ed0
package
plannerOut
;
public
class
Value
{
public
String
name
;
public
String
size
;
public
String
docker
;
}
drip-planner2provisioner/src/main/java/provisionerIn/Eth.java
0 → 100644
View file @
90df0ed0
package
provisionerIn
;
public
class
Eth
{
public
String
name
;
public
String
subnet_name
;
public
String
address
;
}
drip-planner2provisioner/src/main/java/provisionerIn/SubTopology.java
0 → 100644
View file @
90df0ed0
package
provisionerIn
;
import
java.util.ArrayList
;
public
class
SubTopology
{
public
String
publicKeyPath
;
public
String
userName
;
//Indicate a subnet that several can be put in.
public
ArrayList
<
Subnet
>
subnets
;
public
ArrayList
<
VM
>
components
;
}
drip-planner2provisioner/src/main/java/provisionerIn/SubTopologyInfo.java
0 → 100644
View file @
90df0ed0
package
provisionerIn
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
public
class
SubTopologyInfo
{
//The name of the topology. It is also the file name of the low level description.
public
String
topology
;
//Currently, only support "EC2" and "ExoGENI"/"GENI". This is not case sensitive.
public
String
cloudProvider
;
//Point to the detailed description of the sub-topology.
@JsonIgnore
public
SubTopology
subTopology
;
}
drip-planner2provisioner/src/main/java/provisionerIn/Subnet.java
0 → 100644
View file @
90df0ed0
package
provisionerIn
;
public
class
Subnet
{
//The name of the subnet. Two subnets cannot have same name in one subnet.
public
String
name
;
public
String
subnet
;
public
String
netmask
;
}
drip-planner2provisioner/src/main/java/provisionerIn/TopTopology.java
0 → 100644
View file @
90df0ed0
package
provisionerIn
;
import
java.util.ArrayList
;
public
class
TopTopology
{
public
ArrayList
<
SubTopologyInfo
>
topologies
;
}
drip-planner2provisioner/src/main/java/provisionerIn/VM.java
0 → 100644
View file @
90df0ed0
package
provisionerIn
;
import
java.util.ArrayList
;
public
class
VM
{
public
String
name
;
public
String
type
;
public
String
nodeType
;
public
String
OStype
;
//Currently, the SIDE subsystem uses this field for GUI.
public
String
script
;
public
String
domain
;
public
String
installation
;
public
String
clusterType
;
//The role of this node in docker cluster.
//The possible value can only be "null", "slave" and "master".
//This is not case sensitive.
public
String
role
;
//The name of the docker in repository, which can be "null".
public
String
dockers
;
//Do not need to be the same with the node name any more.
//The initial value should be "null", which means the public is not determined.
//When the status of the sub-topology is stopped, deleted or failed, this field should also be "null".
public
String
public_address
;
public
ArrayList
<
Eth
>
ethernet_port
;
}
drip-planner2provisioner/src/test/.DS_Store
0 → 100644
View file @
90df0ed0
File added
drip-planner2provisioner/src/test/java/.DS_Store
0 → 100644
View file @
90df0ed0
File added
drip-planner2provisioner/src/test/java/testConverter.java
0 → 100644
View file @
90df0ed0
import
java.io.File
;
import
java.io.IOException
;
import
java.util.Map
;
import
org.apache.commons.io.FileUtils
;
public
class
testConverter
{
public
static
void
main
(
String
[]
args
)
{
File
jsonFile
=
new
File
(
"input.json"
);
String
json
=
""
;
try
{
json
=
FileUtils
.
readFileToString
(
jsonFile
,
"UTF-8"
);
}
catch
(
IOException
e1
)
{
e1
.
printStackTrace
();
}
try
{
SimplePlanContainer
spc
=
P2PConverter
.
transfer
(
json
,
"zh9314"
,
"Ubuntu 16.04"
,
"kubernetes"
);
System
.
out
.
println
(
"--topLevel:\n"
+
spc
.
topLevelContents
);
System
.
out
.
println
(
"--lowLevel:"
);
for
(
Map
.
Entry
<
String
,
String
>
entry
:
spc
.
lowerLevelContents
.
entrySet
()){
System
.
out
.
println
(
entry
.
getKey
()+
":\n"
+
entry
.
getValue
());
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
pom.xml
View file @
90df0ed0
...
...
@@ -2,16 +2,57 @@
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
nl.uva.sne.drip
</groupId>
<artifactId>
drip
</artifactId>
<artifactId>
drip
-planner2provisioner
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<packaging>
pom
</packaging>
<packaging>
jar
</packaging>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<maven.compiler.source>
1.7
</maven.compiler.source>
<maven.compiler.target>
1.7
</maven.compiler.target>
</properties>
<modules>
<module>
drip-api
</module>
<module>
drip-commons
</module>
<module>
drip-simple_planner
</module>
<module>
drip-provisioner
</module>
</modules>
<dependencies>
<dependency>
<groupId>
com.fasterxml.jackson.dataformat
</groupId>
<artifactId>
jackson-dataformat-yaml
</artifactId>
<version>
2.5.0
</version>
</dependency>
<dependency>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-databind
</artifactId>
<version>
2.5.0
</version>
</dependency>
<dependency>
<groupId>
commons-io
</groupId>
<artifactId>
commons-io
</artifactId>
<version>
2.5
</version>
</dependency>
</dependencies>
<build>
<plugins>
<!--mvn clean compile assembly:single-->
<plugin>
<artifactId>
maven-assembly-plugin
</artifactId>
<configuration>
<archive>
<manifest>
<mainClass></mainClass>
</manifest>
<manifestEntries>
<Class-Path>
.
</Class-Path>
</manifestEntries>
</archive>
<descriptorRefs>
<descriptorRef>
jar-with-dependencies
</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
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