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
0472a4af
Commit
0472a4af
authored
8 years ago
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
deploy kubernetes with API v0.0 works
parent
c36da2cd
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
332 additions
and
149 deletions
+332
-149
DeployClusterService.java
...ava/nl/uva/sne/drip/api/service/DeployClusterService.java
+198
-0
ProvisionService.java
...in/java/nl/uva/sne/drip/api/service/ProvisionService.java
+5
-5
DeployController0.java
...n/java/nl/uva/sne/drip/api/v0/rest/DeployController0.java
+81
-0
ProvisionController0.java
...ava/nl/uva/sne/drip/api/v0/rest/ProvisionController0.java
+2
-21
DeployController.java
...in/java/nl/uva/sne/drip/api/v1/rest/DeployController.java
+9
-114
Deploy.java
...rc/main/java/nl/uva/sne/drip/commons/v0/types/Deploy.java
+27
-0
ClusterCredentials.java
.../nl/uva/sne/drip/commons/v1/types/ClusterCredentials.java
+10
-9
No files found.
drip-api/src/main/java/nl/uva/sne/drip/api/service/DeployClusterService.java
0 → 100644
View file @
0472a4af
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/api/service/ProvisionService.java
View file @
0472a4af
...
...
@@ -120,11 +120,11 @@ public class ProvisionService {
try
(
DRIPCaller
provisioner
=
new
ProvisionerCaller
(
messageBrokerHost
);)
{
Message
provisionerInvokationMessage
=
buildProvisionerMessage
(
req
);
Message
response
=
(
provisioner
.
call
(
provisionerInvokationMessage
));
//
Message response = generateFakeResponse(System.getProperty("user.home")
//
+ File.separator + "workspace" + File.separator + "DRIP"
// + File.separator + "doc" + File.separator + "json_samples" +
//
File.separator + "ec2_provisioner_provisoned2.json");
//
Message response = (provisioner.call(provisionerInvokationMessage));
Message
response
=
generateFakeResponse
(
System
.
getProperty
(
"user.home"
)
+
File
.
separator
+
"workspace"
+
File
.
separator
+
"DRIP"
+
File
.
separator
+
"doc"
+
File
.
separator
+
"json_samples"
+
File
.
separator
+
"ec2_provisioner_provisoned2.json"
);
List
<
MessageParameter
>
params
=
response
.
getParameters
();
for
(
MessageParameter
p
:
params
)
{
...
...
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/api/
service/ClusterCredentialService
.java
→
drip-api/src/main/java/nl/uva/sne/drip/api/
v0/rest/DeployController0
.java
View file @
0472a4af
...
...
@@ -13,51 +13,69 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
nl
.
uva
.
sne
.
drip
.
api
.
service
;
package
nl
.
uva
.
sne
.
drip
.
api
.
v0
.
rest
;
import
java.util.ArrayList
;
import
java.util.List
;
import
nl.uva.sne.drip.api.dao.ClusterCredentialsDao
;
import
nl.uva.sne.drip.commons.v1.types.ClusterCredentials
;
import
nl.uva.sne.drip.commons.v1.types.User
;
import
javax.annotation.security.RolesAllowed
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.prepost.PostAuthorize
;
import
org.springframework.security.access.prepost.PostFilter
;
import
org.springframework.web.bind.annotation.RequestMapping
;
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.service.DeployClusterService
;
import
nl.uva.sne.drip.api.service.UserService
;
import
nl.uva.sne.drip.commons.v0.types.Deploy
;
import
nl.uva.sne.drip.commons.v0.types.File
;
import
nl.uva.sne.drip.commons.v0.types.Result
;
import
nl.uva.sne.drip.commons.v1.types.ClusterCredentials
;
import
org.springframework.http.MediaType
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.s
ecurity.core.context.SecurityContextHolder
;
import
org.springframework.
stereotype.Service
;
import
org.springframework.s
tereotype.Component
;
import
org.springframework.
web.bind.annotation.RequestBody
;
/**
* This controller is responsible for deploying a cluster on provisoned
* resources.
*
* @author S. Koulouzis
*/
@Service
@RestController
@RequestMapping
(
"/user/v0.0/switch/deploy/"
)
@Component
@PreAuthorize
(
"isAuthenticated()"
)
public
class
ClusterCredentialService
{
public
class
DeployController0
{
@Autowired
private
ClusterCredentialsDao
dao
;
private
DeployClusterService
deployService
;
@PostAuthorize
(
"(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))"
)
public
ClusterCredentials
findOne
(
String
id
)
{
return
dao
.
findOne
(
id
);
@RequestMapping
(
value
=
"/kubernetes"
,
method
=
RequestMethod
.
POST
,
consumes
=
MediaType
.
TEXT_XML_VALUE
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
Result
deployKubernetes
(
@RequestBody
Deploy
deploy
)
{
return
deploy
(
deploy
,
"kubernetes"
);
}
@PostFilter
(
"(filterObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))"
)
public
List
<
ClusterCredentials
>
findAll
()
{
return
dao
.
findAll
();
@RequestMapping
(
value
=
"/swarm"
,
method
=
RequestMethod
.
POST
,
consumes
=
MediaType
.
TEXT_XML_VALUE
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
Result
deploySwarm
(
@RequestBody
Deploy
deploy
)
{
return
deploy
(
deploy
,
"swarm"
);
}
@PostAuthorize
(
"(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))"
)
public
ClusterCredentials
delete
(
String
id
)
{
ClusterCredentials
cred
=
dao
.
findOne
(
id
);
dao
.
delete
(
cred
);
return
cred
;
}
private
Result
deploy
(
Deploy
deploy
,
String
clusterType
)
{
String
provisionID
=
deploy
.
action
;
ClusterCredentials
clusterCred
=
deployService
.
deployCluster
(
provisionID
,
clusterType
);
public
ClusterCredentials
save
(
ClusterCredentials
clusterCred
)
{
User
user
=
(
User
)
SecurityContextHolder
.
getContext
().
getAuthentication
().
getPrincipal
();
String
owner
=
user
.
getUsername
();
clusterCred
.
setOwner
(
owner
);
return
dao
.
save
(
clusterCred
);
Result
res
=
new
Result
();
res
.
info
=
"INFO"
;
res
.
status
=
"Success"
;
List
<
File
>
files
=
new
ArrayList
<>();
File
e
=
new
File
();
e
.
content
=
clusterCred
.
getKey
();
files
.
add
(
e
);
res
.
file
=
files
;
return
res
;
}
}
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/api/v0/rest/ProvisionController0.java
View file @
0472a4af
...
...
@@ -79,27 +79,8 @@ public class ProvisionController0 {
@Autowired
private
PlannerService
planService
;
@RequestMapping
(
value
=
"/get"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
TEXT_XML_VALUE
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
Upload
provision
()
{
try
{
Upload
up
=
new
Upload
();
up
.
user
=
"user"
;
up
.
pwd
=
"123"
;
List
<
File
>
files
=
new
ArrayList
<>();
Plan
plan1
=
planService
.
findAll
().
get
(
0
);
File
f
=
Converter
.
plan1toFile
(
plan1
);
files
.
add
(
f
);
up
.
file
=
files
;
return
up
;
}
catch
(
JSONException
ex
)
{
Logger
.
getLogger
(
ProvisionController0
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
return
null
;
}
@RequestMapping
(
value
=
"/upload"
,
method
=
RequestMethod
.
POST
,
consumes
=
MediaType
.
TEXT_XML_VALUE
)
@RolesAllowed
({
UserService
.
USER
,
UserService
.
ADMIN
})
public
@ResponseBody
...
...
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/api/v1/rest/DeployController.java
View file @
0472a4af
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/commons/v0/types/Deploy.java
0 → 100644
View file @
0472a4af
/*
* 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
.
commons
.
v0
.
types
;
import
javax.xml.bind.annotation.XmlRootElement
;
/**
*
* @author S. Koulouzis
*/
@XmlRootElement
public
class
Deploy
extends
Execute
{
}
This diff is collapsed.
Click to expand it.
drip-api/src/main/java/nl/uva/sne/drip/commons/v1/types/ClusterCredentials.java
View file @
0472a4af
...
...
@@ -19,18 +19,18 @@ import com.webcohesion.enunciate.metadata.DocumentationExample;
import
org.springframework.data.annotation.Id
;
/**
This class represents the cluster credentials for a cloud. They can used to
* login to the cluster created by the deployer
*
* This class represents the cluster credentials for a cloud. They can used to
* login to the cluster created by the deployer
*
* @author S. Koulouzis
*/
public
class
ClusterCredentials
extends
OwnedObject
{
public
class
ClusterCredentials
extends
OwnedObject
{
@Id
private
String
id
;
private
String
key
;
public
String
getId
()
{
return
id
;
}
...
...
@@ -43,7 +43,8 @@ public class ClusterCredentials extends OwnedObject{
}
/**
* The key of the login key.
* The key of the login key.
*
* @return the key
*/
@DocumentationExample
(
"BEGINRSAPRIVATEKEY-----\\nMIIEogIBAAKCAQEAm6AALYxkJFNzD3fVJ4+hMY5j0/kqM9CURLKXMlYuAysnvoG8wZKx9Bedefm\\neNSse4zTg798ZA2kDMZFIrwp1AseTwtj8DDu5fhG5DjyI3g6iJltS5zFQdMXneDlHXBX8cncSzNY\\nR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Rmba8iQF1srN577mF+Z7ha4V\\nJ1duCTzvWF1KFX6sk/uhKQKBgAcDFai7rgNjJ8YcCRKxyFcMM9LKPl6hr4XFtWKzTAQPEABUkkuN\\n9gVClsg9f+VRKRECOIf0Ae1UWeCFEwxUXp4wjfHrzkTDVztKvmbWdvSXorDwKrZ7SC7tZpVFSfly\\nxuuLjadpUZT9YFmbAfY1X5oSccOMYqORjRbxEB3svb4BAoGAGTgFuq9Zojh/KIqY8b4HpEfmh6CQ\\nhLVfD98Nqd6GDbxgvIM0v4mFXE92x2jn35Ia0JdFyh3B8Vkl7sqQZfxDFXI9O9pte2mPJxY9ICaY\\n55+X/SN1pd53BH+gaPZJy/R+Vpvs5MN48howjUKy5UKpoFeUWrS5QArjtvNCm4SGlXw=\\n-----ENDRSAPRIVATEKEY-----\\n"
)
...
...
@@ -52,10 +53,10 @@ public class ClusterCredentials extends OwnedObject{
}
/**
* @param
contents
the key to set
* @param
key
the key to set
*/
public
void
set
Contents
(
String
contents
)
{
this
.
key
=
contents
;
public
void
set
Key
(
String
key
)
{
this
.
key
=
key
;
}
}
This diff is collapsed.
Click to expand it.
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