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
4e3f7474
Commit
4e3f7474
authored
Mar 12, 2018
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replaced Ansible data type with keyvalue
parent
f1105ccd
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
88 additions
and
288 deletions
+88
-288
DeployDao.java
...-api/src/main/java/nl/uva/sne/drip/api/dao/DeployDao.java
+2
-2
AnsibleOutputService.java
...ava/nl/uva/sne/drip/api/service/AnsibleOutputService.java
+1
-32
DeployService.java
.../main/java/nl/uva/sne/drip/api/service/DeployService.java
+59
-62
AnsibleOutputController.java
.../nl/uva/sne/drip/api/v1/rest/AnsibleOutputController.java
+2
-32
AnsibleOutput.java
.../drip/commons/data/v1/external/ansible/AnsibleOutput.java
+4
-3
AnsibleResult.java
.../drip/commons/data/v1/external/ansible/AnsibleResult.java
+0
-157
pom.xml
drip-provisioner/pom.xml
+20
-0
No files found.
drip-api/src/main/java/nl/uva/sne/drip/api/dao/DeployDao.java
View file @
4e3f7474
...
...
@@ -16,7 +16,7 @@
package
nl
.
uva
.
sne
.
drip
.
api
.
dao
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.DeployResponse
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.
ansible.AnsibleResult
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.
KeyValueHolder
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
org.springframework.data.mongodb.repository.Query
;
...
...
@@ -27,5 +27,5 @@ import org.springframework.data.mongodb.repository.Query;
public
interface
DeployDao
extends
MongoRepository
<
DeployResponse
,
String
>
{
@Query
(
value
=
"{'statusHistories':{$elemMatch:{'status':{$in:['PROCESSABLE']}}},'created' : { '$gt' : { '$date' : ':?0' } , '$lt' : { '$date' : ':?1'}}}"
,
count
=
true
)
public
Iterable
<
AnsibleResult
>
findByCommand
(
String
cmd
);
public
Iterable
<
KeyValueHolder
>
findByCommand
(
String
cmd
);
}
drip-api/src/main/java/nl/uva/sne/drip/api/service/AnsibleOutputService.java
View file @
4e3f7474
...
...
@@ -21,9 +21,9 @@ import java.util.List;
import
java.util.Set
;
import
nl.uva.sne.drip.api.dao.AnsibleOutputDao
;
import
nl.uva.sne.drip.api.exception.NotFoundException
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.KeyValueHolder
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.User
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.ansible.AnsibleOutput
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.ansible.AnsibleResult
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.prepost.PostAuthorize
;
import
org.springframework.security.access.prepost.PostFilter
;
...
...
@@ -79,35 +79,4 @@ public class AnsibleOutputService {
ansibleOutputDao
.
deleteAll
();
}
public
List
<
String
>
findAllCommands
()
{
List
<
AnsibleOutput
>
all
=
findAll
();
Set
<
String
>
hashset
=
new
HashSet
<>();
for
(
AnsibleOutput
ans
:
all
)
{
AnsibleResult
res
=
ans
.
getAnsibleResult
();
if
(
res
!=
null
)
{
List
<
String
>
commandList
=
res
.
getCmd
();
if
(
commandList
!=
null
)
{
hashset
.
add
(
commandList
.
get
(
0
));
}
}
}
return
new
ArrayList
<>(
hashset
);
}
public
List
<
AnsibleOutput
>
findByCommand
(
String
command
)
{
List
<
AnsibleOutput
>
all
=
findAll
();
List
<
AnsibleOutput
>
filtered
=
new
ArrayList
<>();
for
(
AnsibleOutput
ans
:
all
)
{
AnsibleResult
res
=
ans
.
getAnsibleResult
();
if
(
res
!=
null
)
{
List
<
String
>
commandList
=
res
.
getCmd
();
if
(
commandList
!=
null
&&
commandList
.
get
(
0
).
equals
(
command
))
{
filtered
.
add
(
ans
);
}
}
}
return
filtered
;
}
}
drip-api/src/main/java/nl/uva/sne/drip/api/service/DeployService.java
View file @
4e3f7474
...
...
@@ -54,11 +54,11 @@ import nl.uva.sne.drip.commons.utils.Converter;
import
nl.uva.sne.drip.commons.utils.DRIPLogHandler
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.ConfigurationRepresentation
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.KeyPair
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.KeyValueHolder
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.PlanResponse
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.ScaleRequest
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.ToscaRepresentation
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.ansible.AnsibleOutput
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.ansible.AnsibleResult
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.ansible.BenchmarkResult
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.ansible.SysbenchCPUBenchmark
;
import
org.json.JSONArray
;
...
...
@@ -398,7 +398,7 @@ public class DeployService {
mapper
.
configure
(
DeserializationFeature
.
FAIL_ON_UNKNOWN_PROPERTIES
,
false
);
value
=
parseValue
(
value
);
System
.
err
.
println
(
value
);
List
<
AnsibleOutput
>
outputList
=
mapper
.
readValue
(
value
,
new
TypeReference
<
List
<
AnsibleOutput
>>()
{
});
...
...
@@ -476,66 +476,63 @@ public class DeployService {
}
private
BenchmarkResult
parseSaveBenchmarkResult
(
AnsibleOutput
ansOut
)
{
AnsibleResult
res
=
ansOut
.
getAnsibleResult
();
if
(
res
!=
null
)
{
List
<
String
>
cmdList
=
res
.
getCmd
();
if
(
cmdList
!=
null
)
{
switch
(
cmdList
.
get
(
0
))
{
case
"sysbench"
:
String
[]
out
=
res
.
getStdout
().
split
(
"\n"
);
String
version
=
getSysbeanchVersion
(
out
[
0
]);
int
numOfThreads
=
getNumberOfThreads
(
out
[
3
]);
Double
executionTime
=
getExecutionTime
(
out
[
14
]);
int
totalNumberOfEvents
=
getTotalNumberOfEvents
(
out
[
15
]);
double
minExecutionTimePerRequest
=
getMinExecutionTimePerRequest
(
out
[
18
]);
double
avgExecutionTimePerRequest
=
getAvgExecutionTimePerRequest
(
out
[
19
]);
double
maxExecutionTimePerRequest
=
getMaxExecutionTimePerRequest
(
out
[
20
]);
double
approx95Percentile
=
getApprox95Percentile
(
out
[
21
]);
double
avgEventsPerThread
=
getAvgEventsPerThread
(
out
[
24
]);
double
stddevEventsPerThread
=
getStddevEventsPerThread
(
out
[
24
]);
double
avgExecTimePerThread
=
getAvgExecTimePerThread
(
out
[
25
]);
double
stddevExecTimePerThread
=
getStddevExecTimePerThread
(
out
[
25
]);
SysbenchCPUBenchmark
b
=
new
SysbenchCPUBenchmark
();
b
.
setSysbenchVersion
(
version
);
b
.
setNumberOfThreads
(
numOfThreads
);
b
.
setExecutionTime
(
executionTime
*
1000
);
b
.
setTotalNumberOfEvents
(
totalNumberOfEvents
);
b
.
setAvgEventsPerThread
(
avgEventsPerThread
);
b
.
setStddevEventsPerThread
(
stddevEventsPerThread
);
b
.
setAvgExecTimePerThread
(
avgExecTimePerThread
*
1000
);
b
.
setStddevExecTimePerThread
(
stddevExecTimePerThread
);
b
.
setApprox95Percentile
(
approx95Percentile
);
b
.
setMinExecutionTimePerRequest
(
minExecutionTimePerRequest
);
b
.
setAvgExecutionTimePerRequest
(
avgExecutionTimePerRequest
);
b
.
setMaxExecutionTimePerRequest
(
maxExecutionTimePerRequest
);
b
.
setAnsibleOutputID
(
ansOut
.
getId
());
b
.
setCloudDeploymentDomain
(
ansOut
.
getCloudDeploymentDomain
());
b
.
setDelta
(
ansOut
.
getAnsibleResult
().
getDelta
());
b
.
setStart
(
ansOut
.
getAnsibleResult
().
getStart
());
b
.
setEnd
(
ansOut
.
getAnsibleResult
().
getEnd
());
b
.
setHost
(
ansOut
.
getHost
());
b
.
setVmType
(
ansOut
.
getVmType
());
b
=
(
SysbenchCPUBenchmark
)
benchmarkResultService
.
save
(
b
);
return
b
;
default
:
return
null
;
}
}
}
// KeyValueHolder res = ansOut.getAnsibleResult();
// if (res != null) {
// List<String> cmdList = res.getCmd();
// if (cmdList != null) {
//
// switch (cmdList.get(0)) {
// case "sysbench":
// String[] out = res.getStdout().split("\n");
// String version = getSysbeanchVersion(out[0]);
// int numOfThreads = getNumberOfThreads(out[3]);
// Double executionTime = getExecutionTime(out[14]);
// int totalNumberOfEvents = getTotalNumberOfEvents(out[15]);
//
// double minExecutionTimePerRequest = getMinExecutionTimePerRequest(out[18]);
// double avgExecutionTimePerRequest = getAvgExecutionTimePerRequest(out[19]);
// double maxExecutionTimePerRequest = getMaxExecutionTimePerRequest(out[20]);
// double approx95Percentile = getApprox95Percentile(out[21]);
//
// double avgEventsPerThread = getAvgEventsPerThread(out[24]);
// double stddevEventsPerThread = getStddevEventsPerThread(out[24]);
//
// double avgExecTimePerThread = getAvgExecTimePerThread(out[25]);
// double stddevExecTimePerThread = getStddevExecTimePerThread(out[25]);
//
// SysbenchCPUBenchmark b = new SysbenchCPUBenchmark();
// b.setSysbenchVersion(version);
//
// b.setNumberOfThreads(numOfThreads);
// b.setExecutionTime(executionTime * 1000);
//
// b.setTotalNumberOfEvents(totalNumberOfEvents);
//
// b.setAvgEventsPerThread(avgEventsPerThread);
// b.setStddevEventsPerThread(stddevEventsPerThread);
//
// b.setAvgExecTimePerThread(avgExecTimePerThread * 1000);
// b.setStddevExecTimePerThread(stddevExecTimePerThread);
// b.setApprox95Percentile(approx95Percentile);
//
// b.setMinExecutionTimePerRequest(minExecutionTimePerRequest);
// b.setAvgExecutionTimePerRequest(avgExecutionTimePerRequest);
// b.setMaxExecutionTimePerRequest(maxExecutionTimePerRequest);
//
// b.setAnsibleOutputID(ansOut.getId());
//
// b.setCloudDeploymentDomain(ansOut.getCloudDeploymentDomain());
// b.setHost(ansOut.getHost());
// b.setVmType(ansOut.getVmType());
// b = (SysbenchCPUBenchmark) benchmarkResultService.save(b);
// return b;
//
// default:
// return null;
//
// }
// }
// }
return
null
;
}
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/v1/rest/AnsibleOutputController.java
View file @
4e3f7474
...
...
@@ -70,22 +70,6 @@ public class AnsibleOutputController {
return
resp
;
}
/**
* Query AnsibleOutput by executing command.
*
* @param command
* @return
*/
@RequestMapping
(
method
=
RequestMethod
.
GET
,
params
=
{
"command"
})
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
@StatusCodes
({
@ResponseCode
(
code
=
200
,
condition
=
"Successful query"
)
})
public
@ResponseBody
List
<
AnsibleOutput
>
getByCommand
(
@RequestParam
(
value
=
"command"
)
String
command
)
{
return
ansibleOutputService
.
findByCommand
(
command
);
}
/**
* Returns the ids of stored objects. Empty list if non stored
*
...
...
@@ -106,20 +90,6 @@ public class AnsibleOutputController {
return
ids
;
}
/**
* Query for used (unique) commands
*
* @return
*/
@RequestMapping
(
value
=
"/commands"
,
method
=
RequestMethod
.
GET
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
@StatusCodes
({
@ResponseCode
(
code
=
200
,
condition
=
"Successful query"
)
})
public
@ResponseBody
List
<
String
>
getCommands
()
{
return
ansibleOutputService
.
findAllCommands
();
}
/**
* Deletes object
...
...
drip-commons/src/main/java/nl/uva/sne/drip/drip/commons/data/v1/external/ansible/AnsibleOutput.java
View file @
4e3f7474
...
...
@@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.fasterxml.jackson.annotation.JsonPropertyOrder
;
import
com.webcohesion.enunciate.metadata.DocumentationExample
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.KeyValueHolder
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.OwnedObject
;
import
org.springframework.data.mongodb.core.index.Indexed
;
import
org.springframework.data.mongodb.core.mapping.Document
;
...
...
@@ -42,7 +43,7 @@ public class AnsibleOutput extends OwnedObject {
@Indexed
private
String
vmType
;
private
AnsibleResult
result
;
private
KeyValueHolder
result
;
private
String
provisionID
;
...
...
@@ -72,12 +73,12 @@ public class AnsibleOutput extends OwnedObject {
* @return the result
*/
@JsonProperty
(
"result"
)
public
AnsibleResult
getAnsibleResult
()
{
public
KeyValueHolder
getAnsibleResult
()
{
return
result
;
}
@JsonProperty
(
"result"
)
public
void
setAnsiibleResult
(
AnsibleResult
result
)
{
public
void
setAnsiibleResult
(
KeyValueHolder
result
)
{
this
.
result
=
result
;
}
...
...
drip-commons/src/main/java/nl/uva/sne/drip/drip/commons/data/v1/external/ansible/AnsibleResult.java
deleted
100644 → 0
View file @
f1105ccd
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
nl
.
uva
.
sne
.
drip
.
drip
.
commons
.
data
.
v1
.
external
.
ansible
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
java.util.List
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
java.util.Date
;
/**
* This class represents an ansible execution result. This can be used as a
* archive / log of ansible executions for example how much time it took for
* execution, errors etc.
*
* @author S. Koulouzis
*/
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
class
AnsibleResult
{
private
String
msg
;
private
Boolean
changed
;
@JsonFormat
(
shape
=
JsonFormat
.
Shape
.
STRING
,
pattern
=
"yyyy-MM-dd HH:mm:ss.SSSSSS"
)
private
Date
end
;
@JsonFormat
(
shape
=
JsonFormat
.
Shape
.
STRING
,
pattern
=
"yyyy-MM-dd HH:mm:ss.SSSSSS"
)
private
Date
start
;
@JsonFormat
(
shape
=
JsonFormat
.
Shape
.
STRING
,
pattern
=
"HH:mm:ss.SSSSSS"
)
private
Date
delta
;
private
String
stdout
;
private
String
stderr
;
private
List
<
String
>
cmd
;
// @JsonProperty("stdout_lines")
// private List<String> stdout_lines;
// @JsonProperty("results")
// private List<AnsibleResult_> results = null;
@JsonProperty
(
"msg"
)
public
String
getMsg
()
{
return
msg
;
}
@JsonProperty
(
"msg"
)
public
void
setMsg
(
String
msg
)
{
this
.
msg
=
msg
;
}
@JsonProperty
(
"changed"
)
public
Boolean
getChanged
()
{
return
changed
;
}
@JsonProperty
(
"changed"
)
public
void
setChanged
(
Boolean
changed
)
{
this
.
changed
=
changed
;
}
// @JsonProperty("results")
// public List<AnsibleResult_> getAnsibleResults() {
// return results;
// }
//
// @JsonProperty("results")
// public void setAnsibleResults(List<AnsibleResult_> results) {
// this.results = results;
// }
@JsonProperty
(
"end"
)
public
Date
getEnd
()
{
return
end
;
}
@JsonProperty
(
"end"
)
public
void
setEnd
(
Date
end
)
{
this
.
end
=
end
;
}
@JsonProperty
(
"stdout"
)
public
String
getStdout
()
{
return
stdout
;
}
@JsonProperty
(
"stdout"
)
public
void
setStdout
(
String
stdout
)
{
this
.
stdout
=
stdout
;
}
@JsonProperty
(
"cmd"
)
public
List
<
String
>
getCmd
()
{
return
cmd
;
}
@JsonProperty
(
"cmd"
)
public
void
setCmd
(
List
<
String
>
cmd
)
{
this
.
cmd
=
cmd
;
}
@JsonProperty
(
"start"
)
public
Date
getStart
()
{
return
start
;
}
@JsonProperty
(
"start"
)
public
void
setStart
(
Date
start
)
{
this
.
start
=
start
;
}
@JsonProperty
(
"stderr"
)
public
String
getStderr
()
{
return
stderr
;
}
@JsonProperty
(
"stderr"
)
public
void
setStderr
(
String
stderr
)
{
this
.
stderr
=
stderr
;
}
@JsonProperty
(
"delta"
)
public
Date
getDelta
()
{
return
delta
;
}
@JsonProperty
(
"delta"
)
public
void
setDelta
(
Date
delta
)
{
this
.
delta
=
delta
;
}
// @JsonProperty("stdout_lines")
// public List<String> getStdout_lines() {
// return stdout_lines;
// }
//
// @JsonProperty("stdout_lines")
// public void setStdout_lines(List<String> stdout_lines) {
// this.stdout_lines = stdout_lines;
// }
}
drip-provisioner/pom.xml
View file @
4e3f7474
...
...
@@ -15,8 +15,11 @@
<properties>
<maven.compiler.source>
1.8
</maven.compiler.source>
<maven.compiler.target>
1.8
</maven.compiler.target>
<ch.qos.logback.version>
1.2.3
</ch.qos.logback.version>
</properties>
<dependencies>
<dependency>
<groupId>
nl.uva.sne.drip
</groupId>
...
...
@@ -89,6 +92,23 @@
<version>
2.4.4
</version>
<type>
jar
</type>
</dependency>
<dependency>
<groupId>
ch.qos.logback
</groupId>
<artifactId>
logback-core
</artifactId>
<version>
${ch.qos.logback.version}
</version>
</dependency>
<dependency>
<groupId>
ch.qos.logback
</groupId>
<artifactId>
logback-classic
</artifactId>
<version>
${ch.qos.logback.version}
</version>
</dependency>
<dependency>
<groupId>
ch.qos.logback
</groupId>
<artifactId>
logback-access
</artifactId>
<version>
${ch.qos.logback.version}
</version>
</dependency>
</dependencies>
...
...
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