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
9f6a8fda
Commit
9f6a8fda
authored
Mar 04, 2017
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sloved json format bugs
Added more exceptions
parent
09026e0d
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
215 additions
and
31 deletions
+215
-31
CloudCredentialsNotFoundException.java
...drip/api/exception/CloudCredentialsNotFoundException.java
+36
-0
InternalServerErrorException.java
.../sne/drip/api/exception/InternalServerErrorException.java
+36
-0
PlanNotFoundException.java
.../nl/uva/sne/drip/api/exception/PlanNotFoundException.java
+36
-0
DeployController.java
.../main/java/nl/uva/sne/drip/api/rest/DeployController.java
+25
-0
PlannerController.java
...main/java/nl/uva/sne/drip/api/rest/PlannerController.java
+5
-7
ProvisionController.java
...in/java/nl/uva/sne/drip/api/rest/ProvisionController.java
+32
-2
ToscaController.java
...c/main/java/nl/uva/sne/drip/api/rest/ToscaController.java
+1
-1
UserController.java
...rc/main/java/nl/uva/sne/drip/api/rest/UserController.java
+1
-1
PlannerService.java
...main/java/nl/uva/sne/drip/api/service/PlannerService.java
+19
-0
P2PConverter.java
...ain/java/nl/uva/sne/drip/drip/converter/P2PConverter.java
+1
-1
pom.xml
drip-provisioner/pom.xml
+1
-1
Consumer.java
.../main/java/nl/uva/sne/drip/drip/provisioner/Consumer.java
+22
-18
No files found.
drip-api/src/main/java/nl/uva/sne/drip/api/exception/CloudCredentialsNotFoundException.java
0 → 100644
View file @
9f6a8fda
/*
* 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
.
api
.
exception
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
/**
*
* @author S. Koulouzis
*/
@ResponseStatus
(
value
=
HttpStatus
.
NOT_FOUND
,
reason
=
"Cloud credentials not found"
)
public
class
CloudCredentialsNotFoundException
extends
RuntimeException
{
public
CloudCredentialsNotFoundException
(
String
string
)
{
super
(
string
);
}
public
CloudCredentialsNotFoundException
()
{
super
();
}
}
drip-api/src/main/java/nl/uva/sne/drip/api/exception/InternalServerErrorException.java
0 → 100644
View file @
9f6a8fda
/*
* 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
.
api
.
exception
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
/**
*
* @author S. Koulouzis
*/
@ResponseStatus
(
value
=
HttpStatus
.
INTERNAL_SERVER_ERROR
)
public
class
InternalServerErrorException
extends
RuntimeException
{
public
InternalServerErrorException
(
String
massage
)
{
super
(
massage
);
}
public
InternalServerErrorException
()
{
super
();
}
}
drip-api/src/main/java/nl/uva/sne/drip/api/exception/PlanNotFoundException.java
0 → 100644
View file @
9f6a8fda
/*
* 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
.
api
.
exception
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
/**
*
* @author S. Koulouzis
*/
@ResponseStatus
(
value
=
HttpStatus
.
NOT_FOUND
,
reason
=
"Plan not found"
)
public
class
PlanNotFoundException
extends
RuntimeException
{
public
PlanNotFoundException
(
String
string
)
{
super
(
string
);
}
public
PlanNotFoundException
()
{
super
();
}
}
drip-api/src/main/java/nl/uva/sne/drip/api/rest/DeployController.java
View file @
9f6a8fda
...
...
@@ -28,6 +28,7 @@ import java.util.logging.Logger;
import
javax.annotation.security.RolesAllowed
;
import
nl.uva.sne.drip.api.dao.CloudCredentialsDao
;
import
nl.uva.sne.drip.api.exception.BadRequestException
;
import
nl.uva.sne.drip.api.exception.NotFoundException
;
import
nl.uva.sne.drip.commons.types.Message
;
import
nl.uva.sne.drip.commons.types.MessageParameter
;
import
org.json.JSONException
;
...
...
@@ -107,6 +108,30 @@ public class DeployController {
return
clusterCredentialService
.
getDao
().
findOne
(
id
);
}
@RequestMapping
(
value
=
"/ids"
,
method
=
RequestMethod
.
GET
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
List
<
String
>
getIds
()
{
List
<
ClusterCredentials
>
all
=
clusterCredentialService
.
getDao
().
findAll
();
List
<
String
>
ids
=
new
ArrayList
<>(
all
.
size
());
for
(
ClusterCredentials
pi
:
all
)
{
ids
.
add
(
pi
.
getId
());
}
return
ids
;
}
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
DELETE
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
String
delete
(
@PathVariable
(
"id"
)
String
id
)
{
ClusterCredentials
cred
=
clusterCredentialService
.
getDao
().
findOne
(
id
);
if
(
cred
!=
null
)
{
provisionService
.
getDao
().
delete
(
id
);
return
"Deleted : "
+
id
;
}
throw
new
NotFoundException
();
}
private
Message
buildDeployerMessage
(
String
provisionID
,
String
clusterType
)
{
ProvisionInfo
pro
=
provisionService
.
getDao
().
findOne
(
provisionID
);
String
cloudConfID
=
pro
.
getCloudConfID
();
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/rest/PlannerController.java
View file @
9f6a8fda
...
...
@@ -15,7 +15,6 @@
*/
package
nl
.
uva
.
sne
.
drip
.
api
.
rest
;
import
nl.uva.sne.drip.api.service.SimplePlannerService
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -47,8 +46,7 @@ import org.springframework.web.bind.annotation.RequestParam;
public
class
PlannerController
{
// @Autowired
private
SimplePlannerService
simplePlannerService
;
// private SimplePlannerService simplePlannerService;
@Autowired
private
PlannerService
plannerService
;
...
...
@@ -86,22 +84,22 @@ public class PlannerController {
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
String
getToscaID
(
@PathVariable
(
"id"
)
String
id
)
{
return
simpleP
lannerService
.
getToscaID
(
id
);
return
p
lannerService
.
getToscaID
(
id
);
}
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
DELETE
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
String
delete
(
@PathVariable
(
"id"
)
String
id
)
{
simpleP
lannerService
.
getDao
().
delete
(
id
);
return
"Deleted
tosca :
"
+
id
;
p
lannerService
.
getDao
().
delete
(
id
);
return
"Deleted
:
"
+
id
;
}
@RequestMapping
(
value
=
"/ids"
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
List
<
String
>
getIds
()
{
List
<
Plan
>
all
=
simpleP
lannerService
.
findAll
();
List
<
Plan
>
all
=
p
lannerService
.
findAll
();
List
<
String
>
ids
=
new
ArrayList
<>();
for
(
Plan
tr
:
all
)
{
ids
.
add
(
tr
.
getId
());
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/rest/ProvisionController.java
View file @
9f6a8fda
...
...
@@ -44,7 +44,10 @@ import org.springframework.web.bind.annotation.RequestMethod;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
nl.uva.sne.drip.api.exception.BadRequestException
;
import
nl.uva.sne.drip.api.exception.CloudCredentialsNotFoundException
;
import
nl.uva.sne.drip.api.exception.InternalServerErrorException
;
import
nl.uva.sne.drip.api.exception.NotFoundException
;
import
nl.uva.sne.drip.api.exception.PlanNotFoundException
;
import
nl.uva.sne.drip.api.rpc.DRIPCaller
;
import
nl.uva.sne.drip.api.rpc.ProvisionerCaller
;
import
nl.uva.sne.drip.api.service.ProvisionService
;
...
...
@@ -95,6 +98,30 @@ public class ProvisionController {
return
provisionService
.
getDao
().
findOne
(
id
);
}
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
DELETE
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
String
delete
(
@PathVariable
(
"id"
)
String
id
)
{
ProvisionInfo
provPlan
=
provisionService
.
getDao
().
findOne
(
id
);
if
(
provPlan
!=
null
)
{
provisionService
.
getDao
().
delete
(
id
);
return
"Deleted : "
+
id
;
}
throw
new
NotFoundException
();
}
@RequestMapping
(
value
=
"/ids"
,
method
=
RequestMethod
.
GET
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
List
<
String
>
getIds
()
{
List
<
ProvisionInfo
>
all
=
provisionService
.
getDao
().
findAll
();
List
<
String
>
ids
=
new
ArrayList
<>(
all
.
size
());
for
(
ProvisionInfo
pi
:
all
)
{
ids
.
add
(
pi
.
getId
());
}
return
ids
;
}
@RequestMapping
(
value
=
"/provision"
,
method
=
RequestMethod
.
POST
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
...
...
@@ -108,6 +135,9 @@ public class ProvisionController {
for
(
MessageParameter
p
:
params
)
{
String
name
=
p
.
getName
();
if
(
name
.
toLowerCase
().
contains
(
"exception"
))
{
throw
new
InternalServerErrorException
(
name
+
". "
+
p
.
getValue
());
}
if
(!
name
.
equals
(
"kubernetes"
))
{
String
value
=
p
.
getValue
();
Map
<
String
,
Object
>
kvMap
=
Converter
.
ymlString2Map
(
value
);
...
...
@@ -150,7 +180,7 @@ public class ProvisionController {
List
<
MessageParameter
>
parameters
=
new
ArrayList
();
CloudCredentials
cred
=
cloudCredentialsDao
.
findOne
(
pReq
.
getCloudConfID
());
if
(
cred
==
null
)
{
throw
new
NotFoundException
(
"Cloud credentials :"
+
pReq
.
getCloudConfID
()
+
" not found"
);
throw
new
CloudCredentialsNotFoundException
(
);
}
MessageParameter
conf
=
buildCloudConfParam
(
cred
);
parameters
.
add
(
conf
);
...
...
@@ -217,7 +247,7 @@ public class ProvisionController {
private
List
<
MessageParameter
>
buildTopologyParams
(
String
planID
)
throws
JSONException
{
Plan
plan
=
planService
.
getDao
().
findOne
(
planID
);
if
(
plan
==
null
)
{
throw
new
NotFoundException
();
throw
new
Plan
NotFoundException
();
}
List
<
MessageParameter
>
parameters
=
new
ArrayList
();
MessageParameter
topology
=
new
MessageParameter
();
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/rest/ToscaController.java
View file @
9f6a8fda
...
...
@@ -82,7 +82,7 @@ public class ToscaController {
public
@ResponseBody
String
delete
(
@PathVariable
(
"id"
)
String
id
)
{
toscaService
.
delete
(
id
);
return
"Deleted tosca :
"
+
id
;
return
"Deleted :
"
+
id
;
}
// http://localhost:8080/drip-api/tosca/ids
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/rest/UserController.java
View file @
9f6a8fda
...
...
@@ -117,7 +117,7 @@ public class UserController {
throw
new
UserNotFoundException
(
"User "
+
id
+
" not found"
);
}
service
.
getDao
().
delete
(
user
);
return
"Deleted used :
"
+
id
;
return
"Deleted :
"
+
id
;
}
catch
(
Exception
ex
)
{
Logger
.
getLogger
(
UserController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/service/PlannerService.java
View file @
9f6a8fda
...
...
@@ -154,4 +154,23 @@ public class PlannerService {
return
ymlStr
;
}
public
String
getToscaID
(
String
id
)
{
return
planDao
.
findOne
(
id
).
getToscaID
();
}
public
PlanDao
getDao
()
{
return
this
.
planDao
;
}
public
List
<
Plan
>
findAll
()
{
List
<
Plan
>
all
=
planDao
.
findAll
();
List
<
Plan
>
topLevel
=
new
ArrayList
<>();
for
(
Plan
p
:
all
)
{
if
(
p
.
getLevel
()
==
0
)
{
topLevel
.
add
(
p
);
}
}
return
topLevel
;
}
}
drip-planner2provisioner/src/main/java/nl/uva/sne/drip/drip/converter/P2PConverter.java
View file @
9f6a8fda
...
...
@@ -60,7 +60,7 @@ public class P2PConverter {
curVM
.
clusterType
=
clusterType
;
curVM
.
dockers
=
cmp
.
getDocker
();
curVM
.
public_address
=
cmp
.
getName
();
curVM
.
nodeType
=
"t2"
+
cmp
.
getSize
().
toLowerCase
();
curVM
.
nodeType
=
"t2
.
"
+
cmp
.
getSize
().
toLowerCase
();
Eth
eth
=
new
Eth
();
eth
.
name
=
"p1"
;
...
...
drip-provisioner/pom.xml
View file @
9f6a8fda
drip-provisioner/src/main/java/nl/uva/sne/drip/drip/provisioner/Consumer.java
View file @
9f6a8fda
...
...
@@ -397,26 +397,26 @@ public class Consumer extends DefaultConsumer {
if
(
name
.
equals
(
"topology"
))
{
JSONObject
attributes
=
param
.
getJSONObject
(
"attributes"
);
int
fileLevel
=
Integer
.
valueOf
((
String
)
attributes
.
get
(
"level"
));
String
[]
parts
=
((
String
)
attributes
.
get
(
"filename"
)).
split
(
"_"
);
String
fileName
=
""
;
String
prefix
=
""
;
//Clear date part form file name
for
(
int
j
=
1
;
j
<
parts
.
length
;
j
++)
{
fileName
+=
prefix
+
parts
[
j
];
prefix
=
"_"
;
}
if
(
fileLevel
==
level
)
{
String
originalFilename
=
(
String
)
attributes
.
get
(
"filename"
);
String
fileName
=
""
;
// String[] parts = originalFilename.split("_");
// String prefix = "";
// //Clear date part form file name
// if (isNumeric(parts[0])) {
// for (int j = 1; j < parts.length; j++) {
// fileName += prefix + parts[j];
// prefix = "_";
// }
// } else {
fileName
=
originalFilename
;
// }
File
topologyFile
=
new
File
(
tempInputDirPath
+
File
.
separator
+
fileName
);
if
(
topologyFile
.
createNewFile
())
{
topologyFile
.
createNewFile
();
String
val
=
(
String
)
param
.
get
(
MessageParameter
.
VALUE
);
//Replace '{' with indentation otherwise we get 'End of document execption'
// val = val.replaceAll("- \\{", " - ").replaceAll(", ", "\n ").replaceAll("}", "");
writeValueToFile
(
val
,
topologyFile
);
return
topologyFile
;
}
else
{
return
null
;
}
}
}
}
...
...
@@ -484,4 +484,8 @@ public class Consumer extends DefaultConsumer {
return
null
;
}
private
static
boolean
isNumeric
(
String
str
)
{
return
str
.
matches
(
"-?\\d+(\\.\\d+)?"
);
}
}
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