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
d790ac01
Commit
d790ac01
authored
Mar 19, 2020
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
try to add zip artifact
parent
8afa984c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
92 additions
and
58 deletions
+92
-58
Converter.java
...rc/main/java/nl/uva/sne/drip/commons/utils/Converter.java
+5
-13
CloudStormService.java
...n/java/nl/uva/sne/drip/provisioner/CloudStormService.java
+64
-45
CloudStormServiceTest.java
...va/nl/uva/sne/drip/provisioner/CloudStormServiceTest.java
+23
-0
No files found.
commons/src/main/java/nl/uva/sne/drip/commons/utils/Converter.java
View file @
d790ac01
...
@@ -15,9 +15,11 @@
...
@@ -15,9 +15,11 @@
*/
*/
package
nl
.
uva
.
sne
.
drip
.
commons
.
utils
;
package
nl
.
uva
.
sne
.
drip
.
commons
.
utils
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.file.FileVisitResult
;
import
java.nio.file.FileVisitResult
;
import
java.nio.file.Files
;
import
java.nio.file.Files
;
...
@@ -27,11 +29,14 @@ import java.nio.file.SimpleFileVisitor;
...
@@ -27,11 +29,14 @@ import java.nio.file.SimpleFileVisitor;
import
java.nio.file.attribute.BasicFileAttributes
;
import
java.nio.file.attribute.BasicFileAttributes
;
import
java.security.MessageDigest
;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.ArrayList
;
import
java.util.Base64
;
import
java.util.Base64
;
import
java.util.Enumeration
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipFile
;
import
java.util.zip.ZipOutputStream
;
import
java.util.zip.ZipOutputStream
;
import
org.json.JSONException
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
...
@@ -100,17 +105,4 @@ public class Converter {
...
@@ -100,17 +105,4 @@ public class Converter {
return
new
String
(
encodedBytes
,
StandardCharsets
.
UTF_8
);
return
new
String
(
encodedBytes
,
StandardCharsets
.
UTF_8
);
}
}
public
static
void
zipFolder
(
Path
sourceFolderPath
,
Path
zipPath
)
throws
FileNotFoundException
,
IOException
{
try
(
ZipOutputStream
zos
=
new
ZipOutputStream
(
new
FileOutputStream
(
zipPath
.
toFile
())))
{
Files
.
walkFileTree
(
sourceFolderPath
,
new
SimpleFileVisitor
<
Path
>()
{
@Override
public
FileVisitResult
visitFile
(
Path
file
,
BasicFileAttributes
attrs
)
throws
IOException
{
zos
.
putNextEntry
(
new
ZipEntry
(
sourceFolderPath
.
relativize
(
file
).
toString
()));
Files
.
copy
(
file
,
zos
);
zos
.
closeEntry
();
return
FileVisitResult
.
CONTINUE
;
}
});
}
}
}
}
provisioner/src/main/java/nl/uva/sne/drip/provisioner/CloudStormService.java
View file @
d790ac01
...
@@ -61,10 +61,21 @@ import org.apache.maven.shared.utils.io.DirectoryScanner;
...
@@ -61,10 +61,21 @@ import org.apache.maven.shared.utils.io.DirectoryScanner;
*/
*/
class
CloudStormService
{
class
CloudStormService
{
private
List
<
Map
.
Entry
>
vmTopologies
;
/**
// private String tempInputDirPath;
* @return the helper
// private final ToscaTemplate toscaTemplate;
*/
private
final
ToscaHelper
helper
;
public
ToscaHelper
getHelper
()
{
return
helper
;
}
/**
* @param helper the helper to set
*/
public
void
setHelper
(
ToscaHelper
helper
)
{
this
.
helper
=
helper
;
}
private
ToscaHelper
helper
;
private
final
CloudStormDAO
cloudStormDAO
;
private
final
CloudStormDAO
cloudStormDAO
;
private
final
ObjectMapper
objectMapper
;
private
final
ObjectMapper
objectMapper
;
private
final
String
cloudStormDBPath
;
private
final
String
cloudStormDBPath
;
...
@@ -139,7 +150,7 @@ class CloudStormService {
...
@@ -139,7 +150,7 @@ class CloudStormService {
writeCloudStormInfrasCodeFiles
(
infrasCodeTempInputDirPath
,
cloudStormSubtopologies
);
writeCloudStormInfrasCodeFiles
(
infrasCodeTempInputDirPath
,
cloudStormSubtopologies
);
ToscaTemplate
newToscaTemplate
=
runCloudStorm
(
tempInputDirPath
);
ToscaTemplate
newToscaTemplate
=
runCloudStorm
(
tempInputDirPath
);
helper
.
uploadToscaTemplate
(
newToscaTemplate
);
getHelper
()
.
uploadToscaTemplate
(
newToscaTemplate
);
return
newToscaTemplate
;
return
newToscaTemplate
;
}
}
...
@@ -150,7 +161,7 @@ class CloudStormService {
...
@@ -150,7 +161,7 @@ class CloudStormService {
String
publicKeyPath
=
buildSSHKeyPair
(
topologyTempInputDirPath
,
keyPair
);
String
publicKeyPath
=
buildSSHKeyPair
(
topologyTempInputDirPath
,
keyPair
);
topTopology
.
setPublicKeyPath
(
publicKeyPath
);
topTopology
.
setPublicKeyPath
(
publicKeyPath
);
topTopology
.
setUserName
(
helper
.
getVMTopologyUser
());
topTopology
.
setUserName
(
getHelper
()
.
getVMTopologyUser
());
Map
<
String
,
Object
>
subTopologiesAndVMs
=
getCloudsStormSubTopologiesAndVMs
(
topologyTempInputDirPath
);
Map
<
String
,
Object
>
subTopologiesAndVMs
=
getCloudsStormSubTopologiesAndVMs
(
topologyTempInputDirPath
);
List
<
CloudsStormSubTopology
>
cloudsStormSubTopology
=
(
List
<
CloudsStormSubTopology
>)
subTopologiesAndVMs
.
get
(
"cloud_storm_subtopologies"
);
List
<
CloudsStormSubTopology
>
cloudsStormSubTopology
=
(
List
<
CloudsStormSubTopology
>)
subTopologiesAndVMs
.
get
(
"cloud_storm_subtopologies"
);
...
@@ -181,26 +192,26 @@ class CloudStormService {
...
@@ -181,26 +192,26 @@ class CloudStormService {
}
}
protected
Map
<
String
,
Object
>
getCloudsStormSubTopologiesAndVMs
(
String
tempInputDirPath
)
throws
ApiException
,
IOException
,
Exception
{
protected
Map
<
String
,
Object
>
getCloudsStormSubTopologiesAndVMs
(
String
tempInputDirPath
)
throws
ApiException
,
IOException
,
Exception
{
List
<
NodeTemplateMap
>
vmTopologyTemplatesMap
=
helper
.
getVMTopologyTemplates
();
List
<
NodeTemplateMap
>
vmTopologyTemplatesMap
=
getHelper
()
.
getVMTopologyTemplates
();
List
<
CloudsStormSubTopology
>
cloudsStormSubTopologies
=
new
ArrayList
<>();
List
<
CloudsStormSubTopology
>
cloudsStormSubTopologies
=
new
ArrayList
<>();
Map
<
String
,
Object
>
cloudsStormMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
cloudsStormMap
=
new
HashMap
<>();
List
<
CloudsStormVMs
>
cloudsStormVMsList
=
new
ArrayList
<>();
List
<
CloudsStormVMs
>
cloudsStormVMsList
=
new
ArrayList
<>();
int
i
=
0
;
int
i
=
0
;
for
(
NodeTemplateMap
nodeTemplateMap
:
vmTopologyTemplatesMap
)
{
for
(
NodeTemplateMap
nodeTemplateMap
:
vmTopologyTemplatesMap
)
{
CloudsStormSubTopology
cloudsStormSubTopology
=
new
CloudsStormSubTopology
();
CloudsStormSubTopology
cloudsStormSubTopology
=
new
CloudsStormSubTopology
();
String
domain
=
helper
.
getTopologyDomain
(
nodeTemplateMap
);
String
domain
=
getHelper
()
.
getTopologyDomain
(
nodeTemplateMap
);
String
provider
=
helper
.
getTopologyProvider
(
nodeTemplateMap
);
String
provider
=
getHelper
()
.
getTopologyProvider
(
nodeTemplateMap
);
cloudsStormSubTopology
.
setDomain
(
domain
);
cloudsStormSubTopology
.
setDomain
(
domain
);
cloudsStormSubTopology
.
setCloudProvider
(
provider
);
cloudsStormSubTopology
.
setCloudProvider
(
provider
);
cloudsStormSubTopology
.
setTopology
(
SUB_TOPOLOGY_NAME
+
i
);
cloudsStormSubTopology
.
setTopology
(
SUB_TOPOLOGY_NAME
+
i
);
ToscaHelper
.
NODE_STATES
currentState
=
helper
.
getNodeCurrentState
(
nodeTemplateMap
);
ToscaHelper
.
NODE_STATES
currentState
=
getHelper
()
.
getNodeCurrentState
(
nodeTemplateMap
);
ToscaHelper
.
NODE_STATES
desiredState
=
helper
.
getNodeDesiredState
(
nodeTemplateMap
);
ToscaHelper
.
NODE_STATES
desiredState
=
getHelper
()
.
getNodeDesiredState
(
nodeTemplateMap
);
cloudsStormSubTopology
.
setStatus
(
ToscaHelper
.
nodeCurrentState2CloudStormStatus
(
currentState
));
cloudsStormSubTopology
.
setStatus
(
ToscaHelper
.
nodeCurrentState2CloudStormStatus
(
currentState
));
CloudsStormVMs
cloudsStormVMs
=
new
CloudsStormVMs
();
CloudsStormVMs
cloudsStormVMs
=
new
CloudsStormVMs
();
List
<
CloudsStormVM
>
vms
=
new
ArrayList
<>();
List
<
CloudsStormVM
>
vms
=
new
ArrayList
<>();
List
<
NodeTemplateMap
>
vmTemplatesMap
=
helper
.
getTemplateVMsForVMTopology
(
nodeTemplateMap
);
List
<
NodeTemplateMap
>
vmTemplatesMap
=
getHelper
()
.
getTemplateVMsForVMTopology
(
nodeTemplateMap
);
int
j
=
0
;
int
j
=
0
;
for
(
NodeTemplateMap
vmMap
:
vmTemplatesMap
)
{
for
(
NodeTemplateMap
vmMap
:
vmTemplatesMap
)
{
CloudsStormVM
cloudStromVM
=
getBestMatchingCloudStormVM
(
vmMap
,
provider
);
CloudsStormVM
cloudStromVM
=
getBestMatchingCloudStormVM
(
vmMap
,
provider
);
...
@@ -220,10 +231,10 @@ class CloudStormService {
...
@@ -220,10 +231,10 @@ class CloudStormService {
}
}
protected
CloudsStormVM
getBestMatchingCloudStormVM
(
NodeTemplateMap
vmMap
,
String
provider
)
throws
IOException
,
Exception
{
protected
CloudsStormVM
getBestMatchingCloudStormVM
(
NodeTemplateMap
vmMap
,
String
provider
)
throws
IOException
,
Exception
{
Double
requestedNumOfCores
=
helper
.
getVMNumOfCores
(
vmMap
);
Double
requestedNumOfCores
=
getHelper
()
.
getVMNumOfCores
(
vmMap
);
Double
requestedMemSize
=
helper
.
getVMNMemSize
(
vmMap
);
Double
requestedMemSize
=
getHelper
()
.
getVMNMemSize
(
vmMap
);
String
requestedOs
=
helper
.
getVMNOS
(
vmMap
);
String
requestedOs
=
getHelper
()
.
getVMNOS
(
vmMap
);
Double
requestedDiskSize
=
helper
.
getVMNDiskSize
(
vmMap
);
Double
requestedDiskSize
=
getHelper
()
.
getVMNDiskSize
(
vmMap
);
double
[]
requestedVector
=
convert2ArrayofDoubles
(
requestedNumOfCores
,
requestedMemSize
,
requestedDiskSize
);
double
[]
requestedVector
=
convert2ArrayofDoubles
(
requestedNumOfCores
,
requestedMemSize
,
requestedDiskSize
);
double
min
=
Double
.
MAX_VALUE
;
double
min
=
Double
.
MAX_VALUE
;
CloudsStormVM
bestMatchingVM
=
null
;
CloudsStormVM
bestMatchingVM
=
null
;
...
@@ -262,11 +273,11 @@ class CloudStormService {
...
@@ -262,11 +273,11 @@ class CloudStormService {
}
}
protected
void
writeCloudStormCredentialsFiles
(
String
credentialsTempInputDirPath
)
throws
ApiException
,
Exception
{
protected
void
writeCloudStormCredentialsFiles
(
String
credentialsTempInputDirPath
)
throws
ApiException
,
Exception
{
List
<
NodeTemplateMap
>
vmTopologiesMaps
=
helper
.
getVMTopologyTemplates
();
List
<
NodeTemplateMap
>
vmTopologiesMaps
=
getHelper
()
.
getVMTopologyTemplates
();
List
<
CloudCred
>
cloudStormCredentialList
=
new
ArrayList
<>();
List
<
CloudCred
>
cloudStormCredentialList
=
new
ArrayList
<>();
int
i
=
0
;
int
i
=
0
;
for
(
NodeTemplateMap
vmTopologyMap
:
vmTopologiesMaps
)
{
for
(
NodeTemplateMap
vmTopologyMap
:
vmTopologiesMaps
)
{
Credential
toscaCredentials
=
helper
.
getCredentialsFromVMTopology
(
vmTopologyMap
);
Credential
toscaCredentials
=
getHelper
()
.
getCredentialsFromVMTopology
(
vmTopologyMap
);
CloudCred
cloudStormCredential
=
new
CloudCred
();
CloudCred
cloudStormCredential
=
new
CloudCred
();
cloudStormCredential
.
setCloudProvider
(
toscaCredentials
.
getCloudProviderName
());
cloudStormCredential
.
setCloudProvider
(
toscaCredentials
.
getCloudProviderName
());
String
credInfoFile
=
toscaCredentials
.
getCloudProviderName
()
+
i
+
".yml"
;
String
credInfoFile
=
toscaCredentials
.
getCloudProviderName
()
+
i
+
".yml"
;
...
@@ -303,15 +314,15 @@ class CloudStormService {
...
@@ -303,15 +314,15 @@ class CloudStormService {
}
}
protected
void
writeCloudStormInfrasCodeFiles
(
String
infrasCodeTempInputDirPath
,
List
<
CloudsStormSubTopology
>
cloudStormSubtopologies
)
throws
ApiException
,
IOException
{
protected
void
writeCloudStormInfrasCodeFiles
(
String
infrasCodeTempInputDirPath
,
List
<
CloudsStormSubTopology
>
cloudStormSubtopologies
)
throws
ApiException
,
IOException
{
List
<
NodeTemplateMap
>
vmTopologiesMaps
=
helper
.
getVMTopologyTemplates
();
List
<
NodeTemplateMap
>
vmTopologiesMaps
=
getHelper
()
.
getVMTopologyTemplates
();
int
i
=
0
;
int
i
=
0
;
List
<
InfrasCode
>
infrasCodes
=
new
ArrayList
<>();
List
<
InfrasCode
>
infrasCodes
=
new
ArrayList
<>();
for
(
NodeTemplateMap
vmTopologyMap
:
vmTopologiesMaps
)
{
for
(
NodeTemplateMap
vmTopologyMap
:
vmTopologiesMaps
)
{
ToscaHelper
.
NODE_STATES
nodeCurrentState
=
helper
.
getNodeCurrentState
(
vmTopologyMap
);
ToscaHelper
.
NODE_STATES
nodeCurrentState
=
getHelper
()
.
getNodeCurrentState
(
vmTopologyMap
);
ToscaHelper
.
NODE_STATES
nodeDesiredState
=
helper
.
getNodeDesiredState
(
vmTopologyMap
);
ToscaHelper
.
NODE_STATES
nodeDesiredState
=
getHelper
()
.
getNodeDesiredState
(
vmTopologyMap
);
//Can provision
//Can provision
Map
<
String
,
Object
>
provisionInterface
=
helper
.
getProvisionerInterfaceFromVMTopology
(
vmTopologyMap
);
Map
<
String
,
Object
>
provisionInterface
=
getHelper
()
.
getProvisionerInterfaceFromVMTopology
(
vmTopologyMap
);
OpCode
.
OperationEnum
operation
=
ToscaHelper
.
NodeDesiredState2CloudStormOperation
(
nodeDesiredState
);
OpCode
.
OperationEnum
operation
=
ToscaHelper
.
NodeDesiredState2CloudStormOperation
(
nodeDesiredState
);
Map
<
String
,
Object
>
inputs
=
(
Map
<
String
,
Object
>)
provisionInterface
.
get
(
operation
.
toString
().
toLowerCase
());
Map
<
String
,
Object
>
inputs
=
(
Map
<
String
,
Object
>)
provisionInterface
.
get
(
operation
.
toString
().
toLowerCase
());
inputs
.
put
(
"object_type"
,
cloudStormSubtopologies
.
get
(
i
).
getTopology
());
inputs
.
put
(
"object_type"
,
cloudStormSubtopologies
.
get
(
i
).
getTopology
());
...
@@ -349,27 +360,14 @@ class CloudStormService {
...
@@ -349,27 +360,14 @@ class CloudStormService {
List
<
CloudsStormSubTopology
>
subTopologies
=
_top
.
getTopologies
();
List
<
CloudsStormSubTopology
>
subTopologies
=
_top
.
getTopologies
();
List
<
NodeTemplateMap
>
vmTopologiesMaps
=
helper
.
getVMTopologyTemplates
();
List
<
NodeTemplateMap
>
vmTopologiesMaps
=
getHelper
()
.
getVMTopologyTemplates
();
int
i
=
0
;
int
i
=
0
;
for
(
CloudsStormSubTopology
subTopology
:
subTopologies
)
{
for
(
CloudsStormSubTopology
subTopology
:
subTopologies
)
{
NodeTemplateMap
vmTopologyMap
=
vmTopologiesMaps
.
get
(
i
);
NodeTemplateMap
vmTopologyMap
=
vmTopologiesMaps
.
get
(
i
);
Map
<
String
,
Object
>
artifacts
=
vmTopologyMap
.
getNodeTemplate
().
getArtifacts
();
vmTopologyMap
=
addCloudStromArtifacts
(
vmTopologyMap
,
tempInputDirPath
);
if
(
artifacts
==
null
)
{
artifacts
=
new
HashMap
<>();
}
Map
<
String
,
String
>
provisionedFiles
=
new
HashMap
<>();
provisionedFiles
.
put
(
"type"
,
ENCODED_FILE_DATATYPE
);
Path
zipPath
=
Paths
.
get
(
tempInputDirPath
+
TOPOLOGY_RELATIVE_PATH
+
File
.
separator
+
TOPOLOGY_FOLDER_NAME
+
".zip"
);
Path
sourceFolderPath
=
Paths
.
get
(
tempInputDirPath
+
TOPOLOGY_RELATIVE_PATH
);
Converter
.
zipFolder
(
sourceFolderPath
,
zipPath
);
String
cloudStormZipFileContentsAsBase64
=
Converter
.
encodeFileToBase64Binary
(
zipPath
.
toFile
().
getAbsolutePath
());
getHelper
().
setNodeCurrentState
(
vmTopologyMap
,
cloudStormStatus2NodeState
(
subTopology
.
getStatus
()));
provisionedFiles
.
put
(
"file_contents"
,
cloudStormZipFileContentsAsBase64
);
provisionedFiles
.
put
(
"encoding"
,
"base64"
);
provisionedFiles
.
put
(
"file_ext"
,
"zip"
);
artifacts
.
put
(
"provisioned_files"
,
provisionedFiles
);
helper
.
setNodeCurrentState
(
vmTopologyMap
,
cloudStormStatus2NodeState
(
subTopology
.
getStatus
()));
String
rootKeyPairFolder
=
tempInputDirPath
+
TOPOLOGY_RELATIVE_PATH
String
rootKeyPairFolder
=
tempInputDirPath
+
TOPOLOGY_RELATIVE_PATH
+
File
.
separator
+
subTopology
.
getSshKeyPairId
();
+
File
.
separator
+
subTopology
.
getSshKeyPairId
();
...
@@ -400,7 +398,7 @@ class CloudStormService {
...
@@ -400,7 +398,7 @@ class CloudStormService {
CloudsStormVMs
cloudsStormVMs
=
objectMapper
.
readValue
(
new
File
(
tempInputDirPath
+
TOPOLOGY_RELATIVE_PATH
+
File
.
separator
+
subTopology
.
getTopology
()
+
".yml"
),
CloudsStormVMs
cloudsStormVMs
=
objectMapper
.
readValue
(
new
File
(
tempInputDirPath
+
TOPOLOGY_RELATIVE_PATH
+
File
.
separator
+
subTopology
.
getTopology
()
+
".yml"
),
CloudsStormVMs
.
class
);
CloudsStormVMs
.
class
);
List
<
CloudsStormVM
>
vms
=
cloudsStormVMs
.
getVms
();
List
<
CloudsStormVM
>
vms
=
cloudsStormVMs
.
getVms
();
List
<
NodeTemplateMap
>
vmTemplatesMap
=
helper
.
getTemplateVMsForVMTopology
(
vmTopologyMap
);
List
<
NodeTemplateMap
>
vmTemplatesMap
=
getHelper
()
.
getTemplateVMsForVMTopology
(
vmTopologyMap
);
int
j
=
0
;
int
j
=
0
;
for
(
CloudsStormVM
vm
:
vms
)
{
for
(
CloudsStormVM
vm
:
vms
)
{
NodeTemplateMap
vmTemplateMap
=
vmTemplatesMap
.
get
(
j
);
NodeTemplateMap
vmTemplateMap
=
vmTemplatesMap
.
get
(
j
);
...
@@ -421,10 +419,10 @@ class CloudStormService {
...
@@ -421,10 +419,10 @@ class CloudStormService {
vmAttributes
.
put
(
"root_key_pair"
,
rootKeyPairCredential
);
vmAttributes
.
put
(
"root_key_pair"
,
rootKeyPairCredential
);
vmAttributes
.
put
(
"user_key_pair"
,
userKeyPairCredential
);
vmAttributes
.
put
(
"user_key_pair"
,
userKeyPairCredential
);
vmTemplateMap
.
getNodeTemplate
().
setAttributes
(
vmAttributes
);
vmTemplateMap
.
getNodeTemplate
().
setAttributes
(
vmAttributes
);
toscaTemplate
=
helper
.
setNodeInToscaTemplate
(
toscaTemplate
,
vmTemplateMap
);
toscaTemplate
=
getHelper
()
.
setNodeInToscaTemplate
(
toscaTemplate
,
vmTemplateMap
);
j
++;
j
++;
}
}
toscaTemplate
=
helper
.
setNodeInToscaTemplate
(
toscaTemplate
,
vmTopologyMap
);
toscaTemplate
=
getHelper
()
.
setNodeInToscaTemplate
(
toscaTemplate
,
vmTopologyMap
);
i
++;
i
++;
}
}
return
toscaTemplate
;
return
toscaTemplate
;
...
@@ -437,15 +435,36 @@ class CloudStormService {
...
@@ -437,15 +435,36 @@ class CloudStormService {
protected
KeyPair
getKeyPair
()
throws
ApiException
,
TypeExeption
,
JSchException
{
protected
KeyPair
getKeyPair
()
throws
ApiException
,
TypeExeption
,
JSchException
{
KeyPair
keyPair
=
null
;
KeyPair
keyPair
=
null
;
List
<
NodeTemplateMap
>
vmTopologyTemplatesMap
=
helper
.
getVMTopologyTemplates
();
List
<
NodeTemplateMap
>
vmTopologyTemplatesMap
=
getHelper
()
.
getVMTopologyTemplates
();
for
(
NodeTemplateMap
nodeTemplateMap
:
vmTopologyTemplatesMap
)
{
for
(
NodeTemplateMap
nodeTemplateMap
:
vmTopologyTemplatesMap
)
{
List
<
NodeTemplateMap
>
vmTemplatesMap
=
helper
.
getTemplateVMsForVMTopology
(
nodeTemplateMap
);
List
<
NodeTemplateMap
>
vmTemplatesMap
=
getHelper
()
.
getTemplateVMsForVMTopology
(
nodeTemplateMap
);
for
(
NodeTemplateMap
vmMap
:
vmTemplatesMap
)
{
for
(
NodeTemplateMap
vmMap
:
vmTemplatesMap
)
{
keyPair
=
helper
.
getKeyPairsFromVM
(
vmMap
.
getNodeTemplate
());
keyPair
=
getHelper
()
.
getKeyPairsFromVM
(
vmMap
.
getNodeTemplate
());
break
;
break
;
}
}
}
}
return
keyPair
;
return
keyPair
;
}
}
protected
NodeTemplateMap
addCloudStromArtifacts
(
NodeTemplateMap
vmTopologyMap
,
String
tempInputDirPath
)
throws
IOException
{
Map
<
String
,
Object
>
artifacts
=
vmTopologyMap
.
getNodeTemplate
().
getArtifacts
();
if
(
artifacts
==
null
)
{
artifacts
=
new
HashMap
<>();
}
Map
<
String
,
String
>
provisionedFiles
=
new
HashMap
<>();
provisionedFiles
.
put
(
"type"
,
ENCODED_FILE_DATATYPE
);
Path
zipPath
=
Paths
.
get
(
tempInputDirPath
+
TOPOLOGY_RELATIVE_PATH
+
File
.
separator
+
TOPOLOGY_FOLDER_NAME
+
".zip"
);
Path
sourceFolderPath
=
Paths
.
get
(
tempInputDirPath
+
TOPOLOGY_RELATIVE_PATH
);
Converter
.
zipFolder
(
sourceFolderPath
,
zipPath
);
String
cloudStormZipFileContentsAsBase64
=
Converter
.
encodeFileToBase64Binary
(
zipPath
.
toFile
().
getAbsolutePath
());
provisionedFiles
.
put
(
"file_contents"
,
cloudStormZipFileContentsAsBase64
);
provisionedFiles
.
put
(
"encoding"
,
"base64"
);
provisionedFiles
.
put
(
"file_ext"
,
"zip"
);
artifacts
.
put
(
"provisioned_files"
,
provisionedFiles
);
vmTopologyMap
.
getNodeTemplate
().
setArtifacts
(
artifacts
);
return
vmTopologyMap
;
}
}
}
provisioner/src/test/java/nl/uva/sne/drip/provisioner/CloudStormServiceTest.java
View file @
d790ac01
...
@@ -19,11 +19,16 @@ import java.util.List;
...
@@ -19,11 +19,16 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
import
nl.uva.sne.drip.commons.utils.ToscaHelper
;
import
nl.uva.sne.drip.commons.utils.ToscaHelper
;
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.cloud.storm.CloudsStormInfrasCode
;
import
nl.uva.sne.drip.model.cloud.storm.CloudsStormInfrasCode
;
import
nl.uva.sne.drip.model.cloud.storm.CloudsStormSubTopology
;
import
nl.uva.sne.drip.model.cloud.storm.CloudsStormSubTopology
;
import
nl.uva.sne.drip.model.cloud.storm.CloudsStormTopTopology
;
import
nl.uva.sne.drip.model.cloud.storm.CloudsStormTopTopology
;
import
nl.uva.sne.drip.model.cloud.storm.CloudsStormVM
;
import
nl.uva.sne.drip.model.cloud.storm.CredentialInfo
;
import
nl.uva.sne.drip.model.cloud.storm.InfrasCode
;
import
nl.uva.sne.drip.model.cloud.storm.InfrasCode
;
import
nl.uva.sne.drip.model.cloud.storm.OpCode
;
import
nl.uva.sne.drip.model.cloud.storm.OpCode
;
import
nl.uva.sne.drip.model.tosca.Credential
;
import
nl.uva.sne.drip.model.tosca.ToscaTemplate
;
import
static
nl
.
uva
.
sne
.
drip
.
provisioner
.
CloudStormService
.
APP_FOLDER_NAME
;
import
static
nl
.
uva
.
sne
.
drip
.
provisioner
.
CloudStormService
.
APP_FOLDER_NAME
;
import
static
nl
.
uva
.
sne
.
drip
.
provisioner
.
CloudStormService
.
INFRASTUCTURE_CODE_FILE_NAME
;
import
static
nl
.
uva
.
sne
.
drip
.
provisioner
.
CloudStormService
.
INFRASTUCTURE_CODE_FILE_NAME
;
import
static
nl
.
uva
.
sne
.
drip
.
provisioner
.
CloudStormService
.
INFS_FOLDER_NAME
;
import
static
nl
.
uva
.
sne
.
drip
.
provisioner
.
CloudStormService
.
INFS_FOLDER_NAME
;
...
@@ -279,4 +284,22 @@ public class CloudStormServiceTest {
...
@@ -279,4 +284,22 @@ public class CloudStormServiceTest {
}
}
}
}
/**
* Test of addCloudStromArtifacts method, of class CloudStormService.
*/
@Test
public
void
testAddCloudStromArtifacts
()
throws
Exception
{
if
(
ToscaHelper
.
isServiceUp
(
sureToscaBasePath
))
{
}
System
.
out
.
println
(
"addCloudStromArtifacts"
);
initPaths
();
CloudStormService
instance
=
getService
(
messageExampleProvisioneRequestFilePath
);
List
<
NodeTemplateMap
>
vmTopologiesMaps
=
instance
.
getHelper
().
getVMTopologyTemplates
();
for
(
NodeTemplateMap
vmTopologyMap
:
vmTopologiesMaps
)
{
vmTopologyMap
=
instance
.
addCloudStromArtifacts
(
vmTopologyMap
,
tempInputDirPath
);
}
}
}
}
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