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
a7d5e9ad
Commit
a7d5e9ad
authored
Apr 03, 2017
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented configure id for deploy to map to ansible playbook
parent
a4b4b101
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
32 deletions
+63
-32
DeployClusterService.java
...ava/nl/uva/sne/drip/api/service/DeployClusterService.java
+63
-30
ProvisionController.java
...java/nl/uva/sne/drip/api/v1/rest/ProvisionController.java
+0
-2
No files found.
drip-api/src/main/java/nl/uva/sne/drip/api/service/DeployClusterService.java
View file @
a7d5e9ad
...
...
@@ -48,6 +48,8 @@ import org.springframework.security.core.context.SecurityContextHolder;
import
org.springframework.stereotype.Service
;
import
nl.uva.sne.drip.api.dao.DeployDao
;
import
nl.uva.sne.drip.api.dao.KeyDao
;
import
nl.uva.sne.drip.commons.utils.Converter
;
import
nl.uva.sne.drip.commons.v1.types.PlaybookRepresentation
;
/**
*
...
...
@@ -72,6 +74,9 @@ public class DeployClusterService {
@Autowired
private
ProvisionService
provisionService
;
@Autowired
private
PlaybookService
playbookService
;
@PostAuthorize
(
"(returnObject.owner == authentication.name) or (hasRole('ROLE_ADMIN'))"
)
public
DeployResponse
findOne
(
String
id
)
{
DeployResponse
creds
=
deployDao
.
findOne
(
id
);
...
...
@@ -105,7 +110,10 @@ public class DeployClusterService {
public
DeployResponse
deployCluster
(
DeployRequest
deployInfo
)
{
try
(
DRIPCaller
deployer
=
new
DeployerCaller
(
messageBrokerHost
);)
{
Message
deployerInvokationMessage
=
buildDeployerMessage
(
deployInfo
.
getProvisionID
(),
deployInfo
.
getClusterType
().
toLowerCase
(),
deployInfo
.
getConfigurationID
());
Message
deployerInvokationMessage
=
buildDeployerMessage
(
deployInfo
.
getProvisionID
(),
deployInfo
.
getClusterType
().
toLowerCase
(),
deployInfo
.
getConfigurationID
());
// Message deployerInvokationMessage = MessageGenerator.generateArtificialMessage(System.getProperty("user.home")
// + File.separator + "workspace" + File.separator + "DRIP"
...
...
@@ -133,7 +141,7 @@ public class DeployClusterService {
return
null
;
}
private
Message
buildDeployerMessage
(
String
provisionID
,
String
managerType
,
String
configurationID
)
{
private
Message
buildDeployerMessage
(
String
provisionID
,
String
managerType
,
String
configurationID
)
throws
JSONException
{
ProvisionResponse
pro
=
provisionService
.
findOne
(
provisionID
);
if
(
pro
==
null
)
{
throw
new
NotFoundException
();
...
...
@@ -148,39 +156,22 @@ public class DeployClusterService {
}
List
<
DeployParameter
>
deployParams
=
pro
.
getDeployParameters
();
List
<
MessageParameter
>
parameters
=
new
ArrayList
<>();
for
(
DeployParameter
dp
:
deployParams
)
{
String
cName
=
dp
.
getCloudCertificateName
();
MessageParameter
messageParameter
=
new
MessageParameter
();
messageParameter
.
setName
(
"credential"
);
messageParameter
.
setEncoding
(
"UTF-8"
);
String
key
=
null
;
for
(
Key
lk
:
loginKeys
)
{
String
lkName
=
lk
.
getName
();
if
(
lkName
==
null
)
{
lkName
=
lk
.
getAttributes
().
get
(
"domain_name"
);
}
if
(
lkName
.
equals
(
cName
))
{
key
=
lk
.
getKey
();
break
;
}
}
messageParameter
.
setValue
(
key
);
Map
<
String
,
String
>
attributes
=
new
HashMap
<>();
attributes
.
put
(
"IP"
,
dp
.
getIP
());
attributes
.
put
(
"role"
,
dp
.
getRole
());
attributes
.
put
(
"user"
,
dp
.
getUser
());
messageParameter
.
setAttributes
(
attributes
);
MessageParameter
messageParameter
=
createCredentialPartameter
(
dp
,
loginKeys
);
parameters
.
add
(
messageParameter
);
}
MessageParameter
clusterTypeParameter
=
new
MessageParameter
();
clusterTypeParameter
.
setName
(
"cluster"
);
clusterTypeParameter
.
setEncoding
(
"UTF-8"
);
clusterTypeParameter
.
setValue
(
managerType
);
parameters
.
add
(
clusterTypeParameter
);
Message
deployInvokationMessage
=
new
Message
();
MessageParameter
managerTypeParameter
=
createManagerTypeParameter
(
managerType
);
parameters
.
add
(
managerTypeParameter
);
if
(
managerType
.
toLowerCase
().
equals
(
"ansible"
)
&&
configurationID
!=
null
)
{
MessageParameter
ansibleParameter
=
createAnsibleParameter
(
configurationID
);
parameters
.
add
(
ansibleParameter
);
}
Message
deployInvokationMessage
=
new
Message
();
deployInvokationMessage
.
setParameters
(
parameters
);
deployInvokationMessage
.
setCreationDate
(
System
.
currentTimeMillis
());
return
deployInvokationMessage
;
...
...
@@ -225,4 +216,46 @@ public class DeployClusterService {
public
void
deleteAll
()
{
deployDao
.
deleteAll
();
}
private
MessageParameter
createCredentialPartameter
(
DeployParameter
dp
,
List
<
Key
>
loginKeys
)
{
String
cName
=
dp
.
getCloudCertificateName
();
MessageParameter
messageParameter
=
new
MessageParameter
();
messageParameter
.
setName
(
"credential"
);
messageParameter
.
setEncoding
(
"UTF-8"
);
String
key
=
null
;
for
(
Key
lk
:
loginKeys
)
{
String
lkName
=
lk
.
getName
();
if
(
lkName
==
null
)
{
lkName
=
lk
.
getAttributes
().
get
(
"domain_name"
);
}
if
(
lkName
.
equals
(
cName
))
{
key
=
lk
.
getKey
();
break
;
}
}
messageParameter
.
setValue
(
key
);
Map
<
String
,
String
>
attributes
=
new
HashMap
<>();
attributes
.
put
(
"IP"
,
dp
.
getIP
());
attributes
.
put
(
"role"
,
dp
.
getRole
());
attributes
.
put
(
"user"
,
dp
.
getUser
());
messageParameter
.
setAttributes
(
attributes
);
return
messageParameter
;
}
private
MessageParameter
createManagerTypeParameter
(
String
managerType
)
{
MessageParameter
managerTypeParameter
=
new
MessageParameter
();
managerTypeParameter
.
setName
(
"cluster"
);
managerTypeParameter
.
setEncoding
(
"UTF-8"
);
managerTypeParameter
.
setValue
(
managerType
);
return
managerTypeParameter
;
}
private
MessageParameter
createAnsibleParameter
(
String
configurationID
)
throws
JSONException
{
PlaybookRepresentation
playbook
=
playbookService
.
findOne
(
configurationID
);
MessageParameter
ansibleParameter
=
new
MessageParameter
();
ansibleParameter
.
setName
(
"playbook"
);
ansibleParameter
.
setEncoding
(
"UTF-8"
);
ansibleParameter
.
setValue
(
Converter
.
map2YmlString
(
playbook
.
getKeyValue
()));
return
ansibleParameter
;
}
}
drip-api/src/main/java/nl/uva/sne/drip/api/v1/rest/ProvisionController.java
View file @
a7d5e9ad
...
...
@@ -35,8 +35,6 @@ import nl.uva.sne.drip.api.service.CloudCredentialsService;
import
nl.uva.sne.drip.api.service.PlannerService
;
import
nl.uva.sne.drip.api.service.ProvisionService
;
import
nl.uva.sne.drip.api.service.UserService
;
import
nl.uva.sne.drip.commons.v1.types.CloudCredentials
;
import
nl.uva.sne.drip.commons.v1.types.PlanResponse
;
import
nl.uva.sne.drip.commons.v1.types.ProvisionResponse
;
import
org.json.JSONException
;
import
org.springframework.web.bind.annotation.PathVariable
;
...
...
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