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
22d320fd
Commit
22d320fd
authored
Jan 09, 2020
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added exception if no valid credentials are found. Tested with exogeni provider
parent
e2ec6617
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
52 additions
and
44 deletions
+52
-44
.gitignore
.gitignore
+2
-1
ToscaHelperTest.java
...t/java/nl/uva/sne/drip/commons/utils/ToscaHelperTest.java
+1
-0
DRIPService.java
...er/src/main/java/nl/uva/sne/drip/service/DRIPService.java
+20
-6
ServiceTests.java
...r/src/test/java/nl/uva/sne/drip/service/ServiceTests.java
+2
-1
workspace.xml
drip-planner/.idea/workspace.xml
+17
-22
pom.xml
drip-provisioner/pom.xml
+1
-1
CloudStormService.java
...n/java/nl/uva/sne/drip/provisioner/CloudStormService.java
+8
-10
tosca_template_service.py
...flask-server/sure_tosca/service/tosca_template_service.py
+1
-3
No files found.
.gitignore
View file @
22d320fd
...
...
@@ -47,3 +47,4 @@
/drip-manager-services/nbproject/
/drip-manager-services/target/
/drip-provisioner/nbproject/
/fake_credentials/copy_of_test-geni.jks
\ No newline at end of file
drip-commons/src/test/java/nl/uva/sne/drip/commons/utils/ToscaHelperTest.java
View file @
22d320fd
...
...
@@ -159,6 +159,7 @@ public class ToscaHelperTest {
/**
* Test of getTemplateVMsForVMTopology method, of class ToscaHelper.
* @throws java.lang.Exception
*/
@Test
public
void
testGetTemplateVMsForVMTopology
()
throws
Exception
{
...
...
drip-manager/src/main/java/nl/uva/sne/drip/service/DRIPService.java
View file @
22d320fd
...
...
@@ -91,7 +91,7 @@ public class DRIPService {
this
.
requestQeueName
=
requestQeueName
;
}
private
Credential
getBestCredential
(
NodeTemplate
vmTopology
,
List
<
Credential
>
credentials
)
{
private
Credential
getBestCredential
(
List
<
Credential
>
credentials
)
{
return
credentials
.
get
(
0
);
}
...
...
@@ -100,13 +100,18 @@ public class DRIPService {
List
<
Credential
>
credentials
=
null
;
for
(
NodeTemplateMap
vmTopologyMap
:
vmTopologies
)
{
String
provider
=
helper
.
getTopologyProvider
(
vmTopologyMap
);
credentials
=
credentialService
.
findByProvider
(
provider
.
toLowerCase
());
if
(
credentials
!=
null
&&
credentials
.
size
()
>
0
)
{
Credential
credential
=
getBestCredential
(
vmTopologyMap
.
getNodeTemplate
(),
credentials
);
if
(
needsCredentials
(
provider
))
{
credentials
=
credentialService
.
findByProvider
(
provider
);
if
(
credentials
==
null
||
credentials
.
size
()
<=
0
)
{
throw
new
Exception
(
"Provider: "
+
provider
+
" needs credentials but non clould be found"
);
}
else
{
Credential
credential
=
getBestCredential
(
credentials
);
vmTopologyMap
=
helper
.
setCredentialsInVMTopology
(
vmTopologyMap
,
credential
);
toscaTemplate
=
helper
.
setVMTopologyInToscaTemplate
(
toscaTemplate
,
vmTopologyMap
);
}
}
}
return
toscaTemplate
;
}
...
...
@@ -144,4 +149,13 @@ public class DRIPService {
return
toscaTemplate
;
}
private
boolean
needsCredentials
(
String
provider
)
{
switch
(
provider
)
{
case
"local"
:
return
false
;
default
:
return
true
;
}
}
}
drip-manager/src/test/java/nl/uva/sne/drip/service/ServiceTests.java
View file @
22d320fd
...
...
@@ -38,7 +38,6 @@ import java.util.logging.Logger;
import
nl.uva.sne.drip.Swagger2SpringBoot
;
import
nl.uva.sne.drip.commons.utils.Converter
;
import
nl.uva.sne.drip.configuration.MongoConfig
;
import
nl.uva.sne.drip.model.cloud.storm.CloudDB
;
import
nl.uva.sne.drip.model.tosca.Credential
;
import
org.junit.Assert
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
...
...
@@ -239,6 +238,7 @@ public class ServiceTests {
/**
* Test of getAllIds method, of class ToscaTemplateService.
* @throws java.lang.Exception
*/
@Test
public
void
testToscaTemplateServiceGetAllIds
()
throws
Exception
{
...
...
@@ -322,6 +322,7 @@ public class ServiceTests {
/**
* Test of deleteByID method, of class CredentialService.
* @throws com.fasterxml.jackson.core.JsonProcessingException
*/
@Test
public
void
testCredentialServiceDeleteByID
()
throws
JsonProcessingException
{
...
...
drip-planner/.idea/workspace.xml
View file @
22d320fd
...
...
@@ -2,14 +2,8 @@
<project
version=
"4"
>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"e478ccae-5352-4e8e-9efb-3f5cda44e877"
name=
"Default Changelist"
comment=
""
>
<change
beforePath=
"$PROJECT_DIR$/../drip-commons/src/main/java/nl/uva/sne/drip/commons/utils/Converter.java"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../drip-commons/src/main/java/nl/uva/sne/drip/commons/utils/Converter.java"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../drip-commons/src/main/java/nl/uva/sne/drip/commons/utils/ToscaHelper.java"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../drip-commons/src/main/java/nl/uva/sne/drip/commons/utils/ToscaHelper.java"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../drip-manager/src/main/java/nl/uva/sne/drip/api/CredentialApi.java"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../drip-manager/src/main/java/nl/uva/sne/drip/api/CredentialApi.java"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../drip-manager/src/main/java/nl/uva/sne/drip/api/CredentialApiController.java"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../drip-manager/src/main/java/nl/uva/sne/drip/api/CredentialApiController.java"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../drip-manager/src/main/java/nl/uva/sne/drip/api/DeployerApi.java"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../drip-manager/src/main/java/nl/uva/sne/drip/api/DeployerApi.java"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../drip-manager/src/test/java/nl/uva/sne/drip/service/ServiceTests.java"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../drip-manager/src/test/java/nl/uva/sne/drip/service/ServiceTests.java"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../.gitignore"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../.gitignore"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../openAPI/API/CONF-3.0.0-swagger.yaml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../openAPI/API/CONF-3.0.0-swagger.yaml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/service/tosca_template_service.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/service/tosca_template_service.py"
afterDir=
"false"
/>
</list>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
...
...
@@ -39,7 +33,7 @@
</component>
<component
name=
"PropertiesComponent"
>
<property
name=
"RunOnceActivity.ShowReadmeOnStart"
value=
"true"
/>
<property
name=
"last_opened_file_path"
value=
"$PROJECT_DIR$"
/>
<property
name=
"last_opened_file_path"
value=
"$PROJECT_DIR$
/../../devops-prep/week2Lab1/python-flask-server-generated
"
/>
<property
name=
"settings.editor.selected.configurable"
value=
"com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable"
/>
</component>
<component
name=
"RecentsManager"
>
...
...
@@ -117,9 +111,9 @@
</configuration>
<list>
<item
itemvalue=
"Python.__main__"
/>
<item
itemvalue=
"Python tests.Unittests for test_planner.MyTestCase.test_planner"
/>
<item
itemvalue=
"Python tests.Unittests for test_planner.MyTestCase.test_something"
/>
<item
itemvalue=
"Python tests.Unittests in test_planner.py"
/>
<item
itemvalue=
"Python tests.Unittests for test_planner.MyTestCase.test_planner"
/>
</list>
<recent_temporary>
<list>
...
...
@@ -272,30 +266,31 @@
<screen
x=
"67"
y=
"34"
width=
"2493"
height=
"1406"
/>
</state>
<state
width=
"2155"
height=
"582"
key=
"DebuggerActiveHint/67.34.2493.1406@67.34.2493.1406"
timestamp=
"1577715024259"
/>
<state
x=
"
1043"
y=
"437"
width=
"530"
height=
"598"
key=
"FileChooserDialogImpl"
timestamp=
"157590776901
7"
>
<screen
x=
"67"
y=
"34"
width=
"
2493"
height=
"140
6"
/>
<state
x=
"
792"
y=
"334"
width=
"827"
height=
"663"
key=
"FileChooserDialogImpl"
timestamp=
"157832618015
7"
>
<screen
x=
"67"
y=
"34"
width=
"
1853"
height=
"104
6"
/>
</state>
<state
x=
"792"
y=
"334"
width=
"827"
height=
"663"
key=
"FileChooserDialogImpl/67.34.1853.1046@67.34.1853.1046"
timestamp=
"1578326180157"
/>
<state
x=
"1043"
y=
"437"
width=
"530"
height=
"598"
key=
"FileChooserDialogImpl/67.34.2493.1406@67.34.2493.1406"
timestamp=
"1575907769017"
/>
<state
width=
"2465"
height=
"
413"
key=
"GridCell.Tab.0.bottom"
timestamp=
"1577720249205
"
>
<state
width=
"2465"
height=
"
382"
key=
"GridCell.Tab.0.bottom"
timestamp=
"1578250751968
"
>
<screen
x=
"67"
y=
"34"
width=
"2493"
height=
"1406"
/>
</state>
<state
width=
"1825"
height=
"283"
key=
"GridCell.Tab.0.bottom/67.34.1853.1046@67.34.1853.1046"
timestamp=
"1576165782177"
/>
<state
width=
"2465"
height=
"
413"
key=
"GridCell.Tab.0.bottom/67.34.2493.1406@67.34.2493.1406"
timestamp=
"1577720249205
"
/>
<state
width=
"2465"
height=
"
413"
key=
"GridCell.Tab.0.center"
timestamp=
"1577720249202
"
>
<state
width=
"2465"
height=
"
382"
key=
"GridCell.Tab.0.bottom/67.34.2493.1406@67.34.2493.1406"
timestamp=
"1578250751968
"
/>
<state
width=
"2465"
height=
"
382"
key=
"GridCell.Tab.0.center"
timestamp=
"1578250751968
"
>
<screen
x=
"67"
y=
"34"
width=
"2493"
height=
"1406"
/>
</state>
<state
width=
"1825"
height=
"283"
key=
"GridCell.Tab.0.center/67.34.1853.1046@67.34.1853.1046"
timestamp=
"1576165782175"
/>
<state
width=
"2465"
height=
"
413"
key=
"GridCell.Tab.0.center/67.34.2493.1406@67.34.2493.1406"
timestamp=
"1577720249202
"
/>
<state
width=
"2465"
height=
"
413"
key=
"GridCell.Tab.0.left"
timestamp=
"1577720249200
"
>
<state
width=
"2465"
height=
"
382"
key=
"GridCell.Tab.0.center/67.34.2493.1406@67.34.2493.1406"
timestamp=
"1578250751968
"
/>
<state
width=
"2465"
height=
"
382"
key=
"GridCell.Tab.0.left"
timestamp=
"1578250751968
"
>
<screen
x=
"67"
y=
"34"
width=
"2493"
height=
"1406"
/>
</state>
<state
width=
"1825"
height=
"283"
key=
"GridCell.Tab.0.left/67.34.1853.1046@67.34.1853.1046"
timestamp=
"1576165782174"
/>
<state
width=
"2465"
height=
"
413"
key=
"GridCell.Tab.0.left/67.34.2493.1406@67.34.2493.1406"
timestamp=
"1577720249200
"
/>
<state
width=
"2465"
height=
"
413"
key=
"GridCell.Tab.0.right"
timestamp=
"1577720249203
"
>
<state
width=
"2465"
height=
"
382"
key=
"GridCell.Tab.0.left/67.34.2493.1406@67.34.2493.1406"
timestamp=
"1578250751968
"
/>
<state
width=
"2465"
height=
"
382"
key=
"GridCell.Tab.0.right"
timestamp=
"1578250751968
"
>
<screen
x=
"67"
y=
"34"
width=
"2493"
height=
"1406"
/>
</state>
<state
width=
"1825"
height=
"283"
key=
"GridCell.Tab.0.right/67.34.1853.1046@67.34.1853.1046"
timestamp=
"1576165782176"
/>
<state
width=
"2465"
height=
"
413"
key=
"GridCell.Tab.0.right/67.34.2493.1406@67.34.2493.1406"
timestamp=
"1577720249203
"
/>
<state
width=
"2465"
height=
"
382"
key=
"GridCell.Tab.0.right/67.34.2493.1406@67.34.2493.1406"
timestamp=
"1578250751968
"
/>
<state
width=
"2465"
height=
"413"
key=
"GridCell.Tab.1.bottom"
timestamp=
"1577720249209"
>
<screen
x=
"67"
y=
"34"
width=
"2493"
height=
"1406"
/>
</state>
...
...
@@ -316,10 +311,10 @@
<screen
x=
"67"
y=
"34"
width=
"2493"
height=
"1406"
/>
</state>
<state
x=
"679"
y=
"283"
key=
"SettingsEditor/67.34.2493.1406@67.34.2493.1406"
timestamp=
"1575885393075"
/>
<state
x=
"
893"
y=
"526"
key=
"com.intellij.ide.util.TipDialog"
timestamp=
"1577206106759
"
>
<screen
x=
"67"
y=
"34"
width=
"
2493"
height=
"140
6"
/>
<state
x=
"
681"
y=
"400"
key=
"com.intellij.ide.util.TipDialog"
timestamp=
"1578326162404
"
>
<screen
x=
"67"
y=
"34"
width=
"
1853"
height=
"104
6"
/>
</state>
<state
x=
"681"
y=
"400"
key=
"com.intellij.ide.util.TipDialog/67.34.1853.1046@67.34.1853.1046"
timestamp=
"157
6760567200
"
/>
<state
x=
"681"
y=
"400"
key=
"com.intellij.ide.util.TipDialog/67.34.1853.1046@67.34.1853.1046"
timestamp=
"157
8326162404
"
/>
<state
x=
"893"
y=
"526"
key=
"com.intellij.ide.util.TipDialog/67.34.2493.1406@67.34.2493.1406"
timestamp=
"1577206106759"
/>
<state
x=
"882"
y=
"239"
width=
"862"
height=
"993"
key=
"find.popup"
timestamp=
"1576090708880"
>
<screen
x=
"67"
y=
"34"
width=
"2493"
height=
"1406"
/>
...
...
drip-provisioner/pom.xml
View file @
22d320fd
...
...
@@ -63,7 +63,7 @@
<dependency>
<groupId>
nl.uva.sne.zh
</groupId>
<artifactId>
CloudsStorm
</artifactId>
<version>
b.1.
0
</version>
<version>
b.1.
1
</version>
</dependency>
</dependencies>
...
...
drip-provisioner/src/main/java/nl/uva/sne/drip/provisioner/CloudStormService.java
View file @
22d320fd
...
...
@@ -17,9 +17,7 @@ import com.jcraft.jsch.KeyPair;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.util.ArrayList
;
import
java.util.Base64
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -27,6 +25,7 @@ import java.util.Objects;
import
java.util.Properties
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
nl.uva.sne.drip.commons.utils.Converter
;
import
nl.uva.sne.drip.commons.utils.ToscaHelper
;
import
nl.uva.sne.drip.model.cloud.storm.CloudsStormVM
;
import
nl.uva.sne.drip.model.NodeTemplateMap
;
...
...
@@ -60,6 +59,7 @@ class CloudStormService {
private
final
CloudStormDAO
cloudStormDAO
;
private
final
ObjectMapper
objectMapper
;
private
final
String
cloudStormDBPath
;
private
final
String
SUB_TOPOLOGY_NAME
=
"subTopology"
;
CloudStormService
(
Properties
properties
,
ToscaTemplate
toscaTemplate
)
throws
IOException
,
JsonProcessingException
,
ApiException
{
// this.toscaTemplate = toscaTemplate;
...
...
@@ -157,7 +157,7 @@ class CloudStormService {
String
provider
=
helper
.
getTopologyProvider
(
nodeTemplateMap
);
cloudsStormSubTopology
.
setDomain
(
domain
);
cloudsStormSubTopology
.
setCloudProvider
(
provider
);
cloudsStormSubTopology
.
setTopology
(
"sub-topology"
+
i
);
cloudsStormSubTopology
.
setTopology
(
SUB_TOPOLOGY_NAME
+
i
);
cloudsStormSubTopology
.
setStatus
(
CloudsStormSubTopology
.
StatusEnum
.
FRESH
);
CloudsStormVMs
cloudsStormVMs
=
new
CloudsStormVMs
();
...
...
@@ -175,7 +175,7 @@ class CloudStormService {
j
++;
}
cloudsStormVMs
.
setVms
(
vms
);
objectMapper
.
writeValue
(
new
File
(
tempInputDirPath
+
File
.
separator
+
"sub-topology"
+
i
+
".yml"
),
cloudsStormVMs
);
objectMapper
.
writeValue
(
new
File
(
tempInputDirPath
+
File
.
separator
+
SUB_TOPOLOGY_NAME
+
i
+
".yml"
),
cloudsStormVMs
);
cloudsStormVMsList
.
add
(
cloudsStormVMs
);
cloudsStormSubTopologies
.
add
(
cloudsStormSubTopology
);
i
++;
...
...
@@ -207,7 +207,6 @@ class CloudStormService {
int
i
=
0
;
for
(
NodeTemplateMap
vmTopologyMap
:
vmTopologiesMaps
)
{
Credential
toscaCredentials
=
helper
.
getCredentialsFromVMTopology
(
vmTopologyMap
);
CloudCred
cloudStormCredential
=
new
CloudCred
();
cloudStormCredential
.
setCloudProvider
(
toscaCredentials
.
getCloudProviderName
());
String
credInfoFile
=
toscaCredentials
.
getCloudProviderName
()
+
i
+
".yml"
;
...
...
@@ -223,16 +222,15 @@ class CloudStormService {
objectMapper
.
writeValue
(
new
File
(
credentialsTempInputDirPath
+
File
.
separator
+
"cred.yml"
),
cloudStormCredentials
);
}
private
CredentialInfo
getCloudStormCredentialInfo
(
Credential
toscaCredentials
,
String
tmpPath
)
throws
FileNotFoundException
{
private
CredentialInfo
getCloudStormCredentialInfo
(
Credential
toscaCredentials
,
String
tmpPath
)
throws
FileNotFoundException
,
IOException
{
CredentialInfo
cloudStormCredentialInfo
=
new
CredentialInfo
();
switch
(
toscaCredentials
.
getCloudProviderName
().
toLowerCase
())
{
case
"exogeni"
:
String
base64Keystore
=
toscaCredentials
.
getKeys
().
get
(
"keystore"
);
byte
[]
decoded
=
Base64
.
getDecoder
().
decode
(
base64Keystore
);
try
(
PrintWriter
out
=
new
PrintWriter
(
tmpPath
+
File
.
separator
+
"user.jks"
))
{
out
.
println
(
new
String
(
decoded
));
}
Converter
.
decodeBase64BToFile
(
base64Keystore
,
tmpPath
+
File
.
separator
+
"user.jks"
);
cloudStormCredentialInfo
.
setUserKeyName
(
"user.jks"
);
cloudStormCredentialInfo
.
setKeyAlias
(
toscaCredentials
.
getUser
());
cloudStormCredentialInfo
.
setKeyPassword
(
toscaCredentials
.
getToken
());
...
...
sure_tosca-flask-server/sure_tosca/service/tosca_template_service.py
View file @
22d320fd
...
...
@@ -102,8 +102,6 @@ def save(file):
# tosca_template_file_path = os.path.join(db_dir_path, file.filename)
start
=
time
.
time
()
logger
.
info
(
"Got request for tosca template"
)
purge_all_tables
()
dictionary
=
yaml
.
safe_load
(
file
.
stream
)
...
...
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