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
0662df0a
Commit
0662df0a
authored
Mar 17, 2020
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test only set operation
parent
6b86c1a2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
23 deletions
+34
-23
ToscaHelper.java
.../main/java/nl/uva/sne/drip/commons/utils/ToscaHelper.java
+2
-2
ProvisionerApiController.java
...in/java/nl/uva/sne/drip/api/ProvisionerApiController.java
+6
-1
DRIPService.java
...er/src/main/java/nl/uva/sne/drip/service/DRIPService.java
+16
-14
ServiceTests.java
...r/src/test/java/nl/uva/sne/drip/service/ServiceTests.java
+10
-6
No files found.
commons/src/main/java/nl/uva/sne/drip/commons/utils/ToscaHelper.java
View file @
0662df0a
...
@@ -267,8 +267,8 @@ public class ToscaHelper {
...
@@ -267,8 +267,8 @@ public class ToscaHelper {
}
}
public
NodeTemplateMap
setProvisionerInterfaceInVMTopology
(
NodeTemplateMap
vmTopologyMap
,
Map
<
String
,
Object
>
provisionerInterface
)
{
public
NodeTemplateMap
setProvisionerInterfaceInVMTopology
(
NodeTemplateMap
vmTopologyMap
,
Map
<
String
,
Object
>
provisionerInterface
)
{
System
.
err
.
println
(
provisionerInterface
);
vmTopologyMap
.
getNodeTemplate
().
setInterfaces
(
provisionerInterface
);
throw
new
UnsupportedOperationException
(
"Not supported yet."
);
//To change body of generated methods, choose Tools | Templates.
return
vmTopologyMap
;
}
}
public
String
getVMTopologyUser
()
throws
ApiException
{
public
String
getVMTopologyUser
()
throws
ApiException
{
...
...
manager/src/main/java/nl/uva/sne/drip/api/ProvisionerApiController.java
View file @
0662df0a
package
nl
.
uva
.
sne
.
drip
.
api
;
package
nl
.
uva
.
sne
.
drip
.
api
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
io.swagger.annotations.*
;
import
io.swagger.annotations.*
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -13,6 +14,7 @@ import org.springframework.stereotype.Controller;
...
@@ -13,6 +14,7 @@ import org.springframework.stereotype.Controller;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
nl.uva.sne.drip.model.Exceptions.MissingCredentialsException
;
import
nl.uva.sne.drip.model.Exceptions.MissingCredentialsException
;
import
nl.uva.sne.drip.model.Exceptions.MissingVMTopologyException
;
import
nl.uva.sne.drip.model.Exceptions.TypeExeption
;
import
nl.uva.sne.drip.model.Exceptions.TypeExeption
;
import
nl.uva.sne.drip.service.DRIPService
;
import
nl.uva.sne.drip.service.DRIPService
;
import
nl.uva.sne.drip.sure.tosca.client.ApiException
;
import
nl.uva.sne.drip.sure.tosca.client.ApiException
;
...
@@ -52,9 +54,12 @@ public class ProvisionerApiController implements ProvisionerApi {
...
@@ -52,9 +54,12 @@ public class ProvisionerApiController implements ProvisionerApi {
dripService
.
setRequestQeueName
(
queueName
);
dripService
.
setRequestQeueName
(
queueName
);
String
planedYemplateId
=
dripService
.
provision
(
id
);
String
planedYemplateId
=
dripService
.
provision
(
id
);
return
new
ResponseEntity
<>(
planedYemplateId
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
planedYemplateId
,
HttpStatus
.
OK
);
}
catch
(
ApiException
|
MissingCredentialsException
|
TypeExeption
|
IOException
|
TimeoutException
|
InterruptedException
|
NotFoundException
ex
)
{
}
catch
(
ApiException
|
TypeExeption
|
IOException
|
TimeoutException
|
InterruptedException
|
NotFoundException
ex
)
{
java
.
util
.
logging
.
Logger
.
getLogger
(
ProvisionerApiController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
java
.
util
.
logging
.
Logger
.
getLogger
(
ProvisionerApiController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
return
new
ResponseEntity
<>(
HttpStatus
.
INTERNAL_SERVER_ERROR
);
return
new
ResponseEntity
<>(
HttpStatus
.
INTERNAL_SERVER_ERROR
);
}
catch
(
MissingCredentialsException
|
MissingVMTopologyException
ex
)
{
java
.
util
.
logging
.
Logger
.
getLogger
(
ProvisionerApiController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
body
(
ex
.
getMessage
());
}
}
}
else
{
}
else
{
return
new
ResponseEntity
<>(
HttpStatus
.
NOT_ACCEPTABLE
);
return
new
ResponseEntity
<>(
HttpStatus
.
NOT_ACCEPTABLE
);
...
...
manager/src/main/java/nl/uva/sne/drip/service/DRIPService.java
View file @
0662df0a
...
@@ -95,10 +95,10 @@ public class DRIPService {
...
@@ -95,10 +95,10 @@ public class DRIPService {
return
credentials
.
get
(
0
);
return
credentials
.
get
(
0
);
}
}
pr
ivate
ToscaTemplate
addCredentials
(
ToscaTemplate
toscaTemplate
)
throws
MissingCredentialsException
,
ApiException
,
TypeExeption
,
MissingVMTopologyException
{
pr
otected
ToscaTemplate
addCredentials
(
ToscaTemplate
toscaTemplate
)
throws
MissingCredentialsException
,
ApiException
,
TypeExeption
,
MissingVMTopologyException
{
List
<
NodeTemplateMap
>
vmTopologies
=
helper
.
getVMTopologyTemplates
();
List
<
NodeTemplateMap
>
vmTopologies
=
helper
.
getVMTopologyTemplates
();
if
(
vmTopologies
==
null
)
{
if
(
vmTopologies
==
null
)
{
throw
new
MissingVMTopologyException
(
"ToscaTemplate: "
+
toscaTemplate
+
" has no VM topology"
);
throw
new
MissingVMTopologyException
(
"ToscaTemplate: "
+
toscaTemplate
+
" has no VM topology"
);
}
}
List
<
Credential
>
credentials
=
null
;
List
<
Credential
>
credentials
=
null
;
for
(
NodeTemplateMap
vmTopologyMap
:
vmTopologies
)
{
for
(
NodeTemplateMap
vmTopologyMap
:
vmTopologies
)
{
...
@@ -131,19 +131,21 @@ public class DRIPService {
...
@@ -131,19 +131,21 @@ public class DRIPService {
return
execute
(
toscaTemplate
);
return
execute
(
toscaTemplate
);
}
}
pr
ivate
ToscaTemplate
setProvisionerOperation
(
ToscaTemplate
toscaTemplate
,
PROVISIONER_OPERATION
operation
)
throws
IOException
,
JsonProcessingException
,
ApiException
{
pr
otected
ToscaTemplate
setProvisionerOperation
(
ToscaTemplate
toscaTemplate
,
PROVISIONER_OPERATION
operation
)
throws
IOException
,
JsonProcessingException
,
ApiException
{
List
<
NodeTemplateMap
>
vmTopologies
=
helper
.
getVMTopologyTemplates
();
List
<
NodeTemplateMap
>
vmTopologies
=
helper
.
getVMTopologyTemplates
();
for
(
NodeTemplateMap
vmTopologyMap
:
vmTopologies
)
{
for
(
NodeTemplateMap
vmTopologyMap
:
vmTopologies
)
{
Map
<
String
,
Object
>
provisionerInterface
=
helper
.
getProvisionerInterfaceFromVMTopology
(
vmTopologyMap
);
Map
<
String
,
Object
>
provisionerInterface
=
helper
.
getProvisionerInterfaceFromVMTopology
(
vmTopologyMap
);
// if (!provisionerInterface.containsKey(operation.toString().toLowerCase())) {
if
(
provisionerInterface
==
null
||
!
provisionerInterface
.
containsKey
(
operation
.
toString
().
toLowerCase
()))
{
// Map<String, Object> inputsMap = new HashMap<>();
provisionerInterface
=
new
HashMap
<>();
// inputsMap.put(operation.toString().toLowerCase(), caller);
Map
<
String
,
Object
>
inputsMap
=
new
HashMap
<>();
// Map<String, Object> provisionMap = new HashMap<>();
inputsMap
.
put
(
"code_type"
,
" SEQ"
);
// provisionMap.put("inputs", inputsMap);
inputsMap
.
put
(
"object_type"
,
" SubTopology"
);
// provisionerInterface.put(operation.toString().toLowerCase(), caller);
Map
<
String
,
Object
>
provisionMap
=
new
HashMap
<>();
// vmTopologyMap = helper.setProvisionerInterfaceInVMTopology(vmTopologyMap, provisionerInterface);
provisionMap
.
put
(
"inputs"
,
inputsMap
);
// toscaTemplate = helper.setNodeInToscaTemplate(toscaTemplate, vmTopologyMap);
provisionerInterface
.
put
(
operation
.
toString
().
toLowerCase
(),
provisionMap
);
// }
vmTopologyMap
=
helper
.
setProvisionerInterfaceInVMTopology
(
vmTopologyMap
,
provisionerInterface
);
toscaTemplate
=
helper
.
setNodeInToscaTemplate
(
toscaTemplate
,
vmTopologyMap
);
}
}
}
return
toscaTemplate
;
return
toscaTemplate
;
}
}
...
@@ -162,7 +164,7 @@ public class DRIPService {
...
@@ -162,7 +164,7 @@ public class DRIPService {
return
execute
(
toscaTemplate
);
return
execute
(
toscaTemplate
);
}
}
pr
ivate
ToscaTemplate
initExecution
(
String
id
)
throws
JsonProcessingException
,
NotFoundException
,
IOException
,
ApiException
{
pr
otected
ToscaTemplate
initExecution
(
String
id
)
throws
JsonProcessingException
,
NotFoundException
,
IOException
,
ApiException
{
String
ymlToscaTemplate
=
toscaTemplateService
.
findByID
(
id
);
String
ymlToscaTemplate
=
toscaTemplateService
.
findByID
(
id
);
Logger
.
getLogger
(
DRIPService
.
class
.
getName
()).
log
(
Level
.
FINE
,
"Found ToscaTemplate with id: {0}"
,
id
);
Logger
.
getLogger
(
DRIPService
.
class
.
getName
()).
log
(
Level
.
FINE
,
"Found ToscaTemplate with id: {0}"
,
id
);
ToscaTemplate
toscaTemplate
=
toscaTemplateService
.
getYaml2ToscaTemplate
(
ymlToscaTemplate
);
ToscaTemplate
toscaTemplate
=
toscaTemplateService
.
getYaml2ToscaTemplate
(
ymlToscaTemplate
);
...
...
manager/src/test/java/nl/uva/sne/drip/service/ServiceTests.java
View file @
0662df0a
...
@@ -45,6 +45,7 @@ import nl.uva.sne.drip.model.Exceptions.MissingCredentialsException;
...
@@ -45,6 +45,7 @@ import nl.uva.sne.drip.model.Exceptions.MissingCredentialsException;
import
nl.uva.sne.drip.model.Exceptions.MissingVMTopologyException
;
import
nl.uva.sne.drip.model.Exceptions.MissingVMTopologyException
;
import
nl.uva.sne.drip.model.Exceptions.TypeExeption
;
import
nl.uva.sne.drip.model.Exceptions.TypeExeption
;
import
nl.uva.sne.drip.model.tosca.Credential
;
import
nl.uva.sne.drip.model.tosca.Credential
;
import
nl.uva.sne.drip.model.tosca.ToscaTemplate
;
import
nl.uva.sne.drip.sure.tosca.client.ApiException
;
import
nl.uva.sne.drip.sure.tosca.client.ApiException
;
import
org.junit.Assert
;
import
org.junit.Assert
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
...
@@ -82,6 +83,7 @@ public class ServiceTests {
...
@@ -82,6 +83,7 @@ public class ServiceTests {
private
String
toscaTemplateID
;
private
String
toscaTemplateID
;
private
String
testApplicationExampleToscaContents
;
private
String
testApplicationExampleToscaContents
;
private
static
final
String
testApplicationExampleToscaFilePath
=
".."
+
File
.
separator
+
"TOSCA"
+
File
.
separator
+
"application_example_updated.yaml"
;
private
static
final
String
testApplicationExampleToscaFilePath
=
".."
+
File
.
separator
+
"TOSCA"
+
File
.
separator
+
"application_example_updated.yaml"
;
private
static
final
String
testApplicationExamplePlanedToscaFilePath
=
".."
+
File
.
separator
+
"TOSCA"
+
File
.
separator
+
"application_example_planed.yaml"
;
private
static
final
String
testUpdatedApplicationExampleToscaFilePath
=
".."
+
File
.
separator
+
"TOSCA"
+
File
.
separator
+
"application_example_updated.yaml"
;
private
static
final
String
testUpdatedApplicationExampleToscaFilePath
=
".."
+
File
.
separator
+
"TOSCA"
+
File
.
separator
+
"application_example_updated.yaml"
;
private
static
final
String
testCredentialPath
=
".."
+
File
.
separator
+
"fake_credentials"
+
File
.
separator
+
"test-geni.jks"
;
private
static
final
String
testCredentialPath
=
".."
+
File
.
separator
+
"fake_credentials"
+
File
.
separator
+
"test-geni.jks"
;
...
@@ -388,10 +390,10 @@ public class ServiceTests {
...
@@ -388,10 +390,10 @@ public class ServiceTests {
}
}
@Test
@Test
public
void
test
Provision
()
throws
FileNotFoundException
,
IOException
,
MissingCredentialsException
,
ApiException
,
TypeExeption
,
JsonProcessingException
,
TimeoutException
,
InterruptedException
,
NotFound
Exception
{
public
void
test
SetProvisionerOperation
()
throws
FileNotFoundException
,
IOException
,
MissingCredentialsException
,
ApiException
,
TypeExeption
,
JsonProcessingException
,
TimeoutException
,
InterruptedException
,
NotFoundException
,
MissingVMTopology
Exception
{
if
(
ToscaHelper
.
isServiceUp
(
sureToscaBasePath
)
&&
ToscaHelper
.
isServiceUp
(
"http://"
+
messageBrokerHost
+
":15672"
))
{
if
(
ToscaHelper
.
isServiceUp
(
sureToscaBasePath
)
&&
ToscaHelper
.
isServiceUp
(
"http://"
+
messageBrokerHost
+
":15672"
))
{
Credential
document
=
new
Credential
();
Credential
document
=
new
Credential
();
document
.
setCloudProviderName
(
"
exogeni
"
);
document
.
setCloudProviderName
(
"
ExoGENI
"
);
Map
<
String
,
String
>
keys
=
new
HashMap
<>();
Map
<
String
,
String
>
keys
=
new
HashMap
<>();
keys
.
put
(
"keystore"
,
"/qTlqams0Ppq2rnaOgL5am7ExGO2nMsOZYM61kiAnsvkOixUuoPy9r4d4OfhwQXXg3lZmeRITjNz4ps+hIDKuxodIQXgBtfMy9Kx8Syb9bIl/MQQls5hWyp9yHAl6vAampoxYu0170lceT1sds4OCz3tM9eF7/UoBQwXBPo94QhO1/vSbtICyVsm3Z2HeGKcBWobT3opZV2w30GqX/7OBmNeIG7RBMPuxLsUxJ9Alahi1zXOUjLkd2bmmVFREngmeubgCzPFxxCQQrZK6WratTzJKc1sRVNK5GJzTwi9BlcZSQSgprum9yVHUgQc6Ylmvdrkhn2g9SlluY2JAZyCZvHYaRBKE4o5bXBDumTy1YAPMNPTfpeeLz+YmH0GMfVwKkxtIBpjb045QseoIWcqxke60WWfJguaTqymXknmcqcLNz+UzUdfVfyurOy9X8xmTGCW5V4N"
);
keys
.
put
(
"keystore"
,
"/qTlqams0Ppq2rnaOgL5am7ExGO2nMsOZYM61kiAnsvkOixUuoPy9r4d4OfhwQXXg3lZmeRITjNz4ps+hIDKuxodIQXgBtfMy9Kx8Syb9bIl/MQQls5hWyp9yHAl6vAampoxYu0170lceT1sds4OCz3tM9eF7/UoBQwXBPo94QhO1/vSbtICyVsm3Z2HeGKcBWobT3opZV2w30GqX/7OBmNeIG7RBMPuxLsUxJ9Alahi1zXOUjLkd2bmmVFREngmeubgCzPFxxCQQrZK6WratTzJKc1sRVNK5GJzTwi9BlcZSQSgprum9yVHUgQc6Ylmvdrkhn2g9SlluY2JAZyCZvHYaRBKE4o5bXBDumTy1YAPMNPTfpeeLz+YmH0GMfVwKkxtIBpjb045QseoIWcqxke60WWfJguaTqymXknmcqcLNz+UzUdfVfyurOy9X8xmTGCW5V4N"
);
document
.
setKeys
(
keys
);
document
.
setKeys
(
keys
);
...
@@ -401,13 +403,15 @@ public class ServiceTests {
...
@@ -401,13 +403,15 @@ public class ServiceTests {
String
credentialID
=
credentialService
.
save
(
document
);
String
credentialID
=
credentialService
.
save
(
document
);
assertNotNull
(
credentialID
);
assertNotNull
(
credentialID
);
FileInputStream
in
=
new
FileInputStream
(
testApplicationExampleToscaFilePath
);
FileInputStream
in
=
new
FileInputStream
(
testApplicationExample
Planed
ToscaFilePath
);
MultipartFile
file
=
new
MockMultipartFile
(
"file"
,
in
);
MultipartFile
file
=
new
MockMultipartFile
(
"file"
,
in
);
toscaTemplateID
=
toscaTemplateService
.
saveFile
(
file
);
String
id
=
toscaTemplateService
.
saveFile
(
file
);
// dripService.setRequestQeueName(provisionerQueueName);
dripService
.
setRequestQeueName
(
provisionerQueueName
);
// String planedYemplateId = dripService.provision(toscaTemplateID);
ToscaTemplate
toscaTemplate
=
dripService
.
initExecution
(
id
);
toscaTemplate
=
dripService
.
addCredentials
(
toscaTemplate
);
toscaTemplate
=
dripService
.
setProvisionerOperation
(
toscaTemplate
,
DRIPService
.
PROVISIONER_OPERATION
.
PROVISION
);
}
}
}
}
}
}
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