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
f7f33f11
Commit
f7f33f11
authored
Dec 20, 2019
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change to NodeTemplateMap
parent
a9d61f92
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
243 additions
and
125 deletions
+243
-125
ToscaHelper.java
.../main/java/nl/uva/sne/drip/commons/utils/ToscaHelper.java
+25
-15
NodeTemplateMap.java
.../src/main/java/nl/uva/sne/drip/model/NodeTemplateMap.java
+110
-0
ApiKeyAuth.java
...main/java/nl/uva/sne/drip/sure/tosca/auth/ApiKeyAuth.java
+46
-43
Authentication.java
.../java/nl/uva/sne/drip/sure/tosca/auth/Authentication.java
+4
-1
HttpBasicAuth.java
...n/java/nl/uva/sne/drip/sure/tosca/auth/HttpBasicAuth.java
+1
-0
OAuth.java
.../src/main/java/nl/uva/sne/drip/sure/tosca/auth/OAuth.java
+1
-1
ApiCallback.java
...n/java/nl/uva/sne/drip/sure/tosca/client/ApiCallback.java
+0
-1
ApiClient.java
...ain/java/nl/uva/sne/drip/sure/tosca/client/ApiClient.java
+7
-11
ApiException.java
.../java/nl/uva/sne/drip/sure/tosca/client/ApiException.java
+1
-1
Configuration.java
...java/nl/uva/sne/drip/sure/tosca/client/Configuration.java
+1
-1
DefaultApi.java
...in/java/nl/uva/sne/drip/sure/tosca/client/DefaultApi.java
+17
-25
JSON.java
...src/main/java/nl/uva/sne/drip/sure/tosca/client/JSON.java
+1
-0
Pair.java
...src/main/java/nl/uva/sne/drip/sure/tosca/client/Pair.java
+1
-1
StringUtil.java
...in/java/nl/uva/sne/drip/sure/tosca/client/StringUtil.java
+1
-1
ToscaHelperTest.java
...t/java/nl/uva/sne/drip/commons/utils/ToscaHelperTest.java
+4
-3
DRIPService.java
...er/src/main/java/nl/uva/sne/drip/service/DRIPService.java
+7
-6
CloudStormService.java
...n/java/nl/uva/sne/drip/provisioner/CloudStormService.java
+16
-15
No files found.
drip-commons/src/main/java/nl/uva/sne/drip/commons/utils/ToscaHelper.java
View file @
f7f33f11
...
...
@@ -28,6 +28,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Set
;
import
nl.uva.sne.drip.model.NodeTemplate
;
import
nl.uva.sne.drip.model.NodeTemplateMap
;
import
nl.uva.sne.drip.model.tosca.Credential
;
import
nl.uva.sne.drip.model.tosca.ToscaTemplate
;
import
nl.uva.sne.drip.sure.tosca.client.DefaultApi
;
...
...
@@ -97,20 +98,21 @@ public class ToscaHelper {
return
interfaceDefinitions
;
}
public
List
<
NodeTemplate
>
getVMTopologyTemplates
()
throws
ApiException
{
List
<
NodeTemplate
>
vmTopologyTemplates
=
api
.
getNodeTemplates
(
String
.
valueOf
(
id
),
"tosca.nodes.ARTICONF.VM.topology"
,
null
,
null
,
null
,
null
,
null
,
null
,
null
);
public
List
<
NodeTemplate
Map
>
getVMTopologyTemplates
()
throws
ApiException
{
List
<
NodeTemplate
Map
>
vmTopologyTemplates
=
api
.
getNodeTemplates
(
String
.
valueOf
(
id
),
"tosca.nodes.ARTICONF.VM.topology"
,
null
,
null
,
null
,
null
,
null
,
null
,
null
);
return
vmTopologyTemplates
;
}
public
List
<
NodeTemplate
>
getTemplateVMsForVMTopology
(
NodeTemplate
nodeTemplate
)
throws
ApiException
{
public
List
<
NodeTemplateMap
>
getTemplateVMsForVMTopology
(
NodeTemplateMap
nodeTemplateMap
)
throws
ApiException
{
NodeTemplate
nodeTemplate
=
nodeTemplateMap
.
getNodeTemplate
();
List
<
Map
<
String
,
Object
>>
requirements
=
nodeTemplate
.
getRequirements
();
List
<
NodeTemplate
>
vms
=
new
ArrayList
<>();
List
<
NodeTemplate
Map
>
vms
=
new
ArrayList
<>();
for
(
Map
<
String
,
Object
>
req
:
requirements
)
{
String
nodeName
=
req
.
keySet
().
iterator
().
next
();
Map
<
String
,
Object
>
node
=
(
Map
<
String
,
Object
>)
req
.
get
(
nodeName
);
if
(
node
.
get
(
"capability"
).
equals
(
VM_CAPABILITY
))
{
String
vmName
=
(
String
)
node
.
get
(
"node"
);
List
<
NodeTemplate
>
vmNodeTemplates
=
api
.
getNodeTemplates
(
String
.
valueOf
(
id
),
null
,
vmName
,
null
,
null
,
null
,
null
,
null
,
null
);
List
<
NodeTemplate
Map
>
vmNodeTemplates
=
api
.
getNodeTemplates
(
String
.
valueOf
(
id
),
null
,
vmName
,
null
,
null
,
null
,
null
,
null
,
null
);
vms
.
addAll
(
vmNodeTemplates
);
}
}
...
...
@@ -118,7 +120,8 @@ public class ToscaHelper {
}
public
Double
getVMNumOfCores
(
NodeTemplate
vm
)
throws
Exception
{
public
Double
getVMNumOfCores
(
NodeTemplateMap
vmMap
)
throws
Exception
{
NodeTemplate
vm
=
vmMap
.
getNodeTemplate
();
if
(
vm
.
getType
().
equals
(
VM_TYPE
))
{
return
(
Double
)
vm
.
getProperties
().
get
(
VM_NUM_OF_CORES
);
}
else
{
...
...
@@ -126,7 +129,8 @@ public class ToscaHelper {
}
}
public
Double
getVMNMemSize
(
NodeTemplate
vm
)
throws
Exception
{
public
Double
getVMNMemSize
(
NodeTemplateMap
vmMap
)
throws
Exception
{
NodeTemplate
vm
=
vmMap
.
getNodeTemplate
();
if
(
vm
.
getType
().
equals
(
VM_TYPE
))
{
String
memScalar
=
(
String
)
vm
.
getProperties
().
get
(
MEM_SIZE
);
String
[]
memScalarArray
=
memScalar
.
split
(
" "
);
...
...
@@ -140,7 +144,8 @@ public class ToscaHelper {
}
public
String
getVMNOS
(
NodeTemplate
vm
)
throws
Exception
{
public
String
getVMNOS
(
NodeTemplateMap
vmMap
)
throws
Exception
{
NodeTemplate
vm
=
vmMap
.
getNodeTemplate
();
if
(
vm
.
getType
().
equals
(
VM_TYPE
))
{
return
(
String
)
vm
.
getProperties
().
get
(
VM_OS
);
}
else
{
...
...
@@ -161,15 +166,17 @@ public class ToscaHelper {
}
}
public
String
getTopologyDomain
(
NodeTemplate
nodeTemplate
)
throws
Exception
{
public
String
getTopologyDomain
(
NodeTemplateMap
nodeTemplateMap
)
throws
Exception
{
NodeTemplate
nodeTemplate
=
nodeTemplateMap
.
getNodeTemplate
();
if
(
nodeTemplate
.
getType
().
equals
(
VM_TOPOLOGY
))
{
return
(
String
)
nodeTemplate
.
getProperties
().
get
(
"domain"
);
}
else
{
throw
new
Exception
(
"NodeTemplate is not of type: "
+
VM_TOPOLOGY
+
" it is of type: "
+
nodeTemplate
.
getType
());
throw
new
Exception
(
"NodeTemplate
Map
is not of type: "
+
VM_TOPOLOGY
+
" it is of type: "
+
nodeTemplate
.
getType
());
}
}
public
String
getTopologyProvider
(
NodeTemplate
nodeTemplate
)
throws
Exception
{
public
String
getTopologyProvider
(
NodeTemplateMap
nodeTemplateMap
)
throws
Exception
{
NodeTemplate
nodeTemplate
=
nodeTemplateMap
.
getNodeTemplate
();
if
(
nodeTemplate
.
getType
().
equals
(
VM_TOPOLOGY
))
{
return
(
String
)
nodeTemplate
.
getProperties
().
get
(
"provider"
);
}
else
{
...
...
@@ -177,7 +184,8 @@ public class ToscaHelper {
}
}
public
NodeTemplate
setCredentialsInVMTopology
(
NodeTemplate
vmTopology
,
Credential
credential
)
throws
Exception
{
public
NodeTemplateMap
setCredentialsInVMTopology
(
NodeTemplateMap
vmTopologyMap
,
Credential
credential
)
throws
Exception
{
NodeTemplate
vmTopology
=
vmTopologyMap
.
getNodeTemplate
();
if
(
vmTopology
.
getType
().
equals
(
VM_TOPOLOGY
))
{
Map
<
String
,
Object
>
att
=
vmTopology
.
getAttributes
();
if
(
att
==
null
)
{
...
...
@@ -192,13 +200,15 @@ public class ToscaHelper {
toscaCredential
.
put
(
"cloud_provider_name"
,
credential
.
getCloudProviderName
());
att
.
put
(
"credential"
,
toscaCredential
);
vmTopology
.
setAttributes
(
att
);
return
vmTopology
;
vmTopologyMap
.
setNodeTemplate
(
vmTopology
);
return
vmTopologyMap
;
}
else
{
throw
new
Exception
(
"NodeTemplate is not of type: "
+
VM_TOPOLOGY
+
" it is of type: "
+
vmTopology
.
getType
());
}
}
public
Credential
getCredentialsFromVMTopology
(
NodeTemplate
vmTopology
)
throws
Exception
{
public
Credential
getCredentialsFromVMTopology
(
NodeTemplateMap
vmTopologyMap
)
throws
Exception
{
NodeTemplate
vmTopology
=
vmTopologyMap
.
getNodeTemplate
();
if
(
vmTopology
.
getType
().
equals
(
VM_TOPOLOGY
))
{
Map
<
String
,
Object
>
att
=
vmTopology
.
getAttributes
();
Object
credentialMap
=
att
.
get
(
"credential"
);
...
...
@@ -221,7 +231,7 @@ public class ToscaHelper {
public
ToscaTemplate
setVMTopologyInToscaTemplate
(
ToscaTemplate
toscaTemplate
,
NodeTemplate
vmTopology
)
{
Map
<
String
,
NodeTemplate
>
nodes
=
toscaTemplate
.
getTopologyTemplate
().
getNodeTemplates
();
Set
<
String
>
keys
=
nodes
.
keySet
();
for
(
String
key
:
keys
)
{
for
(
String
key
:
keys
)
{
NodeTemplate
node
=
nodes
.
get
(
key
);
}
return
null
;
...
...
drip-commons/src/main/java/nl/uva/sne/drip/model/NodeTemplateMap.java
0 → 100644
View file @
f7f33f11
/*
* tosca-sure
* TOSCA Simple qUeRy sErvice (SURE).
*
* OpenAPI spec version: 1.0.0
* Contact: S.Koulouzis@uva.nl
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package
nl
.
uva
.
sne
.
drip
.
model
;
import
java.util.Objects
;
import
com.google.gson.annotations.SerializedName
;
import
io.swagger.annotations.ApiModelProperty
;
/**
* NodeTemplateMap
*/
@javax
.
annotation
.
Generated
(
value
=
"io.swagger.codegen.languages.JavaClientCodegen"
,
date
=
"2019-12-20T15:53:11.510Z"
)
public
class
NodeTemplateMap
{
@SerializedName
(
"name"
)
private
String
name
=
null
;
@SerializedName
(
"nodeTemplate"
)
private
NodeTemplate
nodeTemplate
=
null
;
public
NodeTemplateMap
name
(
String
name
)
{
this
.
name
=
name
;
return
this
;
}
/**
* Get name
*
* @return name
*
*/
@ApiModelProperty
(
value
=
""
)
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
NodeTemplateMap
nodeTemplate
(
NodeTemplate
nodeTemplate
)
{
this
.
nodeTemplate
=
nodeTemplate
;
return
this
;
}
/**
* Get nodeTemplate
*
* @return nodeTemplate
*
*/
@ApiModelProperty
(
value
=
""
)
public
NodeTemplate
getNodeTemplate
()
{
return
nodeTemplate
;
}
public
void
setNodeTemplate
(
NodeTemplate
nodeTemplate
)
{
this
.
nodeTemplate
=
nodeTemplate
;
}
@Override
public
boolean
equals
(
java
.
lang
.
Object
o
)
{
if
(
this
==
o
)
{
return
true
;
}
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
{
return
false
;
}
NodeTemplateMap
nodeTemplateMap
=
(
NodeTemplateMap
)
o
;
return
Objects
.
equals
(
this
.
name
,
nodeTemplateMap
.
name
)
&&
Objects
.
equals
(
this
.
nodeTemplate
,
nodeTemplateMap
.
nodeTemplate
);
}
@Override
public
int
hashCode
()
{
return
Objects
.
hash
(
name
,
nodeTemplate
);
}
@Override
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"class NodeTemplateMap {\n"
);
sb
.
append
(
" name: "
).
append
(
toIndentedString
(
name
)).
append
(
"\n"
);
sb
.
append
(
" nodeTemplate: "
).
append
(
toIndentedString
(
nodeTemplate
)).
append
(
"\n"
);
sb
.
append
(
"}"
);
return
sb
.
toString
();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private
String
toIndentedString
(
java
.
lang
.
Object
o
)
{
if
(
o
==
null
)
{
return
"null"
;
}
return
o
.
toString
().
replace
(
"\n"
,
"\n "
);
}
}
drip-commons/src/main/java/nl/uva/sne/drip/sure/tosca/auth/ApiKeyAuth.java
View file @
f7f33f11
...
...
@@ -9,65 +9,68 @@
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package
nl
.
uva
.
sne
.
drip
.
sure
.
tosca
.
auth
;
import
java.util.Map
;
import
java.util.List
;
import
nl.uva.sne.drip.sure.tosca.client.Pair
;
@javax
.
annotation
.
Generated
(
value
=
"io.swagger.codegen.languages.JavaClientCodegen"
,
date
=
"2019-12-
09T20:19:44.689
Z"
)
@javax
.
annotation
.
Generated
(
value
=
"io.swagger.codegen.languages.JavaClientCodegen"
,
date
=
"2019-12-
20T15:53:11.510
Z"
)
public
class
ApiKeyAuth
implements
Authentication
{
private
final
String
location
;
private
final
String
paramName
;
private
final
String
location
;
private
final
String
paramName
;
private
String
apiKey
;
private
String
apiKeyPrefix
;
private
String
apiKey
;
private
String
apiKeyPrefix
;
public
ApiKeyAuth
(
String
location
,
String
paramName
)
{
this
.
location
=
location
;
this
.
paramName
=
paramName
;
}
public
ApiKeyAuth
(
String
location
,
String
paramName
)
{
this
.
location
=
location
;
this
.
paramName
=
paramName
;
}
public
String
getLocation
()
{
return
location
;
}
public
String
getLocation
()
{
return
location
;
}
public
String
getParamName
()
{
return
paramName
;
}
public
String
getParamName
()
{
return
paramName
;
}
public
String
getApiKey
()
{
return
apiKey
;
}
public
String
getApiKey
(
)
{
return
apiKey
;
}
public
void
setApiKey
(
String
apiKey
)
{
this
.
apiKey
=
apiKey
;
}
public
void
setApiKey
(
String
apiKey
)
{
this
.
apiKey
=
apiKey
;
}
public
String
getApiKeyPrefix
(
)
{
return
apiKeyPrefix
;
}
public
String
getApiKeyPrefix
(
)
{
return
apiKeyPrefix
;
}
public
void
setApiKeyPrefix
(
String
apiKeyPrefix
)
{
this
.
apiKeyPrefix
=
apiKeyPrefix
;
}
public
void
setApiKeyPrefix
(
String
apiKeyPrefix
)
{
this
.
apiKeyPrefix
=
apiKeyPrefix
;
@Override
public
void
applyToParams
(
List
<
Pair
>
queryParams
,
Map
<
String
,
String
>
headerParams
)
{
if
(
apiKey
==
null
)
{
return
;
}
@Override
public
void
applyToParams
(
List
<
Pair
>
queryParams
,
Map
<
String
,
String
>
headerParams
)
{
if
(
apiKey
==
null
)
{
return
;
}
String
value
;
if
(
apiKeyPrefix
!=
null
)
{
value
=
apiKeyPrefix
+
" "
+
apiKey
;
}
else
{
value
=
apiKey
;
}
if
(
"query"
.
equals
(
location
))
{
queryParams
.
add
(
new
Pair
(
paramName
,
value
));
}
else
if
(
"header"
.
equals
(
location
))
{
headerParams
.
put
(
paramName
,
value
);
}
String
value
;
if
(
apiKeyPrefix
!=
null
)
{
value
=
apiKeyPrefix
+
" "
+
apiKey
;
}
else
{
value
=
apiKey
;
}
if
(
"query"
.
equals
(
location
))
{
queryParams
.
add
(
new
Pair
(
paramName
,
value
));
}
else
if
(
"header"
.
equals
(
location
))
{
headerParams
.
put
(
paramName
,
value
);
}
}
}
drip-commons/src/main/java/nl/uva/sne/drip/sure/tosca/auth/Authentication.java
View file @
f7f33f11
...
...
@@ -9,14 +9,17 @@
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package
nl
.
uva
.
sne
.
drip
.
sure
.
tosca
.
auth
;
import
java.util.Map
;
import
java.util.List
;
import
nl.uva.sne.drip.sure.tosca.client.Pair
;
public
interface
Authentication
{
/**
* Apply authentication settings to header and query params.
*
...
...
drip-commons/src/main/java/nl/uva/sne/drip/sure/tosca/auth/HttpBasicAuth.java
View file @
f7f33f11
...
...
@@ -20,6 +20,7 @@ import com.squareup.okhttp.Credentials;
import
java.util.Map
;
import
java.util.List
;
import
java.io.UnsupportedEncodingException
;
import
nl.uva.sne.drip.sure.tosca.client.Pair
;
public
class
HttpBasicAuth
implements
Authentication
{
...
...
drip-commons/src/main/java/nl/uva/sne/drip/sure/tosca/auth/OAuth.java
View file @
f7f33f11
...
...
@@ -19,7 +19,7 @@ import java.util.Map;
import
java.util.List
;
import
nl.uva.sne.drip.sure.tosca.client.Pair
;
@javax
.
annotation
.
Generated
(
value
=
"io.swagger.codegen.languages.JavaClientCodegen"
,
date
=
"2019-12-
09T20:19:44.689
Z"
)
@javax
.
annotation
.
Generated
(
value
=
"io.swagger.codegen.languages.JavaClientCodegen"
,
date
=
"2019-12-
20T15:53:11.510
Z"
)
public
class
OAuth
implements
Authentication
{
private
String
accessToken
;
...
...
drip-commons/src/main/java/nl/uva/sne/drip/sure/tosca/client/ApiCallback.java
View file @
f7f33f11
...
...
@@ -13,7 +13,6 @@
package
nl
.
uva
.
sne
.
drip
.
sure
.
tosca
.
client
;
import
java.io.IOException
;
import
java.util.Map
;
import
java.util.List
;
...
...
drip-commons/src/main/java/nl/uva/sne/drip/sure/tosca/client/ApiClient.java
View file @
f7f33f11
...
...
@@ -11,21 +11,17 @@
*/
package
nl
.
uva
.
sne
.
drip
.
sure
.
tosca
.
client
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.squareup.okhttp.*
;
import
javax.net.ssl.*
;
import
java.util.*
;
import
org.threeten.bp.LocalDate
;
import
org.threeten.bp.OffsetDateTime
;
import
org.threeten.bp.format.DateTimeFormatter
;
import
com.squareup.okhttp.internal.http.HttpMethod
;
import
com.squareup.okhttp.logging.HttpLoggingInterceptor
;
import
com.squareup.okhttp.logging.HttpLoggingInterceptor.Level
;
import
okio.BufferedSink
;
import
okio.Okio
;
import
org.threeten.bp.LocalDate
;
import
org.threeten.bp.OffsetDateTime
;
import
org.threeten.bp.format.DateTimeFormatter
;
import
javax.net.ssl.*
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStream
;
...
...
@@ -41,14 +37,14 @@ import java.security.cert.CertificateException;
import
java.security.cert.CertificateFactory
;
import
java.security.cert.X509Certificate
;
import
java.text.DateFormat
;
import
java.util.*
;
import
java.util.Map.Entry
;
import
java.util.concurrent.TimeUnit
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
nl.uva.sne.drip.sure.tosca.auth.ApiKeyAuth
;
import
nl.uva.sne.drip.sure.tosca.auth.Authentication
;
import
nl.uva.sne.drip.sure.tosca.auth.HttpBasicAuth
;
import
nl.uva.sne.drip.sure.tosca.auth.ApiKeyAuth
;
import
nl.uva.sne.drip.sure.tosca.auth.OAuth
;
public
class
ApiClient
{
...
...
@@ -518,7 +514,7 @@ public class ApiClient {
* @return A list containing a single {@code Pair} object.
*/
public
List
<
Pair
>
parameterToPair
(
String
name
,
Object
value
)
{
List
<
Pair
>
params
=
new
ArrayList
<>();
List
<
Pair
>
params
=
new
ArrayList
<
Pair
>();
// preconditions
if
(
name
==
null
||
name
.
isEmpty
()
||
value
==
null
||
value
instanceof
Collection
)
{
...
...
drip-commons/src/main/java/nl/uva/sne/drip/sure/tosca/client/ApiException.java
View file @
f7f33f11
...
...
@@ -16,7 +16,7 @@ package nl.uva.sne.drip.sure.tosca.client;
import
java.util.Map
;
import
java.util.List
;
@javax
.
annotation
.
Generated
(
value
=
"io.swagger.codegen.languages.JavaClientCodegen"
,
date
=
"2019-12-
09T20:19:44.689
Z"
)
@javax
.
annotation
.
Generated
(
value
=
"io.swagger.codegen.languages.JavaClientCodegen"
,
date
=
"2019-12-
20T15:53:11.510
Z"
)
public
class
ApiException
extends
Exception
{
private
int
code
=
0
;
private
Map
<
String
,
List
<
String
>>
responseHeaders
=
null
;
...
...
drip-commons/src/main/java/nl/uva/sne/drip/sure/tosca/client/Configuration.java
View file @
f7f33f11
...
...
@@ -13,7 +13,7 @@
package
nl
.
uva
.
sne
.
drip
.
sure
.
tosca
.
client
;
@javax
.
annotation
.
Generated
(
value
=
"io.swagger.codegen.languages.JavaClientCodegen"
,
date
=
"2019-12-
09T20:19:44.689
Z"
)
@javax
.
annotation
.
Generated
(
value
=
"io.swagger.codegen.languages.JavaClientCodegen"
,
date
=
"2019-12-
20T15:53:11.510
Z"
)
public
class
Configuration
{
private
static
ApiClient
defaultApiClient
=
new
ApiClient
();
...
...
drip-commons/src/main/java/nl/uva/sne/drip/sure/tosca/client/DefaultApi.java
View file @
f7f33f11
...
...
@@ -22,17 +22,9 @@ import java.util.ArrayList;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
nl.uva.sne.drip.model.NodeTemplate
;
import
nl.uva.sne.drip.model.NodeTemplate
Map
;
import
nl.uva.sne.drip.model.tosca.TopologyTemplate
;
import
nl.uva.sne.drip.model.tosca.ToscaTemplate
;
import
nl.uva.sne.drip.sure.tosca.client.ApiCallback
;
import
nl.uva.sne.drip.sure.tosca.client.ApiClient
;
import
nl.uva.sne.drip.sure.tosca.client.ApiException
;
import
nl.uva.sne.drip.sure.tosca.client.ApiResponse
;
import
nl.uva.sne.drip.sure.tosca.client.Configuration
;
import
nl.uva.sne.drip.sure.tosca.client.Pair
;
import
nl.uva.sne.drip.sure.tosca.client.ProgressRequestBody
;
import
nl.uva.sne.drip.sure.tosca.client.ProgressResponseBody
;
public
class
DefaultApi
{
...
...
@@ -1297,12 +1289,12 @@ public class DefaultApi {
* @param hasRequirements filter if has requirements (optional)
* @param hasCapabilities filter if has capabilities (optional)
* @param hasArtifacts filter if has artifacts (optional)
* @return List<NodeTemplate>
* @return List<NodeTemplate
Map
>
* @throws ApiException If fail to call the API, e.g. server error or cannot
* deserialize the response body
*/
public
List
<
NodeTemplate
>
getNodeTemplates
(
String
id
,
String
typeName
,
String
nodeName
,
Boolean
hasInterfaces
,
Boolean
hasProperties
,
Boolean
hasAttributes
,
Boolean
hasRequirements
,
Boolean
hasCapabilities
,
Boolean
hasArtifacts
)
throws
ApiException
{
ApiResponse
<
List
<
NodeTemplate
>>
resp
=
getNodeTemplatesWithHttpInfo
(
id
,
typeName
,
nodeName
,
hasInterfaces
,
hasProperties
,
hasAttributes
,
hasRequirements
,
hasCapabilities
,
hasArtifacts
);
public
List
<
NodeTemplate
Map
>
getNodeTemplates
(
String
id
,
String
typeName
,
String
nodeName
,
Boolean
hasInterfaces
,
Boolean
hasProperties
,
Boolean
hasAttributes
,
Boolean
hasRequirements
,
Boolean
hasCapabilities
,
Boolean
hasArtifacts
)
throws
ApiException
{
ApiResponse
<
List
<
NodeTemplate
Map
>>
resp
=
getNodeTemplatesWithHttpInfo
(
id
,
typeName
,
nodeName
,
hasInterfaces
,
hasProperties
,
hasAttributes
,
hasRequirements
,
hasCapabilities
,
hasArtifacts
);
return
resp
.
getData
();
}
...
...
@@ -1319,13 +1311,13 @@ public class DefaultApi {
* @param hasRequirements filter if has requirements (optional)
* @param hasCapabilities filter if has capabilities (optional)
* @param hasArtifacts filter if has artifacts (optional)
* @return ApiResponse<List<NodeTemplate>>
* @return ApiResponse<List<NodeTemplate
Map
>>
* @throws ApiException If fail to call the API, e.g. server error or cannot
* deserialize the response body
*/
public
ApiResponse
<
List
<
NodeTemplate
>>
getNodeTemplatesWithHttpInfo
(
String
id
,
String
typeName
,
String
nodeName
,
Boolean
hasInterfaces
,
Boolean
hasProperties
,
Boolean
hasAttributes
,
Boolean
hasRequirements
,
Boolean
hasCapabilities
,
Boolean
hasArtifacts
)
throws
ApiException
{
public
ApiResponse
<
List
<
NodeTemplate
Map
>>
getNodeTemplatesWithHttpInfo
(
String
id
,
String
typeName
,
String
nodeName
,
Boolean
hasInterfaces
,
Boolean
hasProperties
,
Boolean
hasAttributes
,
Boolean
hasRequirements
,
Boolean
hasCapabilities
,
Boolean
hasArtifacts
)
throws
ApiException
{
com
.
squareup
.
okhttp
.
Call
call
=
getNodeTemplatesValidateBeforeCall
(
id
,
typeName
,
nodeName
,
hasInterfaces
,
hasProperties
,
hasAttributes
,
hasRequirements
,
hasCapabilities
,
hasArtifacts
,
null
,
null
);
Type
localVarReturnType
=
new
TypeToken
<
List
<
NodeTemplate
>>()
{
Type
localVarReturnType
=
new
TypeToken
<
List
<
NodeTemplate
Map
>>()
{
}.
getType
();
return
apiClient
.
execute
(
call
,
localVarReturnType
);
}
...
...
@@ -1347,7 +1339,7 @@ public class DefaultApi {
* @throws ApiException If fail to process the API call, e.g. serializing
* the request body object
*/
public
com
.
squareup
.
okhttp
.
Call
getNodeTemplatesAsync
(
String
id
,
String
typeName
,
String
nodeName
,
Boolean
hasInterfaces
,
Boolean
hasProperties
,
Boolean
hasAttributes
,
Boolean
hasRequirements
,
Boolean
hasCapabilities
,
Boolean
hasArtifacts
,
final
ApiCallback
<
List
<
NodeTemplate
>>
callback
)
throws
ApiException
{
public
com
.
squareup
.
okhttp
.
Call
getNodeTemplatesAsync
(
String
id
,
String
typeName
,
String
nodeName
,
Boolean
hasInterfaces
,
Boolean
hasProperties
,
Boolean
hasAttributes
,
Boolean
hasRequirements
,
Boolean
hasCapabilities
,
Boolean
hasArtifacts
,
final
ApiCallback
<
List
<
NodeTemplate
Map
>>
callback
)
throws
ApiException
{
ProgressResponseBody
.
ProgressListener
progressListener
=
null
;
ProgressRequestBody
.
ProgressRequestListener
progressRequestListener
=
null
;
...
...
@@ -1369,7 +1361,7 @@ public class DefaultApi {
}
com
.
squareup
.
okhttp
.
Call
call
=
getNodeTemplatesValidateBeforeCall
(
id
,
typeName
,
nodeName
,
hasInterfaces
,
hasProperties
,
hasAttributes
,
hasRequirements
,
hasCapabilities
,
hasArtifacts
,
progressListener
,
progressRequestListener
);
Type
localVarReturnType
=
new
TypeToken
<
List
<
NodeTemplate
>>()
{
Type
localVarReturnType
=
new
TypeToken
<
List
<
NodeTemplate
Map
>>()
{
}.
getType
();
apiClient
.
executeAsync
(
call
,
localVarReturnType
,
callback
);
return
call
;
...
...
@@ -1730,12 +1722,12 @@ public class DefaultApi {
*
* @param id ID of topolog template uplodaed (required)
* @param nodeName node_name (required)
* @return List<NodeTemplate>
* @return List<NodeTemplate
Map
>
* @throws ApiException If fail to call the API, e.g. server error or cannot
* deserialize the response body
*/
public
List
<
NodeTemplate
>
getRelatedNodes
(
String
id
,
String
nodeName
)
throws
ApiException
{
ApiResponse
<
List
<
NodeTemplate
>>
resp
=
getRelatedNodesWithHttpInfo
(
id
,
nodeName
);
public
List
<
NodeTemplate
Map
>
getRelatedNodes
(
String
id
,
String
nodeName
)
throws
ApiException
{
ApiResponse
<
List
<
NodeTemplate
Map
>>
resp
=
getRelatedNodesWithHttpInfo
(
id
,
nodeName
);
return
resp
.
getData
();
}
...
...
@@ -1745,13 +1737,13 @@ public class DefaultApi {
*
* @param id ID of topolog template uplodaed (required)
* @param nodeName node_name (required)
* @return ApiResponse<List<NodeTemplate>>
* @return ApiResponse<List<NodeTemplate
Map
>>
* @throws ApiException If fail to call the API, e.g. server error or cannot
* deserialize the response body
*/
public
ApiResponse
<
List
<
NodeTemplate
>>
getRelatedNodesWithHttpInfo
(
String
id
,
String
nodeName
)
throws
ApiException
{
public
ApiResponse
<
List
<
NodeTemplate
Map
>>
getRelatedNodesWithHttpInfo
(
String
id
,
String
nodeName
)
throws
ApiException
{
com
.
squareup
.
okhttp
.
Call
call
=
getRelatedNodesValidateBeforeCall
(
id
,
nodeName
,
null
,
null
);
Type
localVarReturnType
=
new
TypeToken
<
List
<
NodeTemplate
>>()
{
Type
localVarReturnType
=
new
TypeToken
<
List
<
NodeTemplate
Map
>>()
{
}.
getType
();
return
apiClient
.
execute
(
call
,
localVarReturnType
);
}
...
...
@@ -1766,7 +1758,7 @@ public class DefaultApi {
* @throws ApiException If fail to process the API call, e.g. serializing
* the request body object
*/
public
com
.
squareup
.
okhttp
.
Call
getRelatedNodesAsync
(
String
id
,
String
nodeName
,
final
ApiCallback
<
List
<
NodeTemplate
>>
callback
)
throws
ApiException
{
public
com
.
squareup
.
okhttp
.
Call
getRelatedNodesAsync
(
String
id
,
String
nodeName
,
final
ApiCallback
<
List
<
NodeTemplate
Map
>>
callback
)
throws
ApiException
{
ProgressResponseBody
.
ProgressListener
progressListener
=
null
;
ProgressRequestBody
.
ProgressRequestListener
progressRequestListener
=
null
;
...
...
@@ -1788,7 +1780,7 @@ public class DefaultApi {
}
com
.
squareup
.
okhttp
.
Call
call
=
getRelatedNodesValidateBeforeCall
(
id
,
nodeName
,
progressListener
,
progressRequestListener
);
Type
localVarReturnType
=
new
TypeToken
<
List
<
NodeTemplate
>>()
{
Type
localVarReturnType
=
new
TypeToken
<
List
<
NodeTemplate
Map
>>()
{
}.
getType
();
apiClient
.
executeAsync
(
call
,
localVarReturnType
,
callback
);
return
call
;
...
...
drip-commons/src/main/java/nl/uva/sne/drip/sure/tosca/client/JSON.java
View file @
f7f33f11
...
...
@@ -120,6 +120,7 @@ public class JSON {
* @param returnType The type to deserialize into
* @return The deserialized Java object
*/
@SuppressWarnings
(
"unchecked"
)
public
<
T
>
T
deserialize
(
String
body
,
Type
returnType
)
{
try
{
if
(
isLenientOnJson
)
{
...
...
drip-commons/src/main/java/nl/uva/sne/drip/sure/tosca/client/Pair.java
View file @
f7f33f11
...
...
@@ -13,7 +13,7 @@
package
nl
.
uva
.
sne
.
drip
.
sure
.
tosca
.
client
;
@javax
.
annotation
.
Generated
(
value
=
"io.swagger.codegen.languages.JavaClientCodegen"
,
date
=
"2019-12-
09T20:19:44.689
Z"
)
@javax
.
annotation
.
Generated
(
value
=
"io.swagger.codegen.languages.JavaClientCodegen"
,
date
=
"2019-12-
20T15:53:11.510
Z"
)
public
class
Pair
{
private
String
name
=
""
;
private
String
value
=
""
;
...
...
drip-commons/src/main/java/nl/uva/sne/drip/sure/tosca/client/StringUtil.java
View file @
f7f33f11
...
...
@@ -13,7 +13,7 @@
package
nl
.
uva
.
sne
.
drip
.
sure
.
tosca
.
client
;
@javax
.
annotation
.
Generated
(
value
=
"io.swagger.codegen.languages.JavaClientCodegen"
,
date
=
"2019-12-
09T20:19:44.689
Z"
)
@javax
.
annotation
.
Generated
(
value
=
"io.swagger.codegen.languages.JavaClientCodegen"
,
date
=
"2019-12-
20T15:53:11.510
Z"
)
public
class
StringUtil
{
/**
* Check if the given array contains the given value (with case-insensitive comparison).
...
...
drip-commons/src/test/java/nl/uva/sne/drip/commons/utils/ToscaHelperTest.java
View file @
f7f33f11
...
...
@@ -36,6 +36,7 @@ import java.util.Set;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
nl.uva.sne.drip.model.NodeTemplate
;
import
nl.uva.sne.drip.model.NodeTemplateMap
;
import
nl.uva.sne.drip.model.tosca.ToscaTemplate
;
import
org.junit.After
;
import
org.junit.AfterClass
;
...
...
@@ -131,10 +132,10 @@ public class ToscaHelperTest {
public
void
testGetVMTopologyTemplates
()
throws
ApiException
{
if
(
serviceUp
)
{
System
.
out
.
println
(
"getVMTopologyTemplates"
);
List
<
NodeTemplate
>
result
=
instance
.
getVMTopologyTemplates
();
List
<
NodeTemplate
Map
>
result
=
instance
.
getVMTopologyTemplates
();
assertNotNull
(
result
);
for
(
NodeTemplate
nodeTemplate
:
result
)
{
assertEquals
(
nodeTemplate
.
getType
(),
"tosca.nodes.ARTICONF.VM.topology"
);
for
(
NodeTemplate
Map
nodeTemplateMap
:
result
)
{
assertEquals
(
nodeTemplate
Map
.
getNodeTemplate
()
.
getType
(),
"tosca.nodes.ARTICONF.VM.topology"
);
}
}
}
...
...
drip-manager/src/main/java/nl/uva/sne/drip/service/DRIPService.java
View file @
f7f33f11
...
...
@@ -14,6 +14,7 @@ import java.util.logging.Logger;
import
nl.uva.sne.drip.commons.utils.ToscaHelper
;
import
nl.uva.sne.drip.model.Message
;
import
nl.uva.sne.drip.model.NodeTemplate
;
import
nl.uva.sne.drip.model.NodeTemplateMap
;
import
nl.uva.sne.drip.model.tosca.Credential
;
import
nl.uva.sne.drip.model.tosca.ToscaTemplate
;
import
nl.uva.sne.drip.rpc.DRIPCaller
;
...
...
@@ -94,15 +95,15 @@ public class DRIPService {
private
ToscaTemplate
addCredentials
(
ToscaTemplate
toscaTemplate
)
throws
IOException
,
JsonProcessingException
,
ApiException
,
Exception
{
helper
.
uploadToscaTemplate
(
toscaTemplate
);
List
<
NodeTemplate
>
vmTopologies
=
helper
.
getVMTopologyTemplates
();
List
<
NodeTemplate
Map
>
vmTopologies
=
helper
.
getVMTopologyTemplates
();
List
<
Credential
>
credentials
=
null
;
for
(
NodeTemplate
vmTopology
:
vmTopologies
)
{
String
provider
=
helper
.
getTopologyProvider
(
vmTopology
);
for
(
NodeTemplate
Map
vmTopologyMap
:
vmTopologies
)
{
String
provider
=
helper
.
getTopologyProvider
(
vmTopology
Map
);
credentials
=
credentialService
.
findByProvider
(
provider
.
toLowerCase
());
if
(
credentials
!=
null
&&
credentials
.
size
()
>
0
)
{
Credential
credential
=
getBestCredential
(
vmTopology
,
credentials
);
vmTopology
=
helper
.
setCredentialsInVMTopology
(
vmTopology
,
credential
);
toscaTemplate
=
helper
.
setVMTopologyInToscaTemplate
(
toscaTemplate
,
vmTopology
);
Credential
credential
=
getBestCredential
(
vmTopology
Map
.
getNodeTemplate
()
,
credentials
);
vmTopology
Map
=
helper
.
setCredentialsInVMTopology
(
vmTopologyMap
,
credential
);
toscaTemplate
=
helper
.
setVMTopologyInToscaTemplate
(
toscaTemplate
,
vmTopologyMap
.
getNodeTemplate
()
);
return
toscaTemplate
;
}
}
...
...
drip-provisioner/src/main/java/nl/uva/sne/drip/provisioner/CloudStormService.java
View file @
f7f33f11
...
...
@@ -25,6 +25,7 @@ import java.util.Properties;
import
nl.uva.sne.drip.commons.utils.ToscaHelper
;
import
nl.uva.sne.drip.model.cloud.storm.CloudsStormVM
;
import
nl.uva.sne.drip.model.NodeTemplate
;
import
nl.uva.sne.drip.model.NodeTemplateMap
;
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.CloudsStormVMs
;
...
...
@@ -119,15 +120,15 @@ class CloudStormService {
}
private
Map
<
String
,
Object
>
getCloudsStormSubTopologiesAndVMs
(
ToscaTemplate
toscaTemplate
,
String
tempInputDirPath
)
throws
ApiException
,
IOException
,
Exception
{
List
<
NodeTemplate
>
vmTopologyTemplates
=
helper
.
getVMTopologyTemplates
();
List
<
NodeTemplate
Map
>
vmTopologyTemplatesMap
=
helper
.
getVMTopologyTemplates
();
List
<
CloudsStormSubTopology
>
cloudsStormSubTopologies
=
new
ArrayList
<>();
Map
<
String
,
Object
>
cloudsStormMap
=
new
HashMap
<>();
List
<
CloudsStormVMs
>
cloudsStormVMsList
=
new
ArrayList
<>();
int
i
=
0
;
for
(
NodeTemplate
nodeTemplate
:
vmTopologyTemplates
)
{
for
(
NodeTemplate
Map
nodeTemplateMap
:
vmTopologyTemplatesMap
)
{
CloudsStormSubTopology
cloudsStormSubTopology
=
new
CloudsStormSubTopology
();
String
domain
=
helper
.
getTopologyDomain
(
nodeTemplate
);
String
provider
=
helper
.
getTopologyProvider
(
nodeTemplate
);
String
domain
=
helper
.
getTopologyDomain
(
nodeTemplate
Map
);
String
provider
=
helper
.
getTopologyProvider
(
nodeTemplate
Map
);
cloudsStormSubTopology
.
setDomain
(
domain
);
cloudsStormSubTopology
.
setCloudProvider
(
provider
);
cloudsStormSubTopology
.
setTopology
(
"vm_topology"
+
i
);
...
...
@@ -136,14 +137,14 @@ class CloudStormService {
List
<
CloudsStormVM
>
vms
=
new
ArrayList
<>();
cloudsStormVMs
.
setName
(
"vm_topology"
+
i
);
List
<
NodeTemplate
>
vmTemplates
=
helper
.
getTemplateVMsForVMTopology
(
nodeTemplate
);
List
<
NodeTemplate
Map
>
vmTemplatesMap
=
helper
.
getTemplateVMsForVMTopology
(
nodeTemplateMap
);
int
j
=
0
;
for
(
NodeTemplate
vm
:
vmTemplates
)
{
for
(
NodeTemplate
Map
vmMap
:
vmTemplatesMap
)
{
CloudsStormVM
cloudsStormVM
=
new
CloudsStormVM
();
String
vmType
=
getVMType
(
vm
,
provider
);
String
vmType
=
getVMType
(
vm
Map
,
provider
);
cloudsStormVM
.
setNodeType
(
vmType
);
cloudsStormVM
.
setName
(
"vm"
+
j
);
String
os
=
helper
.
getVMNOS
(
vm
);
String
os
=
helper
.
getVMNOS
(
vm
Map
);
cloudsStormVM
.
setOsType
(
os
);
vms
.
add
(
cloudsStormVM
);
j
++;
...
...
@@ -160,10 +161,10 @@ class CloudStormService {
return
cloudsStormMap
;
}
private
String
getVMType
(
NodeTemplate
vm
,
String
provider
)
throws
IOException
,
Exception
{
Double
numOfCores
=
helper
.
getVMNumOfCores
(
vm
);
Double
memSize
=
helper
.
getVMNMemSize
(
vm
);
String
os
=
helper
.
getVMNOS
(
vm
);
private
String
getVMType
(
NodeTemplate
Map
vmMap
,
String
provider
)
throws
IOException
,
Exception
{
Double
numOfCores
=
helper
.
getVMNumOfCores
(
vm
Map
);
Double
memSize
=
helper
.
getVMNMemSize
(
vm
Map
);
String
os
=
helper
.
getVMNOS
(
vm
Map
);
List
<
VMMetaInfo
>
vmInfos
=
cloudStormDAO
.
findVmMetaInfoByProvider
(
provider
);
for
(
VMMetaInfo
vmInfo
:
vmInfos
)
{
if
(
Objects
.
equals
(
numOfCores
,
Double
.
valueOf
(
vmInfo
.
getCPU
()))
&&
Objects
.
equals
(
memSize
,
Double
.
valueOf
(
vmInfo
.
getMEM
()))
&&
os
.
toLowerCase
().
equals
(
vmInfo
.
getOS
().
toLowerCase
()))
{
...
...
@@ -174,9 +175,9 @@ class CloudStormService {
}
private
void
writeCloudStormCredentialsFiles
(
ToscaTemplate
toscaTemplate
,
String
credentialsTempInputDirPath
)
throws
ApiException
,
Exception
{
List
<
NodeTemplate
>
vmTopologie
s
=
helper
.
getVMTopologyTemplates
();
for
(
NodeTemplate
vmTopology
:
vmTopologie
s
)
{
Credential
credentials
=
helper
.
getCredentialsFromVMTopology
(
vmTopology
);
List
<
NodeTemplate
Map
>
vmTopologiesMap
s
=
helper
.
getVMTopologyTemplates
();
for
(
NodeTemplate
Map
vmTopologyMap
:
vmTopologiesMap
s
)
{
Credential
credentials
=
helper
.
getCredentialsFromVMTopology
(
vmTopology
Map
);
}
}
...
...
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