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
6b86c1a2
Commit
6b86c1a2
authored
Mar 17, 2020
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added MissingVMTopologyException
parent
2a282261
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
263 additions
and
253 deletions
+263
-253
.travis.yml
.travis.yml
+1
-1
DRIPService.java
...er/src/main/java/nl/uva/sne/drip/service/DRIPService.java
+12
-6
ServiceTests.java
...r/src/test/java/nl/uva/sne/drip/service/ServiceTests.java
+245
-243
tosca_template_service.py
...flask-server/sure_tosca/service/tosca_template_service.py
+5
-3
No files found.
.travis.yml
View file @
6b86c1a2
...
@@ -12,7 +12,7 @@ matrix:
...
@@ -12,7 +12,7 @@ matrix:
-
python -m unittest discover
-
python -m unittest discover
-
docker build -t alogo53/planner:3.0.0 .
-
docker build -t alogo53/planner:3.0.0 .
-
language
:
python
-
language
:
python
python
:
3.
8
python
:
3.
7
before_script
:
before_script
:
-
cd sure_tosca-flask-server
-
cd sure_tosca-flask-server
-
pip install -r requirements.txt
-
pip install -r requirements.txt
...
...
manager/src/main/java/nl/uva/sne/drip/service/DRIPService.java
View file @
6b86c1a2
...
@@ -16,6 +16,7 @@ import java.util.logging.Logger;
...
@@ -16,6 +16,7 @@ import java.util.logging.Logger;
import
nl.uva.sne.drip.api.NotFoundException
;
import
nl.uva.sne.drip.api.NotFoundException
;
import
nl.uva.sne.drip.commons.utils.ToscaHelper
;
import
nl.uva.sne.drip.commons.utils.ToscaHelper
;
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.model.Message
;
import
nl.uva.sne.drip.model.Message
;
import
nl.uva.sne.drip.model.NodeTemplateMap
;
import
nl.uva.sne.drip.model.NodeTemplateMap
;
...
@@ -94,8 +95,11 @@ public class DRIPService {
...
@@ -94,8 +95,11 @@ public class DRIPService {
return
credentials
.
get
(
0
);
return
credentials
.
get
(
0
);
}
}
private
ToscaTemplate
addCredentials
(
ToscaTemplate
toscaTemplate
)
throws
MissingCredentialsException
,
ApiException
,
TypeExeption
{
private
ToscaTemplate
addCredentials
(
ToscaTemplate
toscaTemplate
)
throws
MissingCredentialsException
,
ApiException
,
TypeExeption
,
MissingVMTopologyException
{
List
<
NodeTemplateMap
>
vmTopologies
=
helper
.
getVMTopologyTemplates
();
List
<
NodeTemplateMap
>
vmTopologies
=
helper
.
getVMTopologyTemplates
();
if
(
vmTopologies
==
null
){
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
)
{
String
provider
=
helper
.
getTopologyProvider
(
vmTopologyMap
);
String
provider
=
helper
.
getTopologyProvider
(
vmTopologyMap
);
...
@@ -120,7 +124,7 @@ public class DRIPService {
...
@@ -120,7 +124,7 @@ public class DRIPService {
return
execute
(
toscaTemplate
);
return
execute
(
toscaTemplate
);
}
}
public
String
provision
(
String
id
)
throws
MissingCredentialsException
,
ApiException
,
TypeExeption
,
IOException
,
JsonProcessingException
,
TimeoutException
,
InterruptedException
,
NotFoundException
{
public
String
provision
(
String
id
)
throws
MissingCredentialsException
,
ApiException
,
TypeExeption
,
IOException
,
JsonProcessingException
,
TimeoutException
,
InterruptedException
,
NotFoundException
,
MissingVMTopologyException
{
ToscaTemplate
toscaTemplate
=
initExecution
(
id
);
ToscaTemplate
toscaTemplate
=
initExecution
(
id
);
toscaTemplate
=
addCredentials
(
toscaTemplate
);
toscaTemplate
=
addCredentials
(
toscaTemplate
);
toscaTemplate
=
setProvisionerOperation
(
toscaTemplate
,
PROVISIONER_OPERATION
.
PROVISION
);
toscaTemplate
=
setProvisionerOperation
(
toscaTemplate
,
PROVISIONER_OPERATION
.
PROVISION
);
...
@@ -169,12 +173,14 @@ public class DRIPService {
...
@@ -169,12 +173,14 @@ public class DRIPService {
void
deleteActions
(
ToscaTemplate
toscaTemplate
)
throws
ApiException
,
TypeExeption
,
IOException
{
void
deleteActions
(
ToscaTemplate
toscaTemplate
)
throws
ApiException
,
TypeExeption
,
IOException
{
helper
.
uploadToscaTemplate
(
toscaTemplate
);
helper
.
uploadToscaTemplate
(
toscaTemplate
);
List
<
NodeTemplateMap
>
vmTopologies
=
helper
.
getVMTopologyTemplates
();
List
<
NodeTemplateMap
>
vmTopologies
=
helper
.
getVMTopologyTemplates
();
for
(
NodeTemplateMap
vmTopology
:
vmTopologies
)
{
if
(
vmTopologies
!=
null
)
{
CloudsStormSubTopology
.
StatusEnum
status
=
helper
.
getVMTopologyTemplateStatus
(
vmTopology
);
for
(
NodeTemplateMap
vmTopology
:
vmTopologies
)
{
if
(!
status
.
equals
(
CloudsStormSubTopology
.
StatusEnum
.
DELETED
))
{
CloudsStormSubTopology
.
StatusEnum
status
=
helper
.
getVMTopologyTemplateStatus
(
vmTopology
);
if
(!
status
.
equals
(
CloudsStormSubTopology
.
StatusEnum
.
DELETED
))
{
Logger
.
getLogger
(
ToscaHelper
.
class
.
getName
()).
log
(
Level
.
FINE
,
"Deleting VMs from "
+
vmTopology
);
}
}
}
}
}
}
}
...
...
manager/src/test/java/nl/uva/sne/drip/service/ServiceTests.java
View file @
6b86c1a2
...
@@ -42,6 +42,7 @@ import nl.uva.sne.drip.commons.utils.Converter;
...
@@ -42,6 +42,7 @@ import nl.uva.sne.drip.commons.utils.Converter;
import
nl.uva.sne.drip.commons.utils.ToscaHelper
;
import
nl.uva.sne.drip.commons.utils.ToscaHelper
;
import
nl.uva.sne.drip.configuration.MongoConfig
;
import
nl.uva.sne.drip.configuration.MongoConfig
;
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.model.tosca.Credential
;
import
nl.uva.sne.drip.model.tosca.Credential
;
import
nl.uva.sne.drip.sure.tosca.client.ApiException
;
import
nl.uva.sne.drip.sure.tosca.client.ApiException
;
...
@@ -139,96 +140,97 @@ public class ServiceTests {
...
@@ -139,96 +140,97 @@ public class ServiceTests {
Assert
.
assertTrue
(
true
);
Assert
.
assertTrue
(
true
);
}
}
// /**
/**
// * Test of saveFile method, of class ToscaTemplateService.
* Test of saveFile method, of class ToscaTemplateService.
// *
*
// * @throws java.lang.Exception
* @throws java.lang.Exception
// */
*/
// @Test
@Test
// public void testToscaTemplateServiceSaveFile() throws Exception {
public
void
testToscaTemplateServiceSaveFile
()
throws
Exception
{
// Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "saveFile");
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
INFO
,
"saveFile"
);
// FileInputStream in = new FileInputStream(testApplicationExampleToscaFilePath);
FileInputStream
in
=
new
FileInputStream
(
testApplicationExampleToscaFilePath
);
// MultipartFile file = new MockMultipartFile("file", in);
MultipartFile
file
=
new
MockMultipartFile
(
"file"
,
in
);
// toscaTemplateID = toscaTemplateService.saveFile(file);
toscaTemplateID
=
toscaTemplateService
.
saveFile
(
file
);
// Assert.assertNotNull(toscaTemplateID);
Assert
.
assertNotNull
(
toscaTemplateID
);
// testApplicationExampleToscaContents = toscaTemplateService.findByID(toscaTemplateID);
testApplicationExampleToscaContents
=
toscaTemplateService
.
findByID
(
toscaTemplateID
);
// Assert.assertNotNull(testApplicationExampleToscaContents);
Assert
.
assertNotNull
(
testApplicationExampleToscaContents
);
// }
}
//
// /**
/**
// * Test of updateToscaTemplateByID method, of class ToscaTemplateService.
* Test of updateToscaTemplateByID method, of class ToscaTemplateService.
// */
*/
// @Test
@Test
// public void testToscaTemplateServiceUpdateToscaTemplateByID_String_MultipartFile() {
public
void
testToscaTemplateServiceUpdateToscaTemplateByID_String_MultipartFile
()
{
// FileInputStream in = null;
FileInputStream
in
=
null
;
// try {
try
{
// Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "updateToscaTemplateByID");
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
INFO
,
"updateToscaTemplateByID"
);
// if (toscaTemplateID == null) {
if
(
toscaTemplateID
==
null
)
{
// testToscaTemplateServiceSaveFile();
testToscaTemplateServiceSaveFile
();
// }
}
// in = new FileInputStream(testUpdatedApplicationExampleToscaFilePath);
in
=
new
FileInputStream
(
testUpdatedApplicationExampleToscaFilePath
);
// MultipartFile file = new MockMultipartFile("file", in);
MultipartFile
file
=
new
MockMultipartFile
(
"file"
,
in
);
// String expResult = toscaTemplateID;
String
expResult
=
toscaTemplateID
;
// String result = toscaTemplateService.updateToscaTemplateByID(toscaTemplateID, file);
String
result
=
toscaTemplateService
.
updateToscaTemplateByID
(
toscaTemplateID
,
file
);
// assertEquals(expResult, result);
assertEquals
(
expResult
,
result
);
// String updatedTemplate = toscaTemplateService.findByID(result);
String
updatedTemplate
=
toscaTemplateService
.
findByID
(
result
);
// Assert.assertNotNull(updatedTemplate);
Assert
.
assertNotNull
(
updatedTemplate
);
// Assert.assertNotEquals(result, testApplicationExampleToscaContents);
Assert
.
assertNotEquals
(
result
,
testApplicationExampleToscaContents
);
// } catch (FileNotFoundException ex) {
}
catch
(
FileNotFoundException
ex
)
{
// Logger.getLogger(ServiceTests.class.getName()).log(Level.SEVERE, null, ex);
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
// } catch (Exception ex) {
}
catch
(
Exception
ex
)
{
// Logger.getLogger(ServiceTests.class.getName()).log(Level.SEVERE, null, ex);
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
// } finally {
}
finally
{
// try {
try
{
// if (in != null) {
if
(
in
!=
null
)
{
// in.close();
in
.
close
();
// }
}
// } catch (IOException ex) {
}
catch
(
IOException
ex
)
{
// fail(ex.getMessage());
fail
(
ex
.
getMessage
());
// Logger.getLogger(ServiceTests.class.getName()).log(Level.SEVERE, null, ex);
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
// }
}
// }
}
// }
}
//
// /**
/**
// * Test of updateToscaTemplateByID method, of class ToscaTemplateService.
* Test of updateToscaTemplateByID method, of class ToscaTemplateService.
// *
*
// * @throws java.io.FileNotFoundException
* @throws java.io.FileNotFoundException
// */
*/
// @Test
@Test
// public void testToscaTemplateServiceUpdateToscaTemplateByID_Exception_MultipartFile() throws FileNotFoundException, IOException {
public
void
testToscaTemplateServiceUpdateToscaTemplateByID_Exception_MultipartFile
()
throws
FileNotFoundException
,
IOException
{
// FileInputStream in = new FileInputStream(testUpdatedApplicationExampleToscaFilePath);
FileInputStream
in
=
new
FileInputStream
(
testUpdatedApplicationExampleToscaFilePath
);
// MultipartFile file = new MockMultipartFile("file", in);
MultipartFile
file
=
new
MockMultipartFile
(
"file"
,
in
);
// try {
try
{
// toscaTemplateService.updateToscaTemplateByID("0", file);
toscaTemplateService
.
updateToscaTemplateByID
(
"0"
,
file
);
// } catch (Exception ex) {
}
catch
(
Exception
ex
)
{
// if (!(ex instanceof NoSuchElementException)) {
if
(!(
ex
instanceof
NoSuchElementException
))
{
// fail(ex.getMessage());
fail
(
ex
.
getMessage
());
// }
}
// }
}
// }
}
//
// /**
/**
// * Test of findByID method, of class ToscaTemplateService.
* Test of findByID method, of class ToscaTemplateService.
// */
*/
// @Test
@Test
// public void testToscaTemplateServiceFindByID() {
public
void
testToscaTemplateServiceFindByID
()
{
// try {
try
{
// Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "findByID");
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
INFO
,
"findByID"
);
// if (toscaTemplateID == null) {
if
(
toscaTemplateID
==
null
)
{
// testToscaTemplateServiceSaveFile();
testToscaTemplateServiceSaveFile
();
// }
}
// String result = toscaTemplateService.findByID(toscaTemplateID);
String
result
=
toscaTemplateService
.
findByID
(
toscaTemplateID
);
// Assert.assertNotNull(result);
Assert
.
assertNotNull
(
result
);
// assertEquals(testApplicationExampleToscaContents, result);
assertEquals
(
testApplicationExampleToscaContents
,
result
);
// } catch (JsonProcessingException ex) {
}
catch
(
JsonProcessingException
ex
)
{
// fail(ex.getMessage());
fail
(
ex
.
getMessage
());
// Logger.getLogger(ServiceTests.class.getName()).log(Level.SEVERE, null, ex);
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
// } catch (Exception ex) {
}
catch
(
Exception
ex
)
{
// fail(ex.getMessage());
fail
(
ex
.
getMessage
());
// Logger.getLogger(ServiceTests.class.getName()).log(Level.SEVERE, null, ex);
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
// }
}
// }
}
/**
/**
* Test of deleteByID method, of class ToscaTemplateService.
* Test of deleteByID method, of class ToscaTemplateService.
*/
*/
...
@@ -255,157 +257,157 @@ public class ServiceTests {
...
@@ -255,157 +257,157 @@ public class ServiceTests {
}
}
////
/**
/**
////
* Test of getAllIds method, of class ToscaTemplateService.
* Test of getAllIds method, of class ToscaTemplateService.
////
*
*
////
* @throws java.lang.Exception
* @throws java.lang.Exception
////
*/
*/
////
@Test
@Test
////
public void testToscaTemplateServiceGetAllIds() throws Exception {
public
void
testToscaTemplateServiceGetAllIds
()
throws
Exception
{
////
Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "getAllIds");
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
INFO
,
"getAllIds"
);
////
testToscaTemplateServiceDeleteAll();
testToscaTemplateServiceDeleteAll
();
////
int numOfINst = 3;
int
numOfINst
=
3
;
////
for (int i = 1; i <= numOfINst; i++) {
for
(
int
i
=
1
;
i
<=
numOfINst
;
i
++)
{
////
testToscaTemplateServiceSaveFile();
testToscaTemplateServiceSaveFile
();
////
}
}
////
List<String> result = toscaTemplateService.getAllIds();
List
<
String
>
result
=
toscaTemplateService
.
getAllIds
();
////
assertEquals(numOfINst, result.size());
assertEquals
(
numOfINst
,
result
.
size
());
////
}
}
////
////
@Test
@Test
////
public void testToscaTemplateServiceDeleteAll() {
public
void
testToscaTemplateServiceDeleteAll
()
{
////
toscaTemplateService.deleteAll();
toscaTemplateService
.
deleteAll
();
////
int size = toscaTemplateService.getAllIds().size();
int
size
=
toscaTemplateService
.
getAllIds
().
size
();
////
assertEquals(0, size);
assertEquals
(
0
,
size
);
////
}
}
////
////
/**
/**
////
* Test of save method, of class CredentialService.
* Test of save method, of class CredentialService.
////
*/
*/
////
@Test
@Test
////
public void testCredentialServiceSave() {
public
void
testCredentialServiceSave
()
{
////
Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "save");
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
INFO
,
"save"
);
////
saveCredential();
saveCredential
();
////
}
}
////
////
@Test
@Test
////
public void testCredentialService() throws IOException, NoSuchAlgorithmException {
public
void
testCredentialService
()
throws
IOException
,
NoSuchAlgorithmException
{
////
Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "testCredentialService");
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
INFO
,
"testCredentialService"
);
////
String keyStoreEncoded = Converter.encodeFileToBase64Binary(testCredentialPath);
String
keyStoreEncoded
=
Converter
.
encodeFileToBase64Binary
(
testCredentialPath
);
////
////
Credential credential = new Credential();
Credential
credential
=
new
Credential
();
////
credential.setCloudProviderName("ExoGENI");
credential
.
setCloudProviderName
(
"ExoGENI"
);
////
Map<String, String> keys = new HashMap<>();
Map
<
String
,
String
>
keys
=
new
HashMap
<>();
////
keys.put("keystore", keyStoreEncoded);
keys
.
put
(
"keystore"
,
keyStoreEncoded
);
////
credential.setKeys(keys);
credential
.
setKeys
(
keys
);
////
credential.setToken("1234");
credential
.
setToken
(
"1234"
);
////
credential.setTokenType("password");
credential
.
setTokenType
(
"password"
);
////
credential.setUser("user");
credential
.
setUser
(
"user"
);
////
////
String keyStoreEncodedFromCredential = credential.getKeys().get("keystore");
String
keyStoreEncodedFromCredential
=
credential
.
getKeys
().
get
(
"keystore"
);
////
assertEquals(keyStoreEncoded, keyStoreEncodedFromCredential);
assertEquals
(
keyStoreEncoded
,
keyStoreEncodedFromCredential
);
////
////
String copyTestCredentialPath = ".." + File.separator + "fake_credentials" + File.separator + "copy_of_test-geni.jks";
String
copyTestCredentialPath
=
".."
+
File
.
separator
+
"fake_credentials"
+
File
.
separator
+
"copy_of_test-geni.jks"
;
////
Converter.decodeBase64BToFile(keyStoreEncodedFromCredential, copyTestCredentialPath);
Converter
.
decodeBase64BToFile
(
keyStoreEncodedFromCredential
,
copyTestCredentialPath
);
////
////
String keystorFileChecksum = Converter.getFileMD5(testCredentialPath);
String
keystorFileChecksum
=
Converter
.
getFileMD5
(
testCredentialPath
);
////
String keystorFileCopyChecksum = Converter.getFileMD5(copyTestCredentialPath);
String
keystorFileCopyChecksum
=
Converter
.
getFileMD5
(
copyTestCredentialPath
);
////
////
assertEquals(keystorFileChecksum, keystorFileCopyChecksum);
assertEquals
(
keystorFileChecksum
,
keystorFileCopyChecksum
);
////
}
}
////
////
public String saveCredential() {
public
String
saveCredential
()
{
////
Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "saveCredential");
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
INFO
,
"saveCredential"
);
////
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
);
////
document.setToken("secret");
document
.
setToken
(
"secret"
);
////
document.setTokenType("password");
document
.
setTokenType
(
"password"
);
////
////
return credentialService.save(document);
return
credentialService
.
save
(
document
);
////
}
}
////
////
/**
/**
////
* Test of findByID method, of class CredentialService.
* Test of findByID method, of class CredentialService.
////
*
*
////
* @throws java.lang.Exception
* @throws java.lang.Exception
////
*/
*/
////
@Test
@Test
////
public void testCredentialServiceFindByID() throws Exception {
public
void
testCredentialServiceFindByID
()
throws
Exception
{
////
Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "findByID");
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
INFO
,
"findByID"
);
////
String id = saveCredential();
String
id
=
saveCredential
();
////
Credential result = credentialService.findByID(id);
Credential
result
=
credentialService
.
findByID
(
id
);
////
assertNotNull(result);
assertNotNull
(
result
);
////
}
}
////
////
/**
/**
////
* Test of deleteByID method, of class CredentialService.
* Test of deleteByID method, of class CredentialService.
////
*
*
////
* @throws com.fasterxml.jackson.core.JsonProcessingException
* @throws com.fasterxml.jackson.core.JsonProcessingException
////
*/
*/
////
@Test
@Test
////
public void testCredentialServiceDeleteByID() throws JsonProcessingException {
public
void
testCredentialServiceDeleteByID
()
throws
JsonProcessingException
{
////
Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "deleteByID");
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
INFO
,
"deleteByID"
);
////
String id = saveCredential();
String
id
=
saveCredential
();
////
credentialService.deleteByID(id);
credentialService
.
deleteByID
(
id
);
////
try {
try
{
////
Credential res = credentialService.findByID(id);
Credential
res
=
credentialService
.
findByID
(
id
);
////
assertNotNull(res);
assertNotNull
(
res
);
////
} catch (Exception ex) {
}
catch
(
Exception
ex
)
{
////
if (!(ex instanceof NoSuchElementException)) {
if
(!(
ex
instanceof
NoSuchElementException
))
{
////
fail(ex.getMessage());
fail
(
ex
.
getMessage
());
////
}
}
////
}
}
////
}
}
////
////
/**
/**
////
* Test of getAllIds method, of class CredentialService.
* Test of getAllIds method, of class CredentialService.
////
*/
*/
////
@Test
@Test
////
public void testCredentialServiceGetAllIds() {
public
void
testCredentialServiceGetAllIds
()
{
////
Logger.getLogger(ServiceTests.class.getName()).log(Level.INFO, "getAllIds");
Logger
.
getLogger
(
ServiceTests
.
class
.
getName
()).
log
(
Level
.
INFO
,
"getAllIds"
);
////
testCredentialServiceDeleteAll();
testCredentialServiceDeleteAll
();
////
int numOfINst = 3;
int
numOfINst
=
3
;
////
for (int i = 1; i <= numOfINst; i++) {
for
(
int
i
=
1
;
i
<=
numOfINst
;
i
++)
{
////
saveCredential();
saveCredential
();
////
}
}
////
List<String> result = credentialService.getAllIds();
List
<
String
>
result
=
credentialService
.
getAllIds
();
////
assertEquals(numOfINst, result.size());
assertEquals
(
numOfINst
,
result
.
size
());
////
}
}
////
////
/**
/**
////
* Test of deleteAll method, of class CredentialService.
* Test of deleteAll method, of class CredentialService.
////
*/
*/
////
@Test
@Test
////
public void testCredentialServiceDeleteAll() {
public
void
testCredentialServiceDeleteAll
()
{
////
credentialService.deleteAll();
credentialService
.
deleteAll
();
////
int size = credentialService.getAllIds().size();
int
size
=
credentialService
.
getAllIds
().
size
();
////
assertEquals(0, size);
assertEquals
(
0
,
size
);
////
}
}
////
////
@Test
@Test
////
public void testProvision() throws FileNotFoundException, IOException, MissingCredentialsException, ApiException, TypeExeption, JsonProcessingException, TimeoutException, InterruptedException, NotFoundException {
public
void
testProvision
()
throws
FileNotFoundException
,
IOException
,
MissingCredentialsException
,
ApiException
,
TypeExeption
,
JsonProcessingException
,
TimeoutException
,
InterruptedException
,
NotFoundException
{
////
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
);
////
document.setToken("secret");
document
.
setToken
(
"secret"
);
////
document.setTokenType("password");
document
.
setTokenType
(
"password"
);
////
////
String credentialID = credentialService.save(document);
String
credentialID
=
credentialService
.
save
(
document
);
////
assertNotNull(credentialID);
assertNotNull
(
credentialID
);
////
////
FileInputStream in = new FileInputStream(testApplicationExampleToscaFilePath);
FileInputStream
in
=
new
FileInputStream
(
testApplicationExampleToscaFilePath
);
////
////
MultipartFile file = new MockMultipartFile("file", in);
MultipartFile
file
=
new
MockMultipartFile
(
"file"
,
in
);
////
toscaTemplateID = toscaTemplateService.saveFile(file);
toscaTemplateID
=
toscaTemplateService
.
saveFile
(
file
);
////
//
//
dripService.setRequestQeueName(provisionerQueueName);
//
dripService.setRequestQeueName(provisionerQueueName);
//
//
String planedYemplateId = dripService.provision(toscaTemplateID);
//
String planedYemplateId = dripService.provision(toscaTemplateID);
////
}
}
//
}
}
}
}
sure_tosca-flask-server/sure_tosca/service/tosca_template_service.py
View file @
6b86c1a2
...
@@ -221,9 +221,11 @@ def get_node_templates(id, type_name=None, node_name=None, has_interfaces=None,
...
@@ -221,9 +221,11 @@ def get_node_templates(id, type_name=None, node_name=None, has_interfaces=None,
prop
=
None
prop
=
None
queries
.
append
(
query
.
artifacts
!=
prop
)
queries
.
append
(
query
.
artifacts
!=
prop
)
query_results
=
query_db
(
queries
,
db
=
node_template_db
)
query_results
=
query_db
(
queries
,
db
=
node_template_db
)
return
change_to_node_template_model
(
query_results
)
if
query_results
:
return
change_to_node_template_model
(
query_results
)
else
:
return
query_results
def
get_tosca_template_get_dsl_definitions
(
id
,
anchors
,
derived_from
):
def
get_tosca_template_get_dsl_definitions
(
id
,
anchors
,
derived_from
):
...
@@ -479,4 +481,4 @@ def get_default_interface(id, interface_type, instance_name, operation_name):
...
@@ -479,4 +481,4 @@ def get_default_interface(id, interface_type, instance_name, operation_name):
instance_inputs
=
{
'inputs'
:
instance_inputs_list
}
instance_inputs
=
{
'inputs'
:
instance_inputs_list
}
operation
=
{
operation_name
:
instance_inputs
}
operation
=
{
operation_name
:
instance_inputs
}
instance
=
{
instance_name
:
operation
}
instance
=
{
instance_name
:
operation
}
return
instance
return
instance
\ No newline at end of file
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