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
c3f29fd7
Commit
c3f29fd7
authored
Dec 25, 2019
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added get attributes and get tosca credentials
parent
3890b724
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
653 additions
and
193 deletions
+653
-193
pom.xml
drip-commons/pom.xml
+14
-3
Converter.java
...rc/main/java/nl/uva/sne/drip/commons/utils/Converter.java
+54
-0
ToscaHelper.java
.../main/java/nl/uva/sne/drip/commons/utils/ToscaHelper.java
+4
-16
ApiClient.java
...ain/java/nl/uva/sne/drip/sure/tosca/client/ApiClient.java
+88
-104
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
+287
-0
JSON.java
...src/main/java/nl/uva/sne/drip/sure/tosca/client/JSON.java
+3
-1
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
+0
-5
ToscaTemplateApiController.java
.../java/nl/uva/sne/drip/api/ToscaTemplateApiController.java
+4
-0
CloudStormService.java
...n/java/nl/uva/sne/drip/provisioner/CloudStormService.java
+3
-3
default_controller.py
...flask-server/sure_tosca/controllers/default_controller.py
+36
-0
tosca_template_service.py
...flask-server/sure_tosca/service/tosca_template_service.py
+10
-2
swagger.yaml
sure_tosca-flask-server/sure_tosca/swagger/swagger.yaml
+146
-55
No files found.
drip-commons/pom.xml
View file @
c3f29fd7
...
...
@@ -76,7 +76,6 @@
<dependency>
<groupId>
com.google.code.gson
</groupId>
<artifactId>
gson
</artifactId>
<version>
${gson-version}
</version>
</dependency>
<dependency>
<groupId>
io.gsonfire
</groupId>
...
...
@@ -132,7 +131,19 @@
<groupId>
com.google.code.findbugs
</groupId>
<artifactId>
jsr305
</artifactId>
<version>
3.0.2
</version>
</dependency>
</dependency>
<dependency>
<groupId>
org.json
</groupId>
<artifactId>
json
</artifactId>
<version>
20190722
</version>
<type>
jar
</type>
</dependency>
<dependency>
<groupId>
org.yaml
</groupId>
<artifactId>
snakeyaml
</artifactId>
<version>
1.25
</version>
<type>
jar
</type>
</dependency>
</dependencies>
...
...
@@ -151,7 +162,7 @@
</execution>
</executions>
</plugin>
<!-- <plugin>
<!-- <plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.2.2</version>
...
...
drip-commons/src/main/java/nl/uva/sne/drip/commons/utils/Converter.java
0 → 100644
View file @
c3f29fd7
/*
* Copyright 2019 S. Koulouzis
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
nl
.
uva
.
sne
.
drip
.
commons
.
utils
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.yaml.snakeyaml.Yaml
;
/**
*
* @author S. Koulouzis
*/
public
class
Converter
{
public
static
String
map2YmlString
(
Map
<
String
,
Object
>
map
)
throws
JSONException
{
JSONObject
jsonObject
=
new
JSONObject
(
map
);
String
yamlStr
=
json2Yml2
(
jsonObject
.
toString
());
return
yamlStr
;
}
public
static
String
json2Yml2
(
String
jsonString
)
throws
JSONException
{
Yaml
yaml
=
new
Yaml
();
String
yamlStr
=
yaml
.
dump
(
ymlString2Map
(
jsonString
));
return
yamlStr
;
}
public
static
Map
<
String
,
Object
>
ymlString2Map
(
String
yamlString
)
{
Yaml
yaml
=
new
Yaml
();
Object
object
=
yaml
.
load
(
yamlString
);
if
(
object
instanceof
List
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"---"
,
object
);
return
map
;
}
return
(
Map
<
String
,
Object
>)
object
;
}
}
drip-commons/src/main/java/nl/uva/sne/drip/commons/utils/ToscaHelper.java
View file @
c3f29fd7
...
...
@@ -208,30 +208,18 @@ public class ToscaHelper {
NodeTemplate
vmTopology
=
vmTopologyMap
.
getNodeTemplate
();
if
(
vmTopology
.
getType
().
equals
(
VM_TOPOLOGY
))
{
Map
<
String
,
Object
>
att
=
vmTopology
.
getAttributes
();
Object
credentialMap
=
att
.
get
(
"credential"
);
// Map<String, Object> toscaCredential = new HashMap<>();
// toscaCredential.put("protocol", credential.getProtocol());
// toscaCredential.put("token_type", credential.getTokenType());
// toscaCredential.put("token", credential.getToken());
// toscaCredential.put("keys", credential.getKeys());
// toscaCredential.put("user", credential.getUser());
// toscaCredential.put("cloud_provider_name", credential.getCloudProviderName());
// att.put("credential", toscaCredential);
// vmTopology.setAttributes(att);
// return vmTopology;
String
ymlStr
=
Converter
.
map2YmlString
((
Map
<
String
,
Object
>)
att
.
get
(
"credential"
));
Credential
toscaCredential
=
objectMapper
.
readValue
(
ymlStr
,
Credential
.
class
);
return
toscaCredential
;
}
else
{
throw
new
Exception
(
"NodeTemplate is not of type: "
+
VM_TOPOLOGY
+
" it is of type: "
+
vmTopology
.
getType
());
}
return
null
;
}
public
ToscaTemplate
setVMTopologyInToscaTemplate
(
ToscaTemplate
toscaTemplate
,
NodeTemplateMap
vmTopologyMap
)
{
Map
<
String
,
NodeTemplate
>
nodes
=
toscaTemplate
.
getTopologyTemplate
().
getNodeTemplates
();
nodes
.
put
(
vmTopologyMap
.
getName
(),
vmTopologyMap
.
getNodeTemplate
());
// Set<String> keys = nodes.keySet();
// for (String key : keys) {
// NodeTemplate node = nodes.get(key);
// }
return
toscaTemplate
;
}
...
...
drip-commons/src/main/java/nl/uva/sne/drip/sure/tosca/client/ApiClient.java
View file @
c3f29fd7
This diff is collapsed.
Click to expand it.
drip-commons/src/main/java/nl/uva/sne/drip/sure/tosca/client/ApiException.java
View file @
c3f29fd7
...
...
@@ -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-2
0T15:53:11.510
Z"
)
@javax
.
annotation
.
Generated
(
value
=
"io.swagger.codegen.languages.JavaClientCodegen"
,
date
=
"2019-12-2
5T13:58:54.535
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 @
c3f29fd7
...
...
@@ -13,7 +13,7 @@
package
nl
.
uva
.
sne
.
drip
.
sure
.
tosca
.
client
;
@javax
.
annotation
.
Generated
(
value
=
"io.swagger.codegen.languages.JavaClientCodegen"
,
date
=
"2019-12-2
0T15:53:11.510
Z"
)
@javax
.
annotation
.
Generated
(
value
=
"io.swagger.codegen.languages.JavaClientCodegen"
,
date
=
"2019-12-2
5T13:58:54.535
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 @
c3f29fd7
This diff is collapsed.
Click to expand it.
drip-commons/src/main/java/nl/uva/sne/drip/sure/tosca/client/JSON.java
View file @
c3f29fd7
...
...
@@ -23,7 +23,7 @@ import io.gsonfire.GsonFireBuilder;
import
org.threeten.bp.LocalDate
;
import
org.threeten.bp.OffsetDateTime
;
import
org.threeten.bp.format.DateTimeFormatter
;
;
import
okio.ByteString
;
import
java.io.IOException
;
...
...
@@ -35,6 +35,8 @@ import java.text.ParsePosition;
import
java.util.Date
;
import
java.util.Map
;
public
class
JSON
{
private
Gson
gson
;
...
...
drip-commons/src/main/java/nl/uva/sne/drip/sure/tosca/client/Pair.java
View file @
c3f29fd7
...
...
@@ -13,7 +13,7 @@
package
nl
.
uva
.
sne
.
drip
.
sure
.
tosca
.
client
;
@javax
.
annotation
.
Generated
(
value
=
"io.swagger.codegen.languages.JavaClientCodegen"
,
date
=
"2019-12-2
0T15:53:11.510
Z"
)
@javax
.
annotation
.
Generated
(
value
=
"io.swagger.codegen.languages.JavaClientCodegen"
,
date
=
"2019-12-2
5T13:58:54.535
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 @
c3f29fd7
...
...
@@ -13,7 +13,7 @@
package
nl
.
uva
.
sne
.
drip
.
sure
.
tosca
.
client
;
@javax
.
annotation
.
Generated
(
value
=
"io.swagger.codegen.languages.JavaClientCodegen"
,
date
=
"2019-12-2
0T15:53:11.510
Z"
)
@javax
.
annotation
.
Generated
(
value
=
"io.swagger.codegen.languages.JavaClientCodegen"
,
date
=
"2019-12-2
5T13:58:54.535
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 @
c3f29fd7
...
...
@@ -25,17 +25,12 @@ import java.nio.file.Files;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.net.HttpURLConnection
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.nio.file.Paths
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Properties
;
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
;
...
...
drip-manager/src/main/java/nl/uva/sne/drip/api/ToscaTemplateApiController.java
View file @
c3f29fd7
package
nl
.
uva
.
sne
.
drip
.
api
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
io.swagger.annotations.*
;
import
org.slf4j.Logger
;
...
...
@@ -15,6 +16,7 @@ import javax.validation.Valid;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.logging.Level
;
import
nl.uva.sne.drip.service.ToscaTemplateService
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -56,6 +58,8 @@ public class ToscaTemplateApiController implements ToscaTemplateApi {
}
catch
(
IOException
e
)
{
log
.
error
(
"Couldn't serialize response for content type "
,
e
);
return
new
ResponseEntity
<>(
HttpStatus
.
INTERNAL_SERVER_ERROR
);
}
catch
(
NotFoundException
ex
)
{
java
.
util
.
logging
.
Logger
.
getLogger
(
ToscaTemplateApiController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
...
...
drip-provisioner/src/main/java/nl/uva/sne/drip/provisioner/CloudStormService.java
View file @
c3f29fd7
...
...
@@ -202,10 +202,10 @@ class CloudStormService {
}
private
CredentialInfo
getCloudStormCredentialInfo
(
Credential
toscaCredentials
)
throws
FileNotFoundException
{
CredentialInfo
cloudStormCredentialInfo
=
new
CredentialInfo
();
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
(
"user.jks"
))
{
...
...
@@ -217,7 +217,7 @@ CredentialInfo cloudStormCredentialInfo = new CredentialInfo();
return
cloudStormCredentialInfo
;
case
"ec2"
:
// cloudStormCredentialInfo.setAccessKey(toscaCredentials.get);
return
cloudStormCredentialInfo
;
return
cloudStormCredentialInfo
;
}
return
null
;
...
...
sure_tosca-flask-server/sure_tosca/controllers/default_controller.py
View file @
c3f29fd7
...
...
@@ -367,3 +367,39 @@ def upload_tosca_template(file): # noqa: E501
if
res
:
return
res
return
'Bad Request'
,
400
def
set_node_attributes
(
id
,
properties
,
node_name
):
# noqa: E501
"""set_node_attributes
# noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param properties:
:type properties:
:param node_name: node_name
:type node_name: str
:rtype: str
"""
return
'do some magic!'
def
get_node_attributes
(
id
,
node_name
):
# noqa: E501
"""get_node_attributes
# noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: Dict[str, object]
"""
res
=
tosca_template_service
.
get_node_attributes
(
id
,
node_name
)
if
res
:
return
res
return
'Not Found'
,
404
sure_tosca-flask-server/sure_tosca/service/tosca_template_service.py
View file @
c3f29fd7
...
...
@@ -118,7 +118,7 @@ def get_interface_types(id, interface_type=None):
return
query_db
(
queries
,
db
=
interface_types_db
)
def
change_to_node
TemplateM
odel
(
query_results
):
def
change_to_node
_template_m
odel
(
query_results
):
res
=
[]
for
node_template
in
query_results
:
# copy.deepcopy()
...
...
@@ -189,7 +189,7 @@ def get_node_templates(id, type_name=None, node_name=None, has_interfaces=None,
queries
.
append
(
query
.
artifacts
!=
prop
)
query_results
=
query_db
(
queries
,
db
=
node_template_db
)
return
change_to_node
TemplateM
odel
(
query_results
)
return
change_to_node
_template_m
odel
(
query_results
)
def
get_tosca_template_get_dsl_definitions
(
id
,
anchors
,
derived_from
):
...
...
@@ -325,6 +325,14 @@ def get_node_requirements(id, node_name):
return
None
def
get_node_attributes
(
id
,
node_name
):
node_template_map
=
get_node_templates
(
id
,
node_name
=
node_name
)[
0
]
attributes
=
node_template_map
.
node_template
.
attributes
if
attributes
:
return
attributes
return
None
def
get_related_nodes
(
id
,
node_name
):
tosca_template_dict
=
get_tosca_template_dict_by_id
(
id
)
tosca_template
=
get_tosca_template
(
tosca_template_dict
)
...
...
sure_tosca-flask-server/sure_tosca/swagger/swagger.yaml
View file @
c3f29fd7
This diff is collapsed.
Click to expand it.
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